Пример #1
0
class Step1(StepLs):
    story = [
        _("{{wb:random alarm on your dresser}}: {{Bb:\"Beep beep beep! Beep beep beep!\"}}"
          ),
        _("{{wb:something}}: {{Bb:\"Good Morning, this is the 9am news.\"\n"),
        _("\"The town of Folderton has awoken to strange news. There have been reports of missing people and damaged buildings across the town, with more stories coming in as we speak.\""
          ),  # noqa
        _("\n\"Mayor Hubert has called an emergency town meeting and we'll keep you posted as it happens...\"}}\n"
          ),
        _("It's time to get up sleepy head!\n "),
    ]  # TODO: " \ is a hack in this array to stop word wrap code screwing up and adding new lines in where it shouldn't

    story += wrap_in_box([
        _("{{gb:New command:}} Type {{yb:ls}} and press"),
        _("{{ob:Enter}} to {{lb:look around}}."),
    ])

    start_dir = "~/my-house/my-room"
    end_dir = "~/my-house/my-room"
    commands = "ls"
    highlighted_commands = ["ls"]
    hints = [
        _("{{rb:Type}} {{yb:ls}} {{rb:and press}} {{ob:Enter}} {{rb:to take a look around your bedroom.}}"
          )
    ]

    last_step = True

    def __init__(self, xp=""):
        sound_manager = SoundManager()
        sound_manager.play_sound('alarm')
        StepLs.__init__(self, xp)

    def next(self):
        NextChallengeStep(self.xp)
Пример #2
0
class Step4(StepTemplateRm):
    story = [
        _("It has a command inscribed on it."),
        "....{{lb:rm}}...?\n"
    ]

    story += wrap_in_box([
        _("{{gb:New Power:}} Use {{yb:rm}} to"),
        _(" {{lb:remove an item}}.")
    ])

    story += [
        _("Use {{yb:rm note}}, to test the command out on the note."),
        _("Be careful though....it looks dangerous.")
    ]
    start_dir = "~/town/east/library/private-section"
    end_dir = "~/town/east/library/private-section"
    commands = [
        "rm note"
    ]
    highlighted_commands = ["rm"]

    hints = [
        "",
        _("{{rb:Use the command}} {{yb:rm note}}")
    ]
    dark_theme = True

    def next(self):
        return 43, 5
Пример #3
0
class Step1(StepTemplateCd):
    story = [
        _("That's weird. No time for that now though - lets find {{bb:Mum}}.\n "
          ),
    ]
    story += wrap_in_box([
        _("{{gb:New Spell}}: {{yb:cd}} lets you {{lb:move}}"),
        _("between places."),
    ])
    story += [_("Use the command {{yb:cd ..}} to {{lb:leave}} your room.\n")]

    start_dir = "~/my-house/my-room"
    end_dir = "~/my-house"
    commands = ["cd ..", "cd ../", "cd ~/my-house", "cd ~/my-house/"]
    highlighted_commands = ['cd']
    hints = [
        _("{{rb:Type}} {{yb:cd ..}} {{rb:to leave your room. The}} {{lb:..}} {{rb:is the room behind you.}}"
          ),
        _("{{rb:Type}} {{yb:cd ..}} {{rb:to leave your room.}}")
    ]

    def block_command(self):
        return unblock_commands_with_cd_hint(self.last_user_input,
                                             self.commands)

    def next(self):
        Step2()
Пример #4
0
class Step7(StepTemplateEcho):
    story = [
        _("So the note says {{Bb:\"echo hello - will make you say hello\"}}"),
        _("Let's test this out. \n"),
    ]
    story += wrap_in_box([
        _("{{gb:New Spell}}: {{yb:echo}} followed by words"),
        _("lets you {{lb:speak}}"),
    ])

    hints = [
        _("{{rb:Use the command}} {{yb:echo hello}}")
    ]
    commands = [
        "echo hello",
        "echo HELLO",
        "echo Hello"
    ]
    highlighted_commands = ['echo']
    start_dir = "~/my-house/parents-room"
    end_dir = "~/my-house/parents-room"
    last_step = True

    def next(self):
        NextStep(self.xp)
