python function isn't called - why?

Saarlaender said:
nope, it's all in a mod folder and the original is untouched. :)
so I can basically just delete the EventManager in the mod folder?

Just add a .old to the end of the CvEventManager.py file in case you want to see your old file for reference. Also you can remove the handleEvent method in the CvCustomEventManager method.
 
and, as for your comment on the getityList function:
so, instead of
Code:
def getCityList(self, pPlayer):
		iPlayerID = pPlayer.getID()
		lCity = []
		(loopCity, iter) = pPlayer.firstCity(false)
		while(loopCity):
			cityOwner = loopCity.getOwner()
			if ( not loopCity.isNone() and loopCity.getOwner() == pPlayer ): only valid cities
				pCity = pPlayer.getCity(loopCity.getID())
				city = PyCity(self.getID(), loopCity.getID())
				lCity.append(pCity)
			(loopCity, iter) = pPlayer.nextCity(iter, false)
		return lCity
I could just as well code
Code:
def getCityList(self, pPlayer):
		pyPlayer = PyPlayer(pPlayer.getID())
		cityList = pyPlayer.getCityList()
		return cityList
and that would do it?
 
No, just rename your old file by adding .old to the end of it. Also you should remove the handleEvent method in the CvCustomEventManager.py file. It shouldn't be in there since it doesn't change the functionality of the original.
 
Saarlaender said:
and, as for your comment on the getityList function:
so, instead of
Code:
def getCityList(self, pPlayer):
		iPlayerID = pPlayer.getID()
		lCity = []
		(loopCity, iter) = pPlayer.firstCity(false)
		while(loopCity):
			cityOwner = loopCity.getOwner()
			if ( not loopCity.isNone() and loopCity.getOwner() == pPlayer ): only valid cities
				pCity = pPlayer.getCity(loopCity.getID())
				city = PyCity(self.getID(), loopCity.getID())
				lCity.append(pCity)
			(loopCity, iter) = pPlayer.nextCity(iter, false)
		return lCity
I could just as well code
Code:
def getCityList(self, pPlayer):
		pyPlayer = PyPlayer(pPlayer.getID())
		cityList = pyPlayer.getCityList()
		return cityList
and that would do it?

