#Natural Wonders Contants
def doNaturalWondersConstantsInit():
global Game
global iNumPermanentHappy
global iHappyTurns
global iChanceForHappy
Game = CyGame()
iModifier = gc.getGameSpeedInfo(Game.getGameSpeedType()).getUnitGreatWorkPercent()
iNumPermanentHappy = 1 #Happy provided for ownership
iHappyTurns = 10 #Number of turns happiness on discovery
iChanceForHappy = 50 #This is the chance that the city will get happiness over specialist for ownership!
def onGameStart(self, argsList):
'Called at the start of the game'
# Natural Wonders - Start
doNaturalWondersConstantsInit()
# This is the code that spawns each natural wonder into the map to add new wonder see below!
dNaturalWonders = {\
#These are parameters for new wonders, you pick a type ie: "TERRAIN_DESERT" and then things about it
# in order of appearance: is it a hill?, (if coast) is it next to a land tile? is it a river? is it a mountain?
# (if water) is it a lake?, is the tile adjectent to lake or oasis?, is it next to the sea (possibly lake?)?, is it a water tile?
# True for yes
# False for no
# None for doesn't matter (same for terrain, however in this case bWater will handle plot type (bWater CANNOT be None))
#Wonder XML name:[TerrainType, bHills, bAdjecentLand, bRiver, bPeak, bLake, bFreshWater, bCostalLand, bWater (CANNOT BE NONE!)]
"FEATURE_DEVILS_TABLE":["TERRAIN_PLAINS", True, None, None, None, None, None, None, False],\
"FEATURE_LANDSCAPE_ARCH":["TERRAIN_DESERT", False, None, None, False, None, False, None, False],\
"FEATURE_PAMUKKALE":["TERRAIN_GRASS", False, None, None, False, None, False, None, False],\
"FEATURE_VICTORIA_FALLS":["TERRAIN_GRASS", False, None, False, False, None, False, None, False],\
"FEATURE_SOPKA":["TERRAIN_TUNDRA", False, None, False, False, None, False, None, False],\
"FEATURE_ULURU":["TERRAIN_DESERT", False, None, False, False, None, None, None, False],\
"FEATURE_SUGARLOAF":["TERRAIN_COAST", None, True, None, None, None, None, None, True]\
}
iNumCivs = Game.countCivTeamsEverAlive()
#check if all plots are revealed by default
x = 0
bAllRevealed = False
for team in xrange(iNumCivs):
if CyMap().plot(0, 0).isRevealed(team, False):
x += 1
if x == iNumCivs:
bAllRevealed = True
for wonder in dNaturalWonders.iterkeys():
WonderType = gc.getInfoTypeForString(wonder)
TerrainType = gc.getInfoTypeForString(dNaturalWonders[wonder][0])
bHills = dNaturalWonders[wonder][1]
bAdjacentLand = dNaturalWonders[wonder][2]
bRiver = dNaturalWonders[wonder][3]
bPeak = dNaturalWonders[wonder][4]
bLake = dNaturalWonders[wonder][5]
bFreshWater = dNaturalWonders[wonder][6]
bCoastalLand = dNaturalWonders[wonder][7]
bWater = dNaturalWonders[wonder][8]
#start checking plots
lPlots = []
for i in range(CyMap().numPlots()):
pPlot = CyMap().plotByIndex(i)
bPlotPerfect = False
if (not pPlot.isWater() and not pPlot.isAdjacentToLand()) or pPlot.isGoody(): continue #This plot must be a one tile island or have a goody hut
if not pPlot.getFeatureType() == -1:
if gc.getFeatureInfo(pPlot.getFeatureType()).isNaturalWonder(): continue #has a wonder already
if pPlot.getBonusType(-1) != -1: continue
for team in xrange(gc.getMAX_CIV_TEAMS()):
if (pPlot.isRevealed(team, False) and not bAllRevealed):
bPlotPerfect = True
break
if bPlotPerfect: continue
if TerrainType != None:
if pPlot.getTerrainType() != TerrainType: continue
elif pPlot.isWater() != bWater: continue
if bHills != None and pPlot.isHills() != bHills: continue
if bAdjacentLand != None and pPlot.isAdjacentToLand() != bAdjacentLand: continue
if bRiver != None and pPlot.isRiver() != bRiver: continue
if bPeak != None and pPlot.isPeak() != bPeak: continue
if bLake != None and pPlot.isLake() != bLake: continue
if bFreshWater != None and pPlot.isFreshWater() != bFreshWater: continue
if bCoastalLand != None and pPlot.isCoastalLand() != bCoastalLand: continue
lPlots.append(pPlot)
if len(lPlots) > 0:
pPlot = lPlots[Game.getSorenRandNum(len(lPlots), "Random Plot")]
pPlot.setFeatureType(WonderType, 0)
# Natural Wonders - End
def onPlotRevealed(self, argsList):
'Plot Revealed'
pPlot = argsList[0]
iTeam = argsList[1]
# Natural Wonders - Start
iFeature = pPlot.getFeatureType()
if iFeature != -1:
iFeatureInfo = gc.getFeatureInfo(iFeature)
if iFeatureInfo.isNaturalWonder():
pTeam = gc.getTeam(iTeam)
if not pTeam.isBarbarian():
for iPlayerX in range(gc.getMAX_CIV_PLAYERS()):
pPlayerX = gc.getPlayer(iPlayerX)
if pPlayerX.getTeam() == iTeam:
message = "TXT_KEY_WONDERDISCOVERED_YOU"
tValues = (iFeatureInfo.getDescription(),)
(loopCity, iter) = pPlayerX.firstCity(False)
while(loopCity):
loopCity.changeHappinessTimer(iHappyTurns)
(loopCity, iter) = pPlayerX.nextCity(iter, false)
if pPlayerX.isHuman():
popupInfo = CyPopupInfo()
popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
popupInfo.setData1(iFeature)
popupInfo.setData3(3)
popupInfo.setText(u"showWonderMovie")
popupInfo.addPopup(iPlayerX)
else:
message = "TXT_KEY_WONDERDISCOVERED_ELSE"
leader = gc.getPlayer(pTeam.getLeaderID()).getName()
tValues = (leader, iFeatureInfo.getDescription())
message = localText.getText(message, tValues)
CyInterface().addMessage(iPlayerX, True, 20, message, "", InterfaceMessageTypes.MESSAGE_TYPE_MINOR_EVENT,"", -1, -1, -1, False, False)
# Natural Wonders - End
def onCityBuilt(self, argsList):
'City Built'
city = argsList[0]
if (city.getOwner() == gc.getGame().getActivePlayer()):
self.__eventEditCityNameBegin(city, False)
CvUtil.pyPrint('City Built Event: %s' %(city.getName()))
# Natural Wonders - Start
for x in range(city.getX() - 1, city.getX() + 2): # To who ever removed my index loop: you do realise this is first ring tiles only?!
for y in range(city.getY() - 1, city.getY() + 2): # Oh well I wanted that to happen now anyway :p
pPlot = CyMap().plot(x, y)
if pPlot.getFeatureType() > -1:
if gc.getFeatureInfo(pPlot.getFeatureType()).isNaturalWonder():
if Game.getSorenRandNum(100, "Chance for happy") < iChanceForHappy:
city.changeExtraHappiness(iNumPermanentHappy)
else:
city.changeFreeSpecialistCount(Game.getSorenRandNum(5, "Specialist") + 1, 1) #is this too risky? randomly picks between priest, artist, merchant, engineer and scientist
# Natural Wonders - End
def onCityAcquired(self, argsList):
'City Acquired'
iPreviousOwner,iNewOwner,pCity,bConquest,bTrade = argsList
# Natural Wonders - Start
##This code isn't needed as specialists and happiness are permanent effects!
##for x in range(pCity.getX() - 1, pCity.getX() + 2):
## for y in range(pCity.getY() - 1, pCity.getY() + 2):
## pPlot = CyMap().plot(x, y)
## if pPlot.getFeatureType() > -1:
## if gc.getFeatureInfo(pPlot.getFeatureType()).isNaturalWonder():
## pCity.changeCulture(iPreviousOwner, - iCulture, True)
## if abs(pPlot.getX() - pCity.getX()) == 1 and abs(pPlot.getY() - pCity.getY()) == 1:
## pCity.changeCulture(iNewOwner, iCulture, True)
# Natural Wonders - End
CvUtil.pyPrint('City Acquired Event: %s' %(pCity.getName()))
def onCultureExpansion(self, argsList):
'City Culture Expansion'
pCity = argsList[0]
iPlayer = argsList[1]
# Natural Wonders - Start
##This code isn't needed as specialists and happiness are permanent effects!
##for iIndex in range(21):
## pPlot = pCity.getCityIndexPlot(iIndex)
## if pPlot.getFeatureType() > -1:
## if gc.getFeatureInfo(pPlot.getFeatureType()).isNaturalWonder():
## if abs(pPlot.getX() - pCity.getX()) != 1 or abs(pPlot.getY() - pCity.getY()) != 1:
## if pCity.getCultureLevel() == 2: #has the city just gained it's full BFC?
## pCity.changeCulture(iPlayer, iCulture, True)
## gc.getPlayer(iPlayer).changeGold(iGold)
# Natural Wonders - End
CvUtil.pyPrint("City %s's culture has expanded" %(pCity.getName(),))