def test_handle_collision_reverse_direction(self): game = games.Tag(10, self.tree, 5, 3, 4) player1, player2 = list(game._players.values())[:2] dir1, dir2 = player1._direction, player2._direction game.handle_collision(player1._name, player2._name) assert dir1 != player1._direction assert dir2 != player2._direction
def test_handle_collision_one_is_it(self): game = games.Tag(10, self.tree, 5, 3, 4) it = game._it it_points = game._players[it].get_points() not_it = next(p for p in game._players if p != game._it) game.handle_collision(it, not_it) assert game._it == not_it assert it_points + 1 == game._players[game._it].get_points()
def test_check_for_winner_two_left(self): game = games.Tag(2, self.tree, 5, 3, 4) winner = next(p for p in game._players if p != game._it) assert game.check_for_winner() == winner
def test_check_for_winner_one_left(self): game = games.Tag(1, self.tree, 5, 3, 4) assert game.check_for_winner() == list(game._players)[0]
def test_check_for_winner_no_winner(self): game = games.Tag(10, self.tree, 5, 3, 4) assert game.check_for_winner() is None
def test_init(self): game = games.Tag(10, self.tree, 5, 3, 4) assert len(game._players) == 10 assert all(name in game.field for name in game._players) assert game._it in game._players assert game._players[game._it]._colour == 'purple'
def setup_method(self): self.game = games.Tag(5, trees.TwoDTree((0, 0), (500, 500)), 5, 3, 4)
def setup_method(self): self.game = games.Tag(5, trees.QuadTree((250, 250)), 5, 3, 4)