|
@@ -49,26 +49,45 @@ Goals::TGoalVec BuildingBehavior::decompose(const Nullkiller * ai) const
|
|
auto & developmentInfos = ai->buildAnalyzer->getDevelopmentInfo();
|
|
auto & developmentInfos = ai->buildAnalyzer->getDevelopmentInfo();
|
|
auto isGoldPressureLow = !ai->buildAnalyzer->isGoldPressureHigh();
|
|
auto isGoldPressureLow = !ai->buildAnalyzer->isGoldPressureHigh();
|
|
|
|
|
|
|
|
+ ai->dangerHitMap->updateHitMap();
|
|
|
|
+
|
|
for(auto & developmentInfo : developmentInfos)
|
|
for(auto & developmentInfo : developmentInfos)
|
|
{
|
|
{
|
|
- for(auto & buildingInfo : developmentInfo.toBuild)
|
|
|
|
|
|
+ uint8_t closestThreat = UINT8_MAX;
|
|
|
|
+ for (auto threat : ai->dangerHitMap->getTownThreats(developmentInfo.town))
|
|
|
|
+ {
|
|
|
|
+ closestThreat = std::min(closestThreat, threat.turn);
|
|
|
|
+ }
|
|
|
|
+ int fortLevel = developmentInfo.town->fortLevel();
|
|
|
|
+ for (auto& buildingInfo : developmentInfo.toBuild)
|
|
{
|
|
{
|
|
- if(isGoldPressureLow || buildingInfo.dailyIncome[EGameResID::GOLD] > 0)
|
|
|
|
|
|
+ if (closestThreat <= 1 && developmentInfo.town->fortLevel() < BuildingID::CASTLE && !buildingInfo.notEnoughRes)
|
|
{
|
|
{
|
|
- if(buildingInfo.notEnoughRes)
|
|
|
|
|
|
+ if (buildingInfo.id == BuildingID::FORT || buildingInfo.id == BuildingID::CITADEL || buildingInfo.id == BuildingID::CASTLE)
|
|
|
|
+ tasks.push_back(sptr(BuildThis(buildingInfo, developmentInfo)));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (tasks.empty())
|
|
|
|
+ {
|
|
|
|
+ for (auto& buildingInfo : developmentInfo.toBuild)
|
|
|
|
+ {
|
|
|
|
+ if (isGoldPressureLow || buildingInfo.dailyIncome[EGameResID::GOLD] > 0)
|
|
{
|
|
{
|
|
- if(ai->getLockedResources().canAfford(buildingInfo.buildCost))
|
|
|
|
- continue;
|
|
|
|
|
|
+ if (buildingInfo.notEnoughRes)
|
|
|
|
+ {
|
|
|
|
+ if (ai->getLockedResources().canAfford(buildingInfo.buildCost))
|
|
|
|
+ continue;
|
|
|
|
|
|
- Composition composition;
|
|
|
|
|
|
+ Composition composition;
|
|
|
|
|
|
- composition.addNext(BuildThis(buildingInfo, developmentInfo));
|
|
|
|
- composition.addNext(SaveResources(buildingInfo.buildCost));
|
|
|
|
|
|
+ composition.addNext(BuildThis(buildingInfo, developmentInfo));
|
|
|
|
+ composition.addNext(SaveResources(buildingInfo.buildCost));
|
|
|
|
|
|
- tasks.push_back(sptr(composition));
|
|
|
|
|
|
+ tasks.push_back(sptr(composition));
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ tasks.push_back(sptr(BuildThis(buildingInfo, developmentInfo)));
|
|
}
|
|
}
|
|
- else
|
|
|
|
- tasks.push_back(sptr(BuildThis(buildingInfo, developmentInfo)));
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|