Implements clamped statistics for stat boost.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-04-22 21:48:00 +02:00
parent 75baf19ebd
commit 97fa37ea7d
3 changed files with 105 additions and 5 deletions

View File

@@ -50,12 +50,14 @@ void Battling::Creature::SetBattleData(Battling::Battle* battle, Battling::Battl
// region Stat APIs
void Battling::Creature::ChangeStatBoost(Library::Statistic stat, int8_t diffAmount) {
bool Battling::Creature::ChangeStatBoost(Library::Statistic stat, int8_t diffAmount) {
bool changed = false;
if (diffAmount > 0)
this->_statBoost.IncreaseStatBy(stat, diffAmount);
changed = this->_statBoost.IncreaseStatBy(stat, diffAmount);
else
this->_statBoost.DecreaseStatBy(stat, -diffAmount);
changed = this->_statBoost.DecreaseStatBy(stat, -diffAmount);
this->RecalculateBoostedStat(stat);
return changed;
}
uint32_t Battling::Creature::GetFlatStat(Library::Statistic stat) const noexcept { return _flatStats.GetStat(stat); }

View File

@@ -2,6 +2,7 @@
#define CREATURELIB_BATTLECREATURE_HPP
#include <Arbutils/Collections/List.hpp>
#include "../../Library/ClampedStatisticSet.hpp"
#include "../../Library/CreatureData/CreatureSpecies.hpp"
#include "../../Library/Items/Item.hpp"
#include "../ScriptHandling/ScriptAggregator.hpp"
@@ -36,7 +37,7 @@ namespace CreatureLib::Battling {
const Library::Item* _heldItem;
uint32_t _currentHealth;
Library::StatisticSet<int8_t> _statBoost;
Library::ClampedStatisticSet<int8_t, -6, 6> _statBoost;
Library::StatisticSet<uint32_t> _flatStats;
Library::StatisticSet<uint32_t> _boostedStats;
@@ -139,7 +140,7 @@ namespace CreatureLib::Battling {
// region Stat APIs
void ChangeStatBoost(Library::Statistic stat, int8_t diffAmount);
bool ChangeStatBoost(Library::Statistic stat, int8_t diffAmount);
[[nodiscard]] uint32_t GetFlatStat(Library::Statistic stat) const noexcept;
[[nodiscard]] uint32_t GetBoostedStat(Library::Statistic stat) const noexcept;
[[nodiscard]] uint32_t GetBaseStat(Library::Statistic stat) const noexcept;