class CvMesoamericaSpanishInvation:
def __init__(self):
'Constructor'
self.wave = 0
# We keep a list of our invading ships so that we can
# update their AI in CvGameUtils
self.ships = []
self.landingPlots = [CyMap().plot(11, 29),
CyMap().plot(13, 25),
CyMap().plot(15, 22),
CyMap().plot(18, 18),
CyMap().plot(21, 16),
CyMap().plot(25, 15),
CyMap().plot(29, 17),
CyMap().plot(34, 16),
CyMap().plot(36, 20),
CyMap().plot(36, 24),
CyMap().plot(39, 27),
CyMap().plot(42, 28),
CyMap().plot(45, 28),
CyMap().plot(48, 28),
CyMap().plot(49, 24),
CyMap().plot(48, 19),
CyMap().plot(45, 10)]
self.spawnPlots = [CyMap().plot(24, 33),
CyMap().plot(25,33),
CyMap().plot(25, 33)]
def update(self):
'Called every turn'
turn = CyGame().getGameTurn()
if (turn == 50 or turn == 70 or turn == 100 or turn == 130):
#if (turn == 3 or turn == 12 or turn == 24 or turn == 36):
self.__spawnSpanish()
def getShips(self):
return self.ships
# Private methods
def __spawnSpanish(self):
'Spawns a wave of spanish units'
spanishPlayer = PyPlayer(SPANISH_PLAYER)
if (self.wave == 0):
print("Spawing wave 0")
spawnPlot = self.spawnPlots[0]
landingPlot = self.landingPlots[randomNumber(0, len(self.landingPlots) - 1) ]
unitIDs = []
unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_GALLEON'), UnitAITypes.NO_UNITAI])
unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_SETTLER'), UnitAITypes.NO_UNITAI])
unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_EXPLORER'), UnitAITypes.NO_UNITAI])
unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_EXPLORER'), UnitAITypes.NO_UNITAI])
self.__spawnWave(unitIDs, spawnPlot, landingPlot)
elif (self.wave == 1):
print("Spawning wave 1")
spawnPlot = self.spawnPlots[0]
landingPlot = self.landingPlots[randomNumber(0, len(self.landingPlots) - 1) ]
unitIDs = []
unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_GALLEON'), UnitAITypes.NO_UNITAI])
unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_SPANISH_CONQUISTADOR'), UnitAITypes.NO_UNITAI])
unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_EXPLORER'), UnitAITypes.NO_UNITAI])
unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_SETTLER'), UnitAITypes.NO_UNITAI])
self.__spawnWave(unitIDs, spawnPlot, landingPlot)
elif (self.wave == 2):
print("Spawning wave 2")
spawnPlot = self.spawnPlots[0]
landingPlot = self.landingPlots[randomNumber(0, len(self.landingPlots) - 1) ]
unitIDs = []
unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_GALLEON'), UnitAITypes.NO_UNITAI])
unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_SPANISH_CONQUISTADOR'), UnitAITypes.NO_UNITAI])
unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_EXPLORER'), UnitAITypes.NO_UNITAI])
unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_SETTLER'), UnitAITypes.NO_UNITAI])
self.__spawnWave(unitIDs, spawnPlot, landingPlot)
unitIDs = []
unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_GALLEON'), UnitAITypes.NO_UNITAI])
unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_SPANISH_CONQUISTADOR'), UnitAITypes.NO_UNITAI])
unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_EXPLORER'), UnitAITypes.NO_UNITAI])
unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_SETTLER'), UnitAITypes.NO_UNITAI])
spawnPlot = self.spawnPlots[1]
landingPlot = self.landingPlots[randomNumber(0, len(self.landingPlots) - 1) ]
self.__spawnWave(unitIDs, spawnPlot, landingPlot)
unitIDs = []
unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_GALLEON'), UnitAITypes.NO_UNITAI])
unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_EXPLORER'), UnitAITypes.NO_UNITAI])
unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_EXPLORER'), UnitAITypes.NO_UNITAI])
unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_SETTLER'), UnitAITypes.NO_UNITAI])
spawnPlot = self.spawnPlots[2]
landingPlot = self.landingPlots[randomNumber(0, len(self.landingPlots) - 1) ]
self.__spawnWave(unitIDs, spawnPlot, landingPlot)
elif (self.wave == 3):
print("Spawning wave 3")
unitIDs = []
unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_GALLEON'), UnitAITypes.NO_UNITAI])
unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_EXPLORER'), UnitAITypes.NO_UNITAI])
unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_SPANISH_CONQUISTADOR'), UnitAITypes.NO_UNITAI])
unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_SETTLER'), UnitAITypes.NO_UNITAI])
spawnPlot = self.spawnPlots[1]
landingPlot = self.landingPlots[randomNumber(0, len(self.landingPlots) - 1) ]
self.__spawnWave(unitIDs, spawnPlot, landingPlot)
unitIDs = []
unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_GALLEON'), UnitAITypes.NO_UNITAI])
unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_EXPLORER'), UnitAITypes.NO_UNITAI])
unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_SPANISH_CONQUISTADOR'), UnitAITypes.NO_UNITAI])
unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_SETTLER'), UnitAITypes.NO_UNITAI])
spawnPlot = self.spawnPlots[1]
landingPlot = self.landingPlots[randomNumber(0, len(self.landingPlots) - 1) ]
self.__spawnWave(unitIDs, spawnPlot, landingPlot)
unitIDs = []
unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_GALLEON'), UnitAITypes.NO_UNITAI])
unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_EXPLORER'), UnitAITypes.NO_UNITAI])
unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_EXPLORER'), UnitAITypes.NO_UNITAI])
unitIDs.append([CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_SETTLER'), UnitAITypes.NO_UNITAI])
spawnPlot = self.spawnPlots[2]
landingPlot = self.landingPlots[randomNumber(0, len(self.landingPlots) - 1) ]
self.__spawnWave(unitIDs, spawnPlot, landingPlot)
self.wave = self.wave + 1
def __spawnWave(self, unitIDs, spawnPlot, landingPlot):
spanishPlayer = PyPlayer(SPANISH_PLAYER)
print(unitIDs)
# Init the units
units = []
for element in unitIDs:
print(element)
newUnit = spanishPlayer.initUnit(element[0], spawnPlot.getX(), spawnPlot.getY(), element[1])
print(newUnit)
units.append(newUnit)
print(units)
# Assuming a ship is our first unit..
self.ships.append([units[0], landingPlot])
# Push our mission
units[0].getGroup().pushMission(MissionTypes.MISSION_MOVE_TO, landingPlot.getX(), landingPlot.getY(), 0, False, True, MissionAITypes.NO_MISSIONAI, landingPlot, units[0])