Original code looked like this:
Code:
[TAB]def reform(self, iPlayer):
[TAB][TAB]pPlayer = gc.getPlayer(iPlayer)
[TAB][TAB]iStateBelief = pPlayer.getStateReligion()
[TAB][TAB]iCatholic = gc.getInfoTypeForString('RELIGION_CHRISTIANITY')
[TAB][TAB]iPolytheism = gc.getInfoTypeForString('RELIGION_POLYTHEISM')
[TAB][TAB]iIslam = gc.getInfoTypeForString('RELIGION_ISLAM')
[TAB][TAB]iRefCityList = self.getCityList(pPlayer)
[TAB][TAB]
[TAB][TAB]if gc.getTeam(pPlayer.getTeam()).isHasTech(gc.getInfoTypeForString('TECH_THEOLOGY')):
[TAB][TAB][TAB]for pCity in iRefCityList:
[TAB][TAB][TAB][TAB][TAB]if (pCity.isHasReligion(iPolytheism) and pCity.isHolyCityByType(iPolytheism) == False):
[TAB][TAB][TAB][TAB][TAB][TAB]iReform = CyGame().getSorenRandNum(100, "Reform")
[TAB][TAB][TAB][TAB][TAB][TAB]if (iReform <= 40):[TAB][TAB][TAB][TAB]
[TAB][TAB][TAB][TAB][TAB][TAB][TAB]pCity.setHasReligion(iPolytheim, False, True, True)
[TAB][TAB][TAB][TAB][TAB][TAB][TAB]pCity.setHasReligion(iCatholic, True, False, False)
[TAB][TAB][TAB][TAB][TAB][TAB][TAB]CyInterface().addMessage(CyGame().getActivePlayer(),True,25,'Christianisierung! Die Polytheisten sagen dem Kult ab und werden Christen','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Polytheism.dds',ColorTypes(8),pCity.getX(),pCity.getY(),True,True)
[TAB][TAB][TAB][TAB][TAB][TAB]else:
[TAB][TAB][TAB][TAB][TAB][TAB][TAB]CyInterface().addMessage(CyGame().getActivePlayer(),True,25,'keine Reform -',iReform)
[TAB][TAB][TAB][TAB][TAB][TAB][TAB][TAB][TAB][TAB][TAB][TAB][TAB] 
[TAB][TAB]if gc.getTeam(pPlayer.getTeam()).isHasTech(gc.getInfoTypeForString('TECH_DIVINE_RIGHT')):
[TAB][TAB][TAB]for pCity in iRefCityList:
[TAB][TAB][TAB][TAB][TAB]if (pCity.isHasReligion(iPolytheism) and pCity.isHolyCityByType(iPolytheism) == False):
[TAB][TAB][TAB][TAB][TAB][TAB]iReform = CyGame().getSorenRandNum(100, "Reform")
[TAB][TAB][TAB][TAB][TAB][TAB]if (iReform <= 40):[TAB][TAB][TAB][TAB]
[TAB][TAB][TAB][TAB][TAB][TAB][TAB]pCity.setHasReligion(iPolytheim, False, False, False)
[TAB][TAB][TAB][TAB][TAB][TAB][TAB]pCity.setHasReligion(iIslam, True, False, False)
[TAB][TAB][TAB][TAB][TAB][TAB][TAB]CyInterface().addMessage(CyGame().getActivePlayer(),True,25,'Islamisierung! Die Polytheisten sagen dem Kult ab und werden Muslime','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Polytheism.dds',ColorTypes(8),pCity.getX(),pCity.getY(),True,True)
[TAB][TAB][TAB][TAB][TAB][TAB]else:
[TAB][TAB][TAB][TAB][TAB][TAB][TAB]CyInterface().addMessage(CyGame().getActivePlayer(),True,25,'keine Reform -',iReform)
[TAB][TAB][TAB][TAB][TAB][TAB][TAB][TAB][TAB][TAB][TAB][TAB][TAB] 
[TAB][TAB]if gc.getTeam(pPlayer.getTeam()).isHasTech(gc.getInfoTypeForString('TECH_PRINTING_PRESS')):
[TAB][TAB][TAB]for pCity in iRefCityList:
[TAB][TAB][TAB][TAB][TAB]if (pCity.isHasReligion(iCatholic) and pCity.isHolyCityByType(iCatholic) == False):
[TAB][TAB][TAB][TAB][TAB][TAB]iReform = CyGame().getSorenRandNum(100, "Reform")
[TAB][TAB][TAB][TAB][TAB][TAB]if (iReform <= 30):[TAB][TAB][TAB][TAB]
[TAB][TAB][TAB][TAB][TAB][TAB][TAB]pCity.setHasReligion(iCatholic, False, True, True)
[TAB][TAB][TAB][TAB][TAB][TAB][TAB]pCity.setHasReligion(iProtestant, True, False, False)
[TAB][TAB][TAB][TAB][TAB][TAB][TAB]CyInterface().addMessage(CyGame().getActivePlayer(),True,25,'Reformation! Die Katholiken der Stadt sind Protestanten geworden!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Polytheism.dds',ColorTypes(8),pCity.getX(),pCity.getY(),True,True)
[TAB][TAB][TAB][TAB][TAB][TAB]else:
[TAB][TAB][TAB][TAB][TAB][TAB][TAB]CyInterface().addMessage(CyGame().getActivePlayer(),True,25,'keine Reform -',iReform)
[TAB][TAB]return