Пример #5
0
class Step4(StepTemplateMkdir):
    story = [
        _("Ruth: {{Bb:\"This says you can make something using something " +\
        "called}} {{yb:mkdir}}{{Bb:?\"}}"),
        _("\nTry making an igloo using {{yb:mkdir igloo}}\n "),
    ]

    story += wrap_in_box([
        _("{{gb:New Spell}}: {{yb:mkdir}} followed by a word"),
        _("lets you {{lb:create}} a shelter"),
    ])

    hints = [
        _("{{rb:Create an igloo structure by using}} {{yb:mkdir igloo}}\n")
    ]
    start_dir = "~/farm/toolshed"
    end_dir = "~/farm/toolshed"
    commands = ["mkdir igloo"]
    highlighted_commands = ['mkdir']

    def block_command(self):
        return unblock_commands_with_mkdir_hint(self.last_user_input,
                                                self.commands)

    def check_command(self):
        if self.last_user_input == "cat MKDIR":
            self.send_hint(
                _("\n{{gb:Well done for checking the page again!}}"))
            return False

        return StepTemplateMkdir.check_command(self)

    def next(self):
        Step5()
Пример #6
0
class Step2(StepTemplateMv):
    story = [
        _("Edward looks like he has something he wants to say to you.\n"),
        _("{{wb:Edward:}} {{Bb:\"Hey! Can you help me?\"}}"),
        _("{{Bb:\"I've been trying to move this}} {{bb:apple}} {{Bb:into the}} {{bb:basket}}{{Bb:.\"}}"
          ),
        _("{{Bb:\"I was told the command}} {{yb:mv apple basket/}} {{Bb:would make it happen, but I can't seem to make "
          "it work. Do you have the power to make it happen?\"}}\n"),
    ]

    story += wrap_in_box([
        _("{{gb:New Power}}: to {{lb:move}} objects, type {{yb:mv}}"),
        _("and the object name."),
    ])

    start_dir = "~/town/.hidden-shelter"
    end_dir = "~/town/.hidden-shelter"
    commands = ["mv apple basket", "mv apple basket/"]
    highlighted_commands = ['mv']
    hints = [
        _("{{rb:Use the command}} {{yb:mv apple basket/}} {{rb:to move the apple into the basket.}}"
          )
    ]

    def block_command(self, line):
        return unblock_commands(line, self.commands)

    def next(self):
        return 11, 3
Пример #7
0
class Step1(StepCat):
    story = [
        _("Awesome, now you can see the objects around you."),
        _("There's your {{bb:bed}}, an {{bb:alarm}}... "),
        _("Euuughh...turn that {{bb:alarm}} off! \n"),
    ]

    story += wrap_in_box([
        _("{{gb:New Spell}}: to {{lb:examine}} objects, type"),
        _("{{yb:cat}} and the object name."),
    ])

    story += [
        _("Use {{yb:cat alarm}} to {{lb:examine}} the {{bb:alarm}}.")
    ]

    start_dir = "~/my-house/my-room"
    end_dir = "~/my-house/my-room"
    commands = "cat alarm"
    highlighted_commands = ['cat']
    hints = _("{{rb:Type}} {{yb:cat alarm}} {{rb:to investigate the alarm.}}")

    def __init__(self, xp=""):
        StepCat.__init__(self, xp)

    def next(self):
        Step2()
