def test_ghastly_cannot_travel_through_room_boundaries(ui):
    ui, engine = init_tiny_room(ui)
    # Ghastly thinks that he can travel though wall and room boundaries
    # as it turns out, he cannot, but that won't stop him from trying.
    # He will try to walk through all 4 room boundaries of the 2 x 2 room.
    ui.say("Ghastly")

    # He starts in tile 0,0 and tries to go west through a wall
    ui.say("j")

    # Then he tries to go south through a wall
    ui.say("k")

    # These walls are solid and prevent me from travelling there.  So he travels north twice.
    # The second movement is prevented by a wall
    ui.say("i")
    ui.say("i")

    # Now he tries the last wall by travelling east twice.  But cannot travel through the east wall
    ui.say("l")
    ui.say("l")

    # Completely frustrated, Ghastly exits the level.
    ui.say("e")

    # Having seen all there is to see, he quits the game and tells all of his friends about
    # the cool map.
    ui.say("q")
    engine.main_loop()
    assert ui.output_anywhere("You cannot go north")
    assert ui.output_anywhere("You cannot go south")
    assert ui.output_anywhere("You cannot go east")
    assert ui.output_anywhere("You cannot go west")
def test_ghastly_cannot_travel_through_room_boundaries(ui):
    ui, engine = init_tiny_room(ui)
    # Ghastly thinks that he can travel though wall and room boundaries
    # as it turns out, he cannot, but that won't stop him from trying.
    # He will try to walk through all 4 room boundaries of the 2 x 2 room.
    ui.say("Ghastly")
    
    # He starts in tile 0,0 and tries to go west through a wall
    ui.say("j")

    # Then he tries to go south through a wall
    ui.say("k")

    # These walls are solid and prevent me from travelling there.  So he travels north twice.
    # The second movement is prevented by a wall
    ui.say("i")
    ui.say("i")

    # Now he tries the last wall by travelling east twice.  But cannot travel through the east wall
    ui.say("l")
    ui.say("l")

    # Completely frustrated, Ghastly exits the level.
    ui.say("e")

    # Having seen all there is to see, he quits the game and tells all of his friends about
    # the cool map.
    ui.say("q")
    engine.main_loop()
    assert ui.output_anywhere("You cannot go north")
    assert ui.output_anywhere("You cannot go south")
    assert ui.output_anywhere("You cannot go east")
    assert ui.output_anywhere("You cannot go west")
Пример #3
0
def test_roach_runs_to_the_exit(ui):
    # Jimmy steps into the room and turns on the light
    ui, engine = init_roach_room(ui)

    ui.say("Jimmy")
    # He needs to walk through this kitchen to the dark hallway beyond.  In the corner of 
    # his eye he sees a cockroach off in the far corner
    ui.say("k")

    # After making a move towards the door, he notices that the cockroach has moved toward
    # the door as well
    ui.say("k")

    # Feeling a bit preturbed he takes another step towards the exit, the cockroach 
    # trying hard to avoid the light is running full speed toward the exit as well
    ui.say("k")

    # Jimmy makes it to the doorway and exits the room.  He happily shuts off the light and
    # walks down the dark hallway.
    ui.say("e")
    ui.say("q")

    engine.main_loop()
    assert ui.output_anywhere("turn on the light")
    turn_one = ui.output_index("<....r")
    turn_two = ui.output_index("<...r.")
    turn_three = ui.output_index("<..r..")
    turn_four = ui.output_index("@.r...")
    assert turn_one < turn_two
    assert turn_two < turn_three
    assert turn_three < turn_four
def test_power_leveling_paula_delves_deeply(ui):
    ui, engine = init_tiny_room(ui)
    # Power leveling Paula likes to get through a game as quickly as possible.
    # She will be overjoyed to travel through three levels to complete the game as quickly 
    # as possible
    ui.say("Paula")

    travel_to_the_next_level(ui)
    travel_to_the_next_level(ui)
    travel_to_the_next_level(ui)
    
    # Impressed by the game's literary acumen Leslie quits and writes a 5 star review 
    ui.say("q")
    engine.main_loop()
    assert ui.output_anywhere("harrowed and tiny halls of doom")
    assert ui.output_anywhere("second of three tiny rooms")
    assert ui.output_anywhere("third and final tiny room")

    assert ui.output_anywhere("completed the game")
Пример #5
0
def test_galaxy_man_satisfies_his_need_for_literary_immersion(ui):
    # Galaxy Man tries out the text adventure abd wants to see a
    # very interesting and immersive introduction to the game
    ui, engine = init_item_room(ui)

    # He starts it up and enters his name when prompted
    ui.say("begin")
    ui.say("Galaxy Man")
    ui.say("q")

    # Then he recieves a really spectacular introduction
    # describing the purpose of the game and includes an
    # indepth view of the game world.
    engine.main_loop()
    assert ui.output_anywhere("pork belly")
    assert ui.output_anywhere("to rescue the big pile of bacon")
    assert ui.output_anywhere("dark and moss covered room")
    assert ui.output_anywhere("with evil")
    assert ui.output_anywhere("the low-sodium cartel")
