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)
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)
def test_play_invalid(self): map = get_map() x, y = find_pacman(map) play(map, 'x') self.assertEqual(find_pacman(map), (x, y))
def test_play_outside_borders(self): map = ["@..P"] x, y = find_pacman(map) play(map, 'a') self.assertEqual(find_pacman(map), (x, y))
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
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)
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
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
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)
def test_play_die(self): simple_map = get_simple_map() game_finished, win, _ = play(simple_map, 'a') self.assertTrue(game_finished) self.assertFalse(win)
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