Пример #8
0
class Step8(StepTemplateChmod):
    story = [
        "You are unable to move the bird outside the cage.",
        "Bird: {{Bb:\"...didn't work....\"}}",
        "{{Bb:\"...look in}} {{lb:dark-room}} {{Bb:to find help..\"}}",
        "{{Bb:\"..use}} {{yb:chmod +r dark-room}} {{Bb:to switch lights on.\"}}",
        "{{Bb:\"...get me out...and I'll help you.\"}}", ""
    ]
    story += wrap_in_box([
        _("{{gb:New Power:}} Use "),
        _("{{yb:chmod +r dark-room}} "),
        _("to allow yourself to {{lb:read}} "),
        _("the contents of dark-room.")
    ])

    start_dir = "~/woods/cave"
    end_dir = "~/woods/cave"
    commands = ["chmod +r dark-room", "chmod +r dark-room/"]
    highlighted_commands = "chmod"
    hints = [
        "{{rb:Follow the bird's instructions and use}} {{yb:chmod +r dark-room}} {{rb:to turn the lights on in the}} "
        "{{bb:dark-room.}}"
    ]

    def next(self):
        return 35, 1
def test_wrap_in_box():
    output = wrap_in_box([
        '{{gb:This is a long string}}',
        'Short {{lb:string}}',
    ])

    assert output == [
        " ----------------------- ",
        "| {{gb:This is a long string}} |",
        "| Short {{lb:string}}          |",
        " ----------------------- \n",
    ]
Пример #10
0
class Step5(StepTemplateChmod):
    story = wrap_in_box([
        _("{{gb:New Power:}} Type"),
        _("{{yb:chmod +w cage}}"),
        _("to give write permissions to,"),
        _("and thus unlock, the cage."),
    ])
    story += ["Try it out!"]
    start_dir = "~/woods/cave"
    end_dir = "~/woods/cave"
    commands = ["chmod +w cage", "chmod +w cage/"]
    hints = [_("{{rb:Use}} {{yb:chmod +w cage}} {{rb:to unlock the cage.}}")]

    def next(self):
        return 35, 6
Пример #11
0
class Step3(StepTemplateChmod):
    story = wrap_in_box([
        _("{{gb:New Power:}} Use"),
        _("{{yb:chmod +x locked-room}}"),
        _("to unlock the locked-room.")
    ])
    story += [_("Use it on the {{bb:locked-room}}.")]
    start_dir = "~/woods/cave"
    end_dir = "~/woods/cave"
    hints = [
        _("{{rb:Unlock the locked-room with}} {{yb:chmod +x locked-room}}")
    ]
    commands = ["chmod +x locked-room", "chmod +x locked-room/"]
    highlighted_commands = "chmod"

    def next(self):
        return 35, 4
Пример #12
0
class Step2(StepTemplateNano):
    story = [
        _("Bernard: {{Bb:\"Hellooooo. You came back to fix my script!\"}}\n "),
    ]
    story += wrap_in_box([
        _("{{gb:New Spell}}: {{yb:nano}} followed by an"),
        _("object lets you {{lb:edit}} it"),
    ])
    story += [
        _("Let's try and use {{yb:nano best-horn-in-the-world.sh}} to edit it."
          ),
    ]

    start_dir = "~/town/east/shed-shop"
    end_dir = "~/town/east/shed-shop"

    commands = ["nano best-horn-in-the-world.sh"]
    highlighted_commands = ['nano']

    hints = [
        _("{{rb:Use}} {{yb:nano best-horn-in-the-world}} " +\
        "{{rb:to edit the tool.}}")
    ]

    eleanors_speech = \
        _("Eleanor: {{Bb:They taught us how to write at school. " +\
        "I don't think Bernard is very clever.}}")

    goal_nano_end_content = "echo \"Honk!\""
    goal_nano_filepath = "~/town/east/shed-shop/best-horn-in-the-world.sh"
    goal_nano_save_name = "best-horn-in-the-world.sh"

    # Overwrite the default behaviour for most of the steps - nano needs
    # slightly different behaviour.
    def check_command(self):
        if self.last_user_input == "cat Eleanor":
            self.send_text("\n" + self.eleanors_speech)
        else:
            return self.check_nano_input()

    def check_nano_content(self):
        return self.check_nano_content_default()

    def next(self):
        Step3()
