1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-16 10:19:47 +02:00

Army-hiring

Supressing hiring army on turn one seems just bad. Starting the main-hero as strong as possible seems like a good idea to me and hiring the available troops outright will help achieve that goal.

However, if there's a hero for hire, who has army with him that is a better deal, we hire that one first.
This commit is contained in:
Xilmi 2024-07-12 15:41:55 +02:00
parent fdaac9d3c3
commit 663ca23f6f

View File

@ -28,9 +28,6 @@ Goals::TGoalVec BuyArmyBehavior::decompose(const Nullkiller * ai) const
{
Goals::TGoalVec tasks;
if(ai->cb->getDate(Date::DAY) == 1)
return tasks;
auto heroes = cb->getHeroesInfo();
if(heroes.empty())
@ -40,17 +37,28 @@ Goals::TGoalVec BuyArmyBehavior::decompose(const Nullkiller * ai) const
for(auto town : cb->getTownsInfo())
{
//If we can recruit a hero that comes with more army than he costs, we are better off spending our gold on them
if (ai->heroManager->canRecruitHero(town))
{
auto availableHeroes = ai->cb->getAvailableHeroes(town);
for (auto hero : availableHeroes)
{
if (hero->getArmyCost() > GameConstants::HERO_GOLD_COST)
return tasks;
}
}
if (ai->buildAnalyzer->isGoldPressureHigh() && !town->hasBuilt(BuildingID::CITY_HALL))
{
return tasks;
}
auto townArmyAvailableToBuy = ai->armyManager->getArmyAvailableToBuyAsCCreatureSet(
town,
ai->getFreeResources());
for(const CGHeroInstance * targetHero : heroes)
{
if(ai->buildAnalyzer->isGoldPressureHigh() && !town->hasBuilt(BuildingID::CITY_HALL))
{
continue;
}
if(ai->heroManager->getHeroRole(targetHero) == HeroRole::MAIN)
{
auto reinforcement = ai->armyManager->howManyReinforcementsCanGet(