View Full Version : Question Re: Modifying CvGameUtils.py


Aussie_Lurker
Dec 01, 2006, 07:02 AM
Hi guys, I want to have one of my civics prevent the building of Monasteries and Missionaries. Now one approach involves using TheLopez's BuildingCivicPrereq and UnitCivicPrereq modcomps, and simply applying it to every civic except the one I want to exclude Monstaries and Missionaries. The other-much quicker way-is to modify CvGameUtils, using the def CannotTrain and def CannotConstruct sections. Using an example from Kael, I have produced the following code:

def cannotConstruct(self,argsList):
ePlayer = argsList[0]
pCity = argsList[1]
eBuilding = argsList[2]
bContinue = argsList[3]
bTestVisible = argsList[4]
bIgnoreCost = argsList[5]
pPlayer = gc.getPlayer(ePlayer)

if eBuilding == gc.getInfoTypeForString('BUILDING_BUDDHIST_MONASTE RY'):
if pPlayer.getCivic() != gc.getInfoTypeForString('CIVIC_INSULAR'):
return True

if eBuilding == gc.getInfoTypeForString('BUILDING_HINDU_MONASTERY' ):
if pPlayer.getCivic() != gc.getInfoTypeForString('CIVIC_INSULAR'):
return True

if eBuilding == gc.getInfoTypeForString('BUILDING_ISLAMIC_MONASTER Y'):
if pPlayer.getCivic() != gc.getInfoTypeForString('CIVIC_INSULAR'):
return True

if eBuilding == gc.getInfoTypeForString('BUILDING_CONFUCIAN_MONAST ERY'):
if pPlayer.getCivic() != gc.getInfoTypeForString('CIVIC_INSULAR'):
return True

if eBuilding == gc.getInfoTypeForString('BUILDING_CHRISTIAN_MONAST ERY'):
if pPlayer.getCivic() != gc.getInfoTypeForString('CIVIC_INSULAR'):
return True

if eBuilding == gc.getInfoTypeForString('BUILDING_TAOIST_MONASTERY '):
if pPlayer.getCivic() != gc.getInfoTypeForString('CIVIC_INSULAR'):
return True

if eBuilding == gc.getInfoTypeForString('BUILDING_JEWISH_MONASTERY '):
if pPlayer.getCivic() != gc.getInfoTypeForString('CIVIC_INSULAR'):
return True

return False

The problem is that it doesn't seem to work :(. So, I have two questions (1) can someone see a reason why this isn't working? and (2) Can anyone remember how to set up the errorlog system so that I can try and determine the source of the error myself?
Any assistance will be very much appreciated :).

Aussie_Lurker.

Sto
Dec 01, 2006, 08:05 AM
Hi !

For the log :

HidePythonExceptions = 0
LoggingEnabled = 1
OverwriteLogs = 1
MessageLog = 1

for the code :
- if you want that the player cannot build this buildings with the civic "CIVIC_INSULAR" -> the test must be if pPlayer.getCivic() == gc.getInfoTypeForString('CIVIC_INSULAR'):

- pPlayer.getCivic() requires an index of the civic (API): CivicType getCivics(CivicOptionType iIndex)

- This should work , but not tested :
buildingsInsular=[gc.getInfoTypeForString('BUILDING_TAOIST_MONASTERY '),....]
iInsularType=gc.getInfoTypeForString('CIVIC_INSULA R')
if eBuilding in buildingsInsular:
if pPlayer.getCivics(gc.getCivicInfo(iInsularType).ge tCivicOptionType()) == iInsularType:
return True


Tcho !