1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

Fix commander ability accumulation, change commander ability bonus

This commit is contained in:
Dydzio 2023-12-23 20:16:29 +01:00
parent 20ede710c2
commit 9e9849b741
4 changed files with 11 additions and 3 deletions

View File

@ -82,6 +82,13 @@ namespace Selector
return CSelectFieldEqual<BonusValueType>(&Bonus::valType)(valType);
}
CSelector DLL_LINKAGE typeSubtypeValueType(BonusType Type, BonusSubtypeID Subtype, BonusValueType valType)
{
return type()(Type)
.And(subtype()(Subtype))
.And(valueType(valType));
}
DLL_LINKAGE CSelector all([](const Bonus * b){return true;});
DLL_LINKAGE CSelector none([](const Bonus * b){return false;});
}

View File

@ -139,6 +139,7 @@ namespace Selector
CSelector DLL_LINKAGE source(BonusSource source, BonusSourceID sourceID);
CSelector DLL_LINKAGE sourceTypeSel(BonusSource source);
CSelector DLL_LINKAGE valueType(BonusValueType valType);
CSelector DLL_LINKAGE typeSubtypeValueType(BonusType Type, BonusSubtypeID Subtype, BonusValueType valType);
/**
* Selects all bonuses

View File

@ -356,7 +356,7 @@ void CBonusSystemNode::addNewBonus(const std::shared_ptr<Bonus>& b)
void CBonusSystemNode::accumulateBonus(const std::shared_ptr<Bonus>& b)
{
auto bonus = exportedBonuses.getFirst(Selector::typeSubtype(b->type, b->subtype)); //only local bonuses are interesting //TODO: what about value type?
auto bonus = exportedBonuses.getFirst(Selector::typeSubtypeValueType(b->type, b->subtype, b->valType)); //only local bonuses are interesting
if(bonus)
bonus->val += b->val;
else

View File

@ -253,11 +253,11 @@ void CGameHandler::levelUpCommander (const CCommanderInstance * c, int skill)
break;
case ECommander::HEALTH:
scp.accumulatedBonus.type = BonusType::STACK_HEALTH;
scp.accumulatedBonus.valType = BonusValueType::PERCENT_TO_BASE;
scp.accumulatedBonus.valType = BonusValueType::PERCENT_TO_ALL;
break;
case ECommander::DAMAGE:
scp.accumulatedBonus.type = BonusType::CREATURE_DAMAGE;
scp.accumulatedBonus.valType = BonusValueType::PERCENT_TO_BASE;
scp.accumulatedBonus.valType = BonusValueType::PERCENT_TO_ALL;
break;
case ECommander::SPEED:
scp.accumulatedBonus.type = BonusType::STACKS_SPEED;