diff --git a/src/Library/Creature.cpp b/src/Library/Creature.cpp index 46cd091..93c75c8 100644 --- a/src/Library/Creature.cpp +++ b/src/Library/Creature.cpp @@ -34,3 +34,26 @@ std::string CreatureLib::Library::Creature::GetNickname() const { return __Species->GetName(); return _nickname; } + +int32_t CalculateHealth(const CreatureLib::Library::Creature* creature){ + auto baseStat = creature->GetVariant()->GetStatistic(CreatureLib::Core::Statistic::Health); + auto statPotential = creature->GetStatPotential().GetHealth(); + auto statExperience = creature->GetStatExperience().GetHealth(); + auto level = creature->GetLevel(); + return ((2 * baseStat + statPotential + (statExperience / 4) * level) / 100) + level + 10; +} + +int32_t CalculateStat(const CreatureLib::Library::Creature* creature, CreatureLib::Core::Statistic stat){ + auto baseStat = creature->GetVariant()->GetStatistic(stat); + auto statPotential = creature->GetStatPotential().GetStat(stat); + auto statExperience = creature->GetStatExperience().GetStat(stat); + auto level = creature->GetLevel(); + return ((2 * baseStat + statPotential + (statExperience / 4) * level) / 100) + 5; +} + + +int32_t CreatureLib::Library::Creature::CalculateFullStat(CreatureLib::Core::Statistic stat) const { + if (stat == Core::Statistic::Health) + return CalculateHealth(this); + return CalculateStat(this, stat); +} diff --git a/src/Library/Creature.hpp b/src/Library/Creature.hpp index 5a9d07e..fcd728c 100644 --- a/src/Library/Creature.hpp +++ b/src/Library/Creature.hpp @@ -30,8 +30,11 @@ namespace CreatureLib::Library{ Core::StatisticSet statPotential, uint32_t identifier, Gender gender, uint8_t coloring, const Item* heldItem); + virtual ~Creature(){} + std::string GetTalent() const; std::string GetNickname() const; + virtual int32_t CalculateFullStat(Core::Statistic stat) const; }; } diff --git a/src/Library/DataLibrary.cpp b/src/Library/DataLibrary.cpp index 053aafb..3eec271 100644 --- a/src/Library/DataLibrary.cpp +++ b/src/Library/DataLibrary.cpp @@ -3,10 +3,9 @@ CreatureLib::Library::DataLibrary::DataLibrary(CreatureLib::Library::SpeciesLibrary *species, CreatureLib::Library::AttackLibrary *attacks, CreatureLib::Library::ItemLibrary *items, - CreatureLib::Library::GrowthRateLibrary* growthRates) - :_species(species), _attacks(attacks), _items(items), _growthRates(growthRates) - - { + CreatureLib::Library::GrowthRateLibrary *growthRates) + : _species(species), _attacks(attacks), _items(items), + _growthRates(growthRates){ } diff --git a/src/Library/DataLibrary.hpp b/src/Library/DataLibrary.hpp index 5d788d5..aa36b46 100644 --- a/src/Library/DataLibrary.hpp +++ b/src/Library/DataLibrary.hpp @@ -17,7 +17,12 @@ namespace CreatureLib::Library { const ItemLibrary* _items; const GrowthRateLibrary* _growthRates; public: - DataLibrary(SpeciesLibrary* species, AttackLibrary* attacks, ItemLibrary* items, GrowthRateLibrary* growthRates); + DataLibrary(CreatureLib::Library::SpeciesLibrary *species, + CreatureLib::Library::AttackLibrary *attacks, + CreatureLib::Library::ItemLibrary *items, + CreatureLib::Library::GrowthRateLibrary *growthRates + ); + ~DataLibrary(){ delete _species; delete _attacks; diff --git a/tests/LibraryTests/CreatureTests.cpp b/tests/LibraryTests/CreatureTests.cpp index 57bf90e..38ba070 100644 --- a/tests/LibraryTests/CreatureTests.cpp +++ b/tests/LibraryTests/CreatureTests.cpp @@ -1,6 +1,6 @@ #ifdef TESTS_BUILD #include "../../src/Library/CreateCreature.hpp" -#include "TestLibrary.cpp" +#include "../TestLibrary/TestLibrary.cpp" using namespace CreatureLib::Library; TEST_CASE( "Create basic creature", "[Library]" ) { diff --git a/tests/LibraryTests/TestLibraryTests.cpp b/tests/LibraryTests/TestLibraryTests.cpp index f8ce17c..b3d7595 100644 --- a/tests/LibraryTests/TestLibraryTests.cpp +++ b/tests/LibraryTests/TestLibraryTests.cpp @@ -2,7 +2,7 @@ #define CATCH_CONFIG_MAIN #include "../../extern/catch.hpp" -#include "TestLibrary.cpp" +#include "../TestLibrary/TestLibrary.cpp" TEST_CASE( "Can Create Species Library", "[Library]" ) { auto l = BuildSpeciesLibrary(); diff --git a/tests/LibraryTests/TestLibrary.cpp b/tests/TestLibrary/TestLibrary.cpp similarity index 100% rename from tests/LibraryTests/TestLibrary.cpp rename to tests/TestLibrary/TestLibrary.cpp