def onImprovementBuilt(self, argsList):
'Improvement Built'
iImprovement, iX, iY = argsList
pPlot = CyMap().plot(iX,iY)
#GreenMod: get city for terraform checks
if (iImprovement==iWaterland1 or iImprovement==iWaterland2):
bCityCheck = 0
for x in [-1,0,1]:
for y in [-1,0,1]:
if CyMap().plot(iX +x, iY +y).isCity() == 1:
iCityX = iX +x
iCityY = iY +y
pCity = CyMap().plot(iX +x, iY +y).getPlotCity()
bCityCheck = 1
#GreenMod: water and land switching, PART1
if iImprovement==iWaterland1:
#if built on water (coast), for later upgrade to land
if pPlot.getTerrainType() == 5:
#not city near, so delete it
if not bCityCheck == 1:
pPlot.setImprovementType(-1)
else:
#if on land and has just been upgraded to, make to water
pPlot.setImprovementType(-1)
pPlot.setTerrainType(5, 1, 1)
#GreenMod: now the other direction, terraform, PART2
if iImprovement==iWaterland2:
#if built on land (any), for later upgrade to water
if not pPlot.getTerrainType() == 5:
#not city near, so delete it
if not bCityCheck == 1:
pPlot.setImprovementType(-1)
else:
#if on water and has just been upgraded to, make to land
pPlot.setImprovementType(-1)
#city terrain will be terrain of new land
iNewTerrain = 2
iNewTerrain = CyMap().plot(iCityX, iCityY).getTerrainType()
pPlot.setTerrainType(iNewTerrain, 1, 1)
#ocean next to new land? becomes coast now
for x in [-1,0,1]:
for y in [-1,0,1]:
if CyMap().plot(iX +x, iY +y).getTerrainType() == 6:
CyMap().plot(iX +x, iY +y).setTerrainType(5, 1, 1)
#GreenMod: recalculate city graphics after terraform, PART3
if (iImprovement==iWaterland1 or iImprovement==iWaterland2):
bCoastNear = 0
for x in [-1,0,1]:
for y in [-1,0,1]:
iTerrain = CyMap().plot(iCityX +x, iCityY +y).getTerrainType()
if (iTerrain == 5 or iTerrain == 6):
bCoastNear = 1
#reset or remove harbor and drydock if no coast near
if bCoastNear == 1:
if pCity.isHasRealBuilding(14):
pCity.setHasRealBuilding(14, false)
pCity.setHasRealBuilding(14, true)
else:
pCity.setHasRealBuilding(14, true)
pCity.setHasRealBuilding(14, false)
else:
pCity.setHasRealBuilding(13, false)
pCity.setHasRealBuilding(14, false)