Trigger event when stat boost changes.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user