diff --git a/src/Core/StatisticSet.hpp b/src/Core/StatisticSet.hpp index 7fe0606..659adc0 100644 --- a/src/Core/StatisticSet.hpp +++ b/src/Core/StatisticSet.hpp @@ -7,8 +7,7 @@ #include "Statistic.hpp" namespace CreatureLib::Core { - template - class StatisticSet { + template class StatisticSet { protected: T _health; T _physicalAttack; @@ -39,8 +38,8 @@ namespace CreatureLib::Core { case MagicalAttack: return _magicalAttack; case MagicalDefense: return _magicalDefense; case Speed: return _speed; + default: throw NotReachableException(); } - throw NotReachableException(); } inline void SetStat(Statistic stat, T value) { @@ -51,8 +50,8 @@ namespace CreatureLib::Core { case MagicalAttack: _magicalAttack = value; case MagicalDefense: _magicalDefense = value; case Speed: _speed = value; + default: throw NotReachableException(); } - throw NotReachableException(); } inline void IncreaseStatBy(Statistic stat, T amount) { @@ -63,8 +62,8 @@ namespace CreatureLib::Core { case MagicalAttack: _magicalAttack += amount; case MagicalDefense: _magicalDefense += amount; case Speed: _speed += amount; + default: throw NotReachableException(); } - throw NotReachableException(); } inline void DecreaseStatBy(Statistic stat, T amount) { switch (stat) { @@ -74,10 +73,10 @@ namespace CreatureLib::Core { case MagicalAttack: _magicalAttack -= amount; case MagicalDefense: _magicalDefense -= amount; case Speed: _speed -= amount; + default: throw NotReachableException(); } - throw NotReachableException(); } }; } -#endif //CREATURELIB_STATISTICSET_HPP +#endif // CREATURELIB_STATISTICSET_HPP diff --git a/tests/LibraryTests/CreatureTests.cpp b/tests/LibraryTests/CreatureTests.cpp index 8aacb2e..1166647 100644 --- a/tests/LibraryTests/CreatureTests.cpp +++ b/tests/LibraryTests/CreatureTests.cpp @@ -38,4 +38,12 @@ TEST_CASE("Get creature nickname when unset", "[Library]") { delete creature; } +TEST_CASE("Increase creature stat boost", "[Library]") { + auto library = TestLibrary::Get(); + auto creature = CreateCreature(library, "testSpecies1", 1).Create(); + creature->ChangeStatBoost(CreatureLib::Core::Statistic::PhysicalAttack, 6); + REQUIRE(creature->GetStatBoost(CreatureLib::Core::Statistic::PhysicalAttack) == 6); + delete creature; +} + #endif \ No newline at end of file