def onCityRazed(self, argsList): 'City Razed' city, iPlayer = argsList iPreviousOwner = city.getOwner() #print ("onCityRazed", city.getName(), "iPlayer=", gc.getPlayer(iPlayer).getCivilizationShortDescription(0), "iPreviousOwner=", gc.getPlayer(iPreviousOwner).getCivilizationShortDescription(0), "year=", utils.getYear()) if iPreviousOwner == iPlayer and city.getPreviousOwner() != -1: iPreviousOwner = city.getPreviousOwner() #self.pla.onCityRazed(argsList) self.rel.onCityRazed(argsList) self.rfccwaiw.onCityRazed(argsList) if iPlayer != con.iBarbarian or not (gc.getTeam( gc.getPlayer(iPreviousOwner).getTeam()).isHasTech( con.iTrajansColumnFunctionTech)): if iPreviousOwner < con.iNumPlayers and gc.getPlayer( iPreviousOwner).getNumCities() > 1 and gc.getPlayer( iPreviousOwner).getAnarchyTurns() < 1 and gc.getPlayer( iPreviousOwner).getGoldenAgeTurns() < 1: if utils.getYear() < con.tFall[iPreviousOwner]: if (sd.getLastRebellion(iPreviousOwner) ) < utils.getYear() - 5: print( "STABILITY CHECK city razed iPreviousOwner=", gc.getPlayer(iPreviousOwner). getCivilizationShortDescription(0), "year=", utils.getYear()) regionID = gc.getMap().plot(city.getX(), city.getY()).getRegionID() if regionID in utils.getCoreRegions( sd.getCivilization(iPreviousOwner)): utils.stabilityCheck(iPreviousOwner, -3) elif regionID in utils.getNormalRegions( sd.getCivilization(iPreviousOwner)): if not (gc.getTeam( gc.getPlayer(iPreviousOwner).getTeam()). isHasTech(con.iStabilityStable)): utils.stabilityCheck(iPreviousOwner, -2) else: if not (gc.getTeam( gc.getPlayer(iPreviousOwner).getTeam()). isHasTech(con.iStabilityStable)): utils.stabilityCheck(iPreviousOwner, -1) else: print( "STABILITY CHECK city razed iPreviousOwner=", gc.getPlayer( iPreviousOwner).getCivilizationShortDescription(0), "year=", utils.getYear()) regionID = gc.getMap().plot(city.getX(), city.getY()).getRegionID() if regionID in utils.getCoreRegions( sd.getCivilization(iPreviousOwner)): utils.stabilityCheck(iPreviousOwner, -3) elif regionID in utils.getNormalRegions( sd.getCivilization(iPreviousOwner)): if not (gc.getTeam( gc.getPlayer(iPreviousOwner).getTeam()). isHasTech(con.iStabilityStable)): utils.stabilityCheck(iPreviousOwner, -2) else: if not (gc.getTeam( gc.getPlayer(iPreviousOwner).getTeam()). isHasTech(con.iStabilityStable)): utils.stabilityCheck(iPreviousOwner, -1) if iPlayer < con.iNumPlayers and gc.getPlayer( iPreviousOwner).getNumCities() > 1 and gc.getPlayer( iPreviousOwner).getAnarchyTurns( ) < 1 and gc.getPlayer( iPreviousOwner).getGoldenAgeTurns() < 1: print( "STABILITY CHECK city razed iPlayer=", gc.getPlayer(iPlayer).getCivilizationShortDescription( 0), "year=", utils.getYear()) regionID = gc.getMap().plot(city.getX(), city.getY()).getRegionID() if regionID in utils.getCoreRegions( sd.getCivilization(iPlayer)): utils.stabilityCheck(iPlayer, -9) elif regionID in utils.getNormalRegions( sd.getCivilization(iPlayer)): utils.stabilityCheck(iPlayer, -6) else: utils.stabilityCheck(iPlayer, -3) # Refugees sd.setVal('tRazedCityData', (city.getX(), city.getY(), city.getNameKey()))
def onCityAcquired(self, argsList): 'City Acquired' iPreviousOwner, iNewOwner, city, bConquest, bTrade = argsList pNewOwner = gc.getPlayer(iNewOwner) #print ("city acquired", city.getName(), "year=", utils.getYear()) #print ("iNewOwner=", gc.getPlayer(iNewOwner).getCivilizationShortDescription(0), "iPreviousOwner=", gc.getPlayer(iPreviousOwner).getCivilizationShortDescription(0)) self.cnm.renameCity(city, iNewOwner) self.rnf.checkCapitalsOnCapture( city, iNewOwner) # edead: free capital move for the AI if bConquest: if iNewOwner != con.iBarbarian or not (gc.getTeam( gc.getPlayer(iPreviousOwner).getTeam()).isHasTech( con.iTrajansColumnFunctionTech)): if iPreviousOwner < con.iNumPlayers and gc.getPlayer( iPreviousOwner).getNumCities() >= 1 and gc.getPlayer( iPreviousOwner).getGoldenAgeTurns() < 1: if utils.getYear() < con.tFall[iPreviousOwner]: if (sd.getLastRebellion(iPreviousOwner) ) < utils.getYear() - 5: print("STABILITY CHECK city lost iNewOwner=", iNewOwner, "iPreviousOwner=", iPreviousOwner, "year=", utils.getYear()) regionID = gc.getMap().plot( city.getX(), city.getY()).getRegionID() if regionID in utils.getCoreRegions( sd.getCivilization(iPreviousOwner)): utils.stabilityCheck(iPreviousOwner, -3) elif regionID in utils.getNormalRegions( sd.getCivilization(iPreviousOwner)): if not (gc.getTeam( gc.getPlayer(iPreviousOwner).getTeam() ).isHasTech(con.iStabilityStable)): utils.stabilityCheck(iPreviousOwner, -2) else: if not (gc.getTeam( gc.getPlayer(iPreviousOwner).getTeam() ).isHasTech(con.iStabilityStable)): utils.stabilityCheck(iPreviousOwner, -1) else: print("STABILITY CHECK city lost iNewOwner=", iNewOwner, "iPreviousOwner=", iPreviousOwner, "year=", utils.getYear()) regionID = gc.getMap().plot(city.getX(), city.getY()).getRegionID() if regionID in utils.getCoreRegions( sd.getCivilization(iPreviousOwner)): utils.stabilityCheck(iPreviousOwner, -3) elif regionID in utils.getNormalRegions( sd.getCivilization(iPreviousOwner)): if not (gc.getTeam( gc.getPlayer(iPreviousOwner).getTeam()). isHasTech(con.iStabilityStable)): utils.stabilityCheck(iPreviousOwner, -2) else: if not (gc.getTeam( gc.getPlayer(iPreviousOwner).getTeam()). isHasTech(con.iStabilityStable)): utils.stabilityCheck(iPreviousOwner, -1) if iNewOwner < iNumPlayers: utils.spreadMajorCulture(iNewOwner, city.getX(), city.getY()) #self.pla.onCityAcquired(iPreviousOwner, iNewOwner, city) self.dc.onCityAcquired(argsList) self.rel.onCityAcquired(argsList) self.vic.maccabeanCheck() self.corp.onCityAcquired(argsList) self.vic.onCityAcquired(argsList) self.rfccwaiw.onCityAcquired(argsList) self.rnf.onCityAcquired(argsList) # Move the palace to historical backup capital if iPreviousOwner < iNumPlayers: if (city.getX(), city.getY()) == con.tCapitals[iPreviousOwner]: self.rnf.moveCapital(con.tBackupCapitals[iPreviousOwner], iPreviousOwner, True)
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)
def checkGrid(self, iCiv): pCiv = gc.getPlayer(iCiv) tCiv = gc.getTeam(pCiv.getTeam()) lTargetCivs = [] #clean it, sometimes it takes old values in memory for k in range(iNumTotalPlayers): lTargetCivs.append(0) #set alive civs to 1 to differentiate them from dead civs for k in range(iNumTotalPlayers): if gc.getPlayer(k).isAlive() and tCiv.isHasMet(k): lTargetCivs[k] = 1 #set master or vassal to 0 for k in range(iNumPlayers): if gc.getTeam(gc.getPlayer(k).getTeam()).isVassal( iCiv) or tCiv.isVassal(k): lTargetCivs[k] = 0 #if already at war for k in range(iNumTotalPlayers): if tCiv.isAtWar(k): lTargetCivs[k] = 0 lTargetCivs[iCiv] = 0 #edead: changed Rhye's code to Regions (provinces) map = CyMap() for i in range(map.numPlots()): plot = map.plotByIndex(i) if plot.isCity(): iOwner = plot.getOwner() if iOwner >= 0 and iOwner < iNumTotalPlayers and iOwner != iCiv: if lTargetCivs[iOwner] > 0: regionID = plot.getRegionID() if regionID in utils.getCoreRegions(iCiv): lTargetCivs[iOwner] += 10 elif regionID in utils.getNormalRegions(iCiv): lTargetCivs[iOwner] += 5 elif regionID in utils.getBroaderRegions(iCiv): lTargetCivs[iOwner] += 2 #srpt: important war if utils.getYear() >= -250 and utils.getYear() < -150: if iCiv == con.iRome: lTargetCivs[con.iCarthage] += 30 elif iCiv == con.iCarthage: lTargetCivs[con.iRome] += 30 #srpt: important war if utils.getYear() >= -400 and utils.getYear() < -300: if iCiv == con.iMacedon: lTargetCivs[con.iAthens] += 30 elif iCiv == con.iAthens: lTargetCivs[con.iMacedon] += 30 #srpt: important war if utils.getYear() >= -350 and utils.getYear() < -300: if iCiv == con.iQin: lTargetCivs[con.iJinState] += 30 elif iCiv == con.iJinState: lTargetCivs[con.iQin] += 30 #there are other routines for this lTargetCivs[iIndependent1] /= 3 lTargetCivs[iIndependent2] /= 3 lTargetCivs[iIndependent3] /= 3 lTargetCivs[iIndependent4] /= 3 #no random silly wars - edead for k in range(iNumTotalPlayers): if lTargetCivs[k] == 1: lTargetCivs[k] = 0 print("AIWars grid for ", iCiv) print(lTargetCivs) #normalization iMaxTempValue = -1 for k in range(iNumTotalPlayers): if (lTargetCivs[k] > iMaxTempValue): iMaxTempValue = lTargetCivs[k] if (iMaxTempValue > 0): for k in range(iNumTotalPlayers): if (lTargetCivs[k] > 0): lTargetCivs[k] = lTargetCivs[k] * 500 / iMaxTempValue print(lTargetCivs) for iLoopCiv in range(iNumTotalPlayers): if (lTargetCivs[iLoopCiv] <= 0): continue #add a random value if (lTargetCivs[iLoopCiv] <= iThreshold): lTargetCivs[iLoopCiv] += gc.getGame().getSorenRandNum( 100, 'random modifier') if (lTargetCivs[iLoopCiv] > iThreshold): lTargetCivs[iLoopCiv] += gc.getGame().getSorenRandNum( 300, 'random modifier') #balanced with attitude attitude = 2 * (pCiv.AI_getAttitude(iLoopCiv) - 2) if (attitude > 0): lTargetCivs[iLoopCiv] /= attitude #exploit plague if iLoopCiv < iNumPlayers: if (sd.getPlagueCountdown(iLoopCiv) > 0 or sd.getPlagueCountdown(iLoopCiv) < -10 and not (gc.getGame().getGameTurn() <= getTurnForYear( con.tBirth[iLoopCiv]) + utils.getTurns(20))): lTargetCivs[iLoopCiv] *= 3 lTargetCivs[iLoopCiv] /= 2 #balanced with master's attitude for j in range(iNumTotalPlayers): if (tCiv.isVassal(j)): attitude = 2 * (gc.getPlayer(j).AI_getAttitude(iLoopCiv) - 2) if (attitude > 0): lTargetCivs[iLoopCiv] /= attitude #if already at war if (not tCiv.isAtWar(iLoopCiv)): #consider peace counter iCounter = min(7, max(1, tCiv.AI_getAtPeaceCounter(iLoopCiv))) if (iCounter <= 7): lTargetCivs[iLoopCiv] *= 20 + 10 * iCounter lTargetCivs[iLoopCiv] /= 100 #if under pact if (tCiv.isDefensivePact(iLoopCiv)): lTargetCivs[iLoopCiv] /= 4 #if friend of a friend ## for jLoopCiv in range( iNumTotalPlayers ): ## if (tCiv.isDefensivePact(jLoopCiv) and gc.getTeam(gc.getPlayer(iLoopCiv).getTeam()).isDefensivePact(jLoopCiv)): ## lTargetCivs[iLoopCiv] /= 2 print(lTargetCivs) #find max iMaxValue = 0 iTargetCiv = -1 for iLoopCiv in range(iNumTotalPlayers): if (lTargetCivs[iLoopCiv] > iMaxValue): iMaxValue = lTargetCivs[iLoopCiv] iTargetCiv = iLoopCiv print("maxvalue", iMaxValue) print("target civ", iTargetCiv) if (iMaxValue >= iMinValue): return iTargetCiv return -1
def updateBaseStability(self, iGameTurn, iPlayer): pPlayer = gc.getPlayer(iPlayer) teamPlayer = gc.getTeam(pPlayer.getTeam()) iCivic0 = pPlayer.getCivics(0) iCivic1 = pPlayer.getCivics(1) iCivic2 = pPlayer.getCivics(2) iCivic3 = pPlayer.getCivics(3) iCivic4 = pPlayer.getCivics(4) if (iGameTurn % 3 != 0): iNewBaseStability = self.getPartialBaseStability(iPlayer) iEconomy = pPlayer.calculateTotalYield( YieldTypes.YIELD_COMMERCE) - pPlayer.calculateInflatedCosts( ) #used later iIndustry = pPlayer.calculateTotalYield( YieldTypes.YIELD_PRODUCTION) #used later iAgriculture = pPlayer.calculateTotalYield( YieldTypes.YIELD_FOOD) #used later iPopulation = pPlayer.getRealPopulation() #used later iEraModifier = pPlayer.getCurrentEra() #used later else: #every 3 turns # DIPLOMACY iNewBaseStability = 0 iNewBaseStability += 5 * teamPlayer.getDefensivePactTradingCount( ) # +5 per defensive pact iNewBaseStability += 1 * teamPlayer.getOpenBordersTradingCount( ) # +1 per open borders # -3 for unstable neighbor for iLoopCiv in range(iNumPlayers): if (iLoopCiv in con.lNeighbours[iPlayer]): if (gc.getPlayer(iLoopCiv).isAlive()): if (self.getStability(iLoopCiv) < -20): if (self.getStability(iPlayer) >= 0): iNewBaseStability -= 3 #print("iNewBaseStability neighbours", iNewBaseStability, iPlayer) break # Vassal: +10 and from -5 to +5 per Master's stability for iLoopCiv in range(iNumPlayers): if (teamPlayer.isVassal(iLoopCiv)): iNewBaseStability += 10 #print("iNewBaseStability vassal",iNewBaseStability, iPlayer) iNewBaseStability += min( 5, max(-5, self.getStability(iLoopCiv) / 4)) break # Master: +2 (+5 w/Vassalage) and from -2 to +2 per Vassal's stability; for iLoopCiv2 in range(iNumPlayers): if (gc.getTeam( gc.getPlayer(iLoopCiv2).getTeam()).isVassal(iPlayer)): iNewBaseStability += 2 iNewBaseStability += min( 2, max(-2, self.getStability(iLoopCiv2) / 4)) if iCivic1 == 6: iNewBaseStability += 3 iNumContacts = 0 for iLoopCiv3 in range(iNumPlayers): if (pPlayer.canContact(iLoopCiv3) and iLoopCiv3 != iPlayer): iNumContacts += 1 iNewBaseStability -= (iNumContacts / 3 - 4) self.setParameter(iPlayer, iParDiplomacy3, False, iNewBaseStability) # EXPANSION iTempExpansionThreshold = iNewBaseStability iMaxPlotsAbroad = 40 iHandicap = gc.getGame().getHandicapType() if (iHandicap == 0): iMaxPlotsAbroad = 44 elif (iHandicap == 2): iMaxPlotsAbroad = 36 iNumPlotsAbroad = max( 0, self.getOwnedPlotsLastTurn(iPlayer) - iMaxPlotsAbroad) iExpansionPenalty = iNumPlotsAbroad * 2 / 7 iExpansionPenalty = iExpansionPenalty * self.getExpansionPercent( iPlayer) / 100 if self.getOwnedCitiesLastTurn(iPlayer) <= 20: iExpansionPenalty += self.getOwnedCitiesLastTurn(iPlayer) * 7 else: iExpansionPenalty += (self.getOwnedCitiesLastTurn(iPlayer) - 6) * 10 iNewBaseStability -= iExpansionPenalty self.setParameter(iPlayer, iParExpansion3, False, iNewBaseStability - iTempExpansionThreshold) # CIVICS iTempCivicThreshold = iNewBaseStability iStateReligion = pPlayer.getStateReligion() self.setParameter(iPlayer, iParCivics3, False, iNewBaseStability - iTempCivicThreshold) # CITIES apCityList = PyPlayer(iPlayer).getCityList() iTempExpansionPenalty = 0 for pLoopCity in apCityList: iTempCityPenalty = 0 regionID = gc.getMap().plot( pLoopCity.GetCy().getX(), pLoopCity.GetCy().getY()).getRegionID() for iLoop in range(iNumPlayers): if iGameTurn > getTurnForYear( tBirth[iLoop]) and iLoop != iPlayer: if regionID in utils.getCoreRegions( iLoop ) and not regionID in utils.getCoreRegions(iPlayer): if iGameTurn < getTurnForYear(tFall[iLoop]): if regionID in utils.getNormalRegions( iPlayer ) or regionID in utils.getBroaderRegions( iPlayer): iTempCityPenalty = 2 else: iTempCityPenalty = 3 else: if regionID in utils.getNormalRegions( iPlayer ) or regionID in utils.getBroaderRegions( iPlayer): iTempCityPenalty = 1 else: iTempCityPenalty = 2 break elif regionID in utils.getNormalRegions( iLoop) or regionID in utils.getBroaderRegions( iLoop): if regionID not in utils.getCoreRegions( iPlayer ) and regionID not in utils.getNormalRegions( iLoop ) and regionID not in utils.getBroaderRegions( iLoop): iTempCityPenalty = 1 iTempExpansionPenalty += iTempCityPenalty iTempExpansionPenalty = iTempExpansionPenalty * self.getExpansionPercent( iPlayer) / 100 iNewBaseStability -= iTempExpansionPenalty self.setParameter(iPlayer, iParExpansion3, True, -iTempExpansionPenalty) iTotalTempCityStability = 0 for pCity in apCityList: city = pCity.GetCy() pCurrent = gc.getMap().plot(city.getX(), city.getY()) iTempCityStability = 0 if (city.angryPopulation(0) > 0): iTempCityStability -= 2 if (city.healthRate(False, 0) < 0): iTempCityStability -= 1 if (city.getReligionBadHappiness() > 0): iTempCityStability -= max(2, city.getReligionBadHappiness()) if (city.getHurryAngerModifier() > 0): iTempCityStability -= 3 if (city.getNoMilitaryPercentAnger() > 0): iTempCityStability -= 2 if (city.getWarWearinessPercentAnger() > 0): iTempCityStability -= 1 if (iTempCityStability <= -5): #middle check, for optimization iTotalTempCityStability += max(-5, iTempCityStability) #print("iTotalTempCityStability", iTotalTempCityStability, city.getName(), iPlayer) if (iTotalTempCityStability <= -10): #middle check, for optimization break else: continue # instability from non-state religion - skip if player has free religion civic or tolerant trait iTempReligionStability = 0 for iLoop in range(con.iNumReligions): if city.isHasReligion( iLoop) and pPlayer.getStateReligion() != iLoop: iTempReligionStability -= 1 if not city.isHasReligion(pPlayer.getStateReligion()): iTempReligionStability -= 1 iTempReligionStability = max(-4, iTempReligionStability) iTempCityStability += iTempReligionStability for iLoop in range(iNumTotalPlayers + 1): if (iLoop != iPlayer): if (pCurrent.getCulture(iLoop) > 0): if (pCurrent.getCulture(iPlayer) == 0 ): #division by zero may happen iTempCityStability -= 2 else: if (pCurrent.getCulture(iLoop) * 100 / pCurrent.getCulture(iPlayer) >= 15): iTempCityStability -= 2 break if (iTempCityStability < 0): iTotalTempCityStability += max(-5, iTempCityStability) #print("iTotalTempCityStability", iTotalTempCityStability, city.getName(), iPlayer) if (iTotalTempCityStability <= -12): #middle check, for optimization break if iTotalTempCityStability < 0: iTotalTempCityStability += max(-12, iTotalTempCityStability) iNewBaseStability += iTotalTempCityStability #print("iNewBaseStability city check", iNewBaseStability, iPlayer) self.setParameter(iPlayer, iParCities3, False, iTotalTempCityStability) # BUILDINGS iTempBuildingsStability = 0 for pCity in apCityList: city = pCity.GetCy() iNewBaseStability += iTempBuildingsStability self.setParameter(iPlayer, iParCities3, True, iTempBuildingsStability) # HAPPINESS iHappiness = -10 if (pPlayer.calculateTotalCityHappiness() > 0): iHappiness = int((1.0 * pPlayer.calculateTotalCityHappiness()) / (pPlayer.calculateTotalCityHappiness() + \ pPlayer.calculateTotalCityUnhappiness()) * 100) - 60 iNewBaseStability += iHappiness / 10 self.setParameter(iPlayer, iParCities3, True, iHappiness / 10) # PIETY iPietyBonus = con.tFavorLevelsStabilityBonus[utils.getFavorLevel( iPlayer)] if iPlayer == utils.getHumanID(): iPietyBonus *= 3 iPietyBonus /= 2 iNewBaseStability += iPietyBonus self.setParameter(iPlayer, iParCities3, True, iPietyBonus) # ECONOMY iTempEconomyThreshold = iNewBaseStability iImports = pPlayer.calculateTotalImports(YieldTypes.YIELD_COMMERCE) iExports = pPlayer.calculateTotalExports(YieldTypes.YIELD_COMMERCE) iEconomy = pPlayer.calculateTotalYield( YieldTypes.YIELD_COMMERCE) - pPlayer.calculateInflatedCosts() iIndustry = pPlayer.calculateTotalYield( YieldTypes.YIELD_PRODUCTION) iAgriculture = pPlayer.calculateTotalYield(YieldTypes.YIELD_FOOD) iPopulation = pPlayer.getTotalPopulation() iEraModifier = pPlayer.getCurrentEra() iTradeBalance = (iImports + iExports) / 5 - iEraModifier * 2 iTradeBalance = min(6, max(-6, iTradeBalance)) iAgricultureBalance = int( 5 * (float(iAgriculture) / iPopulation - 2)) - 2 iAgricultureBalance = min(4, max(-8, iAgricultureBalance)) iEconomyBalance = int(5 * (float(iEconomy - 8) * (1 - iEraModifier / 5) / iPopulation - 2)) iEconomyBalance = min(8, max(-8, iEconomyBalance)) iIndustryBalance = int(5 * (float(iIndustry) * (1 - iEraModifier / 10) / iPopulation - 2)) iIndustryBalance = min(4, max(-4, iIndustryBalance)) # Decentralization civic iTotalBalance = iTradeBalance + iAgricultureBalance + iEconomyBalance + iIndustryBalance iNewBaseStability = iNewBaseStability + iTotalBalance self.setParameter(iPlayer, iParEconomy3, False, iNewBaseStability - iTempEconomyThreshold) self.setPartialBaseStability(iPlayer, iNewBaseStability) #every turn if (iGameTurn >= getTurnForYear(tBirth[iPlayer]) + utils.getTurns(15)): self.setGNPnew( iPlayer, self.getGNPnew(iPlayer) + (iEconomy + 4 * iIndustry + 2 * iAgriculture) / 7) if (iGameTurn % utils.getTurns(3) == 2): iTempEconomyThreshold = self.getStability(iPlayer) iMaxShrink = 7 iMaxGrowth = 3 iNegativeFasterGrowth = ( self.getGNPnew(iPlayer) - 4) / 3 - self.getGNPold( iPlayer ) / 3 #-1:-1 -2:-2 -3:-2 -4:-2 -5:-3 -6:-3 -7:-3 -8:-4 iNegativeNormalGrowth = ( self.getGNPnew(iPlayer) - 3) / 3 - self.getGNPold( iPlayer ) / 3 #-1:-1 -2:-1 -3:-2 -4:-2 -5:-2 -6:-3 -7:-3 -8:-3 iNegativeSlowerGrowth = ( self.getGNPnew(iPlayer) - 1) / 3 - self.getGNPold( iPlayer ) / 3 #-1: 0 -2:-1 -3:-1 -4:-1 -5:-2 -6:-2 -7:-2 -8:-3 iPositiveFasterGrowth = self.getGNPnew( iPlayer ) / 3 - self.getGNPold( iPlayer ) / 3 # 0: 0 +1: 0 +2: 0 +3:+1 +4:+1 +5:+1 +6:+2 +7:+2 +8:+2 +9:+3 iPositiveNormalGrowth = self.getGNPnew( iPlayer ) / 4 - self.getGNPold( iPlayer ) / 4 # 0: 0 +1: 0 +2: 0 +3: 0 +4:+1 +5:+1 +6:+1 +7:+1 +8:+2 +9:+2 iPositiveSlowerGrowth = self.getGNPnew( iPlayer ) / 5 - self.getGNPold( iPlayer ) / 5 # 0: 0 +1: 0 +2: 0 +3: 0 +4: 0 +5:+1 +6:+1 +7:+1 +8:+1 +9:+1 iNegativeGrowth = iNegativeNormalGrowth iPositiveGrowth = iPositiveNormalGrowth if iPlayer in []: #counterbalance their stagnation due to the very early start iNegativeGrowth = iNegativeSlowerGrowth iPositiveGrowth = iPositiveSlowerGrowth if iPlayer in []: #counterbalance their late start iNegativeGrowth = iNegativeFasterGrowth iPositiveGrowth = iPositiveFasterGrowth if (self.getGNPnew(iPlayer) < self.getGNPold(iPlayer)): self.setStability( iPlayer, self.getStability(iPlayer) + max(-iMaxShrink, iNegativeGrowth)) elif (self.getGNPnew(iPlayer) >= self.getGNPold(iPlayer)): self.setStability( iPlayer, self.getStability(iPlayer) + min(iMaxGrowth, iPositiveGrowth)) self.setParameter( iPlayer, iParEconomyE, True, self.getStability(iPlayer) - iTempEconomyThreshold) iTempEconomyThreshold = iNewBaseStability if (iGameTurn % utils.getTurns(3) == 2): self.setGNPold(iPlayer, self.getGNPnew(iPlayer)) self.setGNPnew(iPlayer, 0) self.setParameter(iPlayer, iParEconomy1, False, iNewBaseStability - iTempEconomyThreshold) iTempCivicThreshold = iNewBaseStability self.setParameter(iPlayer, iParCivics1, False, iNewBaseStability - iTempCivicThreshold) iTempExpansionThreshold = iNewBaseStability iNumPlayerCities = pPlayer.getNumCities() iNumCitiesThreshold = 7 + pPlayer.getCurrentEra() # edead if iNumPlayerCities >= iNumCitiesThreshold: iNewBaseStability -= (iNumPlayerCities - iNumCitiesThreshold + 3) * (iNumPlayerCities - iNumCitiesThreshold + 3) / 9 self.setParameter(iPlayer, iParExpansion1, False, iNewBaseStability - iTempExpansionThreshold) if (self.getCombatResultTempModifier(iPlayer) != 0): iTempExpansionThreshold = iNewBaseStability iNewBaseStability += max( -20, min(20, self.getCombatResultTempModifier(iPlayer))) self.setParameter(iPlayer, iParExpansion1, True, iNewBaseStability - iTempExpansionThreshold) if (self.getCombatResultTempModifier(iPlayer) <= -4 - (iEraModifier / 2)): #great loss self.setStability(iPlayer, self.getStability(iPlayer) - 1) self.setParameter(iPlayer, iParDiplomacyE, True, -1) if (abs(self.getCombatResultTempModifier(iPlayer)) >= 4): self.setCombatResultTempModifier( iPlayer, self.getCombatResultTempModifier(iPlayer) / 2) else: self.setCombatResultTempModifier(iPlayer, 0) if (pPlayer.getAnarchyTurns() != 0): iTempCivicsThreshold = self.getStability(iPlayer) if (self.getStability(iPlayer) > 24): #print("Stability: anarchy permanent", self.getStability(iPlayer) - self.getStability(iPlayer)/8, iPlayer) self.setStability(iPlayer, self.getStability(iPlayer) - self.getStability(iPlayer) / 8 / utils.getTurns(1)) # edead: penalty scaling else: #print("Stability: anarchy permanent", 3, iPlayer) self.setStability( iPlayer, self.getStability(iPlayer) - 3 / utils.getTurns(1)) # edead: penalty scaling self.setParameter( iPlayer, iParCivicsE, True, self.getStability(iPlayer) - iTempCivicsThreshold) iNewBaseStability -= (self.getStability(iPlayer) + 30) / 2 self.setParameter(iPlayer, iParCivics1, True, -(self.getStability(iPlayer) + 30) / 2) #print("iNewBaseStability anarchy",iNewBaseStability, iPlayer) if (pPlayer.isGoldenAge()): iNewBaseStability += 20 #print("iNewBaseStability golden",iNewBaseStability, iPlayer) self.setParameter(iPlayer, iParEconomy1, True, 20) sd.setStability( iPlayer, self.getStability(iPlayer) - self.getBaseStabilityLastTurn(iPlayer) + iNewBaseStability) # if (self.getStability(iPlayer) < -80): # self.setStability(iPlayer, -80) # if (self.getStability(iPlayer) > 80): # self.setStability(iPlayer, 80) self.setBaseStabilityLastTurn(iPlayer, iNewBaseStability)
def checkTurn(self, iGameTurn): #moved here with its own stored value to save loading time (scrolls the map only once instead of every player) if ( iGameTurn % utils.getTurns(6) == 0 ): #3 is too short to detect any change; must be a multiple of 3 anyway map = CyMap() lOwnedPlots = [] lOwnedCities = [] for j in range(iNumPlayers): lOwnedPlots.append(0) lOwnedCities.append(0) for i in range(map.numPlots()): plot = map.plotByIndex(i) iOwner = plot.getOwner() iRegionID = plot.getRegionID() if iOwner >= 0 and iOwner < iNumPlayers and ( plot.isHills() or plot.isFlatlands()): if not iRegionID in utils.getCoreRegions( iOwner ) and not iRegionID in utils.getNormalRegions( iOwner ) and not iRegionID in utils.getBroaderRegions(iOwner): lOwnedPlots[iOwner] += 1 if plot.isCity(): cityOwner = plot.getPlotCity().getOwner() for iLoopPlayer in range(iNumPlayers): if (iLoopPlayer != cityOwner and gc.getPlayer(iLoopPlayer).isAlive() and iGameTurn >= getTurnForYear(tBirth[iLoopPlayer]) + utils.getTurns(30) and iGameTurn >= self.getLatestRebellionTurn(iLoopPlayer) + utils.getTurns(15)): if iRegionID in utils.getCoreRegions( iLoopPlayer ) and not iRegionID in utils.getCoreRegions( iOwner): # allows overlapping - edead lOwnedCities[iLoopPlayer] += 1 for iLoopPlayer in range(iNumPlayers): self.setOwnedPlotsLastTurn(iLoopPlayer, lOwnedPlots[iLoopPlayer]) self.setOwnedCitiesLastTurn(iLoopPlayer, lOwnedCities[iLoopPlayer]) #for up/down arrows if (iGameTurn % 3 == 0 and gc.getActivePlayer().getNumCities() > 0): #numcities required to test autoplay with minor civs self.setLastRecordedStabilityStuff( 0, self.getStability(utils.getHumanID())) self.setLastRecordedStabilityStuff(1, utils.getParCities()) self.setLastRecordedStabilityStuff(2, utils.getParCivics()) self.setLastRecordedStabilityStuff(3, utils.getParEconomy()) self.setLastRecordedStabilityStuff(4, utils.getParExpansion()) self.setLastRecordedStabilityStuff(5, utils.getParDiplomacy()) for iPlayer in range(iNumPlayers): iTempNormalizationThreshold = self.getStability(iPlayer) iStability = iTempNormalizationThreshold if iGameTurn % utils.getTurns(10) == 7: if iStability < -40: if iGameTurn < getTurnForYear(tFall[iPlayer]) or ( sd.getCivStatus(iPlayer) == 1 and iGameTurn < getTurnForYear(tFallRespawned[iPlayer])): self.setStability(iPlayer, iStability + 1) elif iGameTurn % utils.getTurns(10) == 8: if not gc.getPlayer(iPlayer).isGoldenAge(): if iStability > 80: self.setStability(iPlayer, iStability - 2) elif iStability > 40: self.setStability(iPlayer, iStability - 1) iStability = self.getStability(iPlayer) if iGameTurn % utils.getTurns(12) == 7: if iGameTurn >= getTurnForYear(1500) and iStability < 40: if iGameTurn < getTurnForYear(tFall[iPlayer]) or ( sd.getCivStatus(iPlayer) == 1 and iGameTurn < getTurnForYear(tFallRespawned[iPlayer])): self.setStability(iPlayer, iStability + 1) iStability = self.getStability(iPlayer) if iGameTurn % utils.getTurns(20) == 6: if iGameTurn >= getTurnForYear( 1250) and iGameTurn < getTurnForYear( 1500) and iStability < 20: if iGameTurn < getTurnForYear(tFall[iPlayer]) or ( sd.getCivStatus(iPlayer) == 1 and iGameTurn < getTurnForYear(tFallRespawned[iPlayer])): self.setStability(iPlayer, iStability + 1) elif iGameTurn % utils.getTurns(20) == 11: iPermanentModifier = iStability - self.getBaseStabilityLastTurn( iPlayer) if iPermanentModifier > 15: self.setStability(iPlayer, iStability - 1) if iPermanentModifier < -40: self.setStability(iPlayer, iStability + 1) elif iGameTurn % utils.getTurns(20) == 17: if iPlayer != utils.getHumanID(): if iGameTurn > getTurnForYear(tFall[iPlayer]) or ( sd.getCivStatus(iPlayer) == 1 and iGameTurn < getTurnForYear(tFallRespawned[iPlayer])): self.setStability(iPlayer, iStability - 1) if iGameTurn > getTurnForYear(tFall[iPlayer] + 100) or ( sd.getCivStatus(iPlayer) == 1 and iGameTurn < getTurnForYear(tFallRespawned[iPlayer]) + 100): self.setStability(iPlayer, iStability - 1) #print("stability wave", self.getStability(iPlayer) - iTempNormalizationThreshold) self.setParameter( iPlayer, iParDiplomacyE, True, self.getStability(iPlayer) - iTempNormalizationThreshold)
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