def test_power_leveling_paula_delves_deeply(ui):
    ui, engine = init_tiny_room(ui)
    # Power leveling Paula likes to get through a game as quickly as possible.
    # She will be overjoyed to travel through three levels to complete the game as quickly
    # as possible
    ui.say("Paula")

    travel_to_the_next_level(ui)
    travel_to_the_next_level(ui)
    travel_to_the_next_level(ui)

    # Impressed by the game's literary acumen Leslie quits and writes a 5 star review
    ui.say("q")
    engine.main_loop()
    assert ui.output_anywhere("harrowed and tiny halls of doom")
    assert ui.output_anywhere("second of three tiny rooms")
    assert ui.output_anywhere("third and final tiny room")

    assert ui.output_anywhere("completed the game")
def test_galaxy_man_satisfies_his_need_for_literary_immersion(ui):
    # Galaxy Man tries out the text adventure abd wants to see a 
    # very interesting and immersive introduction to the game
    ui, engine = init_item_room(ui)

    # He starts it up and enters his name when prompted
    ui.say("begin")
    ui.say("Galaxy Man")
    ui.say("q")

    # Then he recieves a really spectacular introduction
    # describing the purpose of the game and includes an
    # indepth view of the game world.
    engine.main_loop()
    assert ui.output_anywhere("pork belly")
    assert ui.output_anywhere("to rescue the big pile of bacon")
    assert ui.output_anywhere("dark and moss covered room")
    assert ui.output_anywhere("with evil")
    assert ui.output_anywhere("the low-sodium cartel")
def test_fred_can_stop_the_loop_with_lower_case_q(ui):
    ui, engine = init_test_room(ui)
    # Fred when closing the game as quickly as possible doesn't have time to press shift
    # He sends a lower case 'q' instead
    # The game closes anyway
    ui.say("Fred")
    ui.say("q")
    engine.main_loop()

    # The text adventure ends
    assert ui.output_anywhere(">")
def test_fred_can_stop_the_loop_with_lower_case_q(ui):
    ui, engine = init_test_room(ui)
    # Fred when closing the game as quickly as possible doesn't have time to press shift 
    # He sends a lower case 'q' instead
    # The game closes anyway
    ui.say("Fred")
    ui.say("q")
    engine.main_loop()

    # The text adventure ends 
    assert ui.output_anywhere(">")
def test_literary_leslie_loves_lots_of_lively_loquaciousness(ui):
    ui, engine = init_tiny_room(ui)
    engine.room_file = "tiny_room.json"
    # Literary Leslie likes her games to have nice descriptions of things
    # She would like to see life breathed into this text adventure with wonderous words

    ui.say("h")
    ui.say("j")
    ui.say("k")
    ui.say("l")

    ui.say("Literary")
    assert not ui.output_anywhere("dark and moss covered")
    # She travels to the exit searching for words
    ui.say("k")
    ui.say("l")
    ui.say("e")

    # Impressed by the game's literary acumen Leslie quits and writes a 5 star review
    ui.say("q")
    engine.main_loop()
    assert ui.output_anywhere("dark and moss covered")
def test_literary_leslie_loves_lots_of_lively_loquaciousness(ui):
    ui, engine = init_tiny_room(ui)
    engine.room_file = "tiny_room.json"
    # Literary Leslie likes her games to have nice descriptions of things
    # She would like to see life breathed into this text adventure with wonderous words
    
    ui.say("h")
    ui.say("j")
    ui.say("k")
    ui.say("l")

    ui.say("Literary")
    assert not ui.output_anywhere("dark and moss covered")
    # She travels to the exit searching for words 
    ui.say("k")
    ui.say("l")
    ui.say("e")

    # Impressed by the game's literary acumen Leslie quits and writes a 5 star review 
    ui.say("q")
    engine.main_loop()
    assert ui.output_anywhere("dark and moss covered")
def test_ian_inventory_can_see_all_items_on_map(ui):
    ui, engine = init_item_room(ui)
    # Ian walks into a room filled with lots of stuff and he wants to see the map
    # Ian wants to know all of the stuff in the room and definately wants to see everything
    # on the map
    # He types begin and enters the game
    ui.say("begin")
    ui.say("Ian")
    
    # The map displays all items in the room.  Ian sees the exit is one square south.
    # He moves there and exits
    ui.say("k")
    ui.say("e")

    # Having seen all there is to see, he quits the game and tells all of his friends about
    # the cool map.
    ui.say("q")
    engine.main_loop()
    assert ui.output_anywhere("....G")
    assert ui.output_anywhere("$...*")
    assert ui.output_anywhere("~....")
    assert ui.output_anywhere("<....")
    assert ui.output_anywhere("@....")
