Esempio n. 1
0
	def checkRegions(self, iPlayer, regionList, bVassal=False):
		"""Checks whether iPlayer and his vassals (if bVassal is True) control
		all regions (provinces) in regionList."""
		for regionID in regionList:
			if not utils.checkRegionControl(iPlayer, regionID, bVassal):
				return False
		return True
Esempio n. 2
0
	def getNumProvinces(self, iPlayer):
		"""Returns the number of regions (provinces) that iPlayer controls."""
		iNumProvinces = 0
		regionList = []
		apCityList = PyPlayer(iPlayer).getCityList()
		for pCity in apCityList:
			regionID = gc.getMap().plot(pCity.getX(), pCity.getY()).getRegionID()
			if regionID not in regionList and utils.checkRegionControl(iPlayer, regionID):
				regionList.append(regionID)
				iNumProvinces += 1
		return iNumProvinces
def printStabilityData(iPlayer):

    pPlayer = gc.getPlayer(iPlayer)
    pTeam = gc.getTeam(pPlayer.getTeam())
    apCityList = PyPlayer(iPlayer).getCityList()
    iCiv = sd.getCivilization(iPlayer)
    print("iCiv=", iCiv)
    iGameTurn = gc.getGame().getGameTurn()

    iCivicGovernment = pPlayer.getCivics(0)
    iCivicLegal = pPlayer.getCivics(1)
    iCivicLabor = pPlayer.getCivics(2)
    iCivicEconomy = pPlayer.getCivics(3)
    iCivicReligion = pPlayer.getCivics(4)

    iStateReligion = pPlayer.getStateReligion()

    iNumCities = pPlayer.getNumCities()
    if iNumCities < 1: iNumCities = 1

    # CIVICS
    print "CIVICS"

    iCivicsRating = 2  # srpt civics is hurting too much

    if iCivicGovernment == iMonarchyCivic:
        if iCivicLegal == iBarbarismCivic:
            iCivicsRating -= 1
            print("bad combo", "monarchy", "barbarism")
        if iCivicLegal in [iVassalageCivic, iReligiousLawCivic]:
            iCivicsRating += 1
            print("good combo", "monarchy", "vassalage, or religious law")
        if iCivicLabor == iSerfdomCivic:
            iCivicsRating += 1
            print("good combo", "monarchy", "serfdom")
        if iCivicLabor == iWageLaborCivic:
            iCivicsRating -= 1
            print("bad combo", "monarchy", "wage labor")
        if iCivicEconomy == iPatronageCivic:
            iCivicsRating += 1
            print("good combo", "monarchy", "patronage")
        if iCivicReligion in [iDynasticCultCivic, iStateReligionCivic]:
            iCivicsRating += 1
            print("good combo", "monarchy", "dynastic cult or state religion")

    if iCivicGovernment == iOligarchyCivic:
        if iCivicLegal in [iBarbarismCivic, iTyrannyCivic]:
            iCivicsRating -= 1
            print("bad combo", "oligrachy", "barbarism or tyranny")
        if iCivicLegal == iBureaucracyCivic:
            iCivicsRating += 1
            print("good combo", "oligrachy", "bureaucracy")
        if iCivicLabor == iTribalismCivic:
            iCivicsRating -= 1
            print("bad combo", "oligrachy", "tribalism")
        if iCivicReligion in [iDynasticCultCivic, iMilitancyCivic]:
            iCivicsRating -= 1
            print("bad combo", "oligrachy", "dynastic cult or militancy")
        if iCivicEconomy in [iAgrarianismCivic, iPatronageCivic]:
            iCivicsRating += 1
            print("good combo", "oligrachy", "agrarianism or patronage")

    if iCivicGovernment == iEmpireCivic:
        if iCivicLegal == iBureaucracyCivic:
            iCivicsRating += 1
            print("good combo", "empire", "bureaucracy")
        if iCivicLegal in [iBarbarismCivic, iTyrannyCivic]:
            iCivicsRating -= 1
            print("bad combo", "empire", "tyranny")
        if iCivicLabor == iTribalismCivic:
            iCivicsRating -= 1
            print("bad combo", "empire", "tribalism")
        if iCivicEconomy == iDecentralizationCivic:
            iCivicsRating -= 1
            print("bad combo", "empire", "decentralization")
        if iCivicEconomy == iAgrarianismCivic:
            iCivicsRating += 1
            print("good combo", "empire", "agrarianism")

    if iCivicLegal == iBarbarismCivic:
        if iCivicLabor == iWageLaborCivic:
            iCivicsRating -= 1
            print("bad combo", "barbarism", "wage labor")
        if iCivicEconomy == iTradeEconomyCivic:
            iCivicsRating -= 1
            print("bad combo", "barbarism", "trade economy")

    if iCivicLegal == iTyrannyCivic:
        if iCivicLabor in [iCasteSystemCivic, iWageLaborCivic]:
            iCivicsRating -= 1
            print("bad combo", "tyranny", "caste system or wage labor")
        if iCivicEconomy == iTradeEconomyCivic:
            iCivicsRating -= 1
            print("bad combo", "tyranny", "trade economy")
        if iCivicReligion == iDynasticCultCivic:
            iCivicsRating += 1
            print("good combo", "tyranny", "dynastic cult")
        if iCivicReligion in [
                iStateReligionCivic, iMilitancyCivic, iSyncretismCivic
        ]:
            iCivicsRating -= 1
            print("bad combo", "tyranny",
                  "state religion, militancy or syncretism")

    if iCivicLegal == iVassalageCivic:
        if iCivicLabor in [iCasteSystemCivic, iSerfdomCivic]:
            iCivicsRating += 1
            print("good combo", "vassalge", "caste system or serfdom")
        if iCivicLabor == iWageLaborCivic:
            iCivicsRating -= 1
            print("bad combo", "vassalge", "wage labor")
        if iCivicEconomy == iTradeEconomyCivic:
            iCivicsRating -= 1
            print("bad combo", "vassalge", "trade economy")
        if iCivicEconomy == iPatronageCivic:
            iCivicsRating += 1
            print("good combo", "vassalge", "patronage")
        if iCivicReligion == iDynasticCultCivic:
            iCivicsRating -= 1
            print("bad combo", "vassalage", "dynastic cult")

    if iCivicLegal == iReligiousLawCivic:
        if iCivicLabor in [iCasteSystemCivic, iSerfdomCivic]:
            iCivicsRating += 1
            print("good combo", "religious law", "caste system or serfdom")
        if iCivicLabor == iWageLaborCivic:
            iCivicsRating -= 1
            print("bad combo", "religious law", "wage labor")
        if iCivicEconomy in [iTradeEconomyCivic, iMilitaryEconomyCivic]:
            iCivicsRating -= 1
            print("bad combo", "religious law",
                  "trade economy or military economy")
        if iCivicReligion in [
                iPaganismCivic, iDynasticCultCivic, iSyncretismCivic
        ]:
            iCivicsRating -= 1
            print("bad combo", "religious law",
                  "paganism, dynastic cult or syncretism")

    if iCivicLegal == iBureaucracyCivic:
        if iCivicLabor in [iTribalismCivic, iCasteSystemCivic]:
            iCivicsRating -= 1
            print("bad combo", "bureaucracy", "tribalism or caste system")
        if iCivicLabor == iSlaveryCivic:
            iCivicsRating += 1
            print("good combo", "bureaucracy", "slavery")
        if iCivicEconomy == iDecentralizationCivic:
            iCivicsRating -= 1
            print("bad combo", "bureaucracy", "decentralization")

    if iCivicLabor == iTribalismCivic:
        if iCivicEconomy == iDecentralizationCivic:
            iCivicsRating += 1
            print("good combo", "tribalism", "decentralization")
        if iCivicEconomy in [iTradeEconomyCivic, iMilitaryEconomyCivic]:
            iCivicsRating -= 1
            print("bad combo", "tribalism",
                  "trade economy or military economy")
        if iCivicReligion == iDynasticCultCivic:
            iCivicsRating -= 1
            print("bad combo", "tribalism", "dynastic cult")

    if iCivicLabor == iSlaveryCivic:
        if iCivicEconomy == iAgrarianismCivic:
            iCivicsRating += 1
            print("good combo", "slavery", "agrarianism")

    if iCivicLabor == iCasteSystemCivic:
        if iCivicEconomy == iAgrarianismCivic:
            iCivicsRating += 1
            print("good combo", "caste system", "agrarianism")
        if iCivicEconomy == iTradeEconomyCivic:
            iCivicsRating -= 1
            print("bad combo", "caste system", "trade economy")
        if iCivicReligion in [iDynasticCultCivic, iSyncretismCivic]:
            iCivicsRating -= 1
            print("bad combo", "caste system", "dynastic cult or syncretism")

    if iCivicLabor == iSerfdomCivic:
        if iCivicEconomy == iAgrarianismCivic:
            iCivicsRating += 1
            print("good combo", "serfdom", "agrarianism")
        if iCivicEconomy == iTradeEconomyCivic:
            iCivicsRating -= 1
            print("bad combo", "serfdom", "trade economy")
        if iCivicReligion == iStateReligionCivic:
            iCivicsRating += 1
            print("good combo", "serfdom", "state religion")

    if iCivicLabor == iWageLaborCivic:
        if iCivicEconomy in [iDecentralizationCivic, iAgrarianismCivic]:
            iCivicsRating -= 1
            print("bad combo", "wage labor", "decentralization or agrarianism")
        if iCivicEconomy == iTradeEconomyCivic:
            iCivicsRating += 1
            print("good combo", "wage labor", "trade economy")
        if iCivicReligion == iMilitancyCivic:
            iCivicsRating -= 1
            print("bad combo", "wage labor", "militancy")

    if iCivicEconomy == iTradeEconomyCivic:
        if iCivicReligion in [iDynasticCultCivic, iMilitancyCivic]:
            iCivicsRating -= 1
            print("bad combo", "trade economy", "dynastic cult or militancy")

    # Civics + State Religion

    if iCivicLabor == iCasteSystemCivic and iStateReligion != iHinduism:
        iCivicsRating -= 1
        print "caste wo hindu"

    if iCivicLabor == iSlaveryCivic and iStateReligion == iChristianity:
        iCivicsRating -= 1
        print "christian slaves"

    print("Civics rating:", iCivicsRating)
    print("stored civics rating", sd.getCivicsStability(iPlayer))

    ## HAPPINESS AND HEALTH ##
    print "HEALTH & HAPPINESS"
    # balance of health and happiness per city, with extra penalty for angry citizens

    iHappinessAndHealthRating = 0
    print("total happy",
          pPlayer.calculateTotalCityHappiness(), "total unhappy",
          pPlayer.calculateTotalCityUnhappiness(), "cities", iNumCities)
    print("total health",
          pPlayer.calculateTotalCityHealthiness(), "total unhealth",
          pPlayer.calculateTotalCityUnhealthiness(), "cities", iNumCities)
    iHappiness = ((pPlayer.calculateTotalCityHappiness()) -
                  (pPlayer.calculateTotalCityUnhappiness())) / (iNumCities)
    iHealth = ((pPlayer.calculateTotalCityHealthiness()) -
               (pPlayer.calculateTotalCityUnhealthiness())) / (iNumCities)
    print("iHappiness=", iHappiness, "iHealth=", iHealth)

    if iHappiness < 0: iHappinessAndHealthRating -= 1
    elif iHappiness > 3: iHappinessAndHealthRating += 1

    if iHealth < 0: iHappinessAndHealthRating -= 1
    elif iHealth > 3: iHappinessAndHealthRating += 1

    if iPlayer == utils.getHumanID():  # I think this kills the AI unfairly
        for pLoopCity in apCityList:
            if (pLoopCity.GetCy().angryPopulation(0) > 0):
                iHappinessAndHealthRating -= 1
                print "angry city"

    print("Health & Happiness rating:", iHappinessAndHealthRating)

    ## ECONOMY ##
    print "ECONOMY"
    # balance of income and costs

    iEconomyRating = 0

    #if pPlayer.getGold() < 300:
    iRate = (pPlayer.calculateGoldRate() + pPlayer.calculateBaseNetResearch()
             ) - (pPlayer.calculateInflatedCosts())
    print("gold=", pPlayer.calculateGoldRate(), "research=",
          pPlayer.calculateBaseNetResearch(), "costs=",
          pPlayer.calculateInflatedCosts(), "iRate", iRate)

    if iRate < -300: iEconomyRating -= 4
    elif iRate < -200: iEconomyRating -= 3
    elif iRate < -100: iEconomyRating -= 2
    elif iRate < -20: iEconomyRating -= 1
    elif iRate > +10: iEconomyRating += 1
    elif iRate > +30: iEconomyRating += 2

    iEconomy = pPlayer.calculateTotalYield(
        YieldTypes.YIELD_COMMERCE) - pPlayer.calculateInflatedCosts()
    iIndustry = pPlayer.calculateTotalYield(YieldTypes.YIELD_PRODUCTION)
    iAgriculture = pPlayer.calculateTotalYield(YieldTypes.YIELD_FOOD)

    iGrowth = iEconomy + iIndustry + iAgriculture

    if iGrowth * 2 < sd.getOldEconomyRating(iPlayer):
        iEconomyRating -= 3
        print "high economic decline"
    elif iGrowth * 4 < sd.getOldEconomyRating(iPlayer) * 3:
        iEconomyRating -= 2
        print "med economic decline"
    elif iGrowth < sd.getOldEconomyRating(iPlayer):
        iEconomyRating -= 1
        print "some economic decline"

    sd.setOldEconomyRating(iPlayer, iGrowth)

    print("Economy rating:", iEconomyRating)

    ## EMPIRE ##
    print "EMPIRE"
    # balance of core and empire populations, mitigated by courthouses and civics

    iEmpireRating = 0
    bExiled = True
    for regionID in utils.getCoreRegions(iCiv):
        if (utils.checkRegionOwnedCity(iPlayer, regionID)):
            bExiled = False
        if not (utils.checkRegionControl(iPlayer, regionID)):
            iEmpireRating -= 4
            print "core province not controlled"
    if bExiled:
        print "Exiled"

    iCorePop = 0
    iEmpirePop = 0
    for pLoopCity in apCityList:
        if pLoopCity.GetCy().isCapital():
            iCorePop += pLoopCity.getPopulation() * 3
        else:
            regionID = gc.getMap().plot(
                pLoopCity.GetCy().getX(),
                pLoopCity.GetCy().getY()).getRegionID()
            if regionID in utils.getCoreRegions(
                    iCiv) or regionID in utils.getSpecialRegions(iCiv):
                iCorePop += pLoopCity.getPopulation() * 2
            elif regionID in utils.getNormalRegions(iCiv):
                iFactor = 1
                if not ((iCivicGovernment == iTheocracyCivic) and
                        (pLoopCity.GetCy().isHasReligion(iStateReligion))):
                    if iCivicGovernment != iEmpireCivic: iFactor += 1
                if not (iCivicLegal == iBureaucracyCivic):
                    iFactor += 1
                if not (pLoopCity.GetCy().getNumRealBuilding(iCourthouse)):
                    iFactor += 1
                iEmpirePop += pLoopCity.getPopulation() * iFactor
            else:
                iFactor = 2
                if not ((iCivicGovernment == iTheocracyCivic) and
                        (pLoopCity.GetCy().isHasReligion(iStateReligion))):
                    if iCivicGovernment != iEmpireCivic: iFactor += 1
                if not (iCivicLegal == iBureaucracyCivic):
                    iFactor += 1
                if not (pLoopCity.GetCy().getNumRealBuilding(iCourthouse) > 0):
                    iFactor += 1
                iEmpirePop += pLoopCity.getPopulation() * iFactor

    if (pPlayer.getNumCities()) * 2 < (sd.getNumCities(iPlayer)):
        iEmpireRating -= 6
        print "high city losses"
    elif (pPlayer.getNumCities()) * 3 < (sd.getNumCities(iPlayer)) * 2:
        iEmpireRating -= 3
        print "med city losses"
    elif pPlayer.getNumCities() < sd.getNumCities(iPlayer):
        iEmpireRating -= 1
        print "some losses"

    print("iCorePop=", iCorePop, "iEmpirePop=", iEmpirePop)

    if iCorePop > iEmpirePop * 2: iEmpireRating += 2
    elif iCorePop > iEmpirePop: iEmpireRating += 1
    elif iCorePop * 5 < iEmpirePop: iEmpireRating -= 5
    elif iCorePop * 4 < iEmpirePop: iEmpireRating -= 4
    elif iCorePop * 3 < iEmpirePop: iEmpireRating -= 3
    elif iCorePop * 2 < iEmpirePop: iEmpireRating -= 2
    elif iCorePop < iEmpirePop: iEmpireRating -= 1

    print("iEmpireRating=", iEmpireRating)

    ## RELIGION ##
    print "RELIGION"
    iReligionRating = 0
    iNumForeignReligions = 0
    iNumNonbelievingCities = 0

    if (iCivicReligion == iDynasticCultCivic) or (iCivicReligion
                                                  == iPaganismCivic):
        for pLoopCity in apCityList:
            for iLoopReligion in range(iNumReligions):
                if pLoopCity.GetCy().isHasReligion(iLoopReligion):
                    if iLoopReligion != iHinduism:
                        iNumForeignReligions += 1
                    elif iLoopReligion == iHinduism and iCivicLabor != iCasteSystemCivic:
                        iNumForeignReligions += 1
    elif iCivicReligion == iStateReligionCivic:
        for pLoopCity in apCityList:
            if not pLoopCity.GetCy().isHasReligion(iStateReligion):
                iNumNonbelievingCities += 2
            for iLoopReligion in range(iNumReligions):
                if pLoopCity.GetCy().isHasReligion(
                        iLoopReligion) and iLoopReligion != iStateReligion:
                    iNumForeignReligions += 1
    elif (iCivicReligion == iMilitancyCivic) or (iCivicGovernment
                                                 == iTheocracyCivic):
        for pLoopCity in apCityList:
            if not pLoopCity.GetCy().isHasReligion(iStateReligion):
                iNumNonbelievingCities += 2
            for iLoopReligion in range(iNumReligions):
                if pLoopCity.GetCy().isHasReligion(
                        iLoopReligion) and iLoopReligion != iStateReligion:
                    iNumForeignReligions += 2

    print("iNumForeignReligions", iNumForeignReligions,
          "iNumNonbelievingCities", iNumNonbelievingCities, "iNumCities",
          iNumCities)

    if iNumNonbelievingCities * 2 > iNumCities: iReligionRating -= 2
    elif iNumNonbelievingCities * 4 > iNumCities: iReligionRating -= 1

    if iNumForeignReligions > iNumCities * 2: iReligionRating -= 2
    elif iNumForeignReligions > iNumCities: iReligionRating -= 1

    print("iReligionRating=", iReligionRating)

    print "TOTALS"
    print(
        "Total:", iCivicsRating + iHappinessAndHealthRating + iEconomyRating +
        iEmpireRating + iReligionRating)

    def stabilityCheck(iPlayer, iAdjustment=0):

        #print "stabilityCheck called"

        #CyInterface().addMessage(utils.getHumanID(), True, iDuration, CyTranslator().getText("STABILITY CHECK", ()) + " " + gc.getPlayer(iPlayer).getCivilizationDescription(0), "", 0, "", ColorTypes(iRed), -1, -1, True, True)
        if (iPlayer > iNumPlayers):
            return
        pPlayer = gc.getPlayer(iPlayer)
        pTeam = gc.getTeam(pPlayer.getTeam())
        apCityList = PyPlayer(iPlayer).getCityList()
        iCiv = sd.getCivilization(iPlayer)
        iGameTurn = gc.getGame().getGameTurn()
        iCivicGovernment = pPlayer.getCivics(0)
        iCivicLegal = pPlayer.getCivics(1)
        iCivicLabor = pPlayer.getCivics(2)
        iCivicReligion = pPlayer.getCivics(4)

        # calibrate the system here:
        #iAdjustment -= 1

        if utils.getYear() > tFall[iCiv]:
            iAdjustment -= 3

        if iPlayer == iRome and (tBirth[iByzantines] +
                                 20) > utils.getYear() > (tBirth[iByzantines] -
                                                          20):
            #print "pass on Byzantine birth"
            return

        if (iGameTurn < getTurnForYear(tBirth[iPlayer]) + 50):
            #print "pass, too early"
            return

        if iPlayer == iRome and gc.getPlayer(iByzantines).isAlive(
        ) and sd.getCivilization(iByzantines) == iRebelRome:
            #print "pass for Rome during civil war"
            return
        '''if pTeam.isHasTech(iStabilityCollapsing):
			if iGameTurn > getTurnForYear(tFall[iCiv]):
				print ("quick terminal crisis, iCiv=", gc.getPlayer(iPlayer).getCivilizationShortDescription(0), "year=", utils.getYear())
				self.terminalCrisis(iPlayer, iCiv, pPlayer, pTeam)
				return
			else:
				print ("quick severe crisis, iCiv=", gc.getPlayer(iPlayer).getCivilizationShortDescription(0), "year=", utils.getYear())
				self.severeCrisis(iPlayer, iCiv, pPlayer, pTeam)
				return'''

        ## CIVICS ##

        # combinations of civics and state religions

        # Civics
        #print "CIVICS"

        iCivicsRating = sd.getCivicsStability(iPlayer)

        ## HAPPINESS AND HEALTH ##
        #print "HEALTH & HAPPINESS"
        # balance of health and happiness per city, with extra penalty for angry citizens

        iNumCities = pPlayer.getNumCities()
        if iNumCities < 1: iNumCities = 1

        iHappinessAndHealthRating = 0
        #print ("total happy", pPlayer.calculateTotalCityHappiness(), "total unhappy", pPlayer.calculateTotalCityUnhappiness(), "cities", iNumCities)
        #print ("total health", pPlayer.calculateTotalCityHealthiness(), "total unhealth", pPlayer.calculateTotalCityUnhealthiness(), "cities", iNumCities)
        iHappiness = ((pPlayer.calculateTotalCityHappiness()) -
                      (pPlayer.calculateTotalCityUnhappiness())) / (iNumCities)
        iHealth = ((pPlayer.calculateTotalCityHealthiness()) -
                   (pPlayer.calculateTotalCityUnhealthiness())) / (iNumCities)
        #print ("iHappiness=", iHappiness, "iHealth=", iHealth)

        if iHappiness < 0: iHappinessAndHealthRating -= 1
        elif iHappiness > 3: iHappinessAndHealthRating += 1

        if iHealth < 0: iHappinessAndHealthRating -= 1
        elif iHealth > 3: iHappinessAndHealthRating += 1

        if iPlayer == utils.getHumanID():  # I think this kills the AI unfairly
            for pLoopCity in apCityList:
                if (pLoopCity.GetCy().angryPopulation(0) > 0):
                    iHappinessAndHealthRating -= 1
                    #print "angry city"

        ## ECONOMY ##
        #print "ECONOMY"
        # balance of income and costs

        iEconomyRating = 0

        iRate = (pPlayer.calculateGoldRate() +
                 pPlayer.calculateBaseNetResearch()) - (
                     pPlayer.calculateInflatedCosts())
        #print ("gold=", pPlayer.calculateGoldRate(), "research=", pPlayer.calculateBaseNetResearch(), "costs=", pPlayer.calculateInflatedCosts(), "iRate", iRate)

        if iRate < -300: iEconomyRating -= 4
        elif iRate < -200: iEconomyRating -= 3
        elif iRate < -100: iEconomyRating -= 2
        elif iRate < -20: iEconomyRating -= 1
        elif iRate > +10: iEconomyRating += 1
        elif iRate > +30: iEconomyRating += 2

        #else:
        #iEconomyRating += 2
        #print "pass on savings"

        ## EMPIRE ##
        #print "EMPIRE"
        # balance of core and empire populations, mitigated by courthouses and civics

        iEmpireRating = 0
        bExiled = True
        for regionID in utils.getCoreRegions(iCiv):
            if (utils.checkRegionOwnedCity(iPlayer, regionID)):
                bExiled = False
            if not (utils.checkRegionControl(iPlayer, regionID)):
                iEmpireRating -= 4
                #print "core province not controlled"
        if bExiled:
            #print "Exiled"
            self.terminalCrisis(iPlayer, iCiv, pPlayer, pTeam)

        iCorePop = 0
        iEmpirePop = 0
        for pLoopCity in apCityList:
            if not pLoopCity.isNone():  # possible fix for C++ exception
                if pLoopCity.GetCy().isCapital():
                    iCorePop += pLoopCity.getPopulation() * 3
                else:
                    regionID = gc.getMap().plot(
                        pLoopCity.GetCy().getX(),
                        pLoopCity.GetCy().getY()).getRegionID()
                    if regionID in utils.getCoreRegions(
                            iCiv) or regionID in utils.getSpecialRegions(iCiv):
                        iCorePop += pLoopCity.getPopulation() * 2
                    elif regionID in utils.getNormalRegions(iCiv):
                        iFactor = 1
                        if not (
                            (iCivicGovernment == iTheocracyCivic) and
                            (pLoopCity.GetCy().isHasReligion(iStateReligion))):
                            if iCivicGovernment != iEmpireCivic: iFactor += 1
                        if not (iCivicLegal == iBureaucracyCivic):
                            iFactor += 1
                        print "C++ exception, Normal Regions", (
                            "iPlayer = ",
                            iPlayer), ("Year = ", utils.getYear()), (
                                "Location = ", "(", pLoopCity.GetCy().getX(),
                                ",", pLoopCity.GetCy().getY())
                        if not (pLoopCity.GetCy().getNumRealBuilding(
                                iCourthouse)):
                            print "Courthouse statement answered no"
                            iFactor += 1
                        else:
                            print "Courthouse statement answered yes"
                        iEmpirePop += pLoopCity.getPopulation() * iFactor
                    else:
                        iFactor = 2
                        if not (
                            (iCivicGovernment == iTheocracyCivic) and
                            (pLoopCity.GetCy().isHasReligion(iStateReligion))):
                            if iCivicGovernment != iEmpireCivic: iFactor += 1
                        if not (iCivicLegal == iBureaucracyCivic):
                            iFactor += 1
                        print "C++ exception, Other Regions", (
                            "iPlayer = ",
                            iPlayer), ("Year = ", utils.getYear()), (
                                "Location = ", "(", pLoopCity.GetCy().getX(),
                                ",", pLoopCity.GetCy().getY())
                        if not (pLoopCity.GetCy().getNumRealBuilding(
                                iCourthouse)):
                            print "Courthouse statement answered no"
                            iFactor += 1
                        else:
                            print "Courthouse statement answered yes"
                        iEmpirePop += pLoopCity.getPopulation() * iFactor

        #print ("iCorePop=", iCorePop, "iEmpirePop=", iEmpirePop)

        #if iCorePop > iEmpirePop *5: iEmpireRating += 5
        #elif iCorePop > iEmpirePop *4: iEmpireRating += 4
        #elif iCorePop > iEmpirePop *3: iEmpireRating += 3
        #iEmpireRating += self.empireStability(iCorePop, iEmpirePop)

        if iCorePop > iEmpirePop * 2: iEmpireRating += 2
        elif iCorePop > iEmpirePop: iEmpireRating += 1
        elif iCorePop * 5 < iEmpirePop: iEmpireRating -= 5
        elif iCorePop * 4 < iEmpirePop: iEmpireRating -= 4
        elif iCorePop * 3 < iEmpirePop: iEmpireRating -= 3
        elif iCorePop * 2 < iEmpirePop: iEmpireRating -= 2
        elif iCorePop < iEmpirePop: iEmpireRating -= 1

        #if iCorePop < iEmpirePop:
        #iEmpireRating -= (((iEmpirePop * 10) / iCorePop) * ((iEmpirePop * 10) / iCorePop)) / 100

        #print ("iEmpireRating=", iEmpireRating)

        ## RELIGION ##
        #print "RELIGION"
        iReligionRating = 0
        iNumForeignReligions = 0
        iNumNonbelievingCities = 0

        if (iCivicReligion == iDynasticCultCivic) or (iCivicReligion
                                                      == iPaganismCivic):
            for pLoopCity in apCityList:
                for iLoopReligion in range(iNumReligions):
                    if pLoopCity.GetCy().isHasReligion(iLoopReligion):
                        if iLoopReligion != iHinduism:
                            iNumForeignReligions += 1
                        elif iLoopReligion == iHinduism and iCivicLabor != iCasteSystemCivic:
                            iNumForeignReligions += 1
        elif iCivicReligion == iStateReligionCivic:
            for pLoopCity in apCityList:
                if not pLoopCity.GetCy().isHasReligion(iStateReligion):
                    iNumNonbelievingCities += 2
                for iLoopReligion in range(iNumReligions):
                    if pLoopCity.GetCy().isHasReligion(
                            iLoopReligion) and iLoopReligion != iStateReligion:
                        iNumForeignReligions += 1
        elif (iCivicReligion == iMilitancyCivic) or (iCivicGovernment
                                                     == iTheocracyCivic):
            for pLoopCity in apCityList:
                if not pLoopCity.GetCy().isHasReligion(iStateReligion):
                    iNumNonbelievingCities += 2
                for iLoopReligion in range(iNumReligions):
                    if pLoopCity.GetCy().isHasReligion(
                            iLoopReligion) and iLoopReligion != iStateReligion:
                        iNumForeignReligions += 2

        #print ("iNumForeignReligions", iNumForeignReligions, "iNumNonbelievingCities", iNumNonbelievingCities, "iNumCities", iNumCities)

        if iNumNonbelievingCities * 2 > iNumCities: iReligionRating -= 2
        elif iNumNonbelievingCities * 4 > iNumCities: iReligionRating -= 1

        if iNumForeignReligions > iNumCities * 2: iReligionRating -= 2
        elif iNumForeignReligions > iNumCities: iReligionRating -= 1

        #print ("iReligionRating=", iReligionRating)

        #print "TOTALS"
        #print ("Civics:", iCivicsRating, "Health & Happiness:", iHappinessAndHealthRating, "Economy:", iEconomyRating, "Empire:", iEmpireRating, "Religion:", iReligionRating)
        #print ("Total:", iCivicsRating + iHappinessAndHealthRating + iEconomyRating + iEmpireRating + iReligionRating)
        #iAdjustment = 3
        #print ("iAdjustment=", iAdjustment)

        iStability = iCivicsRating + iHappinessAndHealthRating + iEconomyRating + iEmpireRating + iReligionRating + iAdjustment
        if iPlayer == iByzantines: iStability += 3  # Byzantine UP
        if iGameTurn > getTurnForYear(tFall[iCiv]): iStability -= 3

        ### RESULTS ###

        if pTeam.isHasTech(iStabilityCollapsing):
            if iStability < -3:
                if iGameTurn > getTurnForYear(tFall[iCiv]):
                    #print "RESULT"
                    #print ("already collapsing, terminal crisis, iCiv=", iCiv)
                    self.terminalCrisis(iPlayer, iCiv, pPlayer, pTeam)
                    return
                else:
                    #print "RESULT"
                    #print ("already collapsing, severe crisis, iCiv=", iCiv)
                    self.severeCrisis(iPlayer, iCiv, pPlayer, pTeam)
                    return
            elif iStability < 3:
                #print "RESULT"
                #print ("stability flat at collapsing, moderate crisis, iCiv=", iCiv)
                self.moderateCrisis(iPlayer, iCiv, pPlayer, pTeam)
            elif iStability > 3:
                #print "RESULT"
                #print ("upgrade from collapsing to unstable, iCiv=", iCiv)
                pTeam.setHasTech(iStabilityCollapsing, False, iPlayer, False,
                                 False)
                pTeam.setHasTech(iStabilityUnstable, True, iPlayer, False,
                                 False)
                return

        elif pTeam.isHasTech(iStabilityUnstable):
            if iStability < -6:
                if iGameTurn > getTurnForYear(tFall[iCiv]):
                    #print "RESULT"
                    #print ("downgrade from unstable to collapsing, severe crisis, iCiv=", iCiv)
                    pTeam.setHasTech(iStabilityUnstable, False, iPlayer, False,
                                     False)
                    pTeam.setHasTech(iStabilityCollapsing, True, iPlayer,
                                     False, False)
                    self.severeCrisis(iPlayer, iCiv, pPlayer, pTeam)
                    return
                else:
                    #print "RESULT"
                    #print ("downgrade from unstable to collapsing, moderate crisis, iCiv=", iCiv)
                    pTeam.setHasTech(iStabilityUnstable, False, iPlayer, False,
                                     False)
                    pTeam.setHasTech(iStabilityCollapsing, True, iPlayer,
                                     False, False)
                    self.moderateCrisis(iPlayer, iCiv, pPlayer, pTeam)
                    return
            elif iStability <= 0:
                #print "RESULT"
                #print ("stability flat at unstable, minor crisis, iCiv=", iCiv)
                self.minorCrisis(iPlayer, iCiv, pPlayer, pTeam)
                return
            else:
                #print "RESULT"
                #print ("stability upgrade from unstable to stable, no crisis, iCiv=", iCiv)
                pTeam.setHasTech(iStabilityUnstable, False, iPlayer, False,
                                 False)
                pTeam.setHasTech(iStabilityStable, True, iPlayer, False, False)
                return
        else:
            if iStability < -6:
                #print "RESULT"
                #print ("downgrade from stable to unstable, minor crisis, iCiv=", iCiv)
                pTeam.setHasTech(iStabilityStable, False, iPlayer, False,
                                 False)
                pTeam.setHasTech(iStabilityUnstable, True, iPlayer, False,
                                 False)
                self.minorCrisis(iPlayer, iCiv, pPlayer, pTeam)
                return
            elif iStability < -3:
                #print "RESULT"
                #print ("downgrade from stable to unstable, no crisis, iCiv=", iCiv)
                pTeam.setHasTech(iStabilityStable, False, iPlayer, False,
                                 False)
                pTeam.setHasTech(iStabilityUnstable, True, iPlayer, False,
                                 False)
                return
            #elif iStability >= 0: print ("stability flat at stable, no crisis, iCiv=", iCiv)
