Code
76void CvAdvisorCounsel::BuildCounselList(PlayerTypes ePlayer)77{78 Reset();7980 TeamTypes eTeam = GET_PLAYER(ePlayer).getTeam();81 uint uiCounselIndex = 0;82 Localization::String strLoc;8384 if(GET_PLAYER(ePlayer).getNumCities() == 0)85 {86 bool bSuccess;87 strLoc = Localization::Lookup("TXT_KEY_BUILD_A_CITY_MCFLY_ECONOMIC");88 bSuccess = SetCounselEntry(uiCounselIndex, ADVISOR_ECONOMIC, strLoc.toUTF8(), 99);89 CvAssertMsg(bSuccess, "Unable to add counsel to list. Too many strategies running at once");90 uiCounselIndex++;9192 strLoc = Localization::Lookup("TXT_KEY_BUILD_A_CITY_MCFLY_MILITARY");93 bSuccess = SetCounselEntry(uiCounselIndex, ADVISOR_MILITARY, strLoc.toUTF8(), 99);94 CvAssertMsg(bSuccess, "Unable to add counsel to list. Too many strategies running at once");95 uiCounselIndex++;9697 strLoc = Localization::Lookup("TXT_KEY_BUILD_A_CITY_MCFLY_SCIENCE");98 bSuccess = SetCounselEntry(uiCounselIndex, ADVISOR_SCIENCE, strLoc.toUTF8(), 99);99 CvAssertMsg(bSuccess, "Unable to add counsel to list. Too many strategies running at once");100 uiCounselIndex++;101102 strLoc = Localization::Lookup("TXT_KEY_BUILD_A_CITY_MCFLY_FOREIGN");103 bSuccess = SetCounselEntry(uiCounselIndex, ADVISOR_FOREIGN, strLoc.toUTF8(), 99);104 CvAssertMsg(bSuccess, "Unable to add counsel to list. Too many strategies running at once");105 uiCounselIndex++;106107 std::sort(&m_aCounsel[0], &m_aCounsel[0] + m_aCounsel.size(), CounselSort);108 return;109 }110111 // go through economic strategies112 CvEconomicAI* pEconomicAI = GET_PLAYER(ePlayer).GetEconomicAI();113114 for(int iStrategiesLoop = 0; iStrategiesLoop < pEconomicAI->GetEconomicAIStrategies()->GetNumEconomicAIStrategies(); iStrategiesLoop++)115 {116 EconomicAIStrategyTypes eStrategy = (EconomicAIStrategyTypes) iStrategiesLoop;117 CvEconomicAIStrategyXMLEntry* pStrategy = pEconomicAI->GetEconomicAIStrategies()->GetEntry(iStrategiesLoop);118119 if(pEconomicAI->IsUsingStrategy(eStrategy))120 {121 // if this strategy has an advisor set, then try to add it to the list122 if(pStrategy->GetAdvisor() != NO_ADVISOR_TYPE)123 {124 strLoc = Localization::Lookup(pStrategy->GetAdvisorCounselText());125 bool bSuccess = SetCounselEntry(uiCounselIndex, pStrategy->GetAdvisor(), strLoc.toUTF8(), pStrategy->GetAdvisorCounselImportance());126 CvAssertMsg(bSuccess, "Unable to add counsel to list. Too many strategies running at once");127 if(!bSuccess)128 {129 break;130 }131 uiCounselIndex++;132 }133 }134 }135136 // go through military strategies137 CvMilitaryAI* pMilitaryAI = GET_PLAYER(ePlayer).GetMilitaryAI();138139 for(int iStrategiesLoop = 0; iStrategiesLoop < pMilitaryAI->GetMilitaryAIStrategies()->GetNumMilitaryAIStrategies(); iStrategiesLoop++)140 {141 MilitaryAIStrategyTypes eStrategy = (MilitaryAIStrategyTypes) iStrategiesLoop;142143 if(pMilitaryAI->IsUsingStrategy(eStrategy))144 {145 CvMilitaryAIStrategyXMLEntry* pStrategy = pMilitaryAI->GetMilitaryAIStrategies()->GetEntry(iStrategiesLoop);146 CvAssert(pStrategy != NULL);147 if(pStrategy)148 {149 // if this strategy has an advisor set, then try to add it to the list150 if(pStrategy->GetAdvisor() != NO_ADVISOR_TYPE)151 {152 strLoc = Localization::Lookup(pStrategy->GetAdvisorCounselText());153 bool bSuccess = SetCounselEntry(uiCounselIndex, pStrategy->GetAdvisor(), strLoc.toUTF8(), pStrategy->GetAdvisorCounselImportance());154 CvAssertMsg(bSuccess, "Unable to add counsel to list. Too many strategies running at once");155 if(!bSuccess)156 {157 break;158 }159 uiCounselIndex++;160 }161 }162 }163 }164165 // go through city strategies166 int iLoop;167 CvCity* pLoopCity;168 CvCityStrategyAI* pCityStrategyAI;169 for(pLoopCity = GET_PLAYER(ePlayer).firstCity(&iLoop); pLoopCity != NULL; pLoopCity = GET_PLAYER(ePlayer).nextCity(&iLoop))170 {171 pCityStrategyAI = pLoopCity->GetCityStrategyAI();172 for(int i = 0; i < pCityStrategyAI->GetAICityStrategies()->GetNumAICityStrategies(); i++)173 {174 AICityStrategyTypes eStrategy = (AICityStrategyTypes)i;175 CvAICityStrategyEntry* pStrategy = pCityStrategyAI->GetAICityStrategies()->GetEntry(i);176 if(pCityStrategyAI->IsUsingCityStrategy(eStrategy))177 {178 // if this strategy has an advisor set, then try to add it to the list179 if(pStrategy->GetAdvisor() != NO_ADVISOR_TYPE)180 {181 strLoc = Localization::Lookup(pStrategy->GetAdvisorCounselText());182 strLoc << pLoopCity->getNameKey();183 bool bSuccess = SetCounselEntry(uiCounselIndex, pStrategy->GetAdvisor(), strLoc.toUTF8(), pStrategy->GetAdvisorCounselImportance());184 CvAssertMsg(bSuccess, "Unable to add counsel to list. Too many strategies running at once");185 if(!bSuccess)186 {187 break;188 }189 uiCounselIndex++;190 }191 }192 }193 }194195 // find flavor science196 FlavorTypes eFlavorScience = NO_FLAVOR;197 for(int iFlavorLoop = 0; iFlavorLoop < GC.getNumFlavorTypes(); iFlavorLoop++)198 {199 if(GC.getFlavorTypes((FlavorTypes)iFlavorLoop) == "FLAVOR_SCIENCE")200 {201 eFlavorScience = (FlavorTypes)iFlavorLoop;202 break;203 }204 }205206 // cycle through all the science advisor tips207 // along with military recommendations208 TechTypes eMilitaryUnitTech = NO_TECH;209 UnitTypes eRecommendedUnit = NO_UNIT;210 int iMaxCombatValue = 0;211 TechTypes eMilitaryBuildingTech = NO_TECH;212 BuildingTypes eRecommendedBuilding = NO_BUILDING;213 CvPlayerTechs* pPlayerTechs = GET_PLAYER(ePlayer).GetPlayerTechs();214 for(int iTechLoop = 0; iTechLoop < pPlayerTechs->GetTechs()->GetNumTechs(); iTechLoop++)215 {216 TechTypes eTech = (TechTypes)iTechLoop;217 if(pPlayerTechs->CanResearch(eTech) && pPlayerTechs->GetCurrentResearch() != eTech)218 {219 // go through recommended research for special units220 if(pPlayerTechs->GetCivTechPriority(eTech) > 1)221 {222 bool bUniquenessFound = false;223 if(pPlayerTechs->GetCivTechUniqueUnit(eTech) != NO_UNIT)224 {225 strLoc = Localization::Lookup("TXT_KEY_TECHSTRATEGY_CIV_BONUS_UNIT");226 strLoc << pPlayerTechs->GetTechs()->GetEntry(eTech)->GetTextKey();227 strLoc << GC.getUnitInfo(pPlayerTechs->GetCivTechUniqueUnit(eTech))->GetTextKey();228 strLoc << GET_PLAYER(ePlayer).getCivilizationInfo().getAdjectiveKey();229230 bool bSuccess = SetCounselEntry(uiCounselIndex, ADVISOR_SCIENCE, strLoc.toUTF8(), 2);231 CvAssertMsg(bSuccess, "Unable to add counsel to list. Too many strategies running at once");232 if(!bSuccess)233 {234 break;235 }236 uiCounselIndex++;237 bUniquenessFound = true;238 }239240 if(pPlayerTechs->GetCivTechUniqueBuilding(eTech) != NO_BUILDING)241 {242 strLoc = Localization::Lookup("TXT_KEY_TECHSTRATEGY_CIV_BONUS_BUILDING");243 strLoc << pPlayerTechs->GetTechs()->GetEntry(eTech)->GetTextKey();244 strLoc << GC.getBuildingInfo(pPlayerTechs->GetCivTechUniqueBuilding(eTech))->GetTextKey();245 strLoc << GET_PLAYER(ePlayer).getCivilizationInfo().getAdjectiveKey();246 bool bSuccess = SetCounselEntry(uiCounselIndex, ADVISOR_SCIENCE, strLoc.toUTF8(), 2);247 CvAssertMsg(bSuccess, "Unable to add counsel to list. Too many strategies running at once");248 if(!bSuccess)249 {250 break;251 }252 uiCounselIndex++;253 bUniquenessFound = true;254 }255256 if(pPlayerTechs->GetCivTechUniqueImprovement(eTech) != NO_IMPROVEMENT)257 {258 strLoc = Localization::Lookup("TXT_KEY_TECHSTRATEGY_CIV_BONUS_IMPROVEMENT");259 strLoc << pPlayerTechs->GetTechs()->GetEntry(eTech)->GetTextKey();260 strLoc << GC.getImprovementInfo(pPlayerTechs->GetCivTechUniqueImprovement(eTech))->GetTextKey();261 strLoc << GET_PLAYER(ePlayer).getCivilizationInfo().getAdjectiveKey();262 bool bSuccess = SetCounselEntry(uiCounselIndex, ADVISOR_SCIENCE, strLoc.toUTF8(), 2);263 CvAssertMsg(bSuccess, "Unable to add counsel to list. Too many strategies running at once");264 if(!bSuccess)265 {266 break;267 }268 uiCounselIndex++;269 bUniquenessFound = true;270 }271272 if(!bUniquenessFound)273 {274 // we don't have text for this275 strLoc = Localization::Lookup("TXT_KEY_TECHSTRATEGY_CIV_BONUS");276 strLoc << pPlayerTechs->GetTechs()->GetEntry(eTech)->GetTextKey();277 strLoc << GET_PLAYER(ePlayer).getCivilizationInfo().getAdjectiveKey();278 bool bSuccess = SetCounselEntry(uiCounselIndex, ADVISOR_SCIENCE, strLoc.toUTF8(), 2);279 CvAssertMsg(bSuccess, "Unable to add counsel to list. Too many strategies running at once");280 if(!bSuccess)281 {282 break;283 }284 uiCounselIndex++;285 }286 }287288 // go through recommended research for resources289 if(pPlayerTechs->GetLocaleTechPriority(eTech) > 1)290 {291 // say we need this for a special resource292 strLoc = Localization::Lookup("TXT_KEY_TECHSTRATEGY_RESOURCE");293 strLoc << pPlayerTechs->GetTechs()->GetEntry(eTech)->GetTextKey();294 strLoc << GC.getResourceInfo(pPlayerTechs->GetLocaleTechResource(eTech))->GetTextKey();295 bool bSuccess = SetCounselEntry(uiCounselIndex, ADVISOR_SCIENCE, strLoc.toUTF8(), 60);296 CvAssertMsg(bSuccess, "Unable to add counsel to list. Too many strategies running at once");297 if(!bSuccess)298 {299 break;300 }301 uiCounselIndex++;302 }303304 // look at available buildings305 int iNumBuildingInfos = GC.getNumBuildingInfos();306 BuildingTypes eBuilding1 = NO_BUILDING;307 BuildingTypes eBuilding2 = NO_BUILDING;308 BuildingTypes eBuilding3 = NO_BUILDING;309 for(int iI = 0; iI < iNumBuildingInfos; iI++)310 {311 BuildingTypes eBuilding = (BuildingTypes)iI;312 CvBuildingEntry* pBuilding = GC.getBuildingInfo(eBuilding);313 if(pBuilding && pBuilding->GetPrereqAndTech() == eTech && pBuilding->GetFlavorValue(eFlavorScience) > 0 && !GC.getGame().isBuildingClassMaxedOut((BuildingClassTypes)pBuilding->GetBuildingClassType()))314 {315 if(eBuilding1 == NO_BUILDING)316 {317 eBuilding1 = eBuilding;318 }319 else if(eBuilding2 == NO_BUILDING)320 {321 eBuilding2 = eBuilding;322 }323 else if(eBuilding3 == NO_BUILDING)324 {325 eBuilding3 = eBuilding;326 }327 }328 }329330 if(eBuilding1 != NO_BUILDING)331 {332 if(eBuilding2 != NO_BUILDING)333 {334 if(eBuilding3 != NO_BUILDING)335 {336 strLoc = Localization::Lookup("TXT_KEY_SCIENCESTRATEGY_TECH_THAT_PROVIDES_SCIENCE_BUILDING_3");337 strLoc << pPlayerTechs->GetTechs()->GetEntry(eTech)->GetTextKey();338 strLoc << GC.getBuildingInfo(eBuilding1)->GetTextKey();339 strLoc << GC.getBuildingInfo(eBuilding2)->GetTextKey();340 strLoc << GC.getBuildingInfo(eBuilding3)->GetTextKey();341 }342 else343 {344 strLoc = Localization::Lookup("TXT_KEY_SCIENCESTRATEGY_TECH_THAT_PROVIDES_SCIENCE_BUILDING_2");345 strLoc << pPlayerTechs->GetTechs()->GetEntry(eTech)->GetTextKey();346 strLoc << GC.getBuildingInfo(eBuilding1)->GetTextKey();347 strLoc << GC.getBuildingInfo(eBuilding2)->GetTextKey();348 }349 }350 else351 {352 strLoc = Localization::Lookup("TXT_KEY_SCIENCESTRATEGY_TECH_THAT_PROVIDES_SCIENCE_BUILDING_1");353 strLoc << pPlayerTechs->GetTechs()->GetEntry(eTech)->GetTextKey();354 strLoc << GC.getBuildingInfo(eBuilding1)->GetTextKey();355 }356357 bool bSuccess = SetCounselEntry(uiCounselIndex, ADVISOR_SCIENCE, strLoc.toUTF8(), 15);358 CvAssertMsg(bSuccess, "Unable to add counsel to list. Too many strategies running at once");359 if(!bSuccess)360 {361 break;362 }363 uiCounselIndex++;364 }365366 for(int i = 0; i < GC.getNumUnitInfos(); i++)367 {368 UnitTypes eUnitType = (UnitTypes)i;369 CvUnitEntry* pUnitEntry = GC.getUnitInfo(eUnitType);370 if(pUnitEntry)371 {372 if(pUnitEntry->GetPrereqAndTech() == eTech && pUnitEntry->GetUnitCombatType() != NO_UNITCOMBAT)373 {374 UnitTypes eCivUnit = ((UnitTypes)(GET_PLAYER(ePlayer).getCivilizationInfo().getCivilizationUnits(pUnitEntry->GetUnitClassType())));375 if(eUnitType != eCivUnit)376 {377 continue;378 }379380 int iCombatValue = MAX(pUnitEntry->GetCombat(), pUnitEntry->GetRangedCombat());381 if(iCombatValue <= iMaxCombatValue)382 {383 continue;384 }385386 eMilitaryUnitTech = eTech;387 eRecommendedUnit = eUnitType;388 iMaxCombatValue = iCombatValue;389 }390 }391 }392393 for(int i = 0; i < GC.getNumBuildingInfos(); i++)394 {395 BuildingTypes eBuildingType = (BuildingTypes)i;396 CvBuildingEntry* pBuildingEntry = GC.getBuildingInfo(eBuildingType);397 if(!pBuildingEntry || pBuildingEntry->GetPrereqAndTech() != eTech)398 {399 continue;400 }401402 bool bProvidesExperience = false;403 for(int iDomain = 0; iDomain < NUM_DOMAIN_TYPES; iDomain++)404 {405 if(pBuildingEntry->GetDomainFreeExperience(iDomain) > 0)406 {407 bProvidesExperience = true;408 }409 }410411 if(!bProvidesExperience)412 {413 continue;414 }415416 eMilitaryBuildingTech = eTech;417 eRecommendedBuilding = eBuildingType;418 }419 }420 }421422 if(eRecommendedUnit != NO_UNIT)423 {424 CvUnitEntry* pkUnitInfo = GC.getUnitInfo(eRecommendedUnit);425 if(pkUnitInfo)426 {427 strLoc = Localization::Lookup("TXT_KEY_SCIENCESTRATEGY_RESEARCH_MILITARY_UNITS");428 strLoc << pPlayerTechs->GetTechs()->GetEntry(eMilitaryUnitTech)->GetTextKey();429 strLoc << pkUnitInfo->GetTextKey();430431 bool bSuccess = SetCounselEntry(uiCounselIndex, ADVISOR_MILITARY, strLoc.toUTF8(), 15);432 DEBUG_VARIABLE(bSuccess);433 CvAssertMsg(bSuccess, "Unable to add counsel to list. Too many strategies running at once");434 uiCounselIndex++;435 }436 }437438 if(eRecommendedBuilding != NO_BUILDING)439 {440 CvBuildingEntry* pkBuildingInfo = GC.getBuildingInfo(eRecommendedBuilding);441 if(pkBuildingInfo)442 {443 strLoc = Localization::Lookup("TXT_KEY_SCIENCESTRATEGY_RESEARCH_MILITARY_BUILDING");444 strLoc << pPlayerTechs->GetTechs()->GetEntry(eMilitaryBuildingTech)->GetTextKey();445 strLoc << pkBuildingInfo->GetTextKey();446447 bool bSuccess = SetCounselEntry(uiCounselIndex, ADVISOR_MILITARY, strLoc.toUTF8(), 15);448 DEBUG_VARIABLE(bSuccess);449 CvAssertMsg(bSuccess, "Unable to add counsel to list. Too many strategies running at once");450 uiCounselIndex++;451 }452 }453454 // evaluate the player's science yield according to population455 {456 int iRating = 1;457 int iScience = GET_PLAYER(ePlayer).GetScience();458 int iPopulation = GET_PLAYER(ePlayer).getTotalPopulation();459 int iRatio = 0;460 if(iPopulation > 0)461 {462 iRatio = (iScience * 100) / iPopulation;463 }464465 CvTreasury* pTreasury = GET_PLAYER(ePlayer).GetTreasury();466467 int iGold = pTreasury->GetGold();468 int iRevenue = GET_PLAYER(ePlayer).calculateGoldRate();469470 if((iGold + iRevenue) > 0)471 {472 if(iRatio < 110)473 {474 strLoc = Localization::Lookup("TXT_KEY_SCIENCESTRATEGY_INFO_DOING_POORLY");475 strLoc << iScience;476 strLoc << iPopulation;477 iRating = 10;478 }479 else if(iRatio > 125)480 {481 strLoc = Localization::Lookup("TXT_KEY_SCIENCESTRATEGY_INFO_DOING_WELL");482 strLoc << iScience;483 strLoc << iPopulation;484 iRating = 5;485 }486 else487 {488 strLoc = Localization::Lookup("TXT_KEY_SCIENCESTRATEGY_INFO");489 strLoc << iScience;490 strLoc << iPopulation;491 iRating = 1;492 }493 }494 else495 {496 strLoc = Localization::Lookup("TXT_KEY_SCIENCESTRATEGY_BANKRUPT");497 iRating = 99;498 }499500 bool bSuccess = SetCounselEntry(uiCounselIndex, ADVISOR_SCIENCE, strLoc.toUTF8(), iRating);501 DEBUG_VARIABLE(bSuccess);502 CvAssertMsg(bSuccess, "Unable to add counsel to list. Too many strategies running at once");503 uiCounselIndex++;504 }505506507508 // diplomacy info509 // go through all the other major civs and build info on them510 // for each opposing major511 CvDiplomacyAI* pDiplomacyAI = GET_PLAYER(ePlayer).GetDiplomacyAI();512 for(int iPlayer = 0; iPlayer < MAX_MAJOR_CIVS; iPlayer++)513 {514 if(GC.getGame().isOption(GAMEOPTION_ALWAYS_WAR) || GC.getGame().isOption(GAMEOPTION_ALWAYS_PEACE))515 {516 continue;517 }518519 // reset the ratings per player520 int iMessageRating = 0;521 AdvisorTypes eAdvisor = NO_ADVISOR_TYPE;522523 PlayerTypes eOtherPlayer = (PlayerTypes)iPlayer;524 TeamTypes eOtherTeam = GET_PLAYER(eOtherPlayer).getTeam();525526 // don't evaluate yourself527 if(eOtherPlayer == ePlayer)528 {529 continue;530 }531532 // don't evaluate teammates533 if(eOtherTeam == eTeam)534 {535 continue;536 }537538 // don't evaluate dead people539 if(!GET_PLAYER(eOtherPlayer).isAlive())540 {541 continue;542 }543544 // don't evaluate players we haven't met545 if(!GET_TEAM(eTeam).isHasMet(eOtherTeam))546 {547 continue;548 }549550 WarProjectionTypes eWarProjection = pDiplomacyAI->GetWarProjection(eOtherPlayer);551 StrengthTypes eMilitaryStrengthComparedToUs = pDiplomacyAI->GetPlayerMilitaryStrengthComparedToUs(eOtherPlayer);552553 if(GET_TEAM(eTeam).isAtWar(eOtherTeam))554 {555 switch(eWarProjection)556 {557 case WAR_PROJECTION_DESTRUCTION:558 {559 //if (GET_TEAM(eTeam).isAtWar(eOtherTeam))560 //{561 int iRating = 99;562 // warn player to back out!563 if(iRating > iMessageRating)564 {565 iMessageRating = iRating;566 eAdvisor = ADVISOR_MILITARY;567 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_WARPROJECTION_DESTRUCTION_WAR");568 strLoc << GET_PLAYER(eOtherPlayer).getCivilizationInfo().GetTextKey();569 }570 //}571 //else572 //{573 // int iRating = 50;574 // // warn player to avoid575 // if (iRating > iMessageRating)576 // {577 // iMessageRating = iRating;578 // eAdvisor = ADVISOR_FOREIGN;579 // strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_WARPROJECTION_DESTRUCTION_PEACE");580 // strLoc << GC.getCivilizationInfo(GET_PLAYER(eOtherPlayer).getCivilizationType())->GetTextKey();581 // }582 //}583 }584 break;585 case WAR_PROJECTION_DEFEAT:586 {587 //if (GET_TEAM(eTeam).isAtWar(eOtherTeam))588 //{589590 // warn player to back out!591 int iRating = 98;592 if(iRating > iMessageRating)593 {594 iMessageRating = iRating;595 eAdvisor = ADVISOR_MILITARY;596 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_WARPROJECTION_DEFEAT_WAR");597 strLoc << GET_PLAYER(eOtherPlayer).getCivilizationInfo().GetTextKey();598 }599600 //}601 //else602 //{603 // // warn player to avoid604 // int iRating = 49;605 // if (iRating > iMessageRating)606 // {607 // iMessageRating = iRating;608 // eAdvisor = ADVISOR_MILITARY;609 // strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_WARPROJECTION_DEFEAT_PEACE");610 // strLoc << GC.getCivilizationInfo(GET_PLAYER(eOtherPlayer).getCivilizationType())->GetTextKey();611 // }612 //}613 }614 break;615 case WAR_PROJECTION_UNKNOWN:616 case WAR_PROJECTION_STALEMATE:617 {618 //if (GET_TEAM(eTeam).isAtWar(eOtherTeam))619 //{620621 // even fight622 int iRating = 97;623 if(iRating > iMessageRating)624 {625 iMessageRating = iRating;626 eAdvisor = ADVISOR_MILITARY;627 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_WARPROJECTION_STALEMATE_WAR");628 strLoc << GET_PLAYER(eOtherPlayer).getCivilizationInfo().GetTextKey();629 }630631 //}632 //else633 //{634 // // no warning for other states635 //}636 }637 break;638 case WAR_PROJECTION_GOOD:639 {640 //if (GET_TEAM(eTeam).isAtWar(eOtherTeam))641 //{642643 // things are going well!644 int iRating = 96;645 if(iRating > iMessageRating)646 {647 iMessageRating = iRating;648 eAdvisor = ADVISOR_MILITARY;649 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_WARPROJECTION_GOOD_WAR");650 strLoc << GET_PLAYER(eOtherPlayer).getCivilizationInfo().GetTextKey();651 }652653 //}654 //else655 //{656 // // we could rough them up657 // int iRating = 48;658 // if (iRating > iMessageRating)659 // {660 // iMessageRating = iRating;661 // eAdvisor = ADVISOR_FOREIGN;662 // strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_WARPROJECTION_GOOD_PEACE");663 // strLoc << GC.getCivilizationInfo(GET_PLAYER(eOtherPlayer).getCivilizationType())->GetTextKey();664 // }665 //}666 }667 break;668 case WAR_PROJECTION_VERY_GOOD:669 {670 //if (GET_TEAM(eTeam).isAtWar(eOtherTeam))671 //{672673 // things are going very well!674 int iRating = 97;675 if(iRating > iMessageRating)676 {677 iMessageRating = iRating;678 eAdvisor = ADVISOR_MILITARY;679 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_WARPROJECTION_VERY_GOOD_WAR");680 strLoc << GET_PLAYER(eOtherPlayer).getCivilizationInfo().GetTextKey();681 }682683 //}684 //else685 //{686 // // we could take these guys687 // int iRating = 97;688 // if (iRating > iMessageRating)689 // {690 // iMessageRating = iRating;691 // eAdvisor = ADVISOR_FOREIGN;692 // strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_WARPROJECTION_VERY_GOOD_PEACE");693 // strLoc << GC.getCivilizationInfo(GET_PLAYER(eOtherPlayer).getCivilizationType())->GetTextKey();694 // }695 //}696 }697 break;698 }699 }700 else // not at war701 {702 switch(eMilitaryStrengthComparedToUs)703 {704 case STRENGTH_PATHETIC:705 {706 int iRating = 60;707 if(iRating > iMessageRating)708 {709 iMessageRating = iRating;710 eAdvisor = ADVISOR_MILITARY;711 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_MILITARY_STRENGTH_COMPARED_TO_US_PATHETIC");712 strLoc << GET_PLAYER(eOtherPlayer).getCivilizationInfo().GetTextKey();713 }714 }715 break;716 case STRENGTH_WEAK:717 {718 int iRating = 50;719 if(iRating > iMessageRating)720 {721 iMessageRating = iRating;722 eAdvisor = ADVISOR_MILITARY;723 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_MILITARY_STRENGTH_COMPARED_TO_US_WEAK");724 strLoc << GET_PLAYER(eOtherPlayer).getCivilizationInfo().GetTextKey();725 }726 }727 break;728 case STRENGTH_POOR:729 {730 int iRating = 45;731 if(iRating > iMessageRating)732 {733 iMessageRating = iRating;734 eAdvisor = ADVISOR_MILITARY;735 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_MILITARY_STRENGTH_COMPARED_TO_US_POOR");736 strLoc << GET_PLAYER(eOtherPlayer).getCivilizationInfo().GetTextKey();737 }738 }739 break;740 case STRENGTH_AVERAGE:741 {742 int iRating = 40;743 if(iRating > iMessageRating)744 {745 iMessageRating = iRating;746 eAdvisor = ADVISOR_MILITARY;747 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_MILITARY_STRENGTH_COMPARED_TO_US_AVERAGE");748 strLoc << GET_PLAYER(eOtherPlayer).getCivilizationInfo().GetTextKey();749 }750 }751 break;752 case STRENGTH_STRONG:753 {754 int iRating = 45;755 if(iRating > iMessageRating)756 {757 iMessageRating = iRating;758 eAdvisor = ADVISOR_MILITARY;759 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_MILITARY_STRENGTH_COMPARED_TO_US_STRONG");760 strLoc << GET_PLAYER(eOtherPlayer).getCivilizationInfo().GetTextKey();761 }762 }763 break;764 case STRENGTH_POWERFUL:765 {766 int iRating = 80;767 if(iRating > iMessageRating)768 {769 iMessageRating = iRating;770 eAdvisor = ADVISOR_MILITARY;771 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_MILITARY_STRENGTH_COMPARED_TO_US_POWERFUL");772 strLoc << GET_PLAYER(eOtherPlayer).getCivilizationInfo().GetTextKey();773 }774 }775 break;776 case STRENGTH_IMMENSE:777 {778 int iRating = 90;779 if(iRating > iMessageRating)780 {781 iMessageRating = iRating;782 eAdvisor = ADVISOR_MILITARY;783 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_MILITARY_STRENGTH_COMPARED_TO_US_IMMENSE");784 strLoc << GET_PLAYER(eOtherPlayer).getCivilizationInfo().GetTextKey();785 }786 }787 break;788 }789 }790791 // look at get military posture792 AggressivePostureTypes eMilitaryAggressivePostureTypes = pDiplomacyAI->GetMilitaryAggressivePosture(eOtherPlayer);793 if(!GET_TEAM(eTeam).isAtWar(eOtherTeam))794 {795 switch(eMilitaryAggressivePostureTypes)796 {797 case AGGRESSIVE_POSTURE_NONE:798 break;799 case AGGRESSIVE_POSTURE_LOW:800 break;801 case AGGRESSIVE_POSTURE_MEDIUM:802 {803 int iRating = 51;804 if(iRating > iMessageRating)805 {806 iMessageRating = iRating;807 eAdvisor = ADVISOR_FOREIGN;808 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_MILITARY_AGGRESSIVE_POSTURE_MEDIUM");809 strLoc << GET_PLAYER(eOtherPlayer).getCivilizationInfo().GetTextKey();810 }811 }812 break;813 case AGGRESSIVE_POSTURE_HIGH:814 {815 int iRating = 75;816 if(iRating > iMessageRating)817 {818 iMessageRating = iRating;819 eAdvisor = ADVISOR_FOREIGN;820 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_MILITARY_AGGRESSIVE_POSTURE_HIGH");821 strLoc << GET_PLAYER(eOtherPlayer).getCivilizationInfo().GetTextKey();822 }823 }824 break;825 case AGGRESSIVE_POSTURE_INCREDIBLE:826 {827 int iRating = 90;828 if(iRating > iMessageRating)829 {830 iMessageRating = iRating;831 eAdvisor = ADVISOR_FOREIGN;832 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_MILITARY_AGGRESSIVE_POSTURE_INCREDIBLE");833 strLoc << GET_PLAYER(eOtherPlayer).getCivilizationInfo().GetTextKey();834 }835 }836 break;837 }838 }839840 // look at expansion aggressive posture841 AggressivePostureTypes eExpansionAggressivePostureTypes = pDiplomacyAI->GetExpansionAggressivePosture(eOtherPlayer);842 if(!GET_TEAM(eTeam).isAtWar(eOtherTeam))843 {844 switch(eExpansionAggressivePostureTypes)845 {846 case AGGRESSIVE_POSTURE_NONE:847 break;848 case AGGRESSIVE_POSTURE_LOW:849 break;850 case AGGRESSIVE_POSTURE_MEDIUM:851 {852 int iRating = 41;853 if(iRating > iMessageRating)854 {855 iMessageRating = iRating;856 eAdvisor = ADVISOR_FOREIGN;857 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_EXPANSION_AGGRESSIVE_POSTURE_MEDIUM");858 strLoc << GET_PLAYER(eOtherPlayer).getCivilizationInfo().GetTextKey();859 }860 }861 break;862 case AGGRESSIVE_POSTURE_HIGH:863 {864 int iRating = 65;865 if(iRating > iMessageRating)866 {867 iMessageRating = iRating;868 eAdvisor = ADVISOR_FOREIGN;869 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_EXPANSION_AGGRESSIVE_POSTURE_HIGH");870 strLoc << GET_PLAYER(eOtherPlayer).getCivilizationInfo().GetTextKey();871 }872 }873 break;874 case AGGRESSIVE_POSTURE_INCREDIBLE:875 {876 int iRating = 80;877 if(iRating > iMessageRating)878 {879 iMessageRating = iRating;880 eAdvisor = ADVISOR_FOREIGN;881 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_EXPANSION_AGGRESSIVE_POSTURE_INCREDIBLE");882 strLoc << GET_PLAYER(eOtherPlayer).getCivilizationInfo().GetTextKey();883 }884 }885 break;886 }887 }888889 ThreatTypes eWarmongerThreat = pDiplomacyAI->GetWarmongerThreat(eOtherPlayer);890 if(!GET_TEAM(eTeam).isAtWar(eOtherTeam))891 {892 switch(eWarmongerThreat)893 {894 case THREAT_NONE:895 {896 int iRating = 20;897 if(iRating > iMessageRating)898 {899 iMessageRating = iRating;900 eAdvisor = ADVISOR_FOREIGN;901 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_WARMONGER_THREAT_NONE");902 strLoc << GET_PLAYER(eOtherPlayer).getCivilizationInfo().GetTextKey();903 }904 }905 break;906 case THREAT_MINOR:907 {908 int iRating = 25;909 if(iRating > iMessageRating)910 {911 iMessageRating = iRating;912 eAdvisor = ADVISOR_FOREIGN;913 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_WARMONGER_THREAT_MINOR");914 strLoc << GET_PLAYER(eOtherPlayer).getCivilizationInfo().GetTextKey();915 }916 }917918 break;919 case THREAT_MAJOR:920 {921 int iRating = 30;922 if(iRating > iMessageRating)923 {924 iMessageRating = iRating;925 eAdvisor = ADVISOR_FOREIGN;926 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_WARMONGER_THREAT_MAJOR");927 strLoc << GET_PLAYER(eOtherPlayer).getCivilizationInfo().GetTextKey();928 }929 }930 break;931 case THREAT_SEVERE:932 {933 int iRating = 60;934 if(iRating > iMessageRating)935 {936 iMessageRating = iRating;937 eAdvisor = ADVISOR_FOREIGN;938 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_WARMONGER_THREAT_SEVERE");939 strLoc << GET_PLAYER(eOtherPlayer).getCivilizationInfo().GetTextKey();940 }941 }942 break;943 case THREAT_CRITICAL:944 {945 int iRating = 80;946 if(iRating > iMessageRating)947 {948 iMessageRating = iRating;949 eAdvisor = ADVISOR_FOREIGN;950 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_WARMONGER_THREAT_CRITICAL");951 strLoc << GET_PLAYER(eOtherPlayer).getCivilizationInfo().GetTextKey();952 }953 }954 break;955 }956 }957958 if(eAdvisor != NO_ADVISOR_TYPE)959 {960 bool bSuccess = SetCounselEntry(uiCounselIndex, eAdvisor, strLoc.toUTF8(), iMessageRating);961 CvAssertMsg(bSuccess, "Unable to add counsel to list. Too many strategies running at once");962 if(!bSuccess)963 {964 break;965 }966 uiCounselIndex++;967 }968 }969970 // go through diplomatic list for competitions with other civs with minor civs971 for(int iPlayer = 0; iPlayer < MAX_MAJOR_CIVS; iPlayer++)972 {973 // reset the ratings per player974 int iMessageRating = 0;975 AdvisorTypes eAdvisor = NO_ADVISOR_TYPE;976977 PlayerTypes eOtherPlayer = (PlayerTypes)iPlayer;978 TeamTypes eOtherTeam = GET_PLAYER(eOtherPlayer).getTeam();979980 // don't evaluate yourself981 if(eOtherPlayer == ePlayer)982 {983 continue;984 }985986 // don't evaluate teammates987 if(eOtherTeam == eTeam)988 {989 continue;990 }991992 // don't evaluate dead people993 if(!GET_PLAYER(eOtherPlayer).isAlive())994 {995 continue;996 }997998 // don't evaluate players we haven't met999 if(!GET_TEAM(eTeam).isHasMet(eOtherTeam))1000 {1001 continue;1002 }10031004 if(GET_TEAM(eTeam).isAtWar(eOtherTeam))1005 {1006 continue;1007 }10081009 DisputeLevelTypes eMinorCivDisputeLevel = pDiplomacyAI->GetMinorCivDisputeLevel(eOtherPlayer);1010 switch(eMinorCivDisputeLevel)1011 {10121013 case DISPUTE_LEVEL_NONE:1014 break;10151016 case DISPUTE_LEVEL_WEAK:1017 {1018 iMessageRating = 20;10191020 DiploStatementTypes eStatement;1021 int iMinorCiv = NO_PLAYER;1022 pDiplomacyAI->DoMinorCivCompetitionStatement(eOtherPlayer, eStatement, iMinorCiv, true);10231024 if(iMinorCiv != NO_PLAYER)1025 {1026 eAdvisor = ADVISOR_FOREIGN;1027 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_MINOR_CIV_DISPUTE_LEVEL_WEAK");10281029 strLoc << GET_PLAYER(eOtherPlayer).getCivilizationInfo().GetTextKey();10301031 CvMinorCivInfo* pkMinorCivInfo = GC.getMinorCivInfo(GET_PLAYER((PlayerTypes)iMinorCiv).GetMinorCivAI()->GetMinorCivType());1032 if(pkMinorCivInfo != NULL)1033 strLoc << pkMinorCivInfo->GetTextKey();1034 }1035 }1036 break;1037 case DISPUTE_LEVEL_STRONG:1038 {1039 iMessageRating = 30;1040 DiploStatementTypes eStatement;1041 int iMinorCiv = NO_PLAYER;1042 pDiplomacyAI->DoMinorCivCompetitionStatement(eOtherPlayer, eStatement, iMinorCiv, true);10431044 if(iMinorCiv != NO_PLAYER)1045 {1046 eAdvisor = ADVISOR_FOREIGN;1047 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_MINOR_CIV_DISPUTE_LEVEL_STRONG");10481049 strLoc << GET_PLAYER(eOtherPlayer).getCivilizationInfo().GetTextKey();10501051 CvMinorCivInfo* pkMinorCivInfo = GC.getMinorCivInfo(GET_PLAYER((PlayerTypes)iMinorCiv).GetMinorCivAI()->GetMinorCivType());1052 if(pkMinorCivInfo != NULL)1053 strLoc << pkMinorCivInfo->GetTextKey();1054 }1055 }1056 break;1057 case DISPUTE_LEVEL_FIERCE:1058 {1059 iMessageRating = 40;10601061 DiploStatementTypes eStatement;1062 int iMinorCiv = NO_PLAYER;1063 pDiplomacyAI->DoMinorCivCompetitionStatement(eOtherPlayer, eStatement, iMinorCiv, true);10641065 if(iMinorCiv != NO_PLAYER)1066 {1067 eAdvisor = ADVISOR_FOREIGN;1068 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_MINOR_CIV_DISPUTE_LEVEL_FIERCE");10691070 strLoc << GET_PLAYER(eOtherPlayer).getCivilizationInfo().GetTextKey();10711072 CvMinorCivInfo* pkMinorCivInfo = GC.getMinorCivInfo(GET_PLAYER((PlayerTypes)iMinorCiv).GetMinorCivAI()->GetMinorCivType());1073 if(pkMinorCivInfo != NULL)1074 strLoc << pkMinorCivInfo->GetTextKey();1075 }1076 }1077 break;1078 }10791080 if(eAdvisor != NO_ADVISOR_TYPE)1081 {1082 bool bSuccess = SetCounselEntry(uiCounselIndex, eAdvisor, strLoc.toUTF8(), iMessageRating);1083 CvAssertMsg(bSuccess, "Unable to add counsel to list. Too many strategies running at once");1084 if(!bSuccess)1085 {1086 break;1087 }1088 uiCounselIndex++;1089 }1090 }10911092 // evaluate our gold situation1093 {1094 int iMessageRating = 0;1095 AdvisorTypes eAdvisor = ADVISOR_ECONOMIC;1096 CvTreasury* pTreasury = GET_PLAYER(ePlayer).GetTreasury();10971098 int iGoldIncome = GET_PLAYER(ePlayer).calculateGoldRate();1099 int iGold = pTreasury->GetGold();11001101 int iHighestCost = 0;1102 enum1103 {1104 COST_UNIT_MAINTENANCE,1105 COST_UNIT_SUPPLY,1106 COST_BUILDING_MAINTENANCE,1107 COST_IMPROVEMENT_MAINTENANCE,1108 COST_DIPLOMACY,1109 NUM_COSTS1110 };1111 int uiHighestCostCategory = NUM_COSTS;11121113 for(uint ui = 0; ui < NUM_COSTS; ui++)1114 {1115 switch(ui)1116 {1117 case COST_UNIT_MAINTENANCE:1118 if(pTreasury->GetExpensePerTurnUnitMaintenance() > iHighestCost)1119 {1120 uiHighestCostCategory = ui;1121 iHighestCost = pTreasury->GetExpensePerTurnUnitMaintenance();1122 }1123 break;1124 case COST_UNIT_SUPPLY:1125 if(pTreasury->GetExpensePerTurnUnitSupply() > iHighestCost)1126 {1127 uiHighestCostCategory = ui;1128 iHighestCost = pTreasury->GetExpensePerTurnUnitSupply();1129 }1130 break;1131 case COST_BUILDING_MAINTENANCE:1132 if(pTreasury->GetBuildingGoldMaintenance() > iHighestCost)1133 {1134 uiHighestCostCategory = ui;1135 iHighestCost = pTreasury->GetBuildingGoldMaintenance();1136 }1137 break;1138 case COST_IMPROVEMENT_MAINTENANCE:1139 if(pTreasury->GetImprovementGoldMaintenance() > iHighestCost)1140 {1141 uiHighestCostCategory = ui;1142 iHighestCost = pTreasury->GetBuildingGoldMaintenance();1143 }1144 break;1145 case COST_DIPLOMACY:1146 if(pTreasury->GetGoldPerTurnFromDiplomacy() < -(iHighestCost))1147 {1148 uiHighestCostCategory = ui;1149 iHighestCost = -(pTreasury->GetGoldPerTurnFromDiplomacy());1150 }1151 break;1152 }1153 }115411551156 if(iGold <= 0) // we're bankrupt1157 {1158 if(iGoldIncome <= 0)1159 {1160 // if our income is negative or zero1161 iMessageRating = 99;1162 switch(uiHighestCostCategory)1163 {1164 case COST_UNIT_MAINTENANCE:1165 strLoc = Localization::Lookup("TXT_KEY_FINANCESTRATEGY_BROKE_AND_GOING_DOWN_UNIT_MAINTENANCE");1166 strLoc << iHighestCost;1167 break;1168 case COST_UNIT_SUPPLY:1169 strLoc = Localization::Lookup("TXT_KEY_FINANCESTRATEGY_BROKE_AND_GOING_DOWN_UNIT_SUPPLY");1170 strLoc << iHighestCost;1171 break;1172 case COST_BUILDING_MAINTENANCE:1173 strLoc = Localization::Lookup("TXT_KEY_FINANCESTRATEGY_BROKE_AND_GOING_DOWN_BUILDING_MAINTENANCE");1174 strLoc << iHighestCost;1175 break;1176 case COST_IMPROVEMENT_MAINTENANCE:1177 strLoc = Localization::Lookup("TXT_KEY_FINANCESTRATEGY_BROKE_AND_GOING_DOWN_DIPLOMACY");1178 strLoc << iHighestCost;1179 break;1180 case COST_DIPLOMACY:1181 strLoc = Localization::Lookup("TXT_KEY_FINANCESTRATEGY_BROKE_AND_GOING_DOWN_IMPROVEMENT_MAINTENANCE");1182 strLoc << iHighestCost;1183 break;1184 default:1185 strLoc = Localization::Lookup("TXT_KEY_FINANCESTRATEGY_BROKE_AND_GOING_DOWN");1186 break;1187 }1188 }1189 else1190 {1191 iMessageRating = 95;1192 switch(uiHighestCostCategory)1193 {1194 case COST_UNIT_MAINTENANCE:1195 strLoc = Localization::Lookup("TXT_KEY_FINANCESTRATEGY_BROKE_AND_GOING_UP_UNIT_MAINTENANCE");1196 strLoc << iHighestCost;1197 break;1198 case COST_UNIT_SUPPLY:1199 strLoc = Localization::Lookup("TXT_KEY_FINANCESTRATEGY_BROKE_AND_GOING_UP_UNIT_SUPPLY");1200 strLoc << iHighestCost;1201 break;1202 case COST_BUILDING_MAINTENANCE:1203 strLoc = Localization::Lookup("TXT_KEY_FINANCESTRATEGY_BROKE_AND_GOING_UP_BUILDING_MAINTENANCE");1204 strLoc << iHighestCost;1205 break;1206 case COST_IMPROVEMENT_MAINTENANCE:1207 strLoc = Localization::Lookup("TXT_KEY_FINANCESTRATEGY_BROKE_AND_GOING_UP_IMPROVEMENT_MAINTENANCE");1208 strLoc << iHighestCost;1209 break;1210 case COST_DIPLOMACY:1211 strLoc = Localization::Lookup("TXT_KEY_FINANCESTRATEGY_BROKE_AND_GOING_UP_DIPLOMACY");1212 strLoc << iHighestCost;1213 break;1214 default:1215 strLoc = Localization::Lookup("TXT_KEY_FINANCESTRATEGY_BROKE_AND_GOING_UP");1216 break;1217 }1218 }1219 }1220 else // we're not bankrupt!1221 {1222 if(iGoldIncome <= 0)1223 {1224 // we're going bankrupt1225 if(iGoldIncome < 0 && iGold / abs(iGoldIncome) <= 5)1226 {1227 iMessageRating = 80;1228 switch(uiHighestCostCategory)1229 {1230 case COST_UNIT_MAINTENANCE:1231 strLoc = Localization::Lookup("TXT_KEY_FINANCESTRATEGY_GOING_BROKE_UNIT_MAINTENANCE");1232 strLoc << iHighestCost;1233 break;1234 case COST_UNIT_SUPPLY:1235 strLoc = Localization::Lookup("TXT_KEY_FINANCESTRATEGY_GOING_BROKE_UNIT_SUPPLY");1236 strLoc << iHighestCost;1237 break;1238 case COST_BUILDING_MAINTENANCE:1239 strLoc = Localization::Lookup("TXT_KEY_FINANCESTRATEGY_GOING_BROKE_BUILDING_MAINTENANCE");1240 strLoc << iHighestCost;1241 break;1242 case COST_IMPROVEMENT_MAINTENANCE:1243 strLoc = Localization::Lookup("TXT_KEY_FINANCESTRATEGY_GOING_BROKE_IMPROVEMENT_MAINTENANCE");1244 strLoc << iHighestCost;1245 break;1246 case COST_DIPLOMACY:1247 strLoc = Localization::Lookup("TXT_KEY_FINANCESTRATEGY_GOING_BROKE_DIPLOMACY");1248 strLoc << iHighestCost;1249 break;1250 default:1251 strLoc = Localization::Lookup("TXT_KEY_FINANCESTRATEGY_GOING_BROKE");1252 break;1253 }1254 }1255 else1256 {1257 iMessageRating = 75;1258 switch(uiHighestCostCategory)1259 {1260 case COST_UNIT_MAINTENANCE:1261 strLoc = Localization::Lookup("TXT_KEY_FINANCESTRATEGY_LOSING_MONEY_UNIT_MAINTENANCE");1262 strLoc << iHighestCost;1263 break;1264 case COST_UNIT_SUPPLY:1265 strLoc = Localization::Lookup("TXT_KEY_FINANCESTRATEGY_LOSING_MONEY_UNIT_SUPPLY");1266 strLoc << iHighestCost;1267 break;1268 case COST_BUILDING_MAINTENANCE:1269 strLoc = Localization::Lookup("TXT_KEY_FINANCESTRATEGY_LOSING_MONEY_BUILDING_MAINTENANCE");1270 strLoc << iHighestCost;1271 break;1272 case COST_IMPROVEMENT_MAINTENANCE:1273 strLoc = Localization::Lookup("TXT_KEY_FINANCESTRATEGY_LOSING_MONEY_IMPROVEMENT_MAINTENANCE");1274 strLoc << iHighestCost;1275 break;1276 case COST_DIPLOMACY:1277 strLoc = Localization::Lookup("TXT_KEY_FINANCESTRATEGY_LOSING_MONEY_DIPLOMACY");1278 strLoc << iHighestCost;1279 break;1280 default:1281 strLoc = Localization::Lookup("TXT_KEY_FINANCESTRATEGY_LOSING_MONEY");1282 break;1283 }1284 }1285 }1286 else if(iHighestCost > 0)1287 {1288 iMessageRating = 20;1289 switch(uiHighestCostCategory)1290 {1291 case COST_UNIT_MAINTENANCE:1292 strLoc = Localization::Lookup("TXT_KEY_FINANCESTRATEGY_MAKING_MONEY_UNIT_MAINTENANCE");1293 strLoc << iHighestCost;1294 break;1295 case COST_UNIT_SUPPLY:1296 strLoc = Localization::Lookup("TXT_KEY_FINANCESTRATEGY_MAKING_MONEY_UNIT_SUPPLY");1297 strLoc << iHighestCost;1298 break;1299 case COST_BUILDING_MAINTENANCE:1300 strLoc = Localization::Lookup("TXT_KEY_FINANCESTRATEGY_MAKING_MONEY_BUILDING_MAINTENANCE");1301 strLoc << iHighestCost;1302 break;1303 case COST_IMPROVEMENT_MAINTENANCE:1304 strLoc = Localization::Lookup("TXT_KEY_FINANCESTRATEGY_MAKING_MONEY_IMPROVEMENT_MAINTENANCE");1305 strLoc << iHighestCost;1306 break;1307 case COST_DIPLOMACY:1308 strLoc = Localization::Lookup("TXT_KEY_FINANCESTRATEGY_MAKING_MONEY_DIPLOMACY");1309 strLoc << iHighestCost;1310 break;1311 default:1312 strLoc = Localization::Lookup("TXT_KEY_FINANCESTRATEGY_MAKING_MONEY");1313 break;1314 }13151316 }1317 }13181319 if(iHighestCost > 0)1320 {1321 bool bSuccess = SetCounselEntry(uiCounselIndex, eAdvisor, strLoc.toUTF8(), iMessageRating);1322 DEBUG_VARIABLE(bSuccess);1323 CvAssertMsg(bSuccess, "Unable to add counsel to list. Too many strategies running at once");1324 uiCounselIndex++;1325 }1326 }13271328 // finding minor civs that we are about to lose a friendship/ally status with1329 for(uint ui = MAX_MAJOR_CIVS; ui < MAX_CIV_PLAYERS; ui++)1330 {1331 int iMessageRating = 0;1332 AdvisorTypes eAdvisor = ADVISOR_FOREIGN;1333 //MinorCivQuestTypes eQuest = NO_MINOR_CIV_QUEST_TYPE;1334 PlayerTypes eEnemyPlayer = NO_PLAYER;13351336 PlayerTypes eMinorPlayer = (PlayerTypes)ui;13371338 TeamTypes eMinorTeam = GET_PLAYER(eMinorPlayer).getTeam();13391340 // don't evaluate players we haven't met1341 if(!GET_TEAM(eTeam).isHasMet(eMinorTeam))1342 {1343 continue;1344 }13451346 if(GET_TEAM(eTeam).isAtWar(eMinorTeam))1347 {1348 continue;1349 }13501351 if(!GET_PLAYER(eMinorPlayer).isAlive())1352 {1353 if(!GET_PLAYER(eMinorPlayer).isEverAlive())1354 {1355 continue;1356 }13571358 // see if we ganked their city1359 PlayerTypes eCapturingPlayer = NO_PLAYER;13601361 for(uint ui2 = 0; ui2 < MAX_MAJOR_CIVS; ui2++)1362 {1363 if(eCapturingPlayer != NO_PLAYER)1364 {1365 break;1366 }13671368 PlayerTypes eCheckPlayer = (PlayerTypes)ui2;13691370 int iCityIndex;1371 CvCity* pCapCity;1372 for(pCapCity = GET_PLAYER(eCheckPlayer).firstCity(&iCityIndex); pCapCity != NULL; pCapCity = GET_PLAYER(eCheckPlayer).nextCity(&iCityIndex))1373 {1374 if(pCapCity->getOriginalOwner() == eMinorPlayer)1375 {1376 eCapturingPlayer = pCapCity->getOwner();1377 break;1378 }1379 }1380 }13811382 //antonjs: todo: don't show counsel to liberate if the CS was taken over peacefully with buyout (Austria UA)1383 // don't mention it if we conquered the city-state1384 if(eCapturingPlayer != NO_PLAYER && eCapturingPlayer != ePlayer)1385 {1386 iMessageRating = 10;1387 CvMinorCivAI* pMinorCivAI = GET_PLAYER(eMinorPlayer).GetMinorCivAI();13881389 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_LIBERATE_CITY_STATE");1390 strLoc << GC.getMinorCivInfo(pMinorCivAI->GetMinorCivType())->GetTextKey();1391 strLoc << GET_PLAYER(eCapturingPlayer).getCivilizationInfo().GetTextKey();1392 strLoc << GC.getMinorCivInfo(pMinorCivAI->GetMinorCivType())->GetTextKey();13931394 bool bSuccess = SetCounselEntry(uiCounselIndex, eAdvisor, strLoc.toUTF8(), iMessageRating);1395 CvAssertMsg(bSuccess, "Unable to add counsel to list. Too many strategies running at once");1396 if(!bSuccess)1397 {1398 break;1399 }1400 uiCounselIndex++;1401 }14021403 continue;1404 }14051406 CvMinorCivAI* pMinorCivAI = GET_PLAYER(eMinorPlayer).GetMinorCivAI();140714081409 if(pMinorCivAI->IsAllies(ePlayer) && pMinorCivAI->IsCloseToNotBeingAllies(ePlayer))1410 {1411 // warn the player they are about to not be an ally with a minor civ1412 iMessageRating = 80;1413 if(eEnemyPlayer != NO_PLAYER)1414 {1415 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_ALMOST_LOST_CITY_STATE_ALLY_WAR_WITH_MAJOR");1416 strLoc << GC.getMinorCivInfo(pMinorCivAI->GetMinorCivType())->GetTextKey();1417 strLoc << GET_PLAYER(eEnemyPlayer).getCivilizationInfo().GetTextKey();1418 }1419 /*1420 else if (eQuest != NO_MINOR_CIV_QUEST_TYPE)1421 {1422 int iQuestData = pMinorCivAI->GetQuestData1(ePlayer, eQuest);14231424 switch (eQuest)1425 {1426 case MINOR_CIV_QUEST_ROUTE:1427 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_ALMOST_LOST_CITY_STATE_ALLY_QUEST_ROUTE");1428 strLoc << GC.getMinorCivInfo(pMinorCivAI->GetMinorCivType())->GetTextKey();1429 break;1430 case MINOR_CIV_QUEST_KILL_CAMP:1431 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_ALMOST_LOST_CITY_STATE_ALLY_QUEST_KILL_CAMP");1432 strLoc << GC.getMinorCivInfo(pMinorCivAI->GetMinorCivType())->GetTextKey();1433 break;1434 case MINOR_CIV_QUEST_CONNECT_RESOURCE:1435 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_ALMOST_LOST_CITY_STATE_ALLY_QUEST_CONNECT_RESOURCE");1436 strLoc << GC.getMinorCivInfo(pMinorCivAI->GetMinorCivType())->GetTextKey();1437 strLoc << GC.getResourceInfo((ResourceTypes)iQuestData)->GetTextKey();1438 break;1439 case MINOR_CIV_QUEST_CONSTRUCT_WONDER:1440 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_ALMOST_LOST_CITY_STATE_ALLY_QUEST_CONSTRUCT_WONDER");1441 strLoc << GC.getMinorCivInfo(pMinorCivAI->GetMinorCivType())->GetTextKey();1442 strLoc << GC.getBuildingInfo((BuildingTypes)iQuestData)->GetDescription();1443 break;1444 case MINOR_CIV_QUEST_GREAT_PERSON:1445 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_ALMOST_LOST_CITY_STATE_ALLY_QUEST_GREAT_PERSON");1446 strLoc << GC.getMinorCivInfo(pMinorCivAI->GetMinorCivType())->GetTextKey();1447 strLoc << GC.getUnitInfo((UnitTypes)iQuestData)->GetDescription();1448 break;1449 case MINOR_CIV_QUEST_KILL_CITY_STATE:1450 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_ALMOST_LOST_CITY_STATE_ALLY_QUEST_KILL_CITY_STATE");1451 strLoc << GC.getMinorCivInfo(pMinorCivAI->GetMinorCivType())->GetTextKey();1452 strLoc << GC.getMinorCivInfo(GET_PLAYER((PlayerTypes)iQuestData).GetMinorCivAI()->GetMinorCivType())->GetTextKey();1453 break;1454 case MINOR_CIV_QUEST_FIND_PLAYER:1455 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_ALMOST_LOST_CITY_STATE_ALLY_QUEST_FIND_PLAYER");1456 strLoc << GC.getMinorCivInfo(pMinorCivAI->GetMinorCivType())->GetTextKey();1457 strLoc << GET_PLAYER((PlayerTypes)iQuestData).getCivilizationInfo().GetTextKey();1458 break;1459 case MINOR_CIV_QUEST_FIND_NATURAL_WONDER:1460 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_ALMOST_LOST_CITY_STATE_ALLY_QUEST_FIND_NATURAL_WONDER");1461 strLoc << GC.getMinorCivInfo(pMinorCivAI->GetMinorCivType())->GetTextKey();1462 break;1463 default:1464 CvAssertMsg(false, "No entry for this quest type!");1465 break;1466 }1467 }1468 else if (pMinorCivAI->GetTurnsSinceThreatenedByBarbarians() >= 0)1469 {1470 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_ALMOST_LOST_CITY_STATE_ALLY_QUEST_CLEAR_BARBARIANS");1471 strLoc << GC.getMinorCivInfo(pMinorCivAI->GetMinorCivType())->GetTextKey();1472 }1473 */1474 else1475 {1476 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_ALMOST_LOST_CITY_STATE_ALLY");1477 strLoc << GC.getMinorCivInfo(pMinorCivAI->GetMinorCivType())->GetTextKey();1478 }1479 }1480 else if(pMinorCivAI->IsFriends(ePlayer) && pMinorCivAI->IsCloseToNotBeingFriends(ePlayer))1481 {1482 // warn the player they are about to not be an friend with a minor civ1483 iMessageRating = 60;1484 if(eEnemyPlayer != NO_PLAYER)1485 {1486 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_ALMOST_LOST_CITY_STATE_FRIENDSHIP_WAR_WITH_MAJOR");1487 strLoc << GC.getMinorCivInfo(pMinorCivAI->GetMinorCivType())->GetTextKey();1488 strLoc << GET_PLAYER(eEnemyPlayer).getCivilizationInfo().GetTextKey();1489 }1490 /*1491 else if (eQuest != NO_MINOR_CIV_QUEST_TYPE)1492 {1493 int iQuestData = pMinorCivAI->GetQuestData1(ePlayer, eQuest);14941495 switch (eQuest)1496 {1497 case MINOR_CIV_QUEST_ROUTE:1498 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_ALMOST_LOST_CITY_STATE_FRIENDSHIP_QUEST_ROUTE");1499 strLoc << GC.getMinorCivInfo(pMinorCivAI->GetMinorCivType())->GetTextKey();1500 break;1501 case MINOR_CIV_QUEST_KILL_CAMP:1502 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_ALMOST_LOST_CITY_STATE_FRIENDSHIP_QUEST_KILL_CAMP");1503 strLoc << GC.getMinorCivInfo(pMinorCivAI->GetMinorCivType())->GetTextKey();1504 break;1505 case MINOR_CIV_QUEST_CONNECT_RESOURCE:1506 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_ALMOST_LOST_CITY_STATE_FRIENDSHIP_QUEST_CONNECT_RESOURCE");1507 strLoc << GC.getMinorCivInfo(pMinorCivAI->GetMinorCivType())->GetTextKey();1508 strLoc << GC.getResourceInfo((ResourceTypes)iQuestData)->GetTextKey();1509 break;1510 case MINOR_CIV_QUEST_CONSTRUCT_WONDER:1511 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_ALMOST_LOST_CITY_STATE_FRIENDSHIP_QUEST_CONSTRUCT_WONDER");1512 strLoc << GC.getMinorCivInfo(pMinorCivAI->GetMinorCivType())->GetTextKey();1513 strLoc << GC.getBuildingInfo((BuildingTypes)iQuestData)->GetDescription();1514 break;1515 case MINOR_CIV_QUEST_GREAT_PERSON:1516 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_ALMOST_LOST_CITY_STATE_FRIENDSHIP_QUEST_GREAT_PERSON");1517 strLoc << GC.getMinorCivInfo(pMinorCivAI->GetMinorCivType())->GetTextKey();1518 strLoc << GC.getUnitInfo((UnitTypes)iQuestData)->GetDescription();1519 break;1520 case MINOR_CIV_QUEST_KILL_CITY_STATE:1521 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_ALMOST_LOST_CITY_STATE_FRIENDSHIP_QUEST_KILL_CITY_STATE");1522 strLoc << GC.getMinorCivInfo(pMinorCivAI->GetMinorCivType())->GetTextKey();1523 strLoc << GC.getMinorCivInfo(GET_PLAYER((PlayerTypes)iQuestData).GetMinorCivAI()->GetMinorCivType())->GetTextKey();1524 break;1525 case MINOR_CIV_QUEST_FIND_PLAYER:1526 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_ALMOST_LOST_CITY_STATE_FRIENDSHIP_QUEST_FIND_PLAYER");1527 strLoc << GC.getMinorCivInfo(pMinorCivAI->GetMinorCivType())->GetTextKey();1528 strLoc << GET_PLAYER((PlayerTypes)iQuestData).getCivilizationInfo().GetTextKey();1529 break;1530 case MINOR_CIV_QUEST_FIND_NATURAL_WONDER:1531 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_ALMOST_LOST_CITY_STATE_FRIENDSHIP_QUEST_FIND_NATURAL_WONDER");1532 strLoc << GC.getMinorCivInfo(pMinorCivAI->GetMinorCivType())->GetTextKey();1533 break;1534 default:1535 CvAssertMsg(false, "No entry for this quest type!");1536 break;1537 }1538 }1539 else if (pMinorCivAI->GetTurnsSinceThreatenedByBarbarians() >= 0)1540 {1541 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_ALMOST_LOST_CITY_STATE_FRIENDSHIP_QUEST_CLEAR_BARBARIANS");1542 strLoc << GC.getMinorCivInfo(pMinorCivAI->GetMinorCivType())->GetTextKey();1543 }1544 */1545 else1546 {1547 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_ALMOST_LOST_CITY_STATE_FRIENDSHIP");1548 strLoc << GC.getMinorCivInfo(pMinorCivAI->GetMinorCivType())->GetTextKey();1549 }1550 }1551 else1552 {1553 iMessageRating = 20;1554 if(eEnemyPlayer != NO_PLAYER)1555 {1556 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_BEFRIEND_CITY_STATE_WAR_WITH_MAJOR");1557 strLoc << GC.getMinorCivInfo(pMinorCivAI->GetMinorCivType())->GetTextKey();1558 strLoc << GET_PLAYER(eEnemyPlayer).getCivilizationInfo().GetTextKey();1559 }1560 /*1561 else if (eQuest != NO_MINOR_CIV_QUEST_TYPE)1562 {1563 int iQuestData = pMinorCivAI->GetQuestData1(ePlayer, eQuest);15641565 switch (eQuest)1566 {1567 case MINOR_CIV_QUEST_ROUTE:1568 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_BEFRIEND_CITY_STATE_QUEST_ROUTE");1569 strLoc << GC.getMinorCivInfo(pMinorCivAI->GetMinorCivType())->GetTextKey();1570 break;1571 case MINOR_CIV_QUEST_KILL_CAMP:1572 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_BEFRIEND_CITY_STATE_QUEST_KILL_CAMP");1573 strLoc << GC.getMinorCivInfo(pMinorCivAI->GetMinorCivType())->GetTextKey();1574 break;1575 case MINOR_CIV_QUEST_CONNECT_RESOURCE:1576 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_BEFRIEND_CITY_STATE_QUEST_CONNECT_RESOURCE");1577 strLoc << GC.getMinorCivInfo(pMinorCivAI->GetMinorCivType())->GetTextKey();1578 strLoc << GC.getResourceInfo((ResourceTypes)iQuestData)->GetTextKey();1579 break;1580 case MINOR_CIV_QUEST_CONSTRUCT_WONDER:1581 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_BEFRIEND_CITY_STATE_QUEST_CONSTRUCT_WONDER");1582 strLoc << GC.getMinorCivInfo(pMinorCivAI->GetMinorCivType())->GetTextKey();1583 strLoc << GC.getBuildingInfo((BuildingTypes)iQuestData)->GetDescription();1584 break;1585 case MINOR_CIV_QUEST_GREAT_PERSON:1586 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_BEFRIEND_CITY_STATE_QUEST_GREAT_PERSON");1587 strLoc << GC.getMinorCivInfo(pMinorCivAI->GetMinorCivType())->GetTextKey();1588 strLoc << GC.getUnitInfo((UnitTypes)iQuestData)->GetDescription();1589 break;1590 case MINOR_CIV_QUEST_KILL_CITY_STATE:1591 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_BEFRIEND_CITY_STATE_QUEST_KILL_CITY_STATE");1592 strLoc << GC.getMinorCivInfo(pMinorCivAI->GetMinorCivType())->GetTextKey();1593 strLoc << GC.getMinorCivInfo(GET_PLAYER((PlayerTypes)iQuestData).GetMinorCivAI()->GetMinorCivType())->GetTextKey();1594 break;1595 case MINOR_CIV_QUEST_FIND_PLAYER:1596 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_BEFRIEND_CITY_STATE_QUEST_FIND_PLAYER");1597 strLoc << GC.getMinorCivInfo(pMinorCivAI->GetMinorCivType())->GetTextKey();1598 strLoc << GET_PLAYER((PlayerTypes)iQuestData).getCivilizationInfo().GetTextKey();1599 break;1600 case MINOR_CIV_QUEST_FIND_NATURAL_WONDER:1601 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_BEFRIEND_CITY_STATE_QUEST_FIND_NATURAL_WONDER");1602 strLoc << GC.getMinorCivInfo(pMinorCivAI->GetMinorCivType())->GetTextKey();1603 break;1604 default:1605 CvAssertMsg(false, "No entry for this quest type!");1606 break;1607 }1608 }1609 else if (pMinorCivAI->GetTurnsSinceThreatenedByBarbarians() >= 0)1610 {1611 strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_BEFRIEND_CITY_STATE_QUEST_CLEAR_BARBARIANS");1612 strLoc << GC.getMinorCivInfo(pMinorCivAI->GetMinorCivType())->GetTextKey();1613 }1614 */1615 else1616 {1617 iMessageRating = 0;1618 }1619 //else1620 //{1621 // strLoc = Localization::Lookup("TXT_KEY_DIPLOSTRATEGY_BEFRIEND_CITY_STATE");1622 // strLoc << GC.getMinorCivInfo(pMinorCivAI->GetMinorCivType())->GetTextKey();1623 //}1624 }16251626 if(iMessageRating > 0)1627 {1628 bool bSuccess = SetCounselEntry(uiCounselIndex, eAdvisor, strLoc.toUTF8(), iMessageRating);1629 CvAssertMsg(bSuccess, "Unable to add counsel to list. Too many strategies running at once");1630 if(!bSuccess)1631 {1632 break;1633 }1634 uiCounselIndex++;1635 }1636 }16371638 // find the biggest city1639 CvCity* pBiggestCity = NULL;1640 int iMaxPopulation = 0;1641 for(pLoopCity = GET_PLAYER(ePlayer).firstCity(&iLoop); pLoopCity != NULL; pLoopCity = GET_PLAYER(ePlayer).nextCity(&iLoop))1642 {1643 if(pLoopCity->getPopulation() > iMaxPopulation)1644 {1645 pBiggestCity = pLoopCity;1646 iMaxPopulation = pBiggestCity->getPopulation();1647 }1648 }16491650 if(pBiggestCity)1651 {1652 CvString strBuildingClass;1653 for(uint uiLoop = 0; uiLoop < 4; uiLoop++)1654 {1655 // for every science improvement building1656 switch(uiLoop)1657 {1658 case 0:1659 strBuildingClass = "BUILDINGCLASS_LIBRARY";1660 break;1661 case 1:1662 strBuildingClass = "BUILDINGCLASS_UNIVERSITY";1663 break;1664 case 2:1665 strBuildingClass = "BUILDINGCLASS_PUBLIC_SCHOOL";1666 break;1667 case 3:1668 strBuildingClass = "BUILDINGCLASS_LABORATORY";1669 break;1670 }16711672 BuildingClassTypes eScienceBuildingClass = NO_BUILDINGCLASS;1673 for(int i = 0; i < GC.getNumBuildingClassInfos(); i++)1674 {1675 BuildingClassTypes eBuildingClass = (BuildingClassTypes)i;16761677 CvBuildingClassInfo* pkBuildingClassInfo = GC.getBuildingClassInfo(eBuildingClass);1678 if(!pkBuildingClassInfo)1679 {1680 continue;1681 }16821683 if(GC.getBuildingClassInfo(eBuildingClass)->GetType() == strBuildingClass)1684 {1685 eScienceBuildingClass = eBuildingClass;1686 break;1687 }1688 }16891690 if(eScienceBuildingClass == NO_BUILDINGCLASS)1691 {1692 continue;1693 }16941695 BuildingTypes eRecommendedResearchBuilding = NO_BUILDING;1696 for(int i = 0; i < GC.getNumBuildingInfos(); i++)1697 {1698 BuildingTypes eBuildingType = (BuildingTypes)i;1699 CvBuildingEntry* pkEntry = GC.getBuildingInfo(eBuildingType);1700 if(!pkEntry || pkEntry->GetBuildingClassType() != eScienceBuildingClass)1701 {1702 continue;1703 }17041705 if(pBiggestCity->canConstruct(eBuildingType))1706 {1707 eRecommendedResearchBuilding = eBuildingType;1708 break;1709 }1710 }17111712 if(eRecommendedResearchBuilding != NO_BUILDING)1713 {17141715 strLoc = Localization::Lookup("TXT_KEY_SCIENCESTRATEGY_RESEARCH_BUILDING_IN_BIG_CITY");1716 strLoc << pBiggestCity->getNameKey();1717 strLoc << GC.getBuildingInfo(eRecommendedResearchBuilding)->GetTextKey();1718 strLoc << GC.getBuildingInfo(eRecommendedResearchBuilding)->GetTextKey();17191720 bool bSuccess = SetCounselEntry(uiCounselIndex, ADVISOR_SCIENCE, strLoc.toUTF8(), 20);1721 CvAssertMsg(bSuccess, "Unable to add counsel to list. Too many strategies running at once");1722 if(!bSuccess)1723 {1724 break;1725 }1726 uiCounselIndex++;17271728 break;1729 }1730 }1731 }17321733 CvPlotsVector& aiPlots = GET_PLAYER(ePlayer).GetPlots();1734 ResourceTypes eRecommendedResource = NO_RESOURCE;1735 CvPlot* pResourcePlot = NULL;1736 int iNumOfResource = MAX_INT;1737 for(uint ui = 0; ui < aiPlots.size(); ui++)1738 {1739 CvPlot* pPlot = NULL;1740 // when we encounter the first plot that is invalid, the rest of the list will be invalid1741 if(aiPlots[ui] == -1)1742 {1743 break;1744 }17451746 pPlot = GC.getMap().plotByIndex(aiPlots[ui]);1747 if(!pPlot)1748 {1749 continue;1750 }17511752 ResourceTypes eResource = pPlot->getResourceType(GET_PLAYER(ePlayer).getTeam());1753 if(eResource == NO_RESOURCE)1754 {1755 continue;1756 }17571758 if(GC.getResourceInfo(eResource)->getResourceUsage() == RESOURCEUSAGE_LUXURY || GC.getResourceInfo(eResource)->getResourceUsage() == RESOURCEUSAGE_STRATEGIC)1759 {1760 // if we don't have any of this resource1761 if(GET_PLAYER(ePlayer).getNumResourceTotal(eResource) < iNumOfResource)1762 {1763 for(int iBuild = 0; iBuild < GC.getNumBuildInfos(); iBuild++)1764 {1765 BuildTypes eBuild = (BuildTypes)iBuild;1766 CvBuildInfo* pkBuild = GC.getBuildInfo(eBuild);1767 if(pkBuild == NULL)1768 {1769 continue;1770 }17711772 ImprovementTypes eImprovement = (ImprovementTypes)pkBuild->getImprovement();1773 if(eImprovement == NO_IMPROVEMENT)1774 {1775 continue;1776 }17771778 if(!GC.getImprovementInfo(eImprovement)->IsImprovementResourceTrade(eResource))1779 {1780 continue;1781 }17821783 if(GET_PLAYER(ePlayer).canBuild(pPlot, eBuild))1784 {1785 // ensure there is a city working this tile1786 if(pPlot->getWorkingCity())1787 {1788 // check for a worker in this plot1789 bool bWorkerAlreadyOnIt = false;1790 IDInfo* pPlotUnitNode = pPlot->headUnitNode();17911792 while(pPlotUnitNode != NULL)1793 {1794 CvUnit* pLoopUnit = ::getUnit(*pPlotUnitNode);1795 pPlotUnitNode = pPlot->nextUnitNode(pPlotUnitNode);17961797 if(pLoopUnit->getOwner() != ePlayer)1798 {1799 continue;1800 }18011802 // walk through missions1803 int iNumMissions = pLoopUnit->GetLengthMissionQueue();1804 for(int i = 0; i < iNumMissions; i++)1805 {1806 const MissionData* pMission = pLoopUnit->GetMissionData(i);1807 if(pMission->eMissionType == CvTypes::getMISSION_BUILD() && pMission->iData1 == eBuild)1808 {1809 bWorkerAlreadyOnIt = true;1810 break;1811 }18121813 }18141815 if(bWorkerAlreadyOnIt)1816 {1817 break;1818 }1819 }18201821 if(!bWorkerAlreadyOnIt)1822 {1823 eRecommendedResource = eResource;1824 pResourcePlot = pPlot;1825 iNumOfResource = GET_PLAYER(ePlayer).getNumResourceTotal(eResource);1826 }1827 }1828 }1829 }1830 }1831 }1832 }18331834 if(eRecommendedResource != NO_RESOURCE)1835 {1836 if(iNumOfResource == 0)1837 {1838 strLoc = Localization::Lookup("TXT_KEY_CITYIMPROVEMENTSTRATEGY_PLUG_UP_RESOURCES_HAVE_ZERO");1839 }1840 else1841 {1842 strLoc = Localization::Lookup("TXT_KEY_CITYIMPROVEMENTSTRATEGY_PLUG_UP_RESOURCES_HAVE_MORE");1843 }1844 strLoc << GC.getResourceInfo(eRecommendedResource)->GetTextKey();1845 strLoc << pResourcePlot->getWorkingCity()->getNameKey();18461847 bool bSuccess = SetCounselEntry(uiCounselIndex, ADVISOR_ECONOMIC, strLoc.toUTF8(), 20);1848 DEBUG_VARIABLE(bSuccess);1849 CvAssertMsg(bSuccess, "Unable to add counsel to list. Too many strategies running at once");1850 uiCounselIndex++;1851 }18521853 ResourceTypes eTradableResource = NO_RESOURCE;1854 PlayerTypes eTargetPlayer = NO_PLAYER;1855 TeamTypes ePlayerTeam = GET_PLAYER(ePlayer).getTeam();1856 for(int i = 0; i < GC.getNumResourceInfos(); i++)1857 {1858 ResourceTypes eResource = (ResourceTypes)i;1859 CvResourceInfo* pResourceInfo = GC.getResourceInfo(eResource);1860 if (pResourceInfo == NULL)1861 {1862 continue;1863 }18641865 if(pResourceInfo->getResourceUsage() != RESOURCEUSAGE_LUXURY && pResourceInfo->getResourceUsage() != RESOURCEUSAGE_STRATEGIC)1866 {1867 continue;1868 }18691870 // not enough to trade1871 if(GET_PLAYER(ePlayer).getNumResourceAvailable(eResource, false) <= 1)1872 {1873 continue;1874 }18751876 for(int j = 0; j < MAX_MAJOR_CIVS; j++)1877 {1878 PlayerTypes eOtherPlayer = (PlayerTypes)j;1879 TeamTypes eOtherTeam = GET_PLAYER(eOtherPlayer).getTeam();1880 if(ePlayerTeam == eOtherTeam || !GET_PLAYER(eOtherPlayer).isAlive())1881 {1882 continue;1883 }18841885 // if we haven't met or are at war1886 if(!GET_TEAM(ePlayerTeam).isHasMet(eOtherTeam) || GET_TEAM(ePlayerTeam).isAtWar(eOtherTeam))1887 {1888 continue;1889 }18901891 // other player already has some1892 if(GET_PLAYER(eOtherPlayer).getNumResourceAvailable(eResource, true) != 0)1893 {1894 continue;1895 }18961897 for(int k = 0; k < GC.getNumResourceInfos(); k++)1898 {1899 ResourceTypes eTradebackResource = (ResourceTypes)k;1900 const CvResourceInfo* pkTradeResourceInfo = GC.getResourceInfo(eTradebackResource);1901 if(pkTradeResourceInfo == NULL || (pkTradeResourceInfo->getResourceUsage() != RESOURCEUSAGE_LUXURY && pkTradeResourceInfo->getResourceUsage() != RESOURCEUSAGE_STRATEGIC))1902 {1903 continue;1904 }19051906 // other player has some to trade1907 if(GET_PLAYER(eOtherPlayer).getNumResourceAvailable(eTradebackResource, false) == 0)1908 {1909 continue;1910 }19111912 if(GET_PLAYER(ePlayer).getNumResourceAvailable(eTradebackResource, true) > 0)1913 {1914 continue;1915 }19161917 if(eTradableResource != NO_RESOURCE)1918 {1919 ResourceUsageTypes eTradableResourceUsage = GC.getResourceInfo(eTradableResource)->getResourceUsage();1920 ResourceUsageTypes eResourceUsage = GC.getResourceInfo(eResource)->getResourceUsage();19211922 // prefer trading luxury to strategic1923 if(eTradableResourceUsage == RESOURCEUSAGE_STRATEGIC && eResourceUsage == RESOURCEUSAGE_LUXURY)1924 {1925 eTradableResource = eResource;1926 eTargetPlayer = eOtherPlayer;1927 }1928 }1929 else1930 {1931 eTradableResource = eResource;1932 eTargetPlayer = eOtherPlayer;1933 }1934 }1935 }1936 }19371938 if(eTradableResource != NO_RESOURCE)1939 {1940 ResourceUsageTypes eResourceUsage = GC.getResourceInfo(eTradableResource)->getResourceUsage();1941 if(eResourceUsage == RESOURCEUSAGE_LUXURY)1942 {1943 strLoc = Localization::Lookup("TXT_KEY_RESOURCESTRATEGY_TRADE_LUXURIES");1944 }1945 else if(eResourceUsage == RESOURCEUSAGE_STRATEGIC)1946 {1947 strLoc = Localization::Lookup("TXT_KEY_RESOURCESTRATEGY_TRADE_STRATEGIC");1948 }1949 else1950 {1951 CvAssertMsg(false, "Can't trade a bonus resource");1952 }19531954 strLoc << GC.getResourceInfo(eTradableResource)->GetTextKey();1955 strLoc << GET_PLAYER(eTargetPlayer).getCivilizationInfo().GetTextKey();19561957 bool bSuccess = SetCounselEntry(uiCounselIndex, ADVISOR_FOREIGN, strLoc.toUTF8(), 20);1958 DEBUG_VARIABLE(bSuccess);1959 CvAssertMsg(bSuccess, "Unable to add counsel to list. Too many strategies running at once");1960 uiCounselIndex++;1961 }19621963 // search for each advisor type. If there isn't an entry of that type, add the default string1964 bool abAdvisorUsed[NUM_ADVISOR_TYPES];1965 for(uint ui = 0; ui < NUM_ADVISOR_TYPES; ui++)1966 {1967 abAdvisorUsed[ui] = false;1968 }19691970 for(uint ui = 0; ui < m_aCounsel.size(); ui++)1971 {1972 if(m_aCounsel[ui].m_eAdvisor == NO_ADVISOR_TYPE || m_aCounsel[ui].m_eAdvisor == NUM_ADVISOR_TYPES)1973 {1974 continue;1975 }1976 abAdvisorUsed[m_aCounsel[ui].m_eAdvisor] = true;1977 }19781979 for(uint ui = 0; ui < NUM_ADVISOR_TYPES; ui++)1980 {1981 if(!abAdvisorUsed[ui])1982 {1983 AdvisorTypes eAdvisorTypes = (AdvisorTypes)ui;1984 switch(eAdvisorTypes)1985 {1986 case ADVISOR_SCIENCE:1987 strLoc = Localization::Lookup("TXT_KEY_BASESTRATEGY_NOTHING_TO_SAY_SCIENCE");1988 break;1989 case ADVISOR_ECONOMIC:1990 strLoc = Localization::Lookup("TXT_KEY_BASESTRATEGY_NOTHING_TO_SAY_ECONOMIC");1991 break;1992 case ADVISOR_MILITARY:1993 strLoc = Localization::Lookup("TXT_KEY_BASESTRATEGY_NOTHING_TO_SAY_MILITARY");1994 break;1995 case ADVISOR_FOREIGN:1996 strLoc = Localization::Lookup("TXT_KEY_BASESTRATEGY_NOTHING_TO_SAY_FOREIGN");1997 break;1998 }19992000 bool bSuccess = SetCounselEntry(uiCounselIndex, eAdvisorTypes, strLoc.toUTF8(), 0);2001 DEBUG_VARIABLE(bSuccess);2002 CvAssertMsg(bSuccess, "Unable to add counsel to list. Too many strategies running at once");2003 uiCounselIndex++;2004 }2005 }20062007 // sort the list2008 std::sort(&m_aCounsel[0], &m_aCounsel[0] + m_aCounsel.size(), CounselSort);2009}