Trigger event when stat boost changes.
All checks were successful
continuous-integration/drone/push Build is passing

Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
2021-01-16 21:16:47 +01:00
parent 987f60ee85
commit abccc23851
6 changed files with 40 additions and 2 deletions

View File

@@ -109,10 +109,15 @@ namespace CreatureLib::Battling {
bool Creature::ChangeStatBoost(Library::Statistic stat, int8_t diffAmount) {
bool changed = false;
auto oldValue = this->_statBoost.GetStat(stat);
if (diffAmount > 0)
changed = this->_statBoost.IncreaseStatBy(stat, diffAmount);
else
changed = this->_statBoost.DecreaseStatBy(stat, -diffAmount);
if (this->GetBattle().HasValue()) {
auto newValue = this->_statBoost.GetStat(stat);
this->GetBattle().GetValue()->TriggerEventListener<ChangeStatBoostEvent>(this, stat, oldValue, newValue);
}
this->RecalculateBoostedStat(stat);
return changed;
}