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:
@@ -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));
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user