Religeous Unity

1. The Holy City check makes perfect sense to me. If the player does not have the holy city for the official state religion, then bUnity is False (-1).

Can you give me the error you get ? I suspect that if you let the test with "== -1" it will never be True. So you should check a game were you don't have the holy city and all other prerequ . That should give you the victory even if that would not .(you can create a game in the WB to test that)

Tcho !
 
Can you give me the error you get ? I suspect that if you let the test with "== -1" it will never be True. So you should check a game were you don't have the holy city and all other prerequ . That should give you the victory even if that would not .(you can create a game in the WB to test that)

Tcho !

I performed extensive tests just on the "hasHolyCity(iStateReligion)" line of code. The tests included scenarios having a state religion with a holy city and another without a holy city. To my surprise, the "== -1 :" test failed to detect the absence of the holy city. However, the "not" command did detect the absence of the holy city and would you believe it -- no error whatsoever in tonight's game. :crazyeye:

Reverse tests also worked, both lines detected the holy city. But only the "not" command worked to detect the absence of the holy city. I am now totally convinced and compelled to use your original code line:

if not pPlayer.hasHolyCity(iStateReligion) :

Once again you have been proven correct. :worship:

I have another question. Suppose I wanted to add a bUnity check to insure the state religion shrine was built. Can we do that? My first thought is when we loop through the cities to check for religions, we could also check for buildings.

V/R

Orion Veteran :cool:
 
I have another question. Suppose I wanted to add a bUnity check to insure the state religion shrine was built. Can we do that? My first thought is when we loop through the cities to check for religions, we could also check for buildings.

I don't know how to get simply the shrine of a religion. I've guessed that the shrine is the only building that require the holy city with a cost of -1. If one of your MOD shrine doesn't met these requirements or another building met these requirements in your MOD without being the shrine, you should change the implementation. Entering manually the shrine for each religion is the only way to get the shrine for each religion i think in this case (i don't see an easier way but there is perhaps one ?!).

Here the code :

Spoiler :
Code:
                if (pPlayer.getNumCities() > 0) and (CyGame().getNumCivCities() > 2 * CyGame().countCivPlayersAlive()) and (CyGame().isVictoryValid(gc.getInfoTypeForString("VICTORY_RELIGIOUS"))):
                        bUnity = True
                        iStateReligion = pPlayer.getStateReligion()

                        if iStateReligion == -1 :
                                bUnity = False

                        if bUnity :
                                if not pPlayer.hasHolyCity(iStateReligion) :
                                        bUnity = False

                        if bUnity :
                                if CyGame().calculateReligionPercent(iStateReligion) < 80 :
                                        bUnity = False

                        if bUnity :
                                for pyCity in PyHelpers.PyPlayer(iPlayer).getCityList() :
                                        if pyCity.isHolyCityByType(iStateReligion) :
                                                # the right way should by to enter manualy the shrine of each religion ,
                                                # since I don't know how to get simply the shrine of a religion.
                                                # I will guess that the shrine is the ONLY building that require a holy city, with a cost of -1
                                                # In case the shrine doesn't met these requirements in your MOD or another building met these requirements,
                                                # You should do (or ask me) another implementation to do it.
                                                bHasShrine = False
                                                for iBuilding in pyCity.getBuildingList() :
                                                        buildingXML = gc.getBuildingInfo(iBuilding)
                                                        if (buildingXML.getHolyCity() == iStateReligion) and (buildingXML.getProductionCost() == -1) :
                                                                bHasShrine = True
                                                                break

                                                if not bHasShrine :
                                                        bUnity = False

                                        if not bUnity :
                                                break

                                        for iReligionLoop in range(gc.getNumReligionInfos()):
                                                if iReligionLoop == iStateReligion :
                                                        if not pyCity.hasReligion(iReligionLoop) :
                                                                bUnity = False
                                                                break
                                                elif pyCity.hasReligion(iReligionLoop) :
                                                        bUnity = False
                                                        break

                        if bUnity :
                                CyGame().setWinner(pPlayer.getTeam(), gc.getInfoTypeForString("VICTORY_RELIGIOUS"))

Tcho!
 
I don't know how to get simply the shrine of a religion. I've guessed that the shrine is the only building that require the holy city with a cost of -1. If one of your MOD shrine doesn't met these requirements or another building met these requirements in your MOD without being the shrine, you should change the implementation. Entering manually the shrine for each religion is the only way to get the shrine for each religion i think in this case (i don't see an easier way but there is perhaps one ?!).

