Пример #1
0
    def test_healthmultiplier(self):
        testGame = game.PyFenseGame(1)
        enemy1 = enemy.PyFenseEnemy((0, 0), 0, 1, 1, testGame.movePath, 1)
        enemy2 = enemy.PyFenseEnemy((0, 0), 0, 1, 1, testGame.movePath, 2.5)

        actualResult = enemy1.attributes["maxhealth"] * 2.5
        result = enemy2.healthPoints
        self.assertEqual(result, actualResult)
Пример #2
0
 def test_distance(self):
     test_enemy1 = enemy.PyFenseEnemy((0, 0), 0, 1, 1, 0, 1)
     test_enemy2 = enemy.PyFenseEnemy((4, 3), 0, 1, 1, 0, 1)
     test_enemy3 = enemy.PyFenseEnemy((3, 4), 0, 1, 1, 0, 1)
     test_entities = entities.PyFenseEntities(0, 0, 0)
     actualResult1 = test_entities._distance(test_enemy1, test_enemy2)
     actualResult2 = test_entities._distance(test_enemy1, test_enemy3)
     result = 5
     self.assertEqual(result, actualResult1)
     self.assertEqual(result, actualResult2)
Пример #3
0
 def test_move(self):
     testGame = game.PyFenseGame(1)
     testEnemy = enemy.PyFenseEnemy((0, 0), 0, 1, 1, testGame.movePath, 1)
     testEnemy._move(0)
     actionAssigned = testEnemy.actions
     if not actionAssigned:
         self.fail('No actions assigned!')
Пример #4
0
 def initiate_projectile(self):
     self.testGame = game.PyFenseGame(1)
     self.testPath = self.testGame.movePath
     self.testTower = tower.PyFenseTower(0, (50, 70))
     self.testEnemy = enemy.PyFenseEnemy((50, 40), 0, 1, 1, self.testPath,
                                         2)
     self.testProjectile = projectileParticle.PyFenseProjectileSlow(
         self.testTower, self.testEnemy, 1, 45, 1000, 50, 'normal', 5, 1)
Пример #5
0
 def test_update_enemies_order(self):
     test_entities = entities.PyFenseEntities(0, 0, 0)
     test_enemy1 = enemy.PyFenseEnemy((0, 0), 0, 1, 1, 0, 1)
     test_enemy2 = enemy.PyFenseEnemy((0, 0), 0, 1, 1, 0, 1)
     test_enemy3 = enemy.PyFenseEnemy((0, 0), 0, 1, 1, 0, 1)
     test_entities.enemies = [test_enemy1, test_enemy2, test_enemy3]
     test_enemy1.distance = 5
     test_enemy2.distance = 2
     test_enemy3.distance = 3
     test_entities._update_enemies_order(0)
     result = [5, 3, 2]
     actualResult = [
         test_entities.enemies[0].distance,
         test_entities.enemies[1].distance,
         test_entities.enemies[2].distance
     ]
     self.assertEqual(result, actualResult)
Пример #6
0
    def test_poison(self):
        testGame = game.PyFenseGame(1)
        testEnemy = enemy.PyFenseEnemy((0, 0), 0, 1, 1, testGame.movePath, 1)
        actualResult = testEnemy.healthPoints - 5
        testEnemy.poison(5, 2)
        testEnemy._decrease_health(0)
        result = testEnemy.healthPoints

        self.assertEqual(result, actualResult)
Пример #7
0
    def test_freeze(self):
        testGame = game.PyFenseGame(1)
        testEnemy = enemy.PyFenseEnemy((0, 0), 0, 1, 1, testGame.movePath, 1)

        testEnemy.freeze(5, 2)

        actualResult = testEnemy.attributes['speed']/5
        result = testEnemy.currentSpeed
        self.assertEqual(result, actualResult)
Пример #8
0
 def initiate_tower(self):
     self.testTower = tower.PyFenseTower(1, (0, 0))
     self.testGame = game.PyFenseGame(1)
     self.testEnemy = enemy.PyFenseEnemy((300, 200), 1, 1, 1,
                                         self.testGame.movePath, 1)
     self.testEntities = entities.PyFenseEntities(
         self.testGame.movePath, self.testGame.startTile,
         self.testGame.endTile)
     self.testEntities.add(self.testTower)
     self.testEntities.enemies.append(self.testEnemy)
Пример #9
0
 def initiate_projectile(self):
     self.testGame = game.PyFenseGame(1)
     self.testPath = self.testGame.movePath
     self.image = resources.load_image('projectile01.png')
     self.testTower = tower.PyFenseTower(0, (50, 70))
     self.testEnemy = enemy.PyFenseEnemy((50, 40), 0, 1, 1, self.testPath,
                                         2)
     self.testProjectile = projectile.PyFenseProjectile(
         self.testTower, self.testEnemy, self.image, 0, 0, 1000, 50,
         'normal', 5, 1)
Пример #10
0
    def test_deal_damage(self):
        test_entities = entities.PyFenseEntities(0, 0, 0)
        test_enemy = enemy.PyFenseEnemy((0, 0), 0, 1, 1, 0, 1)

        result_health = test_enemy.attributes["maxhealth"] - 10
        result_speed = test_enemy.attributes["speed"] / 2
        test_entities._deal_damage(10, test_enemy, 'slow', 1, 2)
        actualResult_health = test_enemy.healthPoints
        actualResult_speed = test_enemy.currentSpeed
        self.assertEqual(result_health, actualResult_health)
        self.assertEqual(result_speed, actualResult_speed)
Пример #11
0
 def _add_enemy(self, dt):
     self.unschedule(self._add_enemy)
     newEnemy = enemy.PyFenseEnemy(
         self.startTile, self.spawningList[self.spawnedEnemies][0],
         self.spawningList[self.spawnedEnemies][1], 1, self.path,
         self.multiplier)
     self.enemies.append(newEnemy)
     self.spawnedEnemies += 1
     self.add(newEnemy, z=3)
     self.add(newEnemy.healthBarBackground, z=6)
     self.add(newEnemy.healthBar, z=7)
     if self.spawnedEnemies != self.enemieslength:
         self.schedule_interval(
             self._add_enemy, self.spawningList[self.spawnedEnemies - 1][2])
     self._is_wave_finished()
Пример #12
0
 def test_is_move_function_scheduled(self):
     testGame = game.PyFenseGame(1)
     testEnemy = enemy.PyFenseEnemy((0, 0), 0, 1, 1, testGame.movePath, 1)
     isScheduled = testEnemy.scheduled_interval_calls
     if not isScheduled:
         self.fail('No scheduled calls!')