class UFOCreateTest(unittest.TestCase): def setUp(self): self.game = Game((100, 100), 0, 1, [('w', 1), ('w', 1), ('w', 1), ('w', 1), ('w', 1)], "s", [Asteroid(50, 50, 0, 0, 80, 100, 100)]) def test(self): self.game.create_ufo() self.assertEqual(len(self.game.ufo_list), 1)
class CheckUFOPlayerCollision(unittest.TestCase): def setUp(self): self.game = Game((100, 100), 0, 1, [('w', 1), ('w', 1), ('w', 1), ('w', 1), ('w', 1)], "s", [Asteroid(0, 0, 0, 0, 1, 100, 100)]) def test(self): self.game.create_ufo() self.game.player.x = self.game.ufo_list[0].x self.game.player.y = self.game.ufo_list[0].y self.game.check_collision() self.assertTrue(self.game.player.health == 2)
class UFOShotTest(unittest.TestCase): def setUp(self): self.game = Game((100, 100), 0, 1, [('w', 1), ('w', 1), ('w', 1), ('w', 1), ('w', 1)], "s", [Asteroid(50, 50, 0, 0, 80, 100, 100)]) def test(self): self.game.create_ufo() self.game.shots.append(self.game.ufo_list[0].shot(self.game.player)) self.assertEqual(len(self.game.shots), 1) self.game.ufo_try_shot() self.assertEqual(len(self.game.shots), 2)
class CheckUFOPCollision(unittest.TestCase): def setUp(self): self.game = Game((100, 100), 0, 1, [('w', 1), ('w', 1), ('w', 1), ('w', 1), ('w', 1)], "s", [Asteroid(0, 0, 0, 0, 1, 100, 100)]) def test(self): self.game.create_ufo() self.game.shots.append(self.game.ufo_list[0].shot(self.game.player)) self.game.shots[0].x = self.game.ufo_list[0].x self.game.shots[0].y = self.game.ufo_list[0].y self.game.check_collision() self.assertEqual(len(self.game.ufo_list), 0) self.assertEqual(self.game.player.score, 2) self.assertEqual(len(self.game.shots), 0)