1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-12-01 23:12:49 +02:00

Fix AI to use hillFort all available upgrades. UpgradeInfo refactor.

This commit is contained in:
MichalZr6
2024-11-19 10:49:14 +01:00
parent e8842c2e12
commit d8d3948ac3
16 changed files with 169 additions and 67 deletions

View File

@@ -162,10 +162,10 @@ std::function<void()> CGarrisonSlot::getDismiss() const
/// @return Whether the view should be refreshed
bool CGarrisonSlot::viewInfo()
{
UpgradeInfo pom;
UpgradeInfo pom(ID.getNum());
LOCPLINT->cb->fillUpgradeInfo(getObj(), ID, pom);
bool canUpgrade = getObj()->tempOwner == LOCPLINT->playerID && pom.oldID != CreatureID::NONE; //upgrade is possible
bool canUpgrade = getObj()->tempOwner == LOCPLINT->playerID && pom.canUpgrade(); //upgrade is possible
std::function<void(CreatureID)> upgr = nullptr;
auto dism = getDismiss();
if(canUpgrade) upgr = [=] (CreatureID newID) { LOCPLINT->cb->upgradeCreature(getObj(), ID, newID); };
@@ -177,7 +177,7 @@ bool CGarrisonSlot::viewInfo()
elem->block(true);
redraw();
GH.windows().createAndPushWindow<CStackWindow>(myStack, dism, pom, upgr);
GH.windows().createAndPushWindow<CStackWindow>(myStack, dism, std::move(pom), upgr);
return true;
}