#ifndef CREATURELIB_STATISTICSET_HPP #define CREATURELIB_STATISTICSET_HPP #include #include #include "Exceptions/CreatureException.hpp" #include "Statistic.hpp" namespace CreatureLib::Library { template class StatisticSet { protected: T _health; T _physicalAttack; T _physicalDefense; T _magicalAttack; T _magicalDefense; T _speed; public: StatisticSet(T health, T physicalAttack, T physicalDefense, T magicalAttack, T magicalDefense, T speed) noexcept : _health(health), _physicalAttack(physicalAttack), _physicalDefense(physicalDefense), _magicalAttack(magicalAttack), _magicalDefense(magicalDefense), _speed(speed) {} StatisticSet() noexcept : _health(0), _physicalAttack(0), _physicalDefense(0), _magicalAttack(0), _magicalDefense(0), _speed(0) {} inline T GetHealth() const noexcept { return _health; } inline T GetPhysicalAttack() const noexcept { return _physicalAttack; } inline T GetPhysicalDefense() const noexcept { return _physicalDefense; } inline T GetMagicalAttack() const noexcept { return _magicalAttack; } inline T GetMagicalDefense() const noexcept { return _magicalDefense; } inline T GetSpeed() const noexcept { return _speed; } [[nodiscard]] inline T GetStat(Statistic stat) const { switch (stat) { case CreatureLib::Library::Statistic::Health: return _health; case CreatureLib::Library::Statistic::PhysicalAttack: return _physicalAttack; case CreatureLib::Library::Statistic::PhysicalDefense: return _physicalDefense; case CreatureLib::Library::Statistic::MagicalAttack: return _magicalAttack; case CreatureLib::Library::Statistic::MagicalDefense: return _magicalDefense; case CreatureLib::Library::Statistic::Speed: return _speed; default: NOT_REACHABLE; } } inline void SetStat(Statistic stat, T value) { switch (stat) { case CreatureLib::Library::Statistic::Health: _health = value; break; case CreatureLib::Library::Statistic::PhysicalAttack: _physicalAttack = value; break; case CreatureLib::Library::Statistic::PhysicalDefense: _physicalDefense = value; break; case CreatureLib::Library::Statistic::MagicalAttack: _magicalAttack = value; break; case CreatureLib::Library::Statistic::MagicalDefense: _magicalDefense = value; break; case CreatureLib::Library::Statistic::Speed: _speed = value; break; default: NOT_REACHABLE; } } inline void IncreaseStatBy(Statistic stat, T amount) { switch (stat) { case CreatureLib::Library::Statistic::Health: _health += amount; break; case CreatureLib::Library::Statistic::PhysicalAttack: _physicalAttack += amount; break; case CreatureLib::Library::Statistic::PhysicalDefense: _physicalDefense += amount; break; case CreatureLib::Library::Statistic::MagicalAttack: _magicalAttack += amount; break; case CreatureLib::Library::Statistic::MagicalDefense: _magicalDefense += amount; break; case CreatureLib::Library::Statistic::Speed: _speed += amount; break; default: NOT_REACHABLE; } } inline void DecreaseStatBy(Statistic stat, T amount) { switch (stat) { case CreatureLib::Library::Statistic::Health: _health -= amount; break; case CreatureLib::Library::Statistic::PhysicalAttack: _physicalAttack -= amount; break; case CreatureLib::Library::Statistic::PhysicalDefense: _physicalDefense -= amount; break; case CreatureLib::Library::Statistic::MagicalAttack: _magicalAttack -= amount; break; case CreatureLib::Library::Statistic::MagicalDefense: _magicalDefense -= amount; break; case CreatureLib::Library::Statistic::Speed: _speed -= amount; break; default: NOT_REACHABLE; } } }; } #endif // CREATURELIB_STATISTICSET_HPP