Inquisition

bmarnz

Prince
Joined
Mar 19, 2007
Messages
441
Location
Pennsylvania, USA
I'm trying to get my inquisitor to remove non-state reliogious buildings.

This is what I have so far.
Code:
		# removes buildings
		for iBuildingLoop in range(gc.getNumBuildingInfos( )):
			if pCity.isHasBuilding( iBuildingLoop ):
				pBuilding = gc.getBuildingInfo( iBuildingLoop )
				iRequiredReligion = pBuilding.getPrereqReligion( )
				for iReligionLoop in range(gc.getNumReligionInfos()):
					if iReligionLoop != pPlayer.getStateReligion( ):
						if iRequiredReligion == iReligionLoop:
							pCity.setHasBuilding( iBuildingLoop, -1 )

I get this error in log.
AttributeError: 'CyCity' object has no attribute 'setHasBuilding'

I'd appreciate any help. Please :D
 
try:
pCity.setNumRealBuilding ( iBuildingLoop,0 )

Thanx :D
It worked. I know next to nothing about python and appreciate your help.


EDIT: How do I generate random number to use in succede/fail check.

EDIT: I would also like to add a success/fail message.
 
:confused: When I try to add a message with this code:
Code:
CyInterface().addMessage(pPlayer, false, gc.getEVENT_MESSAGE_TIME(), "Your inquisitor has purged the city of infidels.", "AS2D_BOMBARDED", InterfaceMessageTypes.MESSAGE_TYPE_INFO, pUnit.getButton(), gc.getInfoTypeForString("COLOR_GREEN"), pCity.getX(), pCity.getY(), 1, 1)

I get this error:
TypeError: this constructor takes no arguments
 
This should work:

Code:
CyInterface().addMessage(iPlayer,False,25,CyTranslator().getText("TXT_KEY_MESSAGE_INQUISITION",()),"AS2D_BOMBARDED",InterfaceMessageTypes.MESSAGE_TYPE_INFO,pUnit.getButton(),ColorTypes(8),pCity.getX(),pCity.getY(),True,True)

I suggest you use a text key (as in my snippet above) for the message instead of coding the message directly. That way, the message string can be internationalized.
 
This should work:

Code:
CyInterface().addMessage(iPlayer,False,25,CyTranslator().getText("TXT_KEY_MESSAGE_INQUISITION",()),"AS2D_BOMBARDED",InterfaceMessageTypes.MESSAGE_TYPE_INFO,pUnit.getButton(),ColorTypes(8),pCity.getX(),pCity.getY(),True,True)

I suggest you use a text key (as in my snippet above) for the message instead of coding the message directly. That way, the message string can be internationalized.

Hmm... Didn't work, but no error message. :confused:
 
EDIT: How do I generate random number to use in succede/fail check.


random = gc.getGame().getSorenRand()

if (random.get(100,"") < 50):
...


random.get(100,"") returns a random number between 0..99
 
This should work:

Code:
CyInterface().addMessage(iPlayer,False,25,CyTranslator().getText("TXT_KEY_MESSAGE_INQUISITION",()),"AS2D_BOMBARDED",InterfaceMessageTypes.MESSAGE_TYPE_INFO,pUnit.getButton(),ColorTypes(8),pCity.getX(),pCity.getY(),True,True)

I suggest you use a text key (as in my snippet above) for the message instead of coding the message directly. That way, the message string can be internationalized.

Hmm... Didn't work, but no error message. :confused:

Ha! got it to work once I realized i needed set iPlayer = pPlayer.getID(). :eek:
Thanx :)

random = gc.getGame().getSorenRand()

if (random.get(100,"") < 50):
...


random.get(100,"") returns a random number between 0..99

Once again, many thanx. :) You pointed me in the right direction, but i had to change getSorenRand to getSorenRandNum() for it to work. :crazyeye:
 
Two more questions:

a) How do include city name in the message? I see in the text files where %s2_city is used. Now i need to set up python portion.

In your message text, leave a format parameter called %s. Effectively your string should be something like
Code:
CyTranslator().getText("TXT_KEY_MESSAGE_INQUISITION" % (pCity.getName()))
and the value of TXT_KEY_MESSAGE_INQUISITION should be something like
Code:
Inquisition in %s
 
In your message text, leave a format parameter called %s. Effectively your string should be something like
Code:
CyTranslator().getText("TXT_KEY_MESSAGE_INQUISITION" % (pCity.getName()))
and the value of TXT_KEY_MESSAGE_INQUISITION should be something like
Code:
Inquisition in %s

OK, please bare with me. :blush: Now how do I use it? Do I need to set it to a specific variable.

EDIT: Ooops, didn't see your edit. Thanks again :)
 
Top Bottom