Пример #13
0
def test_ian_inventory_can_see_all_items_on_map(ui):
    ui, engine = init_item_room(ui)
    # Ian walks into a room filled with lots of stuff and he wants to see the map
    # Ian wants to know all of the stuff in the room and definately wants to see everything
    # on the map
    # He types begin and enters the game
    ui.say("begin")
    ui.say("Ian")

    # The map displays all items in the room.  Ian sees the exit is one square south.
    # He moves there and exits
    ui.say("k")
    ui.say("e")

    # Having seen all there is to see, he quits the game and tells all of his friends about
    # the cool map.
    ui.say("q")
    engine.main_loop()
    assert ui.output_anywhere("....G")
    assert ui.output_anywhere("$...*")
    assert ui.output_anywhere("~....")
    assert ui.output_anywhere("<....")
    assert ui.output_anywhere("@....")
def test_fred_can_start_and_stop_the_loop_with_ease(ui):
    ui, engine = init_test_room(ui)
    # Fred is an avid gamer, some would say that he is a compulsive gamer
    # It has gotten so bad that he games in the middle of the night, when he should be sleeping
    # He games in the day at work.
    # Sometimes he games when he should be mowing the lawn.
    # Today Fred is trying a new CodeNewbie text adventure game he found, he starts it up
    # As soon as he gets the prompt of the main loop his boss walks by
    # In a panic Fred presses "Q" to quit.
    ui.say("Fred")
    ui.say("Q")
    engine.main_loop()

    # The text adventure ends
    assert ui.output_anywhere(">")
def test_fred_can_start_and_stop_the_loop_with_ease(ui):
    ui, engine = init_test_room(ui)
    # Fred is an avid gamer, some would say that he is a compulsive gamer
    # It has gotten so bad that he games in the middle of the night, when he should be sleeping
    # He games in the day at work.
    # Sometimes he games when he should be mowing the lawn.
    # Today Fred is trying a new CodeNewbie text adventure game he found, he starts it up
    # As soon as he gets the prompt of the main loop his boss walks by
    # In a panic Fred presses "Q" to quit.
    ui.say("Fred")
    ui.say("Q")
    engine.main_loop()

    # The text adventure ends 
    assert ui.output_anywhere(">")
def test_jaime_can_get_help(ui):
    ui, engine = init_test_room(ui)
    # Jamie has heard from Fred that this new Python powered CodeNewbie text adventure game
    # is not only the cause of his loss of job and sleep, but is also relitively easy for
    # beginners to enjoy because the help functionality is so easy to use.  All she needs to
    # do to check the help is start the main loop.
    # Type 'help' and press enter.
    ui.say("Jaime")
    ui.say("help")
    ui.say("q")
    engine.main_loop()

    # A list of commands will display
    # Jamie can then quit the game and tell her friends all the ease of use.
    print(ui.printed)
    assert ui.output_anywhere("help")
def test_jaime_can_get_help(ui):
    ui, engine = init_test_room(ui)
    # Jamie has heard from Fred that this new Python powered CodeNewbie text adventure game
    # is not only the cause of his loss of job and sleep, but is also relitively easy for
    # beginners to enjoy because the help functionality is so easy to use.  All she needs to
    # do to check the help is start the main loop.
    # Type 'help' and press enter.
    ui.say("Jaime")
    ui.say("help")
    ui.say("q")
    engine.main_loop()

    # A list of commands will display
    # Jamie can then quit the game and tell her friends all the ease of use.
    print(ui.printed)
    assert ui.output_anywhere("help")
Пример #18
0
def test_linus_sees_quit_begin_and_help_in_menu_but_no_other_commands_before_entering_a_room(ui):
    # Linus plays the game for the first time, he has never seen a game like this
    # He wants to use the help menu heavily and try all of the commands he can.
    # He doesn't want any commands that aren't valid for teh state of the game. 
    # For instance he doesn't want to move his character when  he isn't in a room
    # He still wants to be able to start a game, quit and of course get help
    ui, engine = init_test_room(ui)

    ui.say("Guido")
    ui.say("help")
    ui.say("q")
    engine.main_loop()
    assert ui.output_anywhere("help -")
    assert ui.output_anywhere("q -")
    assert ui.output_anywhere("begin -")
    assert ui.output_anywhere("i -")
    assert ui.output_anywhere("j -")
    assert ui.output_anywhere("k -")
    assert ui.output_anywhere("l -")
    assert ui.output_anywhere("x -")