def dacia(pRazedCity, iPlayer):
"""
Power of the Sword - cities within x tiles of a razed city may flip to Dacia.
"""
if iPlayer == eDacia:
tCoordsRazed = getCoords(pRazedCity)
pCivDacia = instance(eDacia)
iPreviousOwner = pRazedCity.getPreviousOwner()
if not checkCityProximity(tCoordsRazed, iDaciaDistance): #this implies that it is not allowed to put a city here (ie there is at least one city within the distance)
tCoords1 = (max(tCoordsRazed[0] - iDaciaDistance, 0), max(tCoordsRazed[1] - iDaciaDistance, 0))
tCoords2 = (min(tCoordsRazed[0] + iDaciaDistance, Map.getGridWidth()), min(tCoordsRazed[1] + iDaciaDistance, Map.getGridHeight()))
x = 0
for pCity in findAreaCities(tCoords1, tCoords2, iPreviousOwner):
if isChance(max(iDaciaChance - max((pCity.getPopulation()-4)*2, 0), 0)) and x < iDaciaMaxCities:
if pCity.isCapital(): continue
flipCity(pCivDacia, pCity, bDaciaFlipUnits)
if cityKnownByHuman(pCity) and not pCivDacia.get(CyPlayer).isHuman():
addMessage(sDaciaFlipMessageThem, (getCivName(gc.getPlayer(iPreviousOwner), "adjective"), pCity.getName()), eWhite, getCoords(pCity))
elif pCivDacia.get(CyPlayer).isHuman():
addMessage(sDaciaFlipMessageUs, (getCivName(gc.getPlayer(iPreviousOwner), "adjective"), pCity.getName()), eGreen, getCoords(pCity))
elif gc.getPlayer(iPreviousOwner).isHuman():
addMessage(sDaciaFlipMessageLost, (pCity.getName()), eRed, getCoords(pCity))
if not bDaciaFlipUnits: spawnCityGarrison(pCivDacia, pCity, 3)
x += 1
def flipCity(pCivPlayer, pCity, bFlipUnits = False, bConquored = False, bTrade = False, bKillUnits = True):
if bFlipUnits:
lUnitTypes = (pUnit.getUnitType() for pUnit in getCityUnits(pCity))
if bKillUnits:
killCityUnits(pCity)
pCivPlayer.get(CyPlayer).acquireCity(pCity, bConquored, bTrade)
if bFlipUnits:
for iUnitType in lUnitTypes:
pCivPlayer.get(PyPlayer).initUnit(iUnitType, pCity.getX(), pCity.getY(), 1)
def killCityUnits(pCity):
"""
Kills all units in pCity belonging to the owner
"""
lUnits = getCityUnits(pCity)
for pUnit in lUnits:
if pUnit.getOwner() == pCity.getOwner(): pUnit.kill(False, pCity.getOwner())
def getCityUnits(pCity):
"""
Returns a list array of all units in pCity (CyCity object) belonging to the city's
owner.
"""
eOwner = pCity.getOwner()
pPlot = pCity.plot()
for pUnit in (pPlot.getUnit(iUnit) for iUnit in xrange(pPlot.getNumUnits())):
if pUnit.getOwner() != eOwner: continue
yield pUnit
## The Motherland Calls Start ##
if bIsWar:
pTeam2 = gc.getTeam(iRivalTeam)
if pTeam2.getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_THE_MOTHERLAND_CALLS")) == 1:
[COLOR="DarkRed"]pTeam = gc.getTeam(iTeam)
if not pTeam.isAVassal():[/COLOR]
for iPlayerX in xrange(gc.getMAX_CIV_PLAYERS()):
pPlayerX = gc.getPlayer(iPlayerX)
if pPlayerX.getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_THE_MOTHERLAND_CALLS")) == 1:
(loopCity, iter) = pPlayerX.firstCity(false)
while(loopCity):
loopCity.changeHappinessTimer(10)
pNewUnit = pPlayerX.initUnit(loopCity.getConscriptUnit(), loopCity.getX(), loopCity.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION)
loopCity.addProductionExperience(pNewUnit, true)
(loopCity, iter) = pPlayerX.nextCity(iter, false)
[COLOR="DarkRed"]break[/COLOR]
## The Motherland Calls End ##