Here is your re-written code:
Code:
[TAB]def reform(self, iPlayer):
[TAB][TAB]pPlayer = gc.getPlayer(iPlayer)
[TAB][TAB]iStateBelief = pPlayer.getStateReligion()
[TAB][TAB]iCatholic = gc.getInfoTypeForString('RELIGION_CHRISTIANITY')
[TAB][TAB]iPolytheism = gc.getInfoTypeForString('RELIGION_POLYTHEISM')
[TAB][TAB]iIslam = gc.getInfoTypeForString('RELIGION_ISLAM')
[TAB][TAB]iRefCityList = PyHelpers.PyPlayer(iPlayer).getCityList()
[TAB][TAB]
[TAB][TAB]for pCity in iRefCityList:
[TAB][TAB][TAB]if (pCity.isHasReligion(iPolytheism) and pCity.isHolyCityByType(iPolytheism) == False):
[TAB][TAB][TAB][TAB]if gc.getTeam(pPlayer.getTeam()).isHasTech(gc.getInfoTypeForString('TECH_THEOLOGY')):
[TAB][TAB][TAB][TAB][TAB]iReform = CyGame().getSorenRandNum(100, "Reform")
[TAB][TAB][TAB][TAB][TAB]if (iReform <= 40):[TAB][TAB][TAB][TAB]
[TAB][TAB][TAB][TAB][TAB][TAB]pCity.getCy().setHasReligion(iPolytheim, False, True, True)
[TAB][TAB][TAB][TAB][TAB][TAB]pCity.getCy().setHasReligion(iCatholic, True, False, False)
[TAB][TAB][TAB][TAB][TAB][TAB]CyInterface().addMessage(CyGame().getActivePlayer(),True,25,'Christianisierung! Die Polytheisten sagen dem Kult ab und werden Christen','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Polytheism.dds',ColorTypes(8),pCity.getX(),pCity.getY(),True,True)
[TAB][TAB][TAB][TAB][TAB]else:
[TAB][TAB][TAB][TAB][TAB][TAB]CyInterface().addMessage(CyGame().getActivePlayer(),True,25,'keine Reform -',iReform)[TAB][TAB][TAB][TAB]
[TAB][TAB]
[TAB][TAB][TAB][TAB]if gc.getTeam(pPlayer.getTeam()).isHasTech(gc.getInfoTypeForString('TECH_DIVINE_RIGHT')):
[TAB][TAB][TAB][TAB][TAB]iReform = CyGame().getSorenRandNum(100, "Reform")
[TAB][TAB][TAB][TAB][TAB]if (iReform <= 40):[TAB][TAB][TAB][TAB]
[TAB][TAB][TAB][TAB][TAB][TAB]pCity.getCy().setHasReligion(iPolytheim, False, False, False)
[TAB][TAB][TAB][TAB][TAB][TAB]pCity.getCy().setHasReligion(iIslam, True, False, False)
[TAB][TAB][TAB][TAB][TAB][TAB]CyInterface().addMessage(CyGame().getActivePlayer(),True,25,'Islamisierung! Die Polytheisten sagen dem Kult ab und werden Muslime','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Polytheism.dds',ColorTypes(8),pCity.getX(),pCity.getY(),True,True)
[TAB][TAB][TAB][TAB][TAB]else:
[TAB][TAB][TAB][TAB][TAB][TAB]CyInterface().addMessage(CyGame().getActivePlayer(),True,25,'keine Reform -',iReform)

[TAB][TAB][TAB]if (pCity.isHasReligion(iCatholic) and pCity.isHolyCityByType(iCatholic) == False):
[TAB][TAB][TAB][TAB]if gc.getTeam(pPlayer.getTeam()).isHasTech(gc.getInfoTypeForString('TECH_PRINTING_PRESS')):
[TAB][TAB][TAB][TAB][TAB]iReform = CyGame().getSorenRandNum(100, "Reform")
[TAB][TAB][TAB][TAB][TAB]if (iReform <= 30):[TAB][TAB][TAB][TAB]
[TAB][TAB][TAB][TAB][TAB][TAB]pCity.getCy().setHasReligion(iCatholic, False, True, True)
[TAB][TAB][TAB][TAB][TAB][TAB]pCity.getCy().setHasReligion(iProtestant, True, False, False)
[TAB][TAB][TAB][TAB][TAB][TAB]CyInterface().addMessage(CyGame().getActivePlayer(),True,25,'Reformation! Die Katholiken der Stadt sind Protestanten geworden!','AS2D_RELIGION_CONVERT',1,'Art/Interface/Buttons/Religions/Polytheism.dds',ColorTypes(8),pCity.getX(),pCity.getY(),True,True)
[TAB][TAB][TAB][TAB][TAB]else:
[TAB][TAB][TAB][TAB][TAB][TAB]CyInterface().addMessage(CyGame().getActivePlayer(),True,25,'keine Reform -',iReform)
[TAB][TAB]return

Please note that I have optimized some of your code but it is not very flexible. If you want I can mull it over and try to give you something that is really flexible ...
 
thanks for the help. I haven't had any time to see how this works now, but once I get to it, I'll let you know. Now that it works, I'll also add some more stuff.
I've always thought, though, that this isn't the most unflexible part, the cross-coded missionary conversion code has about 100 lines at least, but as long as it doesn't slow down the game and works, I guess I'm glad it works :)
Again, thank you!
 
Back
Top Bottom