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

Bonus system: fix N_DAYS bonus duration

This commit is contained in:
ArseniyShestakov
2015-11-09 14:18:36 +03:00
parent 74198a537b
commit 5bfbd8526b
3 changed files with 20 additions and 0 deletions

View File

@@ -763,6 +763,24 @@ void CBonusSystemNode::popBonuses(const CSelector &s)
child->popBonuses(s);
}
void CBonusSystemNode::updateBonuses(const CSelector &s)
{
BonusList bl;
exportedBonuses.getBonuses(bl, s);
for(Bonus *b : bl)
{
if(b->duration & Bonus::N_DAYS)
{
b->turnsRemain--;
if(b->turnsRemain <= 0)
removeBonus(b);
}
}
for(CBonusSystemNode *child : children)
child->updateBonuses(s);
}
void CBonusSystemNode::addNewBonus(Bonus *b)
{
assert(!vstd::contains(exportedBonuses,b));

View File

@@ -686,6 +686,7 @@ public:
//bool isLimitedOnUs(Bonus *b) const; //if bonus should be removed from list acquired from this node
void popBonuses(const CSelector &s);
void updateBonuses(const CSelector &s);
virtual std::string bonusToString(const Bonus *bonus, bool description) const {return "";}; //description or bonus name
virtual std::string nodeName() const;

View File

@@ -1026,6 +1026,7 @@ DLL_LINKAGE void NewTurn::applyGs( CGameState *gs )
if(gs->getDate(Date::DAY_OF_WEEK) == 1) //new week
gs->globalEffects.popBonuses(Bonus::OneWeek); //works for children -> all game objs
gs->globalEffects.updateBonuses(Bonus::NDays);
//TODO not really a single root hierarchy, what about bonuses placed elsewhere? [not an issue with H3 mechanics but in the future...]
for(CGTownInstance* t : gs->map->towns)