Esempio n. 4
0
	def getUHVHelp(self, iPlayer, iGoal):
		"""Returns an array of help strings used by the Victory Screen table."""
		
		aHelp = []
		pPlayer = gc.getPlayer(iPlayer)
		iGameTurn = gc.getGame().getGameTurn()
		
		# the info is outdated or irrelevant once the goal has been accomplished or failed
		if sd.getGoal(iPlayer, iGoal) == 1:
			aHelp.append(self.getIcon(True) + localText.getText("TXT_KEY_VICTORY_GOAL_ACCOMPLISHED", ()))
			return aHelp
		elif sd.getGoal(iPlayer, iGoal) == 0:
			aHelp.append(self.getIcon(False) + localText.getText("TXT_KEY_VICTORY_GOAL_FAILED", ()))
			return aHelp
				
		
		if iPlayer == con.iCarthage:
			if iGoal == 0: 
				iTurnsLeft = abs(max(0, getTurnForYear(-350) - iGameTurn))
				iLuxuryCount = self.getNumLuxuries(con.iCarthage)
				iStrategicCount = self.getNumStrategicResources(con.iCarthage)
				aHelp.append(self.getIcon(iLuxuryCount >= 6 and iStrategicCount >= 6) + 'Luxury resources: ' + str(iLuxuryCount) + ' / 6' + self.getIcon(iStrategicCount >= 6) + 'Strategic resources: ' + str(iStrategicCount) + ' / 6')
				if iTurnsLeft > 0 and sd.getGoal(iPlayer, 0) == -1:
					aHelp.append(str(iTurnsLeft) + ' turns left')
					
			if iGoal == 1: 
				iTurnsLeft = abs(max(0, getTurnForYear(-300) - iGameTurn))
				bComplete = False
				iCarthageTrade = gc.getMap().plot(23, 33).getPlotCity().getTradeYield(YieldTypes.YIELD_COMMERCE)
				iBestTrade = 0
				for city in utils.getAllCities():
					if city.getX() != 23 and city.getY() != 33:
						iCityTrade = city.getTradeYield(YieldTypes.YIELD_COMMERCE)
						if iCityTrade > iBestTrade:
							iBestTrade = iCityTrade
							pBestCity = city
				aHelp.append('Top trade city: ' + pBestCity.getName() + 'Trade: ' + str(iBestTrade))
				if iCarthageTrade > iCityTrade:
					aHelp.append(self.getIcon(iCarthageTrade > iBestTrade) + 'Carthage top trade city')
				else:
					aHelp.append(self.getIcon(iCarthageTrade > iBestTrade) + pBestCity.getName() + ' top trade city')
							
				if iTurnsLeft > 0 and sd.getGoal(iPlayer, 0) == -1:
					aHelp.append(str(iTurnsLeft) + ' turns left')
					
			if iGoal == 2:  
				iTurnsLeft = abs(max(0, getTurnForYear(-200) - iGameTurn))
				bComplete = False
				if sd.getGoal(con.iCarthage, 1) == 1: bComplete = True
				aHelp.append(self.getIcon(bComplete) + 'Romans destroyed')
				if iTurnsLeft > 0 and sd.getGoal(iPlayer, 0) == -1:
					aHelp.append(str(iTurnsLeft) + ' turns left')
					
		if iPlayer == con.iAthens:
			if iGoal == 0:
				iTurnsLeft = abs(max(0, getTurnForYear(-350) - iGameTurn))
				iPorts = 0
				for city in utils.getCityList(iPlayer):
					if (city.getX(), city.getY()) in con.lAegeanPortTiles:
						iPorts += 1
				aHelp.append(self.getIcon(iPorts >= 5) + 'Aegean ports: ' + str(iPorts) + ' / 5')
				if iTurnsLeft > 0 and sd.getGoal(iPlayer, 0) == -1:
					aHelp.append(str(iTurnsLeft) + ' turns left')
						
			if iGoal == 1:
				bParthenon = self.getNumBuildings(iPlayer, con.iParthenon)
				bDionysis = self.getNumBuildings(iPlayer, con.iDionysis)
				bAcademy = self.getNumBuildings(iPlayer, con.iAcademy)
				aHelp.append(self.getIcon(bParthenon) + 'Parthenon, ' + self.getIcon(bDionysis) + 'Dionysis, ' + self.getIcon(bAcademy) + 'Academy')
				
			if iGoal == 2:
				iTurnsLeft = abs(max(0, getTurnForYear(-300) - iGameTurn))
				iCount = 0
				if pPlayer.getNumCities() > 0:
					capital = pPlayer.getCapitalCity()
					iCount = self.countGreatPeople((capital.getX(), capital.getY()))
				aHelp.append(self.getIcon(iCount >= 5) + 'Great people settled: ' + str(iCount) + ' / 5')
				if iTurnsLeft > 0 and sd.getGoal(iPlayer, 0) == -1:
					aHelp.append(str(iTurnsLeft) + ' turns left')
				
				
		if iPlayer == con.iNandas:
			if iGoal == 0:
				iTurnsLeft = abs(max(0, getTurnForYear(-330) - iGameTurn))
				bMagadha = utils.checkRegionControl(iPlayer, con.rMagadha, True)
				bAnga = utils.checkRegionControl(iPlayer, con.rAnga, True)
				bAvanti = utils.checkRegionControl(iPlayer, con.rAvanti, True)
				bPunjab = utils.checkRegionControl(iPlayer, con.rPunjab, True)
				aHelp.append(self.getIcon(bMagadha) + 'Magadha, ' + self.getIcon(bAnga) + 'Anga, ' + self.getIcon(bPunjab) + 'Punjab, ' + self.getIcon(bAvanti) + 'Avanti')
				if iTurnsLeft > 0 and sd.getGoal(iPlayer, 0) == -1:
					aHelp.append(str(iTurnsLeft) + ' turns left')
			if iGoal == 1:
				iTurnsLeft = abs(max(0, getTurnForYear(-330) - iGameTurn))
				iBestArmy = 0
				iNandaArmy = gc.getPlayer(iPlayer).getNumUnits()
				for iLoopPlayer in range(con.iNumPlayers):
					iLoopArmy = gc.getPlayer(iLoopPlayer).getNumUnits()
					if iLoopArmy > iBestArmy:
						iBestArmy = iLoopArmy
				aHelp.append(self.getIcon(iNandaArmy > iBestArmy) + 'Army size: ' + str(iNandaArmy) + '    Rival army size: ' + str(iBestArmy))
				if iTurnsLeft > 0 and sd.getGoal(iPlayer, 0) == -1:
					aHelp.append(str(iTurnsLeft) + ' turns left')
			if iGoal == 2:
				iTurnsLeft = abs(max(0, getTurnForYear(-330) - iGameTurn))
				iBestGold = 0
				iNandaGold = gc.getPlayer(iPlayer).getGold()
				for iLoopPlayer in range(con.iNumPlayers):
					iLoopGold = gc.getPlayer(iLoopPlayer).getGold()
					if iLoopGold > iBestGold:
						iBestGold = iLoopGold
				aHelp.append(self.getIcon(iNandaGold > iBestGold) + 'Gold: ' + str(iNandaGold) + '    Rival gold: ' + str(iBestGold))
				if iTurnsLeft > 0 and sd.getGoal(iPlayer, 0) == -1:
					aHelp.append(str(iTurnsLeft) + ' turns left')
		
		if iPlayer == con.iQin:
			if iGoal == 0: 
				iTurnsLeft = abs(max(0, getTurnForYear(-215) - iGameTurn))
				bWall = self.getNumBuildings(iPlayer, con.iGreatWall)
				bArmy = self.getNumBuildings(iPlayer, con.iTerracottaArmy)
				aHelp.append(self.getIcon(bWall) + 'The Great Wall, ' + self.getIcon(bArmy) + 'The Terracotta Army')
				if iTurnsLeft > 0 and sd.getGoal(iPlayer, 0) == -1:
					aHelp.append(str(iTurnsLeft) + ' turns left')
			if iGoal == 1:
				iTurnsLeft = abs(max(0, getTurnForYear(-210) - iGameTurn))
				bQin = utils.checkRegionControl(iPlayer, con.rQin)
				bHan = utils.checkRegionControl(iPlayer, con.rHan)
				bYan = utils.checkRegionControl(iPlayer, con.rYan)
				bZhao = utils.checkRegionControl(iPlayer, con.rZhao)
				bChu = utils.checkRegionControl(iPlayer, con.rChu)
				bNanYue = utils.checkRegionControl(iPlayer, con.rNanYue)
				bWu = utils.checkRegionControl(iPlayer, con.rWu)
				bQi = utils.checkRegionControl(iPlayer, con.rQi)
				aHelp.append(self.getIcon(bQin) + 'Qin, ' + self.getIcon(bHan) + 'Han, ' + self.getIcon(bYan) + 'Yan, ' + self.getIcon(bZhao) + 'Zhao, ' + self.getIcon(bChu) + 'Chu ' + self.getIcon(bNanYue) + 'Nan Yue, ' + self.getIcon(bQi) + 'Qi ' + self.getIcon(bWu) + 'Wu')
				if iTurnsLeft > 0 and sd.getGoal(iPlayer, 0) == -1:
					aHelp.append(str(iTurnsLeft) + ' turns left')
			if iGoal == 2:
				iTurnsLeft = abs(max(0, getTurnForYear(-100) - iGameTurn))
				iCount = self.getNumProvinces(iPlayer)
				aHelp.append(self.getIcon(iCount >= 9) + 'Provinces controlled: ' + str(iCount) + ' / 9')
				if iTurnsLeft > 0 and sd.getGoal(iPlayer, 0) == -1:
					aHelp.append(str(iTurnsLeft) + ' turns left')
				
		
				
				
		
		
		
		return aHelp
