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)
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)
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)
def on_build_tower(self, towerNumber, pos_x, pos_y): if self._get_grid_pix(pos_x, pos_y) > 3: return toBuildTower = tower.PyFenseTower(towerNumber, (pos_x, pos_y)) if toBuildTower.attributes["cost"] > self.currentCurrency: return self.currentCurrency -= self.entityMap.build_tower(toBuildTower) self.hud.update_currency_number(self.currentCurrency) self._set_grid_pix( pos_x, pos_y, int(float("1" + str(towerNumber) + str(toBuildTower.attributes["lvl"]))))
def test_build_remove(self): test_entities = entities.PyFenseEntities(0, 0, 0) test_tower = tower.PyFenseTower(0, (50, 70)) result = test_entities.build_tower(test_tower) actualResult = 50 self.assertEqual(result, actualResult) self.assertEqual(test_entities.towers[0], test_tower) result2 = test_entities.remove_tower((50, 70)) actualResult2 = 50 self.assertEqual(result2, actualResult2) self.assertEqual(test_entities.towers, [])
def on_upgrade_tower(self, position): """ Updates the the tower at the given position with a new tower with upgraded attributes and assets. Also updates the change in the Map-Matrix """ oldTower = self.entityMap.get_tower_at(position) towerLevel = oldTower.attributes["lvl"] if towerLevel == 3: return towerNumber = oldTower.attributes["tower"] cost = resources.tower[towerNumber][towerLevel + 1]["cost"] if cost > self.currentCurrency: return self.currentCurrency -= cost self.hud.update_currency_number(self.currentCurrency) self.entityMap.remove_tower(position) newTower = tower.PyFenseTower( towerNumber, position, towerLevel + 1) self.entityMap.build_tower(newTower) (x, y) = position self._set_grid_pix(x, y, int(float("1" + str(towerNumber) + str(towerLevel + 1))))