Пример #1
0
 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
Пример #2
0
 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
Пример #3
0
 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'
Пример #4
0
 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'
Пример #5
0
 def test_check_for_winner_humans_win(self):
     game = games.ZombieTag(2, self.tree, 5, 3, 4)
     assert game.check_for_winner() == 'humans'