diff --git a/src/Battling/Models/BattleCreature.cpp b/src/Battling/Models/BattleCreature.cpp index 4453b94..afcf5fb 100644 --- a/src/Battling/Models/BattleCreature.cpp +++ b/src/Battling/Models/BattleCreature.cpp @@ -21,11 +21,11 @@ void Battling::BattleCreature::ApplyPostBattleEffects() { } -uint32_t Battling::BattleCreature::GetFlatStat(Core::Statistic stat) { +uint32_t Battling::BattleCreature::GetFlatStat(Core::Statistic stat) const{ return _flatStats.GetStat(stat); } -uint32_t Battling::BattleCreature::GetBoostedStat(Core::Statistic stat) { +uint32_t Battling::BattleCreature::GetBoostedStat(Core::Statistic stat) const{ return _boostedStats.GetStat(stat); } @@ -46,4 +46,12 @@ void Battling::BattleCreature::RecalculateFlatStat(Core::Statistic stat) { void Battling::BattleCreature::RecalculateBoostedStat(Core::Statistic stat) { auto s = this->__Battle->GetLibrary()->GetStatCalculator()->CalculateBoostedStat(this, 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); } \ No newline at end of file diff --git a/src/Battling/Models/BattleCreature.hpp b/src/Battling/Models/BattleCreature.hpp index 7fadec1..563d180 100644 --- a/src/Battling/Models/BattleCreature.hpp +++ b/src/Battling/Models/BattleCreature.hpp @@ -24,13 +24,15 @@ namespace CreatureLib::Battling{ const Library::Creature* GetBackingCreature(); void ApplyPostBattleEffects(); - uint32_t GetFlatStat(Core::Statistic stat); - uint32_t GetBoostedStat(Core::Statistic stat); + uint32_t GetFlatStat(Core::Statistic stat) const; + uint32_t GetBoostedStat(Core::Statistic stat) const; + void RecalculateFlatStats(); void RecalculateBoostedStats(); - void RecalculateFlatStat(Core::Statistic); void RecalculateBoostedStat(Core::Statistic); + + void ChangeStatBoost(Core::Statistic stat, int8_t diffAmount); }; } diff --git a/src/Core/StatisticSet.cpp b/src/Core/StatisticSet.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/src/Core/StatisticSet.hpp b/src/Core/StatisticSet.hpp index 63d2e42..f6880be 100644 --- a/src/Core/StatisticSet.hpp +++ b/src/Core/StatisticSet.hpp @@ -55,6 +55,29 @@ namespace CreatureLib::Core{ } throw std::exception(); } + + inline void IncreaseStatBy(Statistic stat, T amount){ + switch (stat){ + case Health: _health += amount; + case PhysicalAttack: _physicalAttack += amount; + case PhysicalDefense: _physicalDefense += amount; + case MagicalAttack: _magicalAttack += amount; + case MagicalDefense: _magicalDefense += amount; + case Speed: _speed += amount; + } + throw std::exception(); + } + inline void DecreaseStatBy(Statistic stat, T amount){ + switch (stat){ + case Health: _health -= amount; + case PhysicalAttack: _physicalAttack -= amount; + case PhysicalDefense: _physicalDefense -= amount; + case MagicalAttack: _magicalAttack -= amount; + case MagicalDefense: _magicalDefense -= amount; + case Speed: _speed -= amount; + } + throw std::exception(); + } }; }