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

Bonus system: add turnsRemain support for ONE_WEEK duration

This commit is contained in:
ArseniyShestakov 2015-11-20 12:11:35 +03:00
parent d6bb599bc8
commit 6d395bcba7
2 changed files with 7 additions and 8 deletions

View File

@ -294,7 +294,7 @@ struct DLL_LINKAGE Bonus
};
ui16 duration; //uses BonusDuration values
si16 turnsRemain; //used if duration is N_TURNS or N_DAYS
si16 turnsRemain; //used if duration is N_TURNS, N_DAYS or ONE_WEEK
BonusType type; //uses BonusType values - says to what is this bonus - 1 byte
TBonusSubtype subtype; //-1 if not applicable - 4 bytes
@ -828,13 +828,11 @@ public:
bool operator()(const Bonus *bonus) const
{
if(daysRequested <= 0)
if(daysRequested <= 0 || bonus->duration & Bonus::PERMANENT || bonus->duration & Bonus::ONE_BATTLE)
return true;
else if(bonus->duration & Bonus::ONE_DAY)
return false;
else if(bonus->duration & Bonus::PERMANENT || bonus->duration & Bonus::ONE_BATTLE)
return true;
else if(bonus->duration & Bonus::N_DAYS)
else if(bonus->duration & Bonus::N_DAYS || bonus->duration & Bonus::ONE_WEEK)
{
return bonus->turnsRemain > daysRequested;
}

View File

@ -263,6 +263,9 @@ DLL_LINKAGE void GiveBonus::applyGs( CGameState *gs )
assert(cbsn);
if(Bonus::OneWeek(&bonus))
bonus.turnsRemain = 8 - gs->getDate(Date::DAY_OF_WEEK); // set correct number of days before adding bonus
auto b = new Bonus(bonus);
cbsn->addNewBonus(b);
@ -1023,10 +1026,8 @@ DLL_LINKAGE void NewTurn::applyGs( CGameState *gs )
creatureSet.second.applyGs(gs);
gs->globalEffects.popBonuses(Bonus::OneDay); //works for children -> all game objs
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);
gs->globalEffects.updateBonuses(Bonus::OneWeek);
//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)