diff --git a/CMakeLists.txt b/CMakeLists.txt index e004021..5d23136 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,7 +49,6 @@ elseif (LEVEL_SIZE STREQUAL "32") elseif (LEVEL_SIZE STREQUAL "64") add_definitions(-DLEVEL_U64) message(STATUS "Using level size of 64") - else () message(FATAL_ERROR, "Invalid level size was given.") endif () @@ -87,7 +86,7 @@ target_link_libraries(CreatureLib PUBLIC ${_LIBRARYLINKS} Threads::Threads) if (TESTS) # Create Test executable file(GLOB_RECURSE TEST_FILES "tests/*.cpp" "tests/*.hpp") - add_executable(CreatureLibTests ${TEST_FILES} extern/doctest.hpp tests/BattleTests/EventHookTests.cpp) + add_executable(CreatureLibTests ${TEST_FILES} extern/doctest.hpp) target_link_libraries(CreatureLibTests PUBLIC CreatureLib Arbutils) # Add a definition for the test library diff --git a/src/Library/StatisticSet.hpp b/src/Library/StatisticSet.hpp index 379efe7..f6b6a72 100644 --- a/src/Library/StatisticSet.hpp +++ b/src/Library/StatisticSet.hpp @@ -4,7 +4,11 @@ #include "Statistic.hpp" namespace CreatureLib::Library { - template class StatisticSet { + template concept StatisticSetType = std::is_integral::value; + + /// @brief A class to hold all the different stats a creature can have. + /// @tparam T An integer type that defines the kind the different fields in the set can have. + template class StatisticSet { protected: T _health; T _physicalAttack; @@ -14,19 +18,42 @@ namespace CreatureLib::Library { T _speed; public: + /// @brief Initialises the set with its different values. + /// @param health The amount of health given in the set. + /// @param physicalAttack The amount of physical attack given in the set. + /// @param physicalDefense The amount of physical defense given in the set. + /// @param magicalAttack The amount of magical attack given in the set. + /// @param magicalDefense The amount of magical attack given in the set. + /// @param speed The amount of speed given in the set. 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) {} + /// @brief Initialises the set with 0 as every value. StatisticSet() noexcept : _health(0), _physicalAttack(0), _physicalDefense(0), _magicalAttack(0), _magicalDefense(0), _speed(0) {} + /// @brief Returns the health in the set. + /// @return The health in the set. inline T GetHealth() const noexcept { return _health; } + /// @brief Returns the Physical Attack in the set. + /// @return The Physical Attack in the set. inline T GetPhysicalAttack() const noexcept { return _physicalAttack; } + /// @brief Returns the Physical Defense in the set. + /// @return The Physical Defense in the set. inline T GetPhysicalDefense() const noexcept { return _physicalDefense; } + /// @brief Returns the Magical Attack in the set. + /// @return The Magical Attack in the set. inline T GetMagicalAttack() const noexcept { return _magicalAttack; } + /// @brief Returns the Magical Defense in the set. + /// @return The Magical Defense in the set. inline T GetMagicalDefense() const noexcept { return _magicalDefense; } + /// @brief Returns the Speed in the set. + /// @return The Speed in the set. inline T GetSpeed() const noexcept { return _speed; } + /// @brief Returns a stat given a Statistic enum. + /// @param stat The desired stat. + /// @return The value of the desired stat. [[nodiscard]] inline T GetStat(Statistic stat) const { switch (stat) { case CreatureLib::Library::Statistic::Health: return _health; @@ -39,6 +66,9 @@ namespace CreatureLib::Library { } } + /// @brief Sets a specific stat to a value. + /// @param stat The stat to set. + /// @param value The value to set the stat at. inline void SetStat(Statistic stat, T value) { switch (stat) { case CreatureLib::Library::Statistic::Health: _health = value; break; @@ -51,6 +81,9 @@ namespace CreatureLib::Library { } } + /// @brief Increment a stat by a given amount. + /// @param stat The stat to increment. + /// @param amount The value to increment it by. inline void IncreaseStatBy(Statistic stat, T amount) { switch (stat) { case CreatureLib::Library::Statistic::Health: _health += amount; break; @@ -62,6 +95,10 @@ namespace CreatureLib::Library { default: NOT_REACHABLE; } } + + /// @brief Decrement a stat by a given amount. + /// @param stat The stat to decrement. + /// @param amount The value to decrement it by. inline void DecreaseStatBy(Statistic stat, T amount) { switch (stat) { case CreatureLib::Library::Statistic::Health: _health -= amount; break; diff --git a/src/Precompiled.hxx b/src/Precompiled.hxx index df28684..0b0bc03 100644 --- a/src/Precompiled.hxx +++ b/src/Precompiled.hxx @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include