Esempio n. 5
0
	def checkPlayerTurn(self, iGameTurn, iPlayer):
		
		iHuman = utils.getHumanID()
		pPlayer = gc.getPlayer(iPlayer)
		
		# CARTHAGE
		if iPlayer == con.iCarthage:
				
			# Carthaginian UHV1: Obtain 6 luxury resources and 6 strategic resources by 350BC
			if sd.getGoal(iPlayer, 0) == -1:
				if iGameTurn <= getTurnForYear(-350):
					if self.getNumLuxuries(iPlayer) >= 6 and self.getNumStrategicResources(iPlayer) >= 6:
						sd.setGoal(iPlayer, 0, 1)
				else:
					sd.setGoal(iPlayer, 0, 0)
						
			# Carthaginian UHV2: Make Carthage the most prosperous trading city in the world in 300BC
			if iGameTurn <= getTurnForYear(-300):
				iCarthageTrade = gc.getMap().plot(23, 33).getPlotCity().getTradeYield(YieldTypes.YIELD_COMMERCE)
				iBestTrade = 0
				for city in utils.getAllCities():
					if city.getX() != 23 and city.getY() != 33:
						iCityTrade = city.getTradeYield(YieldTypes.YIELD_COMMERCE)
						if iCityTrade > iBestTrade:
							iBestTrade = iCityTrade
				if iCarthageTrade > iBestTrade:
					sd.setGoal(iPlayer, 1, 1)
				else:
					sd.setGoal(iPlayer, 1, 0)
		
		# ATHENS
		if iPlayer == con.iAthens:
		
			# Control five Aegean ports by 350BC
			if sd.getGoal(iPlayer, 0) == -1:
				if iGameTurn <= getTurnForYear(-350):
					iPorts = 0
					for city in utils.getCityList(iPlayer):
						if (city.getX(), city.getY()) in con.lAegeanPortTiles:
							iPorts += 1
					if iPorts >= 5:
						sd.setGoal(iPlayer, 0, 1)
				else:
					sd.setGoal(iPlayer, 0, 0)
					
			# Build the Parthenon, the Theatre of Dionysis and the Academy see onBuildingBuilt
			
			# Settle five Great People in your capital by 300BC
			if sd.getGoal(iPlayer, 2) == -1:
				if iGameTurn <= getTurnForYear(300):
					iCount = 0
					if pPlayer.getNumCities() > 0:
						capital = pPlayer.getCapitalCity()
						if self.countGreatPeople((capital.getX(), capital.getY())) >= 5:
							sd.setGoal(iPlayer, 2, 1)
				else:
					sd.setGoal(iPlayer, 2, 0)
					
		# NANDAS
		if iPlayer == con.iNandas:
			
			# Control northern India by 330BC
			if sd.getGoal(iPlayer, 0) == -1:
				if iGameTurn <= getTurnForYear(-330):
					bControl = true
					regionList = [con.rMagadha, con.rAnga, con.rAvanti, con.rPunjab]
					for regionID in regionList:
						if not utils.checkRegionControl(iPlayer, regionID, True):
							bControl = false
					if bControl:
						sd.setGoal(iPlayer, 0, 1)
				else:
					sd.setGoal(iPlayer, 0, 0)
						
			# Control the world's largest army by 330BC
			if sd.getGoal(iPlayer, 1) == -1:
				if iGameTurn <= getTurnForYear(-330):
					iBestArmy = 0
					iNandaArmy = gc.getPlayer(iPlayer).getNumUnits()
					for iLoopPlayer in range(con.iNumPlayers):
						iLoopArmy = gc.getPlayer(iLoopPlayer).getNumUnits()
						if iLoopArmy > iBestArmy:
							iBestArmy = iLoopArmy
					if iBestArmy > iNandaArmy:
						sd.setGoal(iPlayer, 1, 1)
				else:
					sd.setGoal(iPlayer, 1, 0)
					
			# Be the world's richest civilization in 330BC
			if iGameTurn == getTurnForYear(-330):
				iBestGold = 0
				iNandaGold = gc.getPlayer(iPlayer).getGold()
				for iLoopPlayer in range(con.iNumPlayers):
					iLoopGold = gc.getPlayer(iPlayer).getGold()
					if iLoopGold > iBestGold:
						iBestGold = iLoopGold
				if iNandaGold > iBestGold:
					sd.setGoal(iPlayer, 2, 1)
				else:
					sd.setGoal(iPlayer, 2, 0)
					
		# QIN
		if iPlayer == con.iQin:
		# Qin UHV1: Build the Great Wall and the Terracotta Army by 215BC see onBuildingBuilt
			if sd.getGoal(iPlayer, 0) == -1:
				if iGameTurn >= getTurnForYear(-215):
					sd.setGoal(iPlayer, 0, 0)
			
			# Qin UHV2: control central and north China by 210BC
			if sd.getGoal(iPlayer, 1) == -1:
				if iGameTurn <= getTurnForYear(-210):
					bControl = True
					regionList = [con.rQin, con.rHan, con.rYan, con.rZhao, con.rChu, con.rNanYue, con.rQi, con.rWu, con.rShu]
					for regionID in regionList:
						if not utils.checkRegionControl(iPlayer, regionID):
							bControl = False
					if bControl:
						sd.setGoal(iPlayer, 1, 1)
				else:
					sd.setGoal(iPlayer, 1, 0)
			
			# Qin UHV3: control at least 9 provinces in 100BC
			if sd.getGoal(iPlayer, 2) == -1:
				if iGameTurn == getTurnForYear(-100):
					if self.getNumProvinces(iPlayer) >= 9:
						sd.setGoal(iPlayer, 2, 1)
					else:
						sd.setGoal(iPlayer, 2, 0)
						
			
			
		
		# HISTORICAL VICTORY
		if gc.getGame().isVictoryValid(iHistoricalVictory):
		
			
			
			#generic checks
			if pPlayer.isAlive() and iPlayer < con.iNumPlayers:
				if sd.get2OutOf3(iPlayer) == False:
					if utils.countAchievedGoals(iPlayer) == 2:
						#intermediate bonus
						sd.set2OutOf3(iPlayer, True)
						if pPlayer.getNumCities() > 0: #this check is needed, otherwise game crashes
							pPlayer.changeGoldenAgeTurns(pPlayer.getGoldenAgeLength()) # edead
							iWarCounter = 0
							iRndnum = gc.getGame().getSorenRandNum(con.iNumPlayers, 'civs')
							iHandicap = gc.getGame().getHandicapType()
							for i in range(iRndnum, con.iNumPlayers + iRndnum):
								iCiv = i % con.iNumPlayers
								pCiv = gc.getPlayer(iCiv)
								if pCiv.isAlive() and pCiv.canContact(iPlayer):                                                                
									if pCiv.AI_getAttitude(iPlayer) <= 0:
										teamCiv = gc.getTeam(pCiv.getTeam())
										if not teamCiv.isAtWar(iPlayer) and not teamCiv.isDefensivePact(iPlayer) and not utils.isAVassal(iCiv):
											teamCiv.AI_setWarPlan(iPlayer, WarPlanTypes.WARPLAN_PREPARING_TOTAL) # edead: prepare for total war
											iWarCounter += 1
											if iWarCounter == 1 + max(1, iHandicap):
												break
			if gc.getGame().getWinner() == -1:
				if sd.getGoal(iPlayer, 0) == 1 and sd.getGoal(iPlayer, 1) == 1 and sd.getGoal(iPlayer, 2) == 1:
					gc.getGame().setWinner(iPlayer, iHistoricalVictory)
				
		# RELIGIOUS VICTORY
		if gc.getGame().isVictoryValid(iReligiousVictory) and iPlayer == iHuman:
			if iGameTurn >= getTurnForYear(con.tBirth[iPlayer]) and gc.getPlayer(iPlayer).getStateReligion() != -1:
				for i in range(3):
					if sd.getReligiousGoal(iPlayer, i) == -1:
						if self.getURV(iPlayer, i):
							sd.setReligiousGoal(iPlayer, i, 1)
				if gc.getGame().getWinner() == -1:
					if sd.getReligiousGoal(iPlayer, 0) == 1 and sd.getReligiousGoal(iPlayer, 1) == 1 and sd.getReligiousGoal(iPlayer, 2) == 1:
						gc.getGame().setWinner(iPlayer, iReligiousVictory)
	def drawContents(self):
		
		self.deleteAllWidgets()

		# Create a new screen, called FinanceAdvisor, using the file FinanceAdvisor.py for input
		screen = self.getScreen()
	
		player = gc.getPlayer(self.iActiveLeader)

		ePlayer = self.iActiveLeader #Rhye
		#Rhye - start ## srpt stability conversion
		## srpt stability conversion replaced below
		#Rhye - end
		
		pTeam = gc.getTeam(gc.getPlayer(utils.getHumanID()).getTeam())
		
		if pTeam.isHasTech(con.iStabilityStable):
			szTempBuffer = localText.getText("TXT_KEY_STABILITY_STABLE", ())
		elif pTeam.isHasTech(con.iStabilityUnstable):
			szTempBuffer = localText.getText("TXT_KEY_STABILITY_UNSTABLE", ())
		elif pTeam.isHasTech(con.iStabilityCollapsing):
			szTempBuffer = localText.getText("TXT_KEY_STABILITY_COLLAPSING", ())
			
		## srpt stability conversion end
	
		numCities = player.getNumCities()	
					
		totalUnitCost = player.calculateUnitCost()
		totalUnitSupply = player.calculateUnitSupply()
		totalMaintenance = player.getTotalMaintenance()
		totalCivicUpkeep = player.getCivicUpkeep([], False)
		totalPreInflatedCosts = player.calculatePreInflatedCosts()
		totalInflatedCosts = player.calculateInflatedCosts()
		goldCommerce = player.getCommerceRate(CommerceTypes.COMMERCE_GOLD)
		if (not player.isCommerceFlexible(CommerceTypes.COMMERCE_RESEARCH)):
			goldCommerce += player.calculateBaseNetResearch()
		gold = player.getGold()
		goldFromCivs = player.getGoldPerTurn()
		
		# < Mercenaries Start >
		totalMercenaryMaintenanceCost = objMercenaryUtils.getPlayerMercenaryMaintenanceCost(self.iActiveLeader)
		# totalMercenaryContractIncome = objMercenaryUtils.getPlayerMercenaryContractIncome(self.iActiveLeader)
		# < Mercenaries End   >

		szTreasuryPanel = self.getNextWidgetName()
		screen.addPanel(szTreasuryPanel, u"", "", True, True, self.X_SLIDERS, self.Y_TREASURY, self.X_EXPENSES + self.PANE_WIDTH - self.X_SLIDERS, self.H_TREASURY, PanelStyles.PANEL_STYLE_MAIN )
		screen.setLabel(self.getNextWidgetName(), szTreasuryPanel, u"<font=4>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_TREASURY", (gold, )).upper() + u"</font>", CvUtil.FONT_CENTER_JUSTIFY, (self.X_SLIDERS + self.PANE_WIDTH + self.X_EXPENSES)/2, self.Y_TREASURY + self.H_TREASURY/2 - self.Y_SPACING/2, self.Z_CONTROLS, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_HELP_FINANCE_GOLD_RESERVE, -1, -1 )

		szCommercePanel = self.getNextWidgetName()
		screen.addPanel(szCommercePanel, u"", "", True, True, self.X_SLIDERS, self.Y_LOCATION, self.PANE_WIDTH, self.PANE_HEIGHT, PanelStyles.PANEL_STYLE_MAIN )
		screen.setLabel(self.getNextWidgetName(), "Background",  u"<font=3>" + localText.getText("TXT_KEY_CONCEPT_COMMERCE", ()).upper() + u"</font>", CvUtil.FONT_CENTER_JUSTIFY, self.X_SLIDERS + self.PANE_WIDTH/2, self.Y_LOCATION + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
				
		szIncomePanel = self.getNextWidgetName()
		screen.addPanel(szIncomePanel, u"", "", True, True, self.X_INCOME, self.Y_LOCATION, self.PANE_WIDTH, self.PANE_HEIGHT, PanelStyles.PANEL_STYLE_MAIN )
		screen.setLabel(self.getNextWidgetName(), "Background",  u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_INCOME_HEADER", ()).upper() + u"</font>", CvUtil.FONT_CENTER_JUSTIFY, self.X_INCOME + self.PANE_WIDTH/2, self.Y_LOCATION + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
		
		szExpensePanel = self.getNextWidgetName()
		screen.addPanel(szExpensePanel, u"", "", True, True, self.X_EXPENSES, self.Y_LOCATION, self.PANE_WIDTH, self.PANE_HEIGHT, PanelStyles.PANEL_STYLE_MAIN )
		screen.setLabel(self.getNextWidgetName(), "Background",  u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_EXPENSES_HEADER", ()).upper() + u"</font>", CvUtil.FONT_CENTER_JUSTIFY, self.X_EXPENSES + self.PANE_WIDTH/2, self.Y_LOCATION + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )

		#Rhye - start
		iHuman = utils.getHumanID()
		pPlayer = gc.getPlayer(iHuman)
		apCityList = PyPlayer(utils.getHumanID()).getCityList()
		iNumCities = pPlayer.getNumCities()
		if iNumCities < 1: iNumCities =1
		iCivicGovernment = pPlayer.getCivics(0)
		iCivicLegal = pPlayer.getCivics(1)
		iCivicLabor = pPlayer.getCivics(2)
		iCivicReligion = pPlayer.getCivics(4)
		iStateReligion = pPlayer.getStateReligion()
		
		szStabilityPanel = self.getNextWidgetName()
		screen.addPanel(szStabilityPanel, u"", "", True, True, self.X_SLIDERS, self.Y_STABILITY, self.X_EXPENSES + self.PANE_WIDTH - self.X_SLIDERS, self.H_TREASURY, PanelStyles.PANEL_STYLE_MAIN )
		screen.setLabel(self.getNextWidgetName(), szStabilityPanel, u"<font=4>" + localText.getText("TXT_KEY_STABILITY_ADVISOR_TITLE", ()).upper() + " " + szTempBuffer + u"</font>", CvUtil.FONT_CENTER_JUSTIFY, (self.X_SLIDERS + self.PANE_WIDTH + self.X_EXPENSES)/2, self.Y_STABILITY + self.H_TREASURY/2 - self.Y_SPACING/2, self.Z_CONTROLS, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )

		szParametersPanel1 = self.getNextWidgetName()
		screen.addPanel(szParametersPanel1, u"", "", True, True, self.X_PARAMETERS1, self.Y_PARAMETERS, self.PARAMETERS_WIDTH, self.H_PARAMETERS, PanelStyles.PANEL_STYLE_MAIN )
		screen.setLabel(self.getNextWidgetName(), "Background",  u"<font=3>" + localText.getText("TXT_KEY_STABILITY_CIVICS", ()) + u"</font>", CvUtil.FONT_CENTER_JUSTIFY, self.X_PARAMETERS1 + self.PARAMETERS_WIDTH/2, self.Y_PARAMETERS + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
		
		## srpt stability data ##
		
		## Civics calculation
		iCivicsRating = sd.getCivicsStability(iHuman)
		
		self.printNumber(ePlayer, self.getNextWidgetName(), iCivicsRating, self.X_PARAMETERS1 + self.PARAMETERS_WIDTH/2, self.Y_PARAMETERS + self.TEXT_MARGIN + 60, self.Z_CONTROLS + self.DZ)
		
		szParametersPanel2 = self.getNextWidgetName()
		screen.addPanel(szParametersPanel2, u"", "", True, True, self.X_PARAMETERS2, self.Y_PARAMETERS, self.PARAMETERS_WIDTH, self.H_PARAMETERS, PanelStyles.PANEL_STYLE_MAIN )
		screen.setLabel(self.getNextWidgetName(), "Background",  u"<font=3>" + localText.getText("TXT_KEY_STABILITY_HH", ()) + u"</font>", CvUtil.FONT_CENTER_JUSTIFY, self.X_PARAMETERS2 + self.PARAMETERS_WIDTH/2, self.Y_PARAMETERS + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
		
		## H & H calculation
		iHappinessAndHealthRating = 0
		iHappiness = ((pPlayer.calculateTotalCityHappiness()) - (pPlayer.calculateTotalCityUnhappiness())) / (iNumCities)
		iHealth = ((pPlayer.calculateTotalCityHealthiness()) - (pPlayer.calculateTotalCityUnhealthiness())) / (iNumCities)
		if iHappiness < 0: iHappinessAndHealthRating -= 1
		elif iHappiness > 3: iHappinessAndHealthRating += 1
		if iHealth < 0: iHappinessAndHealthRating -= 1
		elif iHealth > 3: iHappinessAndHealthRating += 1
		for pLoopCity in apCityList:
			if (pLoopCity.GetCy().angryPopulation(0) > 0): 
				iHappinessAndHealthRating -= 1
		self.printNumber(ePlayer, self.getNextWidgetName(), iHappinessAndHealthRating, self.X_PARAMETERS2 + self.PARAMETERS_WIDTH/2, self.Y_PARAMETERS + self.TEXT_MARGIN + 60, self.Z_CONTROLS + self.DZ)
		
		szParametersPanel3 = self.getNextWidgetName()
		screen.addPanel(szParametersPanel3, u"", "", True, True, self.X_PARAMETERS3, self.Y_PARAMETERS, self.PARAMETERS_WIDTH, self.H_PARAMETERS, PanelStyles.PANEL_STYLE_MAIN )
		screen.setLabel(self.getNextWidgetName(), "Background",  u"<font=3>" + localText.getText("TXT_KEY_STABILITY_ECONOMY", ()) + u"</font>", CvUtil.FONT_CENTER_JUSTIFY, self.X_PARAMETERS3 + self.PARAMETERS_WIDTH/2, self.Y_PARAMETERS + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
		
		## Economy calculation
		iEconomyRating = 0
		#if pPlayer.getGold() < 300:
		iRate = (pPlayer.calculateGoldRate() + pPlayer.calculateBaseNetResearch()) - (pPlayer.calculateInflatedCosts())
		if iRate < -300: iEconomyRating -= 4
		elif iRate < -200: iEconomyRating -= 3
		elif iRate < -100: iEconomyRating -= 2
		elif iRate < -20: iEconomyRating -= 1
		elif iRate > +10: iEconomyRating += 1
		elif iRate > +30: iEconomyRating += 2
		
		
		iEconomy = pPlayer.calculateTotalYield(YieldTypes.YIELD_COMMERCE) - pPlayer.calculateInflatedCosts()
		iIndustry = pPlayer.calculateTotalYield(YieldTypes.YIELD_PRODUCTION)
		iAgriculture = pPlayer.calculateTotalYield(YieldTypes.YIELD_FOOD)
		
		iGrowth = iEconomy + iIndustry + iAgriculture
			
			
		if iGrowth * 2 < sd.getOldEconomyRating(iHuman): 
			iEconomyRating -= 3 
			#print "high economic decline"
		elif iGrowth * 4 < sd.getOldEconomyRating(iHuman) * 3: 
			iEconomyRating -= 2 
			#print "med economic decline"
		elif iGrowth < sd.getOldEconomyRating(iHuman): 
			iEconomyRating -= 1
			#print "some economic decline"
			
		self.printNumber(ePlayer, self.getNextWidgetName(), iEconomyRating, self.X_PARAMETERS3 + self.PARAMETERS_WIDTH/2, self.Y_PARAMETERS + self.TEXT_MARGIN + 60, self.Z_CONTROLS + self.DZ)
		
		szParametersPanel4 = self.getNextWidgetName()
		screen.addPanel(szParametersPanel4, u"", "", True, True, self.X_PARAMETERS4, self.Y_PARAMETERS, self.PARAMETERS_WIDTH, self.H_PARAMETERS, PanelStyles.PANEL_STYLE_MAIN )
		screen.setLabel(self.getNextWidgetName(), "Background",  u"<font=3>" + localText.getText("TXT_KEY_STABILITY_EMPIRE", ()) + u"</font>", CvUtil.FONT_CENTER_JUSTIFY, self.X_PARAMETERS4 + self.PARAMETERS_WIDTH/2, self.Y_PARAMETERS + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
		
		## Empire calculation
		iEmpireRating = 0
		for regionID in utils.getCoreRegions(iHuman):
			if not (utils.checkRegionControl(iHuman, regionID)): 
				iEmpireRating -= 3
		iCorePop = 0
		iEmpirePop = 0
		for pLoopCity in apCityList:
			if pLoopCity.GetCy().isCapital():
				iCorePop += pLoopCity.getPopulation() * 3
			else:
				regionID = gc.getMap().plot(pLoopCity.GetCy().getX(),pLoopCity.GetCy().getY()).getRegionID()
				if regionID in utils.getCoreRegions(iHuman) or regionID in utils.getSpecialRegions(iHuman): 
					iCorePop += pLoopCity.getPopulation() * 2
				elif regionID in utils.getNormalRegions(iHuman):
					iFactor = 1
					if not ((iCivicGovernment == con.iTheocracyCivic) and (pLoopCity.GetCy().isHasReligion(iStateReligion))):
						if iCivicGovernment != con.iEmpireCivic: iFactor += 1
					if not (iCivicLegal == con.iBureaucracyCivic):
						iFactor += 1
					if not (pLoopCity.GetCy().getNumRealBuilding(con.iCourthouse) > 0):
						iFactor += 1
					iEmpirePop += pLoopCity.getPopulation() * iFactor
				else:
					iFactor = 2
					if not ((iCivicGovernment == con.iTheocracyCivic) and (pLoopCity.GetCy().isHasReligion(iStateReligion))):
						if iCivicGovernment != con.iEmpireCivic: iFactor += 1
					if not (iCivicLegal == con.iBureaucracyCivic):
						iFactor += 1
					if not (pLoopCity.GetCy().getNumRealBuilding(con.iCourthouse) > 0):
						iFactor += 1
					iEmpirePop += pLoopCity.getPopulation() * iFactor
					
		if iCorePop > iEmpirePop *2: iEmpireRating += 2
		elif iCorePop > iEmpirePop: iEmpireRating += 1
		elif iCorePop *5 < iEmpirePop: iEmpireRating -= 5
		elif iCorePop *4 < iEmpirePop: iEmpireRating -= 4
		elif iCorePop *3 < iEmpirePop: iEmpireRating -= 3
		elif iCorePop *2 < iEmpirePop: iEmpireRating -= 2
		elif iCorePop < iEmpirePop: iEmpireRating -= 1
				
		if (pPlayer.getNumCities()) * 2 < (sd.getNumCities(iHuman)): 
			iEmpireRating -= 6
		elif (pPlayer.getNumCities()) * 3 < (sd.getNumCities(iHuman)) * 2: 
			iEmpireRating -= 3
		elif pPlayer.getNumCities() < sd.getNumCities(iHuman): 
			iEmpireRating -= 1
		
		self.printNumber(ePlayer, self.getNextWidgetName(), iEmpireRating, self.X_PARAMETERS4 + self.PARAMETERS_WIDTH/2, self.Y_PARAMETERS + self.TEXT_MARGIN + 60, self.Z_CONTROLS + self.DZ)
		
		szParametersPanel5 = self.getNextWidgetName()
		screen.addPanel(szParametersPanel5, u"", "", True, True, self.X_PARAMETERS5, self.Y_PARAMETERS, self.PARAMETERS_WIDTH, self.H_PARAMETERS, PanelStyles.PANEL_STYLE_MAIN )
		screen.setLabel(self.getNextWidgetName(), "Background",  u"<font=3>" + localText.getText("TXT_KEY_STABILITY_RELIGION", ()) + u"</font>", CvUtil.FONT_CENTER_JUSTIFY, self.X_PARAMETERS5 + self.PARAMETERS_WIDTH/2, self.Y_PARAMETERS + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
		
		
		## Religion calculation
		iReligionRating = 0
		iNumForeignReligions = 0
		iNumNonbelievingCities = 0
		if (iCivicReligion == con.iDynasticCultCivic) or (iCivicReligion == con.iPaganismCivic): 
			for pLoopCity in apCityList:
				for iLoopReligion in range(con.iNumReligions):
					if pLoopCity.GetCy().isHasReligion(iLoopReligion):
						if iLoopReligion != con.iHinduism: 
							iNumForeignReligions += 1
						elif iLoopReligion == con.iHinduism and iCivicLabor != con.iCasteSystemCivic:
							iNumForeignReligions += 1
		elif iCivicReligion == con.iStateReligionCivic: 
			for pLoopCity in apCityList:
				if not pLoopCity.GetCy().isHasReligion(iStateReligion):
					iNumNonbelievingCities += 2
				for iLoopReligion in range(con.iNumReligions):
					if pLoopCity.GetCy().isHasReligion(iLoopReligion) and iLoopReligion != iStateReligion:
						iNumForeignReligions += 1
		elif (iCivicReligion == con.iMilitancyCivic) or (iCivicGovernment == con.iTheocracyCivic): 
			for pLoopCity in apCityList:
				if not pLoopCity.GetCy().isHasReligion(iStateReligion):
					iNumNonbelievingCities += 2
				for iLoopReligion in range(con.iNumReligions):
					if pLoopCity.GetCy().isHasReligion(iLoopReligion) and iLoopReligion != iStateReligion:
						iNumForeignReligions += 2
		
		#if sd.getPiety(iHuman) > 70: iReligionRating += 2
		#elif sd.getPiety(iHuman) > 40: iReligionRating += 1
		#elif sd.getPiety(iHuman) < 30: iReligionRating -= 1
		self.printNumber(ePlayer, self.getNextWidgetName(), iReligionRating, self.X_PARAMETERS5 + self.PARAMETERS_WIDTH/2, self.Y_PARAMETERS + self.TEXT_MARGIN + 60, self.Z_CONTROLS + self.DZ)

		 ## srpt stability conversion
		#Rhye - end		

		
		# Slider percentages
		yLocation  = self.Y_LOCATION
	
		yLocation += 0.5 * self.Y_SPACING
		for iI in range(CommerceTypes.NUM_COMMERCE_TYPES):
			eCommerce = (iI + 1) % CommerceTypes.NUM_COMMERCE_TYPES

			if (player.isCommerceFlexible(eCommerce)):
				yLocation += self.Y_SPACING
				screen.setButtonGFC(self.getNextWidgetName(), u"", "", self.X_SLIDERS + self.TEXT_MARGIN, int(yLocation) + self.TEXT_MARGIN, 20, 20, WidgetTypes.WIDGET_CHANGE_PERCENT, eCommerce, gc.getDefineINT("COMMERCE_PERCENT_CHANGE_INCREMENTS"), ButtonStyles.BUTTON_STYLE_CITY_PLUS )
				screen.setButtonGFC(self.getNextWidgetName(), u"", "", self.X_SLIDERS + self.TEXT_MARGIN + 24, int(yLocation) + self.TEXT_MARGIN, 20, 20, WidgetTypes.WIDGET_CHANGE_PERCENT, eCommerce, -gc.getDefineINT("COMMERCE_PERCENT_CHANGE_INCREMENTS"), ButtonStyles.BUTTON_STYLE_CITY_MINUS )

				szText = u"<font=3>" + gc.getCommerceInfo(eCommerce).getDescription() + u" (" + unicode(player.getCommercePercent(eCommerce)) + u"%)</font>"
				screen.setLabel(self.getNextWidgetName(), "Background",  szText, CvUtil.FONT_LEFT_JUSTIFY, self.X_SLIDERS + self.TEXT_MARGIN + 50, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
				szRate = u"<font=3>" + unicode(player.getCommerceRate(CommerceTypes(eCommerce))) + u"</font>"
				screen.setLabel(self.getNextWidgetName(), "Background", szRate, CvUtil.FONT_RIGHT_JUSTIFY, self.X_SLIDERS + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)


		yLocation += self.Y_SPACING
		szText = u"<font=3>" + gc.getCommerceInfo(CommerceTypes.COMMERCE_GOLD).getDescription() + u" (" + unicode(player.getCommercePercent(CommerceTypes.COMMERCE_GOLD)) + u"%)</font>"
		screen.setLabel(self.getNextWidgetName(), "Background",  szText, CvUtil.FONT_LEFT_JUSTIFY, self.X_SLIDERS + self.TEXT_MARGIN + 50, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
		szCommerce = u"<font=3>" + unicode(goldCommerce) + u"</font>"
		screen.setLabel(self.getNextWidgetName(), "Background", szCommerce, CvUtil.FONT_RIGHT_JUSTIFY, self.X_SLIDERS + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)

		# Income
		yLocation  = self.Y_LOCATION
		iIncome = 0

		yLocation += 1.5 * self.Y_SPACING
		screen.setLabel(self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_TAXES", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_INCOME + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_GROSS_INCOME, -1, -1 )
		screen.setLabel(self.getNextWidgetName(), "Background", u"<font=3>" + unicode(goldCommerce) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_GROSS_INCOME, -1, -1 )
		iIncome += goldCommerce

		# < Mercenaries Start >
		# yLocation += 1.5 * self.Y_SPACING
		# screen.setLabel(self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_MERCENARY_CONTRACT_INCOME", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_INCOME + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
		# screen.setLabel(self.getNextWidgetName(), "Background", u"<font=3>" + unicode(totalMercenaryContractIncome) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
		# iIncome += totalMercenaryContractIncome
		# < Mercenaries End   >

		if (goldFromCivs > 0):
			yLocation += self.Y_SPACING
			szText = unicode(goldFromCivs) + " : " + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_PER_TURN", ())
			screen.setLabel(self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_PER_TURN", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_INCOME + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_FOREIGN_INCOME, self.iActiveLeader, 1)
			screen.setLabel(self.getNextWidgetName(), "Background", u"<font=3>" + unicode(goldFromCivs) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_FOREIGN_INCOME, self.iActiveLeader, 1)
			iIncome += goldFromCivs

		yLocation += 1.5 * self.Y_SPACING
		screen.setLabel(self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_INCOME", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_INCOME + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
		screen.setLabel(self.getNextWidgetName(), "Background", u"<font=3>" + unicode(iIncome) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_INCOME + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
		iIncome += goldFromCivs


		# Expenses
		yLocation = self.Y_LOCATION
		iExpenses = 0

		yLocation += 1.5 * self.Y_SPACING
		screen.setLabel(self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_UNITCOST", ()) + u"</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_EXPENSES + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_UNIT_COST, self.iActiveLeader, 1)
		screen.setLabel(self.getNextWidgetName(), "Background", u"<font=3>" + unicode(totalUnitCost) + u"</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_EXPENSES + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_UNIT_COST, self.iActiveLeader, 1)
		iExpenses += totalUnitCost

		yLocation += self.Y_SPACING
		screen.setLabel(self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_UNITSUPPLY", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_EXPENSES + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_AWAY_SUPPLY, self.iActiveLeader, 1)
		screen.setLabel(self.getNextWidgetName(), "Background", u"<font=3>" + unicode(totalUnitSupply) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_EXPENSES + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_AWAY_SUPPLY, self.iActiveLeader, 1)
		iExpenses += totalUnitSupply

		# < Mercenaries Start >
		yLocation += self.Y_SPACING
		screen.setLabel(self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_MERCENARY_MAINTENANCE_COST", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_EXPENSES + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, self.iActiveLeader, 1)
		screen.setLabel(self.getNextWidgetName(), "Background", u"<font=3>" + unicode(totalMercenaryMaintenanceCost) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_EXPENSES + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, self.iActiveLeader, 1)
		iExpenses += totalMercenaryMaintenanceCost
		# < Mercenaries End   >

		yLocation += self.Y_SPACING
		screen.setLabel(self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_MAINTENANCE", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_EXPENSES + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_CITY_MAINT, self.iActiveLeader, 1)
		screen.setLabel(self.getNextWidgetName(), "Background", u"<font=3>" + unicode(totalMaintenance) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_EXPENSES + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_CITY_MAINT, self.iActiveLeader, 1)
		iExpenses += totalMaintenance

		yLocation += self.Y_SPACING
		screen.setLabel(self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_CIVICS", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_EXPENSES + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_CIVIC_UPKEEP, self.iActiveLeader, 1)
		screen.setLabel(self.getNextWidgetName(), "Background", u"<font=3>" + unicode(totalCivicUpkeep) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_EXPENSES + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_CIVIC_UPKEEP, self.iActiveLeader, 1)
		iExpenses += totalCivicUpkeep

		if (goldFromCivs < 0):
			yLocation += self.Y_SPACING
			screen.setLabel(self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_COST_PER_TURN", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_EXPENSES + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_FOREIGN_INCOME, self.iActiveLeader, 1)
			screen.setLabel(self.getNextWidgetName(), "Background", u"<font=3>" + unicode(-goldFromCivs) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_EXPENSES + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_FOREIGN_INCOME, self.iActiveLeader, 1)
			iExpenses -= goldFromCivs

		yLocation += self.Y_SPACING
		iInflation = totalInflatedCosts - totalPreInflatedCosts
		screen.setLabel(self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_INFLATION", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_EXPENSES + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_INFLATED_COSTS, self.iActiveLeader, 1)
		screen.setLabel(self.getNextWidgetName(), "Background", u"<font=3>" + unicode(iInflation) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_EXPENSES + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_HELP_FINANCE_INFLATED_COSTS, self.iActiveLeader, 1)
		iExpenses += iInflation

		yLocation += 1.5 * self.Y_SPACING
		screen.setLabel(self.getNextWidgetName(), "Background", u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_EXPENSES", ()) + "</font>", CvUtil.FONT_LEFT_JUSTIFY, self.X_EXPENSES + self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
		screen.setLabel(self.getNextWidgetName(), "Background", u"<font=3>" + unicode(iExpenses) + "</font>", CvUtil.FONT_RIGHT_JUSTIFY, self.X_EXPENSES + self.PANE_WIDTH - self.TEXT_MARGIN, yLocation + self.TEXT_MARGIN, self.Z_CONTROLS + self.DZ, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )

		return 0
Esempio n. 7
0
    def checkPlayerTitle(self, iTitle, iPlayer):
        """Checks if the player is eligible for the given title."""

        if iPlayer >= con.iNumPlayers:
            return

        # Skip if title is already taken, unless previous owner is a vassal of iPlayer
        for iLoopPlayer in range(con.iNumPlayers):
            if gc.getTeam(gc.getPlayer(iLoopPlayer).getTeam()).getProjectCount(
                    iTitle):
                if not gc.getTeam(
                        gc.getPlayer(iLoopPlayer).getTeam()).isVassal(iPlayer):
                    return

        iStateReligion = gc.getPlayer(iPlayer).getStateReligion()

        if iTitle == con.iRomanEmperor:
            if gc.getMap().plot(
                    con.tRome[0],
                    con.tRome[1]).getOwner() == iPlayer or gc.getMap().plot(
                        con.tConstantinople[0],
                        con.tConstantinople[1]).getOwner() == iPlayer:
                iNumCities = 0
                regionList = [
                    con.rGreece, con.rAsia, con.rThrace, con.rSyria,
                    con.rJudea, con.rEgypt, con.rLibya, con.rAfrica,
                    con.rIberia, con.rSeptimania, con.rGaul
                ]
                apCityList = PyPlayer(iPlayer).getCityList()
                for pCity in apCityList:
                    if pCity.GetCy().plot().getRegionID() in regionList:
                        iNumCities += 1
                if iNumCities >= 20:
                    gc.getTeam(
                        gc.getPlayer(iPlayer).getTeam()).changeProjectCount(
                            iTitle, 1)

        elif iTitle == con.iCaliph:
            pBabylon = gc.getMap().plot(con.tBabylon[0],
                                        con.tBabylon[1]).getPlotCity()
            if not pBabylon is None and not pBabylon.isNone():
                if pBabylon.getOwner() == iPlayer and (iStateReligion
                                                       == con.iIslam):
                    gc.getTeam(
                        gc.getPlayer(iPlayer).getTeam()).changeProjectCount(
                            iTitle, 1)
                    # Fatimid UHV3
                    #if iPlayer == con.iHan:
                    #if sd.getGoal(con.iHan, 2) == -1:
                    #sd.setGoal(con.iHan, 2, 1)

        elif iTitle == con.iShahanshah:
            if iStateReligion != con.iZoroastrianism:
                return
            bControl = True
            for iRegion in con.lTitleRegions[con.iShahanshah]:
                if not utils.checkRegionControl(iPlayer, iRegion):
                    bControl = False
                    break
            if bControl:
                gc.getTeam(gc.getPlayer(iPlayer).getTeam()).changeProjectCount(
                    iTitle, 1)
                gc.getPlayer(iPlayer).changeFreeCityCommerce(
                    CommerceTypes.COMMERCE_CULTURE, 1)
                # Sassanid UHV
                if iPlayer == con.iSassanids:
                    if sd.getGoal(con.iSassanids, 0) == -1:
                        sd.setGoal(con.iSassanids, 0, 1)
                #elif iPlayer == con.iTang:
                #if sd.getGoal(con.iTang, 2) == -1:
                #sd.setGoal(con.iTang, 2, 1)
                #elif iPlayer == con.iArabs:
                #if sd.getGoal(con.iArabs, 0) == -1:
                #sd.setGoal(con.iArabs, 0, 1)

        elif iTitle == con.iRaja:
            if iStateReligion != con.iHinduism:
                return
            iNumRegions = 0
            for iRegion in con.lTitleRegions[con.iRaja]:
                if utils.checkRegionControl(iPlayer, iRegion):
                    iNumRegions += 1
                    if iNumRegions == 6:
                        gc.getTeam(gc.getPlayer(
                            iPlayer).getTeam()).changeProjectCount(iTitle, 1)
                        break

        elif iTitle == con.iSharif:
            return

        elif iTitle == con.iProtector:
            return