From ae4d8f5e12da94b9cdc700940f0fa66fdf43de43 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Fri, 27 Dec 2019 12:19:38 +0100 Subject: [PATCH] Removes some variables that are better handled in implementations. --- src/Battling/Library/BattleStatCalculator.cpp | 7 ++--- src/Battling/Models/CreateCreature.cpp | 4 +-- src/Battling/Models/Creature.cpp | 14 +++------- src/Battling/Models/Creature.hpp | 7 +---- src/Library/CreatureData/CreatureSpecies.cpp | 4 +-- src/Library/CreatureData/CreatureSpecies.hpp | 3 +-- tests/LibraryTests/CreatureTests.cpp | 26 ------------------- tests/TestLibrary/TestLibrary.cpp | 2 +- 8 files changed, 13 insertions(+), 54 deletions(-) diff --git a/src/Battling/Library/BattleStatCalculator.cpp b/src/Battling/Library/BattleStatCalculator.cpp index fe29e52..87fdddd 100644 --- a/src/Battling/Library/BattleStatCalculator.cpp +++ b/src/Battling/Library/BattleStatCalculator.cpp @@ -24,16 +24,13 @@ Core::StatisticSet Battling::BattleStatCalculator::CalculateBoostedSta uint32_t CalculateHealthStat(Battling::Creature* creature) { auto level = creature->GetLevel(); - auto a = - (creature->GetBaseStat(Core::Statistic::Health) + creature->GetStatPotential(Core::Statistic::Health)) * 2 + - floor(sqrt(creature->GetStatExperience(Core::Statistic::Health) / 4.0)) * level; + auto a = (creature->GetBaseStat(Core::Statistic::Health)) * 2 * level; return floor(a / 100) + level + 10; } uint32_t CalculateOtherStat(Battling::Creature* creature, Core::Statistic stat) { auto level = creature->GetLevel(); - auto a = (creature->GetBaseStat(stat) + creature->GetStatPotential(stat)) * 2 + - floor(sqrt(creature->GetStatExperience(stat) / 4.0)) * level; + auto a = (creature->GetBaseStat(stat)) * 2 * level; return floor(a / 100) + 10; } diff --git a/src/Battling/Models/CreateCreature.cpp b/src/Battling/Models/CreateCreature.cpp index 96eedcc..60a5c4e 100644 --- a/src/Battling/Models/CreateCreature.cpp +++ b/src/Battling/Models/CreateCreature.cpp @@ -111,6 +111,6 @@ Creature* CreateCreature::Create() { auto kv = _attacks[i]; attacks[i] = new LearnedAttack(std::get<0>(kv), std::get<1>(kv)); } - return new Creature(_library, species, variant, _level, experience, statExperience, statPotential, identifier, - gender, _coloring, heldItem, _nickname, talent, attacks); + return new Creature(_library, species, variant, _level, experience, identifier, gender, _coloring, heldItem, + _nickname, talent, attacks); } diff --git a/src/Battling/Models/Creature.cpp b/src/Battling/Models/Creature.cpp index 3f82a84..cfa6ccd 100644 --- a/src/Battling/Models/Creature.cpp +++ b/src/Battling/Models/Creature.cpp @@ -7,14 +7,12 @@ using namespace CreatureLib; Battling::Creature::Creature(const BattleLibrary* library, const Library::CreatureSpecies* species, - const Library::SpeciesVariant* variant, uint8_t level, uint32_t experience, - Core::StatisticSet statExp, Core::StatisticSet statPotential, - uint32_t uid, Library::Gender gender, uint8_t coloring, const Library::Item* heldItem, + const Library::SpeciesVariant* variant, uint8_t level, uint32_t experience, uint32_t uid, + Library::Gender gender, uint8_t coloring, const Library::Item* heldItem, std::string nickname, int8_t talent, std::vector attacks) : _library(library), __Species(species), __Variant(variant), __Level(level), __Experience(experience), - __StatExperience(statExp), __StatPotential(statPotential), __UniqueIdentifier(uid), __Gender(gender), - __Coloring(coloring), __HeldItem(heldItem), _nickname(std::move(nickname)), _talentIndex(talent), - _hasOverridenTalent(false), _attacks(std::move(attacks)) { + __UniqueIdentifier(uid), __Gender(gender), __Coloring(coloring), __HeldItem(heldItem), + _nickname(std::move(nickname)), _talentIndex(talent), _hasOverridenTalent(false), _attacks(std::move(attacks)) { RecalculateFlatStats(); __CurrentHealth = GetBoostedStat(Core::Statistic::Health); _activeTalent = _library->LoadScript(ScriptResolver::ScriptCategory::Talent, GetActiveTalent()); @@ -59,10 +57,6 @@ uint32_t Battling::Creature::GetBoostedStat(Core::Statistic stat) const { return uint32_t Battling::Creature::GetBaseStat(Core::Statistic stat) const { return __Variant->GetStatistic(stat); } -uint32_t Battling::Creature::GetStatPotential(Core::Statistic stat) const { return __StatPotential.GetStat(stat); } - -uint32_t Battling::Creature::GetStatExperience(Core::Statistic stat) const { return __StatExperience.GetStat(stat); } - int8_t Battling::Creature::GetStatBoost(Core::Statistic stat) const { return _statBoost.GetStat(stat); } void Battling::Creature::RecalculateFlatStats() { diff --git a/src/Battling/Models/Creature.hpp b/src/Battling/Models/Creature.hpp index 8f515e0..95e50cc 100644 --- a/src/Battling/Models/Creature.hpp +++ b/src/Battling/Models/Creature.hpp @@ -24,8 +24,6 @@ namespace CreatureLib::Battling { GetProperty(uint8_t, Level); GetProperty(uint32_t, Experience); - GetProperty(Core::StatisticSet, StatExperience); - GetProperty(Core::StatisticSet, StatPotential); GetProperty(uint32_t, UniqueIdentifier); GetProperty(Library::Gender, Gender); GetProperty(uint8_t, Coloring); @@ -58,8 +56,7 @@ namespace CreatureLib::Battling { public: Creature(const BattleLibrary* library, const Library::CreatureSpecies* species, - const Library::SpeciesVariant* variant, uint8_t level, uint32_t experience, - Core::StatisticSet statExp, Core::StatisticSet statPotential, uint32_t uid, + const Library::SpeciesVariant* variant, uint8_t level, uint32_t experience, uint32_t uid, Library::Gender gender, uint8_t coloring, const Library::Item* heldItem, std::string nickname, int8_t talent, std::vector attacks); @@ -104,8 +101,6 @@ namespace CreatureLib::Battling { [[nodiscard]] uint32_t GetFlatStat(Core::Statistic stat) const; [[nodiscard]] uint32_t GetBoostedStat(Core::Statistic stat) const; [[nodiscard]] uint32_t GetBaseStat(Core::Statistic stat) const; - [[nodiscard]] uint32_t GetStatPotential(Core::Statistic stat) const; - [[nodiscard]] uint32_t GetStatExperience(Core::Statistic stat) const; [[nodiscard]] int8_t GetStatBoost(Core::Statistic stat) const; void RecalculateFlatStats(); void RecalculateBoostedStats(); diff --git a/src/Library/CreatureData/CreatureSpecies.cpp b/src/Library/CreatureData/CreatureSpecies.cpp index 96c48a3..9eeac8a 100644 --- a/src/Library/CreatureData/CreatureSpecies.cpp +++ b/src/Library/CreatureData/CreatureSpecies.cpp @@ -3,9 +3,9 @@ using namespace CreatureLib::Library; CreatureSpecies::CreatureSpecies(uint16_t id, std::string name, const SpeciesVariant* defaultVariant, float genderRatio, - std::string growthRate, uint8_t captureRate, uint8_t baseHappiness) + std::string growthRate, uint8_t captureRate) : __Id(id), __GenderRate(genderRatio), __GrowthRate(std::move(growthRate)), __CaptureRate(captureRate), - __BaseHappiness(baseHappiness), _variants({{"default", defaultVariant}}), _name(std::move(name)) {} + _variants({{"default", defaultVariant}}), _name(std::move(name)) {} const SpeciesVariant* CreatureSpecies::GetVariant(const std::string& key) const { return _variants.at(key); } diff --git a/src/Library/CreatureData/CreatureSpecies.hpp b/src/Library/CreatureData/CreatureSpecies.hpp index 1500134..088e4d0 100644 --- a/src/Library/CreatureData/CreatureSpecies.hpp +++ b/src/Library/CreatureData/CreatureSpecies.hpp @@ -16,7 +16,6 @@ namespace CreatureLib::Library { GetProperty(float, GenderRate); GetProperty(std::string, GrowthRate); GetProperty(uint8_t, CaptureRate); - GetProperty(uint8_t, BaseHappiness); private: std::unordered_map _variants; @@ -24,7 +23,7 @@ namespace CreatureLib::Library { public: CreatureSpecies(uint16_t id, std::string name, const SpeciesVariant* defaultVariant, float genderRatio, - std::string growthRate, uint8_t captureRate, uint8_t baseHappiness); + std::string growthRate, uint8_t captureRate); ~CreatureSpecies() { for (auto v : _variants) diff --git a/tests/LibraryTests/CreatureTests.cpp b/tests/LibraryTests/CreatureTests.cpp index f20d37a..8aacb2e 100644 --- a/tests/LibraryTests/CreatureTests.cpp +++ b/tests/LibraryTests/CreatureTests.cpp @@ -38,30 +38,4 @@ TEST_CASE("Get creature nickname when unset", "[Library]") { delete creature; } -TEST_CASE("Get creature stat potentials when unset", "[Library]") { - auto library = TestLibrary::Get(); - auto creature = CreateCreature(library, "testSpecies1", 1).Create(); - auto potentials = creature->GetStatPotential(); - REQUIRE(potentials.GetHealth() == 0); - REQUIRE(potentials.GetPhysicalAttack() == 0); - REQUIRE(potentials.GetPhysicalDefense() == 0); - REQUIRE(potentials.GetMagicalAttack() == 0); - REQUIRE(potentials.GetMagicalDefense() == 0); - REQUIRE(potentials.GetSpeed() == 0); - delete creature; -} - -TEST_CASE("Get creature stat experience when unset", "[Library]") { - auto library = TestLibrary::Get(); - auto creature = CreateCreature(library, "testSpecies1", 1).Create(); - auto experiences = creature->GetStatExperience(); - REQUIRE(experiences.GetHealth() == 0); - REQUIRE(experiences.GetPhysicalAttack() == 0); - REQUIRE(experiences.GetPhysicalDefense() == 0); - REQUIRE(experiences.GetMagicalAttack() == 0); - REQUIRE(experiences.GetMagicalDefense() == 0); - REQUIRE(experiences.GetSpeed() == 0); - delete creature; -} - #endif \ No newline at end of file diff --git a/tests/TestLibrary/TestLibrary.cpp b/tests/TestLibrary/TestLibrary.cpp index 6000eba..98e93ed 100644 --- a/tests/TestLibrary/TestLibrary.cpp +++ b/tests/TestLibrary/TestLibrary.cpp @@ -27,7 +27,7 @@ SpeciesLibrary* TestLibrary::BuildSpeciesLibrary() { 0, "testSpecies1", new SpeciesVariant("default", 1, 1, 10, {0, 1}, StatisticSet(10, 10, 10, 10, 10, 10), {"testTalent"}, {"testSecretTalent"}, new LearnableAttacks(100)), - 0.5f, "testGrowthRate", 5, 100)); + 0.5f, "testGrowthRate", 5)); return l; }