def test_play_outside_borders():
    map = ["@..P"]

    x, y = find_pacman(map)
    play(map, 'a')

    assert find_pacman(map) == (x, y)
def test_play_wall():
    map = ["|@..P"]

    x, y = find_pacman(map)
    play(map, 'a')

    assert find_pacman(map) == (x, y)
Exemplo n.º 3
0
    def test_play_wall(self):
        map = ["|@..P"]

        x, y = find_pacman(map)
        play(map, 'a')

        self.assertEqual(find_pacman(map), (x, y))
def test_play_invalid():
    map = get_map()

    x, y = find_pacman(map)
    play(map, 'x')

    assert find_pacman(map) == (x, y)
def test_play_move():
    map = get_map()

    x, y = find_pacman(map)
    play(map, 'a')

    assert find_pacman(map) == (x, y - 1)
Exemplo n.º 6
0
    def test_play_invalid(self):
        map = get_map()

        x, y = find_pacman(map)
        play(map, 'x')

        self.assertEqual(find_pacman(map), (x, y))
Exemplo n.º 7
0
    def test_play_outside_borders(self):
        map = ["@..P"]

        x, y = find_pacman(map)
        play(map, 'a')

        self.assertEqual(find_pacman(map), (x, y))
Exemplo n.º 8
0
    def test_play_move(self):
        map = get_map()

        x, y = find_pacman(map)
        play(map, 'a')

        self.assertEqual(find_pacman(map), (x, y - 1))
def test_play_eat_pills():
    map = get_map()

    x, y = find_pacman(map)
    play(map, 'a')

    assert find_pacman(map) == (x, y - 1)
    assert total_pills(map) == 3

    play(map, 'w')

    assert find_pacman(map) == (x - 1, y - 1)
    assert total_pills(map) == 2
Exemplo n.º 10
0
    def test_play_eat_pills(self):
        map = get_map()

        x, y = find_pacman(map)
        play(map, 'a')

        self.assertEqual(find_pacman(map), (x, y - 1))
        self.assertEqual(total_pills(map), 3)

        play(map, 'w')

        self.assertEqual(find_pacman(map), (x - 1, y - 1))
        self.assertEqual(total_pills(map), 2)
Exemplo n.º 11
0
def test_play_win():
    simple_map_2 = get_simple_map_2()

    game_finished, win = play(simple_map_2, 'd')

    assert game_finished is True
    assert win is True
Exemplo n.º 12
0
def test_play_die():
    simple_map = get_simple_map()

    game_finished, win = play(simple_map, 'a')

    assert game_finished is True
    assert win is False
Exemplo n.º 13
0
    def test_play_win(self):
        simple_map_2 = get_simple_map_2()

        game_finished, win, _ = play(simple_map_2, 'd')

        self.assertTrue(game_finished)
        self.assertTrue(win)
Exemplo n.º 14
0
    def test_play_die(self):
        simple_map = get_simple_map()

        game_finished, win, _ = play(simple_map, 'a')

        self.assertTrue(game_finished)
        self.assertFalse(win)
Exemplo n.º 15
0
def run(map, ui_print, ui_key, ui_final_message, generate_int):
    game_finished = False
    win = False
    while not game_finished:

        ui_print(map)

        key = ui_key()
        game_finished, win = play(map, key)

        if not game_finished:
            game_finished, win = move_ghosts(map, generate_int)

    # print the map for the last time
    ui_print(map)
    ui_final_message(win)

    return game_finished, win