diff --git a/src/Battling/Models/BattleCreature.cpp b/src/Battling/Models/BattleCreature.cpp index afcf5fb..13268d7 100644 --- a/src/Battling/Models/BattleCreature.cpp +++ b/src/Battling/Models/BattleCreature.cpp @@ -10,7 +10,8 @@ Battling::BattleCreature::BattleCreature(Battling::Battle *battle, _creature(creature), _statBoost(Core::StatisticSet()) { - + // Initialize boosted stats. This initializes flat stats as well. + RecalculateBoostedStats(); } const Library::Creature* Battling::BattleCreature::GetBackingCreature() { @@ -21,6 +22,16 @@ void Battling::BattleCreature::ApplyPostBattleEffects() { } +//region Stat APIs + +void Battling::BattleCreature::ChangeStatBoost(Core::Statistic stat, int8_t diffAmount){ + if (diffAmount > 0) + this->_statBoost.IncreaseStatBy(stat, diffAmount); + else + this->_statBoost.DecreaseStatBy(stat, diffAmount); + this->RecalculateBoostedStat(stat); +} + uint32_t Battling::BattleCreature::GetFlatStat(Core::Statistic stat) const{ return _flatStats.GetStat(stat); } @@ -48,10 +59,9 @@ void Battling::BattleCreature::RecalculateBoostedStat(Core::Statistic stat) { this->_boostedStats.SetStat(stat, s); } -void Battling::BattleCreature::ChangeStatBoost(Core::Statistic stat, int8_t diffAmount){ - if (diffAmount > 0) - this->_statBoost.IncreaseStatBy(stat, diffAmount); - else - this->_statBoost.DecreaseStatBy(stat, diffAmount); - this->RecalculateBoostedStat(stat); +//endregion + +void Battling::BattleCreature::ChangeLevel(int8_t amount) { + this->__Level += amount; + RecalculateFlatStats(); } \ No newline at end of file diff --git a/src/Battling/Models/BattleCreature.hpp b/src/Battling/Models/BattleCreature.hpp index 563d180..d4eb733 100644 --- a/src/Battling/Models/BattleCreature.hpp +++ b/src/Battling/Models/BattleCreature.hpp @@ -24,15 +24,19 @@ namespace CreatureLib::Battling{ const Library::Creature* GetBackingCreature(); void ApplyPostBattleEffects(); - uint32_t GetFlatStat(Core::Statistic stat) const; - uint32_t GetBoostedStat(Core::Statistic stat) const; + //region Stat APIs + + void ChangeStatBoost(Core::Statistic stat, int8_t diffAmount); + [[nodiscard]] uint32_t GetFlatStat(Core::Statistic stat) const; + [[nodiscard]] uint32_t GetBoostedStat(Core::Statistic stat) const; void RecalculateFlatStats(); void RecalculateBoostedStats(); void RecalculateFlatStat(Core::Statistic); void RecalculateBoostedStat(Core::Statistic); + //endregion - void ChangeStatBoost(Core::Statistic stat, int8_t diffAmount); + void ChangeLevel(int8_t amount); }; }