I wanted to make a civic specific improvement. A pasture that doesn't require ressources for semi-nomadic developpement.
It worked, except that it overwrote the xml, as a consequence I could put it anywhere, even on desert or cities and on itself (I fear that the AI might build it on itself infinitely)... not really the goal. I tried to put limit it's use: to limit it to the plains and grass tiles.
It worked, except that it overwrote the xml, as a consequence I could put it anywhere, even on desert or cities and on itself (I fear that the AI might build it on itself infinitely)... not really the goal. I tried to put limit it's use: to limit it to the plains and grass tiles.
Code:
def canBuild(self,argsList):
iX, iY, iBuild, iPlayer = argsList
eCivic = argsList[1]
pPlayer = gc.getPlayer(iPlayer)
pPlot = CyMap().plot(iX, iY)
iterrain=pPlot.getTerrainType()
iPasture_nomad = CvUtil.findInfoTypeNum(gc.getBuildInfo,gc.getNumBuildInfos(),'BUILD_PASTURE_NOMAD')
if iBuild == gc.getInfoTypeForString('BUILD_PASTURE_NOMAD'):
if (pPlot.isCity or pPlot.getImprovementType()==gc.getInfoTypeForString('IMPROVEMENT_PASTURE_NOMAD')):
return False
elif (iterrain==gc.getInfoTypeForString('TERRAIN_DESERT') or iterrain==gc.getInfoTypeForString('TERRAIN_TOUNDRA') or iterrain==gc.getInfoTypeForString('TERRAIN_ICE')):
return False
elif pPlayer.getCivics(gc.getInfoTypeForString('CIVICOPTION_LABOR')) == gc.getInfoTypeForString('CIVIC_PASTORALISME'):
return True
return -1 # Returning -1 means ignore; 0 means Build cannot be performed; 1 or greater means it can