1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-24 03:47:18 +02:00

renamed CBonusSystemNode::popBonuses to removeBonusesRecursive

This commit is contained in:
Henning Koehler 2018-03-05 19:51:35 +13:00 committed by ArseniyShestakov
parent 4c0a67041b
commit d3e4fc6e7a
6 changed files with 13 additions and 14 deletions

View File

@ -825,7 +825,7 @@ void CCommanderInstance::setAlive (bool Alive)
alive = Alive;
if (!alive)
{
popBonuses(Bonus::UntilCommanderKilled);
removeBonusesRecursive(Bonus::UntilCommanderKilled);
}
}

View File

@ -1243,7 +1243,7 @@ void CGameState::prepareCrossoverHeroes(std::vector<CGameState::CampaignHeroRepl
// Removing short-term bonuses
for(CGHeroInstance * cgh : crossoverHeroes)
{
cgh->popBonuses(CSelector(Bonus::OneDay)
cgh->removeBonusesRecursive(CSelector(Bonus::OneDay)
.Or(CSelector(Bonus::OneWeek))
.Or(CSelector(Bonus::NTurns))
.Or(CSelector(Bonus::NDays))

View File

@ -791,7 +791,7 @@ void CBonusSystemNode::detachFrom(CBonusSystemNode *parent)
CBonusSystemNode::treeHasChanged();
}
void CBonusSystemNode::popBonuses(const CSelector &s)
void CBonusSystemNode::removeBonusesRecursive(const CSelector &s)
{
BonusList bl;
exportedBonuses.getBonuses(bl, s, Selector::all);
@ -799,7 +799,7 @@ void CBonusSystemNode::popBonuses(const CSelector &s)
removeBonus(b);
for(CBonusSystemNode *child : children)
child->popBonuses(s);
child->removeBonusesRecursive(s);
}
void CBonusSystemNode::reduceBonusDurations(const CSelector &s)

View File

@ -710,13 +710,12 @@ public:
void unpropagateBonus(std::shared_ptr<Bonus> b);
void removeBonus(const std::shared_ptr<Bonus>& b);
void removeBonuses(const CSelector &selector);
void removeBonusesRecursive(const CSelector &s);
void newRedDescendant(CBonusSystemNode *descendant); //propagation needed
void removedRedDescendant(CBonusSystemNode *descendant); //de-propagation needed
bool isIndependentNode() const; //node is independent when it has no parents nor children
bool actsAsBonusSourceOnly() const;
///removes bonuses by selector
void popBonuses(const CSelector &s);
///updates count of remaining turns and removes outdated bonuses by selector
void reduceBonusDurations(const CSelector &s);
virtual std::string bonusToString(const std::shared_ptr<Bonus>& bonus, bool description) const {return "";}; //description or bonus name

View File

@ -1084,7 +1084,7 @@ DLL_LINKAGE void NewTurn::applyGs(CGameState *gs)
gs->day = day;
// Update bonuses before doing anything else so hero don't get more MP than needed
gs->globalEffects.popBonuses(Bonus::OneDay); //works for children -> all game objs
gs->globalEffects.removeBonusesRecursive(Bonus::OneDay); //works for children -> all game objs
gs->globalEffects.reduceBonusDurations(Bonus::NDays);
gs->globalEffects.reduceBonusDurations(Bonus::OneWeek);
//TODO not really a single root hierarchy, what about bonuses placed elsewhere? [not an issue with H3 mechanics but in the future...]
@ -1286,7 +1286,7 @@ void BattleResult::applyGs(CGameState *gs)
{
if(auto h = gs->curB->battleGetFightingHero(i))
{
h->popBonuses(Bonus::OneBattle); //remove any "until next battle" bonuses
h->removeBonusesRecursive(Bonus::OneBattle); //remove any "until next battle" bonuses
if (h->commander && h->commander->alive)
{
for (auto art : h->commander->artifactsWorn) //increment bonuses for commander artifacts
@ -1342,7 +1342,7 @@ DLL_LINKAGE void BattleAttack::applyGs(CGameState * gs)
for(BattleStackAttacked & stackAttacked : bsa)
stackAttacked.applyGs(gs);
attacker->popBonuses(Bonus::UntilAttack);
attacker->removeBonusesRecursive(Bonus::UntilAttack);
}
DLL_LINKAGE void StartAction::applyGs(CGameState *gs)
@ -1542,7 +1542,7 @@ DLL_LINKAGE void BattleSetStackProperty::applyGs(CGameState * gs)
}
case UNBIND:
{
stack->popBonuses(Selector::type(Bonus::BIND_EFFECT));
stack->removeBonusesRecursive(Selector::type(Bonus::BIND_EFFECT));
break;
}
case CLONED:

View File

@ -781,7 +781,7 @@ void BattleInfo::nextTurn(uint32_t unitId)
CStack * st = getStack(activeStack);
//remove bonuses that last until when stack gets new turn
st->popBonuses(Bonus::UntilGetsTurn);
st->removeBonusesRecursive(Bonus::UntilGetsTurn);
st->afterGetsTurn();
}
@ -852,7 +852,7 @@ void BattleInfo::setUnitState(uint32_t id, const JsonNode & data, int64_t health
if(healthDelta < 0)
{
changedStack->popBonuses(Bonus::UntilBeingAttacked);
changedStack->removeBonusesRecursive(Bonus::UntilBeingAttacked);
}
resurrected = resurrected || (killed && changedStack->alive());
@ -881,7 +881,7 @@ void BattleInfo::setUnitState(uint32_t id, const JsonNode & data, int64_t health
else
return false;
};
changedStack->popBonuses(selector);
changedStack->removeBonusesRecursive(selector);
}
if(!changedStack->alive() && changedStack->isClone())
@ -989,7 +989,7 @@ void BattleInfo::removeUnitBonus(uint32_t id, const std::vector<Bonus> & bonus)
&& one.effectRange == b->effectRange
&& one.description == b->description;
};
sta->popBonuses(selector);
sta->removeBonusesRecursive(selector);
}
}