1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-02-03 13:01:33 +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; alive = Alive;
if (!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 // Removing short-term bonuses
for(CGHeroInstance * cgh : crossoverHeroes) for(CGHeroInstance * cgh : crossoverHeroes)
{ {
cgh->popBonuses(CSelector(Bonus::OneDay) cgh->removeBonusesRecursive(CSelector(Bonus::OneDay)
.Or(CSelector(Bonus::OneWeek)) .Or(CSelector(Bonus::OneWeek))
.Or(CSelector(Bonus::NTurns)) .Or(CSelector(Bonus::NTurns))
.Or(CSelector(Bonus::NDays)) .Or(CSelector(Bonus::NDays))

View File

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

View File

@ -710,13 +710,12 @@ public:
void unpropagateBonus(std::shared_ptr<Bonus> b); void unpropagateBonus(std::shared_ptr<Bonus> b);
void removeBonus(const std::shared_ptr<Bonus>& b); void removeBonus(const std::shared_ptr<Bonus>& b);
void removeBonuses(const CSelector &selector); void removeBonuses(const CSelector &selector);
void removeBonusesRecursive(const CSelector &s);
void newRedDescendant(CBonusSystemNode *descendant); //propagation needed void newRedDescendant(CBonusSystemNode *descendant); //propagation needed
void removedRedDescendant(CBonusSystemNode *descendant); //de-propagation needed void removedRedDescendant(CBonusSystemNode *descendant); //de-propagation needed
bool isIndependentNode() const; //node is independent when it has no parents nor children bool isIndependentNode() const; //node is independent when it has no parents nor children
bool actsAsBonusSourceOnly() const; bool actsAsBonusSourceOnly() const;
///removes bonuses by selector
void popBonuses(const CSelector &s);
///updates count of remaining turns and removes outdated bonuses by selector ///updates count of remaining turns and removes outdated bonuses by selector
void reduceBonusDurations(const CSelector &s); void reduceBonusDurations(const CSelector &s);
virtual std::string bonusToString(const std::shared_ptr<Bonus>& bonus, bool description) const {return "";}; //description or bonus name 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; gs->day = day;
// Update bonuses before doing anything else so hero don't get more MP than needed // 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::NDays);
gs->globalEffects.reduceBonusDurations(Bonus::OneWeek); 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...] //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)) 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) if (h->commander && h->commander->alive)
{ {
for (auto art : h->commander->artifactsWorn) //increment bonuses for commander artifacts 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) for(BattleStackAttacked & stackAttacked : bsa)
stackAttacked.applyGs(gs); stackAttacked.applyGs(gs);
attacker->popBonuses(Bonus::UntilAttack); attacker->removeBonusesRecursive(Bonus::UntilAttack);
} }
DLL_LINKAGE void StartAction::applyGs(CGameState *gs) DLL_LINKAGE void StartAction::applyGs(CGameState *gs)
@ -1542,7 +1542,7 @@ DLL_LINKAGE void BattleSetStackProperty::applyGs(CGameState * gs)
} }
case UNBIND: case UNBIND:
{ {
stack->popBonuses(Selector::type(Bonus::BIND_EFFECT)); stack->removeBonusesRecursive(Selector::type(Bonus::BIND_EFFECT));
break; break;
} }
case CLONED: case CLONED:

View File

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