Пример #13
0
class Step2(StepTemplateNano):
    story = [
        _("Bernard: {{Bb:\"Hellooooo. You came back to fix my script!\"}}\n "),
    ]
    story += wrap_in_box([
        _("{{gb:New Power}}: {{yb:nano}} followed by an"),
        _("object lets you {{lb:edit}} it"),
    ])
    story += [
        _("Let's try and use {{yb:nano best-horn-in-the-world.sh}} to edit it."
          ),
    ]

    start_dir = "~/town/east/shed-shop"
    end_dir = "~/town/east/shed-shop"

    commands = ["nano best-horn-in-the-world.sh"]
    highlighted_commands = ['nano']

    hints = [
        _("{{rb:Use}} {{yb:nano best-horn-in-the-world}} " +\
        "{{rb:to edit the tool.}}")
    ]

    companion_speech = _(
        "Eleanor: {{Bb:They taught us how to write at school. I don't think Bernard is very clever.}}"
    )

    def _setup_nano(self):
        self._nano.set_goal_nano_save_name("best-horn-in-the-world.sh")
        self._nano.set_goal_nano_end_content("echo \"Honk!\"")
        self._nano.set_goal_nano_filepath(
            "~/town/east/shed-shop/best-horn-in-the-world.sh")

    def check_command(self, line):
        if line == "cat Eleanor":
            self.send_hint("\n" + self.companion_speech)
        else:
            return self._nano.check_nano_input()

    def check_nano_contents(self):
        return self._nano.check_nano_content_default()

    def next(self):
        return 27, 3
Пример #14
0
class Step2(StepTemplateMv):
    story = [
        _("Edward looks like he has something he wants to say to you.\n"),
        _("{{wb:Edward:}} {{Bb:\"Hi there. Can you help me with something?\""),

        _("\"I learnt this spell for moving items from " +
          "one place to another. But I can't seem to make it work.\""),

        _("\"I've been trying to move this}} {{bb:apple}} {{Bb:into the}} " +
          "{{bb:basket}}{{Bb:\"}}"),

        _("{{Bb:\"I was told the command was}} {{yb:mv apple basket/}}{{Bb:\"}}"),
        _("{{Bb:\"But I don't understand what that means. Do I say it? " +
          "Or write it?\"}}\n"),
    ]

    story += wrap_in_box([
        _("{{gb:New Spell}}: to {{lb:move}} objects, type {{yb:mv}}"),
        _("and the object name."),
    ])

    start_dir = "~/town/.hidden-shelter"
    end_dir = "~/town/.hidden-shelter"
    commands = [
        "mv apple basket",
        "mv apple basket/"
    ]
    highlighted_commands = ['mv']
    hints = [
        _("{{rb:Use the command}} {{yb:mv apple basket/}} {{rb:to move the apple into the basket.}}")
    ]
    # This is to add the apple into the virtual tree
    # we would like to integrate when using mv with the tree
    # automatically

    def block_command(self):
        return unblock_commands(self.last_user_input, self.commands)

    def next(self):
        Step3()
Пример #15
0
class Step3(StepTemplateSudo):
    story = wrap_in_box([
        _("{{gb:New Power:}} Use {{yb:sudo}} to"),
        _(" {{lb:make yourself into a Super User.}}")
    ])
    story += [
        _("Try it out. Use {{yb:sudo ls}} to look around."),
        _("You will be asked for a password."), "",
        _("Swordmaster: {{Bb:The Rabbit couldn't guess the password.}}"),
        _("{{Bb:Can you figure it out?}}"), "",
        _("Tip: The password will be invisible to keep it secret. It will look like you've typed nothing, so you need to be careful."
          )
    ]
    commands = ["sudo ls", "sudo ls .", "sudo ls ./"]
    start_dir = "~/woods/thicket/rabbithole"
    end_dir = "~/woods/thicket/rabbithole"
    hints = [
        "{{rb:Try again! Use}} {{yb:sudo ls}}{{rb:. The default password is}} {{yb:kano}}"
        "{{rb:. If you've changed the password, try that here instead.}}"
    ]

    def next(self):
        return 46, 4