2021-05-15 20:36:50 +02:00
|
|
|
/*
|
|
|
|
* BuildingManager.cpp, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "StdInc.h"
|
|
|
|
#include "ArmyManager.h"
|
2020-05-04 17:58:43 +02:00
|
|
|
#include "../Engine/Nullkiller.h"
|
2021-05-16 13:55:57 +02:00
|
|
|
#include "../../../CCallback.h"
|
|
|
|
#include "../../../lib/mapObjects/MapObjects.h"
|
2021-05-15 20:36:50 +02:00
|
|
|
|
2021-05-16 13:39:20 +02:00
|
|
|
class StackUpgradeInfo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CreatureID initialCreature;
|
|
|
|
CreatureID upgradedCreature;
|
|
|
|
TResources cost;
|
|
|
|
int count;
|
|
|
|
uint64_t upgradeValue;
|
|
|
|
|
|
|
|
StackUpgradeInfo(CreatureID initial, CreatureID upgraded, int count)
|
|
|
|
:initialCreature(initial), upgradedCreature(upgraded), count(count)
|
|
|
|
{
|
|
|
|
cost = (upgradedCreature.toCreature()->cost - initialCreature.toCreature()->cost) * count;
|
|
|
|
upgradeValue = (upgradedCreature.toCreature()->AIValue - initialCreature.toCreature()->AIValue) * count;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-05-16 13:56:42 +02:00
|
|
|
uint64_t ArmyManager::howManyReinforcementsCanGet(const CGHeroInstance * hero, const CCreatureSet * source) const
|
|
|
|
{
|
|
|
|
return howManyReinforcementsCanGet(hero, hero, source);
|
|
|
|
}
|
|
|
|
|
2021-05-15 20:36:50 +02:00
|
|
|
std::vector<SlotInfo> ArmyManager::getSortedSlots(const CCreatureSet * target, const CCreatureSet * source) const
|
|
|
|
{
|
|
|
|
const CCreatureSet * armies[] = { target, source };
|
|
|
|
|
|
|
|
//we calculate total strength for each creature type available in armies
|
|
|
|
std::map<const CCreature *, SlotInfo> creToPower;
|
|
|
|
std::vector<SlotInfo> resultingArmy;
|
|
|
|
|
|
|
|
for(auto armyPtr : armies)
|
|
|
|
{
|
|
|
|
for(auto & i : armyPtr->Slots())
|
|
|
|
{
|
|
|
|
auto & slotInfp = creToPower[i.second->type];
|
|
|
|
|
|
|
|
slotInfp.creature = i.second->type;
|
|
|
|
slotInfp.power += i.second->getPower();
|
|
|
|
slotInfp.count += i.second->count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for(auto pair : creToPower)
|
|
|
|
resultingArmy.push_back(pair.second);
|
|
|
|
|
2019-04-07 06:31:47 +02:00
|
|
|
boost::sort(resultingArmy, [](const SlotInfo & left, const SlotInfo & right) -> bool
|
2021-05-15 20:36:50 +02:00
|
|
|
{
|
|
|
|
return left.power > right.power;
|
|
|
|
});
|
|
|
|
|
|
|
|
return resultingArmy;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<SlotInfo>::iterator ArmyManager::getWeakestCreature(std::vector<SlotInfo> & army) const
|
|
|
|
{
|
2019-04-07 06:31:47 +02:00
|
|
|
auto weakest = boost::min_element(army, [](const SlotInfo & left, const SlotInfo & right) -> bool
|
2021-05-15 20:36:50 +02:00
|
|
|
{
|
|
|
|
if(left.creature->level != right.creature->level)
|
|
|
|
return left.creature->level < right.creature->level;
|
|
|
|
|
|
|
|
return left.creature->Speed() > right.creature->Speed();
|
|
|
|
});
|
|
|
|
|
|
|
|
return weakest;
|
|
|
|
}
|
|
|
|
|
2021-05-16 13:56:53 +02:00
|
|
|
class TemporaryArmy : public CArmedInstance
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
void armyChanged() override {}
|
|
|
|
};
|
|
|
|
|
2021-05-16 13:56:42 +02:00
|
|
|
std::vector<SlotInfo> ArmyManager::getBestArmy(const IBonusBearer * armyCarrier, const CCreatureSet * target, const CCreatureSet * source) const
|
2021-05-15 20:36:50 +02:00
|
|
|
{
|
2021-05-16 13:56:42 +02:00
|
|
|
auto sortedSlots = getSortedSlots(target, source);
|
|
|
|
std::map<TFaction, uint64_t> alignmentMap;
|
|
|
|
|
|
|
|
for(auto & slot : sortedSlots)
|
|
|
|
{
|
|
|
|
alignmentMap[slot.creature->faction] += slot.power;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::set<TFaction> allowedFactions;
|
|
|
|
std::vector<SlotInfo> resultingArmy;
|
|
|
|
uint64_t armyValue = 0;
|
|
|
|
|
2021-05-16 13:56:53 +02:00
|
|
|
TemporaryArmy newArmyInstance;
|
2021-05-16 13:56:42 +02:00
|
|
|
auto bonusModifiers = armyCarrier->getBonuses(Selector::type(Bonus::MORALE));
|
2021-05-15 20:36:50 +02:00
|
|
|
|
2021-05-16 13:56:42 +02:00
|
|
|
for(auto bonus : *bonusModifiers)
|
2021-05-15 20:36:50 +02:00
|
|
|
{
|
2021-05-16 13:56:42 +02:00
|
|
|
// army bonuses will change and object bonuses are temporary
|
|
|
|
if(bonus->source != Bonus::ARMY || bonus->source != Bonus::OBJECT)
|
|
|
|
{
|
|
|
|
newArmyInstance.addNewBonus(bonus);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
while(allowedFactions.size() < alignmentMap.size())
|
|
|
|
{
|
|
|
|
auto strongestAlignment = vstd::maxElementByFun(alignmentMap, [&](std::pair<TFaction, uint64_t> pair) -> uint64_t
|
|
|
|
{
|
|
|
|
return vstd::contains(allowedFactions, pair.first) ? 0 : pair.second;
|
|
|
|
});
|
|
|
|
|
|
|
|
allowedFactions.insert(strongestAlignment->first);
|
|
|
|
|
|
|
|
std::vector<SlotInfo> newArmy;
|
|
|
|
uint64_t newValue = 0;
|
|
|
|
newArmyInstance.clear();
|
|
|
|
|
|
|
|
for(auto & slot : sortedSlots)
|
|
|
|
{
|
|
|
|
if(vstd::contains(allowedFactions, slot.creature->faction))
|
|
|
|
{
|
|
|
|
auto slotID = newArmyInstance.getSlotFor(slot.creature);
|
|
|
|
|
|
|
|
if(slotID.validSlot())
|
|
|
|
{
|
|
|
|
newArmyInstance.setCreature(slotID, slot.creature->idNumber, slot.count);
|
|
|
|
newArmy.push_back(slot);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-16 13:56:53 +02:00
|
|
|
newArmyInstance.updateMoraleBonusFromArmy();
|
|
|
|
|
2021-05-16 13:56:42 +02:00
|
|
|
for(auto & slot : newArmyInstance.Slots())
|
|
|
|
{
|
|
|
|
auto morale = slot.second->MoraleVal();
|
|
|
|
auto multiplier = 1.0f;
|
|
|
|
|
|
|
|
if(morale < 0)
|
|
|
|
{
|
|
|
|
multiplier += morale * 0.083f;
|
|
|
|
}
|
2021-05-16 13:56:53 +02:00
|
|
|
else if(morale > 0)
|
|
|
|
{
|
|
|
|
multiplier += morale * 0.04f;
|
|
|
|
}
|
2021-05-16 13:56:42 +02:00
|
|
|
|
|
|
|
newValue += multiplier * slot.second->getPower();
|
|
|
|
}
|
|
|
|
|
|
|
|
if(armyValue >= newValue)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
resultingArmy = newArmy;
|
|
|
|
armyValue = newValue;
|
2021-05-15 20:36:50 +02:00
|
|
|
}
|
2021-05-16 13:56:42 +02:00
|
|
|
|
|
|
|
if(resultingArmy.size() <= GameConstants::ARMY_SIZE
|
|
|
|
&& allowedFactions.size() == alignmentMap.size()
|
|
|
|
&& source->needsLastStack())
|
2021-05-15 20:36:50 +02:00
|
|
|
{
|
|
|
|
auto weakest = getWeakestCreature(resultingArmy);
|
|
|
|
|
|
|
|
if(weakest->count == 1)
|
|
|
|
{
|
|
|
|
resultingArmy.erase(weakest);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
weakest->power -= weakest->power / weakest->count;
|
|
|
|
weakest->count--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return resultingArmy;
|
|
|
|
}
|
|
|
|
|
|
|
|
ui64 ArmyManager::howManyReinforcementsCanBuy(const CCreatureSet * h, const CGDwelling * t) const
|
2021-05-16 13:59:35 +02:00
|
|
|
{
|
|
|
|
return howManyReinforcementsCanBuy(h, t, cb->getResourceAmount());
|
|
|
|
}
|
|
|
|
|
|
|
|
ui64 ArmyManager::howManyReinforcementsCanBuy(
|
|
|
|
const CCreatureSet * h,
|
|
|
|
const CGDwelling * t,
|
|
|
|
const TResources & availableResources) const
|
2021-05-15 20:36:50 +02:00
|
|
|
{
|
|
|
|
ui64 aivalue = 0;
|
2021-05-16 13:59:35 +02:00
|
|
|
auto army = getArmyAvailableToBuy(h, t, availableResources);
|
2021-05-15 20:36:50 +02:00
|
|
|
|
2021-05-16 13:13:48 +02:00
|
|
|
for(const creInfo & ci : army)
|
2021-05-15 20:36:50 +02:00
|
|
|
{
|
2021-05-16 13:13:48 +02:00
|
|
|
aivalue += ci.count * ci.cre->AIValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
return aivalue;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<creInfo> ArmyManager::getArmyAvailableToBuy(const CCreatureSet * hero, const CGDwelling * dwelling) const
|
|
|
|
{
|
2021-05-16 13:57:26 +02:00
|
|
|
return getArmyAvailableToBuy(hero, dwelling, cb->getResourceAmount());
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<creInfo> ArmyManager::getArmyAvailableToBuy(const CCreatureSet * hero, const CGDwelling * dwelling, TResources availableRes) const
|
|
|
|
{
|
2021-05-16 13:13:48 +02:00
|
|
|
std::vector<creInfo> creaturesInDwellings;
|
|
|
|
int freeHeroSlots = GameConstants::ARMY_SIZE - hero->stacksCount();
|
|
|
|
|
|
|
|
for(int i = dwelling->creatures.size() - 1; i >= 0; i--)
|
|
|
|
{
|
|
|
|
auto ci = infoFromDC(dwelling->creatures[i]);
|
2021-05-15 20:36:50 +02:00
|
|
|
|
|
|
|
if(!ci.count || ci.creID == -1)
|
|
|
|
continue;
|
|
|
|
|
2021-05-16 13:13:48 +02:00
|
|
|
SlotID dst = hero->getSlotFor(ci.creID);
|
|
|
|
if(!hero->hasStackAtSlot(dst)) //need another new slot for this stack
|
2021-05-15 20:36:50 +02:00
|
|
|
{
|
2021-05-16 13:13:48 +02:00
|
|
|
if(!freeHeroSlots) //no more place for stacks
|
|
|
|
continue;
|
|
|
|
else
|
|
|
|
freeHeroSlots--; //new slot will be occupied
|
2021-05-15 20:36:50 +02:00
|
|
|
}
|
2021-05-16 13:13:48 +02:00
|
|
|
|
|
|
|
vstd::amin(ci.count, availableRes / ci.cre->cost); //max count we can afford
|
|
|
|
|
|
|
|
if(!ci.count)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
ci.level = i; //this is important for Dungeon Summoning Portal
|
|
|
|
creaturesInDwellings.push_back(ci);
|
|
|
|
availableRes -= ci.cre->cost * ci.count;
|
2021-05-15 20:36:50 +02:00
|
|
|
}
|
|
|
|
|
2021-05-16 13:13:48 +02:00
|
|
|
return creaturesInDwellings;
|
2021-05-15 20:36:50 +02:00
|
|
|
}
|
|
|
|
|
2021-05-16 13:56:42 +02:00
|
|
|
ui64 ArmyManager::howManyReinforcementsCanGet(const IBonusBearer * armyCarrier, const CCreatureSet * target, const CCreatureSet * source) const
|
2021-05-15 20:36:50 +02:00
|
|
|
{
|
2021-05-16 13:56:42 +02:00
|
|
|
auto bestArmy = getBestArmy(armyCarrier, target, source);
|
2021-05-15 20:36:50 +02:00
|
|
|
uint64_t newArmy = 0;
|
|
|
|
uint64_t oldArmy = target->getArmyStrength();
|
|
|
|
|
|
|
|
for(auto & slot : bestArmy)
|
|
|
|
{
|
|
|
|
newArmy += slot.power;
|
|
|
|
}
|
|
|
|
|
|
|
|
return newArmy > oldArmy ? newArmy - oldArmy : 0;
|
|
|
|
}
|
2021-05-16 13:15:03 +02:00
|
|
|
|
|
|
|
uint64_t ArmyManager::evaluateStackPower(const CCreature * creature, int count) const
|
|
|
|
{
|
|
|
|
return creature->AIValue * count;
|
|
|
|
}
|
|
|
|
|
|
|
|
SlotInfo ArmyManager::getTotalCreaturesAvailable(CreatureID creatureID) const
|
|
|
|
{
|
|
|
|
auto creatureInfo = totalArmy.find(creatureID);
|
|
|
|
|
|
|
|
return creatureInfo == totalArmy.end() ? SlotInfo() : creatureInfo->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ArmyManager::update()
|
|
|
|
{
|
|
|
|
logAi->trace("Start analysing army");
|
|
|
|
|
|
|
|
std::vector<const CCreatureSet *> total;
|
|
|
|
auto heroes = cb->getHeroesInfo();
|
|
|
|
auto towns = cb->getTownsInfo();
|
|
|
|
|
|
|
|
std::copy(heroes.begin(), heroes.end(), std::back_inserter(total));
|
|
|
|
std::copy(towns.begin(), towns.end(), std::back_inserter(total));
|
|
|
|
|
|
|
|
totalArmy.clear();
|
|
|
|
|
|
|
|
for(auto army : total)
|
|
|
|
{
|
|
|
|
for(auto slot : army->Slots())
|
|
|
|
{
|
|
|
|
totalArmy[slot.second->getCreatureID()].count += slot.second->count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for(auto army : totalArmy)
|
|
|
|
{
|
|
|
|
army.second.creature = army.first.toCreature();
|
|
|
|
army.second.power = evaluateStackPower(army.second.creature, army.second.count);
|
|
|
|
}
|
2021-05-16 13:15:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<SlotInfo> ArmyManager::convertToSlots(const CCreatureSet * army) const
|
|
|
|
{
|
|
|
|
std::vector<SlotInfo> result;
|
|
|
|
|
|
|
|
for(auto slot : army->Slots())
|
|
|
|
{
|
|
|
|
SlotInfo slotInfo;
|
|
|
|
|
|
|
|
slotInfo.creature = slot.second->getCreatureID().toCreature();
|
|
|
|
slotInfo.count = slot.second->count;
|
|
|
|
slotInfo.power = evaluateStackPower(slotInfo.creature, slotInfo.count);
|
|
|
|
|
|
|
|
result.push_back(slotInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2021-05-16 13:39:20 +02:00
|
|
|
std::vector<StackUpgradeInfo> ArmyManager::getHillFortUpgrades(const CCreatureSet * army) const
|
2021-05-16 13:15:12 +02:00
|
|
|
{
|
2021-05-16 13:39:20 +02:00
|
|
|
std::vector<StackUpgradeInfo> upgrades;
|
2021-05-16 13:15:12 +02:00
|
|
|
|
|
|
|
for(auto creature : army->Slots())
|
|
|
|
{
|
|
|
|
CreatureID initial = creature.second->getCreatureID();
|
|
|
|
auto possibleUpgrades = initial.toCreature()->upgrades;
|
|
|
|
|
|
|
|
if(possibleUpgrades.empty())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
CreatureID strongestUpgrade = *vstd::minElementByFun(possibleUpgrades, [](CreatureID cre) -> uint64_t
|
|
|
|
{
|
|
|
|
return cre.toCreature()->AIValue;
|
|
|
|
});
|
|
|
|
|
2021-05-16 13:39:20 +02:00
|
|
|
StackUpgradeInfo upgrade = StackUpgradeInfo(initial, strongestUpgrade, creature.second->count);
|
2021-05-16 13:15:12 +02:00
|
|
|
|
|
|
|
if(initial.toCreature()->level == 1)
|
|
|
|
upgrade.cost = TResources();
|
|
|
|
|
|
|
|
upgrades.push_back(upgrade);
|
|
|
|
}
|
|
|
|
|
|
|
|
return upgrades;
|
|
|
|
}
|
|
|
|
|
2021-05-16 13:39:20 +02:00
|
|
|
std::vector<StackUpgradeInfo> ArmyManager::getDwellingUpgrades(const CCreatureSet * army, const CGDwelling * dwelling) const
|
2021-05-16 13:15:12 +02:00
|
|
|
{
|
2021-05-16 13:39:20 +02:00
|
|
|
std::vector<StackUpgradeInfo> upgrades;
|
2021-05-16 13:15:12 +02:00
|
|
|
|
2021-05-16 13:19:00 +02:00
|
|
|
for(auto creature : army->Slots())
|
|
|
|
{
|
|
|
|
CreatureID initial = creature.second->getCreatureID();
|
|
|
|
auto possibleUpgrades = initial.toCreature()->upgrades;
|
|
|
|
|
|
|
|
vstd::erase_if(possibleUpgrades, [&](CreatureID creID) -> bool
|
|
|
|
{
|
|
|
|
for(auto pair : dwelling->creatures)
|
|
|
|
{
|
|
|
|
if(vstd::contains(pair.second, creID))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
|
|
|
|
if(possibleUpgrades.empty())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
CreatureID strongestUpgrade = *vstd::minElementByFun(possibleUpgrades, [](CreatureID cre) -> uint64_t
|
|
|
|
{
|
|
|
|
return cre.toCreature()->AIValue;
|
|
|
|
});
|
|
|
|
|
2021-05-16 13:39:20 +02:00
|
|
|
StackUpgradeInfo upgrade = StackUpgradeInfo(initial, strongestUpgrade, creature.second->count);
|
2021-05-16 13:19:00 +02:00
|
|
|
|
|
|
|
upgrades.push_back(upgrade);
|
|
|
|
}
|
|
|
|
|
2021-05-16 13:15:12 +02:00
|
|
|
return upgrades;
|
|
|
|
}
|
|
|
|
|
2021-05-16 13:39:20 +02:00
|
|
|
std::vector<StackUpgradeInfo> ArmyManager::getPossibleUpgrades(const CCreatureSet * army, const CGObjectInstance * upgrader) const
|
2021-05-16 13:15:12 +02:00
|
|
|
{
|
2021-05-16 13:39:20 +02:00
|
|
|
std::vector<StackUpgradeInfo> upgrades;
|
2021-05-16 13:15:12 +02:00
|
|
|
|
|
|
|
if(upgrader->ID == Obj::HILL_FORT)
|
|
|
|
{
|
|
|
|
upgrades = getHillFortUpgrades(army);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
auto dwelling = dynamic_cast<const CGDwelling *>(upgrader);
|
|
|
|
|
|
|
|
if(dwelling)
|
|
|
|
{
|
|
|
|
upgrades = getDwellingUpgrades(army, dwelling);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return upgrades;
|
|
|
|
}
|
|
|
|
|
|
|
|
ArmyUpgradeInfo ArmyManager::calculateCreateresUpgrade(
|
|
|
|
const CCreatureSet * army,
|
|
|
|
const CGObjectInstance * upgrader,
|
|
|
|
const TResources & availableResources) const
|
|
|
|
{
|
2021-05-16 13:19:00 +02:00
|
|
|
if(!upgrader)
|
|
|
|
return ArmyUpgradeInfo();
|
|
|
|
|
2021-05-16 13:39:20 +02:00
|
|
|
std::vector<StackUpgradeInfo> upgrades = getPossibleUpgrades(army, upgrader);
|
2021-05-16 13:15:12 +02:00
|
|
|
|
2021-05-16 13:39:20 +02:00
|
|
|
vstd::erase_if(upgrades, [&](const StackUpgradeInfo & u) -> bool
|
2021-05-16 13:15:12 +02:00
|
|
|
{
|
|
|
|
return !availableResources.canAfford(u.cost);
|
|
|
|
});
|
|
|
|
|
|
|
|
if(upgrades.empty())
|
|
|
|
return ArmyUpgradeInfo();
|
|
|
|
|
2021-05-16 13:39:20 +02:00
|
|
|
std::sort(upgrades.begin(), upgrades.end(), [](const StackUpgradeInfo & u1, const StackUpgradeInfo & u2) -> bool
|
2021-05-16 13:15:12 +02:00
|
|
|
{
|
|
|
|
return u1.upgradeValue > u2.upgradeValue;
|
|
|
|
});
|
|
|
|
|
|
|
|
TResources resourcesLeft = availableResources;
|
|
|
|
ArmyUpgradeInfo result;
|
|
|
|
|
|
|
|
result.resultingArmy = convertToSlots(army);
|
|
|
|
|
|
|
|
for(auto upgrade : upgrades)
|
|
|
|
{
|
|
|
|
if(resourcesLeft.canAfford(upgrade.cost))
|
|
|
|
{
|
|
|
|
SlotInfo upgradedArmy;
|
|
|
|
|
2021-05-16 13:39:47 +02:00
|
|
|
upgradedArmy.creature = upgrade.upgradedCreature.toCreature();
|
2021-05-16 13:15:12 +02:00
|
|
|
upgradedArmy.count = upgrade.count;
|
|
|
|
upgradedArmy.power = evaluateStackPower(upgradedArmy.creature, upgradedArmy.count);
|
|
|
|
|
|
|
|
auto slotToReplace = std::find_if(result.resultingArmy.begin(), result.resultingArmy.end(), [&](const SlotInfo & slot) -> bool {
|
2021-05-16 13:39:47 +02:00
|
|
|
return slot.count == upgradedArmy.count && slot.creature->idNumber == upgrade.initialCreature;
|
2021-05-16 13:15:12 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
resourcesLeft -= upgrade.cost;
|
|
|
|
result.upgradeCost += upgrade.cost;
|
|
|
|
result.upgradeValue += upgrade.upgradeValue;
|
|
|
|
|
|
|
|
*slotToReplace = upgradedArmy;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
2021-05-16 13:15:03 +02:00
|
|
|
}
|