Question Re: Modifying CvGameUtils.py

Joined
Jul 21, 2003
Messages
7,819
Location
Adelaide, South Australia
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:

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_MONASTERY'):
                        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_MONASTERY'):
                        if pPlayer.getCivic() != gc.getInfoTypeForString('CIVIC_INSULAR'):
                                return True

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

                if eBuilding == gc.getInfoTypeForString('BUILDING_CHRISTIAN_MONASTERY'):
                        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.
 
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 :
Code:
buildingsInsular=[gc.getInfoTypeForString('BUILDING_TAOIST_MONASTERY'),....]
iInsularType=gc.getInfoTypeForString('CIVIC_INSULAR')
if eBuilding in buildingsInsular:
        if pPlayer.getCivics(gc.getCivicInfo(iInsularType).getCivicOptionType()) == iInsularType:
                return True

Tcho !
 
Back
Top Bottom