def onBeginPlayerTurn(self, argsList):
'Called at the beginning of a players turn'
iGameTurn, iPlayer = argsList
## Crusade Start ##
pPlayer = gc.getPlayer(iPlayer)
b_Crusade = gc.getInfoTypeForString("BUILDING_CRUSADE")
obsoleteTech = gc.getBuildingInfo(b_Crusade).getObsoleteTech()
if ( gc.getTeam(pPlayer.getTeam()).isHasTech(obsoleteTech) == false or obsoleteTech == -1 ):
for iCity in range(pPlayer.getNumCities()):
ppCity = pPlayer.getCity(iCity)
if ppCity.getNumActiveBuilding(b_Crusade) == true:
iX = ppCity.getX()
iY = ppCity.getY()
u_crusader = gc.getInfoTypeForString( 'UNIT_CRUSADER' )
estiEnd = CyGame().getEstimateEndTurn()
if ( estiEnd >= 1000 ):
if ( iGameTurn % 12 ) == 0:
for i in range(1):
pNewUnit = pPlayer.initUnit( u_crusader, iX, iY, UnitAITypes.UNITAI_ATTACK_CITY, DirectionTypes.NO_DIRECTION )
elif ( estiEnd >= 700 ):
if ( iGameTurn % 8 ) == 0:
for i in range(1):
pNewUnit = pPlayer.initUnit( u_crusader, iX, iY, UnitAITypes.UNITAI_ATTACK_CITY, DirectionTypes.NO_DIRECTION )
elif ( estiEnd >= 500 ):
if ( iGameTurn % 6 ) == 0:
for i in range(1):
pNewUnit = pPlayer.initUnit( u_crusader, iX, iY, UnitAITypes.UNITAI_ATTACK_CITY, DirectionTypes.NO_DIRECTION )
elif ( estiEnd >= 300 ):
if ( iGameTurn % 4 ) == 0:
for i in range(1):
pNewUnit = pPlayer.initUnit( u_crusader, iX, iY, UnitAITypes.UNITAI_ATTACK_CITY, DirectionTypes.NO_DIRECTION )
else:
if ( iGameTurn % 4 ) == 0:
for i in range(1):
pNewUnit = pPlayer.initUnit( u_crusader, iX, iY, UnitAITypes.UNITAI_ATTACK_CITY, DirectionTypes.NO_DIRECTION )
basechance = 12
estiEnd = CyGame().getEstimateEndTurn()
if ( estiEnd >= 1000 ):
basechance = basechance
elif ( estiEnd >= 700 ):
basechance = 6
elif ( estiEnd >= 500 ):
basechance = 4
elif ( estiEnd >= 300 ):
basechance = 2
else:
basechance = 1
chance = CyGame().getSorenRandNum(basechance, "free state religion spread chance")
if ( chance == 0 ):
lppCityUber5 = []
for iiCity in range(pPlayer.getNumCities()):
ppCity = pPlayer.getCity(iiCity)
if ( not ppCity.isHasReligion(pPlayer.getStateReligion()) ):
lppCityUber5.append(ppCity)
if ( len(lppCityUber5) != 0 ):
chance = CyGame().getSorenRandNum(len(lppCityUber5), "which city")
ppCity = lppCityUber5[chance]
ppCity.setHasReligion(pPlayer.getStateReligion(), true, true, true)
## Crusade End ##