• Civilization 7 has been announced. For more info please check the forum here .

Tying Unit and Building Availability to Civics choices

Alyph said:
Hi Kael,

Is this CannotTrain function the one located in CvGameInterface.py and CvGameUtils.py? Does it work? When will this func be called? very before player open the city window or small building list? I try to use another CannotConstruct func to disable building, but didn't see it take effect? Could you bring me more details please?

I use CvGameInterface.py, but I've rewritten most everything so I have given up any hope of making anything I have done modular. The following is my CannotConstruct event:

Code:
def cannotConstruct(argsList):
	pCity = argsList[0]
	eBuilding = argsList[1]
	bContinue = argsList[2]
	bTestVisible = argsList[3]
	bIgnoreCost = argsList[4]

	if eBuilding == gc.getInfoTypeForString('BUILDING_ABATTOIR'):
		if pPlayer.getStateReligion() == gc.getInfoTypeForString('RELIGION_THE_ORDER'):
			return True

	if eBuilding == gc.getInfoTypeForString('BUILDING_ABATTOIR'):
		if pPlayer.getStateReligion() == gc.getInfoTypeForString('RELIGION_RUNES_OF_KILMORPH'):
			return True

	if eBuilding == gc.getInfoTypeForString('BUILDING_CASTLE'):
		if pPlayer.getStateReligion() == gc.getInfoTypeForString('RELIGION_THE_ASHEN_VEIL'):
			return True

	if eBuilding == gc.getInfoTypeForString('BUILDING_CASTLE'):
		if pPlayer.getStateReligion() == gc.getInfoTypeForString('RELIGION_OCTOPUS_OVERLORDS'):
			return True

	if eBuilding == gc.getInfoTypeForString('BUILDING_CATHEDRAL'):
		if pPlayer.getStateReligion() == gc.getInfoTypeForString('RELIGION_THE_ASHEN_VEIL'):
			return True

	if eBuilding == gc.getInfoTypeForString('BUILDING_SUMMONING_CHAMBER'):
		if pPlayer.getStateReligion() == gc.getInfoTypeForString('RELIGION_THE_ORDER'):
			return True

	return False

This code takes place when the game goes to build the list of available object the player can build. As it places each in the list it runs each through this function. If it comes through False then it gets added to the list, if it comes through True then is doesn't get added ot the list.

That may seem backward but rememebr this is the CannotConstruct function, so if it it True that it cannot construct it then it cant be built.

So in my code if it is checking out an ABATTOIR it does a check to see what the players religion is. If it is The Order then it is rejected and the player isn't allowed to build it. From the players perspective they are never presented with the option to build the building.
 
Thanks.
I just hope the game run it before everytime it need get a building list. But last time I test this and found it was never called. So, ask a most basic question: If I simplly return a True in this func, like:
def cannotConstruct(argsList):
pCity = argsList[0]
eBuilding = argsList[1]
bContinue = argsList[2]
bTestVisible = argsList[3]
bIgnoreCost = argsList[4]
return True
does it mean all buildings will disapear in the availible construction list?
 
Hey, Awesome!
I tried again, and this time I write into CvGameInterface.py.(last time in CvGameUtils, not know what's difference yet) It WORKS! Every building disapears!~~ Cheers!
 
Alyph said:
Hey, Awesome!
I tried again, and this time I write into CvGameInterface.py.(last time in CvGameUtils, not know what's difference yet) It WORKS! Every building disapears!~~ Cheers!

Woot! Have fun.
 
Man, it seems like everyone can write in python except for me :(. As I said, thanks for all the advice guys. I know it will all come in handy but-for the time being-I am focussing on the XML side, as it is a LOT quicker!!

Yours,
Aussie_Lurker.
 
Top Bottom