Esempio n. 1
0
    def wrapper(self, *args, **kwargs):
        if not _is_game_started(self.game):
            print('Game is not running.')
            return

        func(self, *args, **kwargs)
        print(string_game_renderer.render(self.game))
def it_returns_a_human_readable_string_when_player_has_been_killed_by_wumpus():
    game = a_game().with_hunter().build()
    game.gold.position = Vector2D(3, 3)
    game.wumpus.position = Vector2D(0, 0)

    human_readable_string = string_game_renderer.render(game)

    assert human_readable_string == string_game_renderer.KILLED_BY_WUMPUS
def it_returns_a_human_readable_string_when_player_leaves_successfully_the_dungeon_with_the_gold_and_the_wumpus_alive(
):
    game = a_game().with_hunter().build()
    game.player.has_gold = True
    game.status = GameStatus.WIN

    human_readable_string = string_game_renderer.render(game)

    assert human_readable_string == string_game_renderer.WIN_WITHOUT_KILL_WUMPUS
Esempio n. 4
0
    def do_start_game(self, line):
        """Starts new game. Usage: start_game [columns=4] [rows=4] [hunter_arrows=2] [bottomless_pits=4]"""
        game_options = wumpus_cli_command_parser.parse_game_value_options(line)

        try:
            self.game = game_service.start(game_options)
            print(string_game_renderer.render(self.game))
        except GameBuilderError:
            print(f"Game options does not fit constraints: {line}")
def it_returns_a_human_readable_string_when_player_has_fallen_in_the_bottomless_pit(
):
    game = a_game().with_hunter().build()
    game.gold.position = Vector2D(3, 3)
    game.wumpus.position = Vector2D(3, 3)
    game.add_bottomless_pit(BottomlessPit(Vector2D(0, 0)))

    human_readable_string = string_game_renderer.render(game)

    assert human_readable_string == string_game_renderer.DEAD_BY_PIT
def it_returns_a_human_readable_string_telling_the_current_game_situation():
    game = a_game().with_hunter().build()
    game.gold.position = Vector2D(3, 3)
    game.wumpus.position = Vector2D(3, 2)

    human_readable_string = string_game_renderer.render(game)

    assert human_readable_string == ('---------------------\n'
                                     'Position:    [0, 0]\n'
                                     'Direction    NORTH\n'
                                     'Golds:       0\n'
                                     'Arrows left: 10\n'
                                     '---------------------\n'
                                     'Presences: \n'
                                     ' * You are in the exit position\n')
def it_returns_a_human_readable_string_without_presences():
    game = a_game().with_hunter().build()
    game.gold.position = Vector2D(3, 3)
    game.wumpus.position = Vector2D(3, 2)
    game.exit = Vector2D(3, 1)

    human_readable_string = string_game_renderer.render(game)

    assert human_readable_string == ('---------------------\n'
                                     'Position:    [0, 0]\n'
                                     'Direction    NORTH\n'
                                     'Golds:       0\n'
                                     'Arrows left: 10\n'
                                     '---------------------\n'
                                     'Presences: \n')
def it_returns_a_human_readable_string_with_3_arrows_left():
    game = a_game().with_hunter().build()
    game.gold.position = Vector2D(3, 3)
    game.wumpus.position = Vector2D(3, 2)
    game.player.arrows_left = 3

    human_readable_string = string_game_renderer.render(game)

    assert human_readable_string == ('---------------------\n'
                                     'Position:    [0, 0]\n'
                                     'Direction    NORTH\n'
                                     'Golds:       0\n'
                                     'Arrows left: 3\n'
                                     '---------------------\n'
                                     'Presences: \n'
                                     ' * You are in the exit position\n')
def it_returns_a_human_readable_string_when_player_is_in_front_of_a_wall():
    game = a_game().with_hunter(direction=Direction.SOUTH).build()
    game.exit = Vector2D(3, 3)
    game.wumpus.position = Vector2D(3, 3)

    human_readable_string = string_game_renderer.render(game)

    assert human_readable_string == (
        '---------------------\n'
        'Position:    [0, 0]\n'
        'Direction    SOUTH\n'
        'Golds:       0\n'
        'Arrows left: 10\n'
        '---------------------\n'
        'Presences: \n'
        ' * It feels too strong to pass through... could it be a wall?\n')
Esempio n. 10
0
def it_returns_a_human_readable_string_when_player_has_gold():
    game = a_game().with_hunter().build()
    game.player.has_gold = True
    game.gold = None
    game.status = GameStatus.PLAYING
    game.wumpus.position = Vector2D(3, 3)
    game.exit = Vector2D(3, 3)

    human_readable_string = string_game_renderer.render(game)

    assert human_readable_string == ('---------------------\n'
                                     'Position:    [0, 0]\n'
                                     'Direction    NORTH\n'
                                     'Golds:       1\n'
                                     'Arrows left: 10\n'
                                     '---------------------\n'
                                     'Presences: \n')
Esempio n. 11
0
def it_returns_a_human_readable_string_with_bottomless_pit_presence():
    game = a_game().with_hunter().build()
    game.gold.position = Vector2D(3, 3)
    game.wumpus.position = Vector2D(3, 3)
    game.add_bottomless_pit(BottomlessPit(Vector2D(1, 0)))
    game.exit = Vector2D(3, 3)

    human_readable_string = string_game_renderer.render(game)

    assert human_readable_string == (
        '---------------------\n'
        'Position:    [0, 0]\n'
        'Direction    NORTH\n'
        'Golds:       0\n'
        'Arrows left: 10\n'
        '---------------------\n'
        'Presences: \n'
        ' * A fresh breeze fills you with determination\n')
Esempio n. 12
0
def it_returns_a_human_readable_string_when_player_is_over_a_dead_wumpus():
    game = a_game().with_hunter().build()
    game.wumpus.is_alive = False
    game.wumpus.position = game.player.position
    game.exit = Vector2D(3, 3)

    human_readable_string = string_game_renderer.render(game)

    assert human_readable_string == (
        '---------------------\n'
        'Position:    [0, 0]\n'
        'Direction    NORTH\n'
        'Golds:       0\n'
        'Arrows left: 10\n'
        '---------------------\n'
        'Presences: \n'
        ' * You feel that Cupid is near after watch that arrow in the Wumpus heart\n'
    )
Esempio n. 13
0
def it_returns_many_overlapped_presences():
    game = a_game().with_hunter(direction=Direction.SOUTH).build()
    game.wumpus.is_alive = False
    game.gold.position = game.player.position
    game.wumpus.position = game.player.position
    game.add_bottomless_pit(BottomlessPit(Vector2D(1, 0)))

    human_readable_string = string_game_renderer.render(game)

    assert human_readable_string == (
        '---------------------\n'
        'Position:    [0, 0]\n'
        'Direction    SOUTH\n'
        'Golds:       0\n'
        'Arrows left: 10\n'
        '---------------------\n'
        'Presences: \n'
        ' * You are in the exit position\n'
        ' * A fresh breeze fills you with determination\n'
        ' * You feel that Cupid is near after watch that arrow in the Wumpus heart\n'
        ' * It feels too strong to pass through... could it be a wall?\n'
        ' * The gold is here!\n')