After countless hours and testing, here is my comprehensive shrine check:
Code:
if bUnity :
	# Comprehensive Shrine Check
	playerStateReligion = gc.getPlayer(iPlayer).getStateReligion( )
	if playerStateReligion == CvUtil.findInfoTypeNum(gc.getReligionInfo, gc.getNumReligionInfos(), 'RELIGION_JUDAISM'):
		iShrine = CvUtil.findInfoTypeNum(gc.getBuildingInfo, gc.getNumBuildingInfos(), 'BUILDING_JEWISH_SHRINE')					
	elif playerStateReligion == CvUtil.findInfoTypeNum(gc.getReligionInfo, gc.getNumReligionInfos(), 'RELIGION_CHRISTIANITY'):
		iShrine = CvUtil.findInfoTypeNum(gc.getBuildingInfo, gc.getNumBuildingInfos(), 'BUILDING_CHRISTIAN_SHRINE')					
	elif playerStateReligion == CvUtil.findInfoTypeNum(gc.getReligionInfo, gc.getNumReligionInfos(), 'RELIGION_ISLAM'):	
		iShrine = CvUtil.findInfoTypeNum(gc.getBuildingInfo, gc.getNumBuildingInfos(), 'BUILDING_ISLAMIC_SHRINE')					
	elif playerStateReligion == CvUtil.findInfoTypeNum(gc.getReligionInfo, gc.getNumReligionInfos(), 'RELIGION_HINDUISM'):
		iShrine = CvUtil.findInfoTypeNum(gc.getBuildingInfo, gc.getNumBuildingInfos(), 'BUILDING_HINDU_SHRINE')					
	elif playerStateReligion == CvUtil.findInfoTypeNum(gc.getReligionInfo, gc.getNumReligionInfos(), 'RELIGION_BUDDHISM'):
		iShrine = CvUtil.findInfoTypeNum(gc.getBuildingInfo, gc.getNumBuildingInfos(), 'BUILDING_BUDDHIST_SHRINE')					
	elif playerStateReligion == CvUtil.findInfoTypeNum(gc.getReligionInfo, gc.getNumReligionInfos(), 'RELIGION_CONFUCIANISM'):
		iShrine = CvUtil.findInfoTypeNum(gc.getBuildingInfo, gc.getNumBuildingInfos(), 'BUILDING_CONFUCIAN_SHRINE')					
	elif playerStateReligion == CvUtil.findInfoTypeNum(gc.getReligionInfo, gc.getNumReligionInfos(), 'RELIGION_TAOISM'):
		iShrine = CvUtil.findInfoTypeNum(gc.getBuildingInfo, gc.getNumBuildingInfos(), 'BUILDING_TAOIST_SHRINE')
							  
	bHasShrine = False
	(loopCity, iter) = pPlayer.firstCity(false)
	
	while(loopCity): 
		if (loopCity.isHasBuilding(iShrine)):
			# City has the official State Religion Shrine - New Prerequisite						
			#CyInterface().addMessage(CyGame().getActivePlayer(),True,25,'A Shrine was Found!','AS2D_DISCOVERBONUS',1,'Art/Interface/Buttons/TerrainFeatures/Forest.dds',ColorTypes(8),0,0,False,False)
			bHasShrine = True
			break
		(loopCity, iter) = pPlayer.nextCity(iter, false)
				
	if not bHasShrine :
		#CyInterface().addMessage(CyGame().getActivePlayer(),True,25,'No State Shrine was Found!','AS2D_DISCOVERBONUS',1,'Art/Interface/Buttons/TerrainFeatures/Forest.dds',ColorTypes(8),0,0,False,False)
		bUnity = False


Orion Veteran :cool:
 
If you notice, the comprehensive shrine check above is in it's own bUnity check. So now we have six prerequisites:

1. A player must have an official State Religion
2. A player must have the Holy City for the official State Religion
3. A player must have built the Shrine for the official State Religion
4. All of a player's cities must have the official state religion established.
5. All of a player's cities must not have any non-state religions established.
6. Religious influence must be at least 80%

All tests passed without any errors. What do you think?

Sincerely,

Orion Veteran :cool:
 
The essential is that's work :goodjob:. Sure i would not have done this like that , but this is good. :)

Tcho !
 
Ok this is awesome, can this be turned into a mod with the sdk changes visible so that the community could use it for merging purposes.
 
Top Bottom