## Sid Meier's Civilization 4
## Copyright Firaxis Games 2005
##
## Implementaion of miscellaneous game functions
import CvUtil
from CvPythonExtensions import *
import CvEventInterface
[COLOR="Blue"]import BugUtil[/COLOR]
# globals
gc = CyGlobalContext()
class DiplomacyGameUtils:
[COLOR="Blue"] def canTrain(self,argsList):
pCity = argsList[0]
eUnit = argsList[1]
bContinue = argsList[2]
bTestVisible = argsList[3]
bIgnoreCost = argsList[4]
bIgnoreUpgrades = argsList[5]
## BAMYAN BUDDHA STATUES Start ##
iMissionary = []
iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_JEWISH_MISSIONARY'))
iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_CHRISTIAN_MISSIONARY'))
iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_ISLAMIC_MISSIONARY'))
iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_HINDU_MISSIONARY'))
iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_BUDDHIST_MISSIONARY'))
iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_CONFUCIAN_MISSIONARY'))
iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_TAOIST_MISSIONARY'))
iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_OLYMP_MISSIONARY'))
iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_ASEN_MISSIONARY'))
iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_VOODOO_MISSIONARY'))
iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_SHINTO_MISSIONARY'))
iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_ZORO_MISSIONARY'))
iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_RA_MISSIONARY'))
iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_TOLTEC_MISSIONARY'))
iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_SHAMAN_MISSIONARY'))
iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_LEVANT_MISSIONARY'))
iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_DRUID_MISSIONARY'))
iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_ANUNNAKI_MISSIONARY'))
iMoreMissionariesWonder = CvUtil.findInfoTypeNum(gc.getBuildingInfo,gc.getNumBuildingInfos(),'BUILDING_BAMYAN')
obsoleteTech = gc.getBuildingInfo(iMoreMissionariesWonder).getObsoleteTech()
pPlayer = gc.getPlayer(pCity.getOwner())
NumReligions = 18
for i in range (NumReligions):
if eUnit == iMissionary[i]:
BugUtil.debug("Unit %d is a missionary for religion %d", eUnit, i)
if pCity.isHasReligion(i):
BugUtil.debug("City has correct religion")
pUnit = gc.getUnitInfo (eUnit)
Class = pUnit.getUnitClassType ()
MissionaryCount = pPlayer.getUnitClassCount(Class)
if MissionaryCount <6:
BugUtil.debug("Player has less than 6 missionaries")
if (obsoleteTech == -1 or not gc.getTeam(pPlayer.getTeam()).isHasTech(obsoleteTech)):
for iCity in range(pPlayer.getNumCities()):
ppCity = pPlayer.getCity(iCity)
if ppCity.getNumActiveBuilding(iMoreMissionariesWonder) > 0:
return True
## BAMYAN BUDDHA STATUES End ##[/COLOR]
return False
def cannotConstruct(self,argsList):
pCity = argsList[0]
eBuilding = argsList[1]
bContinue = argsList[2]
bTestVisible = argsList[3]
bIgnoreCost = argsList[4]
# player can't build an arcology if they have shielding or advanced shielding
if eBuilding == gc.getInfoTypeForString("BUILDING_ARCOLOGY"):
if pCity.getNumRealBuilding(gc.getInfoTypeForString("BUILDING_ARCOLOGY_SHIELDING")) or pCity.getNumRealBuilding(gc.getInfoTypeForString("BUILDING_DEFLECTOR_SHIELDING")):
return True
# player can't build shielding if they have advanced
if eBuilding == gc.getInfoTypeForString("BUILDING_ARCOLOGY_SHIELDING"):
if pCity.getNumRealBuilding(gc.getInfoTypeForString("BUILDING_DEFLECTOR_SHIELDING")):
return True
return False
def getUpgradePriceOverride(self, argsList):
iPlayer, iUnitID, iUnitTypeUpgrade = argsList
## Leonardo's Workshop Start ##
pPlayer = gc.getPlayer(iPlayer)
pUnit = pPlayer.getUnit(iUnitID)
iPrice = gc.getDefineINT("BASE_UNIT_UPGRADE_COST")
iPrice += (max(0, (pPlayer.getUnitProductionNeeded(iUnitTypeUpgrade) - pPlayer.getUnitProductionNeeded(pUnit.getUnitType()))) * gc.getDefineINT("UNIT_UPGRADE_COST_PER_PRODUCTION"))
if ((not pPlayer.isHuman()) and (not pPlayer.isBarbarian())):
pHandicapInfo = gc.getHandicapInfo(gc.getGame().getHandicapType())
iPrice = iPrice * pHandicapInfo.getAIUnitUpgradePercent() / 100
iPrice = iPrice * max(0, ((pHandicapInfo.getAIPerEraModifier() * pPlayer.getCurrentEra()) + 100)) / 100
iPrice = iPrice - ((iPrice * pUnit.getUpgradeDiscount()) / 100)
b_Leonardo = gc.getInfoTypeForString("BUILDING_LEONARDO")
obsoleteTech = gc.getBuildingInfo(b_Leonardo).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_Leonardo) == true:
iPrice = ((gc.getDefineINT("BASE_UNIT_UPGRADE_COST"))/2)
iPrice += (((max(0, (pPlayer.getUnitProductionNeeded(iUnitTypeUpgrade) - pPlayer.getUnitProductionNeeded(pUnit.getUnitType()))) * gc.getDefineINT("UNIT_UPGRADE_COST_PER_PRODUCTION")))/2)
if ((not pPlayer.isHuman()) and (not pPlayer.isBarbarian())):
pHandicapInfo = gc.getHandicapInfo(gc.getGame().getHandicapType())
iPrice = ((iPrice * pHandicapInfo.getAIUnitUpgradePercent() / 100)/2)
iPrice = ((iPrice * max(0, ((pHandicapInfo.getAIPerEraModifier() * pPlayer.getCurrentEra()) + 100)) / 100)/2)
iPrice = ((iPrice - ((iPrice * pUnit.getUpgradeDiscount()) / 100))/2)
if pUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_LEADER')):
iPrice = 0
return iPrice
## Leonardo's Workshop End ##
## Leonardo's Workshop Start ##
#
## NOTE: You need to comment out (add a # before) the original return -1 (done below) ##
#
# return -1 # Any value 0 or above will be used
#
## Leonardo's Workshop End ##