def test_handle_collision_reverse_direction(self): game = games.ZombieTag(10, self.tree, 5, 3, 4) player1, player2 = list(game._humans.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_zombie_attack(self): game = games.ZombieTag(10, self.tree, 5, 3, 4) human = list(game._humans.values())[0] zombie = list(game._zombies.values())[0] game.handle_collision(human._name, zombie._name) assert zombie._name in game._zombies assert human._name in game._zombies assert human._name not in game._humans
def test_init(self): game = games.ZombieTag(10, self.tree, 5, 3, 4) assert len(game._humans) == 10 assert all(name in game.field for name in game._zombies) assert all(name in game.field for name in game._humans) assert len(game._zombies.keys() & game._humans.keys()) == 0 assert all(player._colour == 'green' for _, player in game._humans.items()) assert len(game._zombies) == 1 assert game._zombies.popitem()[1]._colour == 'purple'
def test_check_for_winner_zombies_win(self): game = games.ZombieTag(1, self.tree, 5, 3, 4) human = list(game._humans.values())[0] zombie = list(game._zombies.values())[0] game.handle_collision(human._name, zombie._name) assert game.check_for_winner() == 'zombies'
def test_check_for_winner_humans_win(self): game = games.ZombieTag(2, self.tree, 5, 3, 4) assert game.check_for_winner() == 'humans'