mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-18 03:21:27 +02:00
Update BuildAnalyzer.cpp
Removed the restrictions of the greedy-playstyle. Only count forts as gold-producing prerequisites when no same- or higher-level fort exists somewhere else in the empire.
This commit is contained in:
parent
b7e4219fde
commit
f0ca1c6112
@ -150,16 +150,10 @@ void BuildAnalyzer::update()
|
||||
auto towns = ai->cb->getTownsInfo();
|
||||
|
||||
float economyDevelopmentCost = 0;
|
||||
uint8_t closestThreat = UINT8_MAX;
|
||||
ai->dangerHitMap->updateHitMap();
|
||||
|
||||
for(const CGTownInstance* town : towns)
|
||||
{
|
||||
for (auto threat : ai->dangerHitMap->getTownThreats(town))
|
||||
{
|
||||
closestThreat = std::min(closestThreat, threat.turn);
|
||||
}
|
||||
logAi->trace("Checking town %s closest threat: %u", town->getNameTranslated(), (unsigned int)closestThreat);
|
||||
logAi->trace("Checking town %s", town->getNameTranslated());
|
||||
|
||||
developmentInfos.push_back(TownDevelopmentInfo(town));
|
||||
TownDevelopmentInfo & developmentInfo = developmentInfos.back();
|
||||
@ -182,9 +176,6 @@ void BuildAnalyzer::update()
|
||||
}
|
||||
}
|
||||
|
||||
if (closestThreat < 7)
|
||||
economyDevelopmentCost = 0;
|
||||
|
||||
std::sort(developmentInfos.begin(), developmentInfos.end(), [](const TownDevelopmentInfo & t1, const TownDevelopmentInfo & t2) -> bool
|
||||
{
|
||||
auto val1 = convertToGold(t1.armyCost) - convertToGold(t1.townDevelopmentCost);
|
||||
@ -254,6 +245,12 @@ BuildingInfo BuildAnalyzer::getBuildingOrPrerequisite(
|
||||
logAi->trace("checking %s", info.name);
|
||||
logAi->trace("buildInfo %s", info.toString());
|
||||
|
||||
int highestFort = 0;
|
||||
for (auto twn : ai->cb->getTownsInfo())
|
||||
{
|
||||
highestFort = std::max(highestFort, (int)twn->fortLevel());
|
||||
}
|
||||
|
||||
if(!town->hasBuilt(building))
|
||||
{
|
||||
auto canBuild = ai->cb->canBuildStructure(town, building);
|
||||
@ -298,7 +295,15 @@ BuildingInfo BuildAnalyzer::getBuildingOrPrerequisite(
|
||||
prerequisite.baseCreatureID = info.baseCreatureID;
|
||||
prerequisite.prerequisitesCount++;
|
||||
prerequisite.armyCost = info.armyCost;
|
||||
prerequisite.dailyIncome = info.dailyIncome;
|
||||
bool haveSameOrBetterFort = false;
|
||||
if (prerequisite.id == BuildingID::FORT && highestFort >= CGTownInstance::EFortLevel::FORT)
|
||||
haveSameOrBetterFort = true;
|
||||
if (prerequisite.id == BuildingID::CITADEL && highestFort >= CGTownInstance::EFortLevel::CITADEL)
|
||||
haveSameOrBetterFort = true;
|
||||
if (prerequisite.id == BuildingID::CASTLE && highestFort >= CGTownInstance::EFortLevel::CASTLE)
|
||||
haveSameOrBetterFort = true;
|
||||
if(!haveSameOrBetterFort)
|
||||
prerequisite.dailyIncome = info.dailyIncome;
|
||||
|
||||
return prerequisite;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user