Пример #1
0
class Step4(StepTemplateChmod):
    print_text = [_("{{yb:Do you know why people are disappearing?}}")]
    story = [
        _("Swordmaster: {{Bb:\"I wasn't aware people were disappearing. Is that what is causing that bell?"
          ),
        _("Perhaps it is good you are here then.\""),
        _("\"Tell me, what is your name?\"}}")
    ]
    start_dir = "~/woods/clearing/house"
    end_dir = "~/woods/clearing/house"
    commands = ["echo " + get_username()]
    hints = [
        _("{{rb:Use}} {{yb:echo " + get_username() +
          "}} {{rb:to give your name.}}")
    ]

    def check_command(self, last_user_input):
        if last_user_input.startswith(
                "echo") and last_user_input not in self.commands:
            self.send_hint(
                _("Swordmaster: {{Bb:\"That's a strange name. Is that really your name?\"}}"
                  ))
        return StepTemplateChmod.check_command(self, last_user_input)

    def next(self):
        return 39, 5
Пример #2
0
    def get_print_text(self):
        print_text = ""

        if self.print_text:
            coloured_username = "******" + get_username() + ":}} "
            print_text = coloured_username + "\n".join(self.print_text)

        return print_text
Пример #3
0
    def get_print_text(self):
        print_text = ""

        if self.print_text:
            coloured_username = "******" + get_username() + ":}} "
            print_text = coloured_username + "\n".join(self.print_text)

        return print_text
Пример #4
0
    def cat_people(self):
        people = {
            "Mum": _("Mum: {{Bb:\"" + get_username() + ", I'm so glad to see you, but it's not safe here!\"}}"),

            "Dad": _("Dad: {{Bb:\"" + get_username() + ", strangest thing happened. I was kidnapped by a rabbit! "
                     "Although, it seems to be acting even stranger now.\"}}"),

            "grumpy-man": _("grumpy-man: {{Bb:\"My legs are fixed. I hope my wife knows I'm safe.\"}}"),
            "Mayor": _("Mayor: {{Bb:\"When I get out of here, I'm going to make a law to hunt all rabbits.\"}}"),
            "little-boy": _("little-boy: {{Bb:\"I miss my mummy!\"}}"),
            "young-girl": _("young-girl: {{Bb:\"I don't like being in here.\"}}"),
            "Edith": _("Edith: {{Bb:\"You, " + get_username() + "! Get us out of here!\"}}"),
            "Edward": _("Edward: {{Bb:\"Edith dear, calm down...\"}}"),
            "dog": _("dog: {{Bb:\"Woof woof!\"}}"),
            "Bernard": _("Bernard: {{Bb:\"After you left, I heard this sound\"}}"),
            "head-librarian": _("head-librarian: {{Bb:\"Who are you?\"}}")
        }
        for person in people:
            if self._last_user_input == "cat cage/" + person:
                return people[person]

        return ""
Пример #5
0
    def _set_prompt(self):
        # Why is this done like this? Can we shorten this to just use the prompt?
        fake_cwd = self._location.get_real_path().replace(fake_home_dir, '~')

        if fake_cwd[-1] == '/':
            fake_cwd = fake_cwd[:-1]

        username = get_username()
        yellow_part = username + "@kano "
        yellow_part = colour_string_with_preset(yellow_part, "yellow", True)

        blue_part = fake_cwd + ' $ '
        blue_part = colour_string_with_preset(blue_part, "blue", True)
        self.prompt = yellow_part + blue_part
Пример #6
0
class Step7(StepTemplateSudo):
    story = [
        _("You see your Mum, Dad and everyone else you met on your adventure. They stand around you in the street "
          "clapping and cheering."),
        _("{{lb:Talk to everyone.}}")
    ]
    start_dir = "~/town"
    end_dir = "~/town"

    hints = [_("")]

    all_commands = {
        "cat Mum":
        _("Mum: {{Bb:\"You saved Folderton! You're a hero!\"}}"),
        "cat Dad":
        _("Dad: {{Bb:\"I'm so proud of you, " + get_username() + ".\"}}"),
        "cat Mayor":
        _("Mayor: {{Bb:\"Now that you're a Super User, you must always remember:\n"
          " 1. Respect the privacy of others.\n"
          " 2. Think before you type.\n"
          " 3. With great power comes great responsibility.\"}}")
    }

    other_commands = {
        "cat grumpy-man":
        _("grumpy-man: {{Bb:\"Ruth told me about how you helped hide her and our animals. "
          "Thank you!}}"),
        "cat Ruth":
        _("Ruth: {{Bb:\"If you ever come by the farm, you can have a glass of milk on us!\"}}"
          ),
        "cat little-boy":
        _("little-boy: {{Bb:\"Mummy is safe!\"}}"),
        "cat young-girl":
        _("young-girl: {{Bb:\"We found Mummy. I'm really glad she's safe.\"}}"
          ),
        "cat Edith":
        _("Edith: {{Bb:\"I'm so glad Eleanor is safe! Thank you for saving Edward and I.\"}}"
          ),
        "cat Edward":
        _("Edward: {{Bb:\"Now all this is over, we can go back to our house and stop living in "
          "hiding.\"}}"),
        "cat Eleanor":
        _("Eleanor: {{Bb:\"You found my parents! I knew they'd be alright.\"}}"
          ),
        "cat dog":
        _("dog: {{Bb:\"Woof woof!\"}}"),
        "cat Bernard":
        _("Bernard: {{Bb:\"Who is that Masked Swordmaster? He looks oddly familiar.\"}}"
          ),
        "cat Clara":
        _("Clara: {{Bb:\"Eleanor helped me feel brave, but I'm so happy you found my children}} {{bb:young-girl}} {{Bb:and}} "
          "{{bb:little-boy}}{{Bb:! Thank you " + get_username() + "!\"}}"),
        "cat Swordmaster":
        _("Swordmaster: {{Bb:\"You've done well. You are indeed a force to be reckoned with. "
          "Keep training and you'll become even more powerful.\"}}"),
        "cat Rabbit":
        _("Rabbit: {{Bb:....}}")
    }

    def check_command(self, line):

        # If we've emptied the list of available commands, then pass the level
        if not self.all_commands:
            return True

        # If they enter ls, say Well Done
        if line == 'ls':
            hint = _("\n{{gb:You look around.}}")
            self.send_hint(hint)
            return False
        elif line in self.other_commands:
            hint = "\n" + self.other_commands[line]
            self.send_hint(hint)
            return False

        # check through list of commands
        self.hints = [
            _("{{rb:Use}} {{yb:%s}} {{rb:to progress.}}") %
            self.all_commands.keys()[0]
        ]

        end_dir_validated = self.get_fake_path() == self.end_dir

        if (line in self.all_commands.keys()) and end_dir_validated:
            hint = "\n" + self.all_commands[line]
            self.all_commands.pop(line, None)

            if len(self.all_commands) == 0:
                hint += _("\n\n{{gb:Press}} {{ob:Enter}} {{gb:to continue.}}")

            self.send_hint(hint)
        else:
            self.send_stored_hint()

        # Always return False unless the list of valid commands have been
        # emptied
        return False

    def next(self):
        from kano_profile.badges import save_app_state_variable_with_dialog
        save_app_state_variable_with_dialog('linux-story', 'finished',
                                            'challenge_46')
        self._is_finished = True
        self.exit()
        return -1, -1