コード例 #1
0
def test_play_outside_borders():
    map = ["@..P"]

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

    assert find_pacman(map) == (x, y)
コード例 #2
0
def test_play_wall():
    map = ["|@..P"]

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

    assert find_pacman(map) == (x, y)
コード例 #3
0
    def test_play_wall(self):
        map = ["|@..P"]

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

        self.assertEqual(find_pacman(map), (x, y))
コード例 #4
0
def test_play_invalid():
    map = get_map()

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

    assert find_pacman(map) == (x, y)
コード例 #5
0
def test_play_move():
    map = get_map()

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

    assert find_pacman(map) == (x, y - 1)
コード例 #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))
コード例 #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))
コード例 #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))
コード例 #9
0
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
コード例 #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)
コード例 #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
コード例 #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
コード例 #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)
コード例 #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)
コード例 #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