ripple01
Emperor
Hi everyone,
I am using a mod component by GIR (who hasn't been active since February) and am running into a small issue. I'm hoping there is a python guru who can help me out.
The mod component can be found here: http://forums.civfanatics.com/downloads.php?do=file&id=6903
The problem I am running into is this: The python code allows the city with the Petra Wonder to have a 25% chance of replacing a building with a unique building from any civ. So for example, you build a University in your city with the Petra wonder. You would have a 25% chance of receiving a Seowon (Korean UB) in your city instead of a normal University. The code works fine except for one problem:
Using the example above, you build a University and you get lucky and get a Seowon instead. The problem is that you can still build a University in your city. This can become quickly overpowering if this exploit is used. I have pasted the relevant code below. Could someone add a check to disallow building the default building if you get a Unique Building through the wonder? It would be GREATLY appreciated.
Cheers,
ripple01
I am using a mod component by GIR (who hasn't been active since February) and am running into a small issue. I'm hoping there is a python guru who can help me out.
The mod component can be found here: http://forums.civfanatics.com/downloads.php?do=file&id=6903
The problem I am running into is this: The python code allows the city with the Petra Wonder to have a 25% chance of replacing a building with a unique building from any civ. So for example, you build a University in your city with the Petra wonder. You would have a 25% chance of receiving a Seowon (Korean UB) in your city instead of a normal University. The code works fine except for one problem:
Using the example above, you build a University and you get lucky and get a Seowon instead. The problem is that you can still build a University in your city. This can become quickly overpowering if this exploit is used. I have pasted the relevant code below. Could someone add a check to disallow building the default building if you get a Unique Building through the wonder? It would be GREATLY appreciated.
Code:
###########################
### ub chance home city ###
###########################
if pCity.getNumActiveBuilding(gc.getInfoTypeForString("BUILDING_PETRA"))==true:
### chance to get a UB instead of the DB ###
chance = CyGame().getSorenRandNum(100, "chance for UB")
if ( chance <= 25):
### note: the code identifies the first building of a certain buildingclass in the CIV4BuildingInfos.xml file to be the default building
### find buildings with the same buildingClassType ###
lgleicheBC = []
buildingClassType = gc.getBuildingInfo(iBuildingType).getBuildingClassType()
for i in range(gc.getNumBuildingInfos()):
if ( buildingClassType == gc.getBuildingInfo(i).getBuildingClassType() ):
lgleicheBC.append(i)
if ( len(lgleicheBC) >= 2 ):
### is Building the default building? ###
if ( iBuildingType == lgleicheBC[0] ):
### get a random UB of the same building class like the DB ###
chance = CyGame().getSorenRandNum(len(lgleicheBC) - 1, "Random for UB")
### replace DB with UB ###
pCity.setNumRealBuilding(lgleicheBC[0],0)
pCity.setNumRealBuilding(lgleicheBC[chance + 1],1)
### ausgabe ###
CyInterface().addMessage(pCity.plot().getOwner(),false,15,CyTranslator().getText("TXT_KEY_PETRA_GAMETXT2",( pCity.getName(), PyHelpers.PyInfo.BuildingInfo(lgleicheBC[chance + 1]).getDescription() , PyHelpers.PyInfo.BuildingInfo(lgleicheBC[0]).getDescription() )),'',0,gc.getBuildingInfo(lgleicheBC[chance + 1]).getButton(),ColorTypes(11),pCity.getX(),pCity.getY(),True,True)
### message: In %s1 the Petra Wonder provides a %s2 instead of a %s3 ###
Cheers,
ripple01