Removes some variables that are better handled in implementations.
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Deukhoofd 2019-12-27 12:19:38 +01:00
parent 72c51c6513
commit ae4d8f5e12
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
8 changed files with 13 additions and 54 deletions

View File

@ -24,16 +24,13 @@ Core::StatisticSet<uint32_t> 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;
}

View File

@ -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);
}

View File

@ -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<uint8_t> statExp, Core::StatisticSet<uint8_t> 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<LearnedAttack*> 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() {

View File

@ -24,8 +24,6 @@ namespace CreatureLib::Battling {
GetProperty(uint8_t, Level);
GetProperty(uint32_t, Experience);
GetProperty(Core::StatisticSet<uint8_t>, StatExperience);
GetProperty(Core::StatisticSet<uint8_t>, 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<uint8_t> statExp, Core::StatisticSet<uint8_t> 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<LearnedAttack*> 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();

View File

@ -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); }

View File

@ -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<std::string, const SpeciesVariant*> _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)

View File

@ -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

View File

@ -27,7 +27,7 @@ SpeciesLibrary* TestLibrary::BuildSpeciesLibrary() {
0, "testSpecies1",
new SpeciesVariant("default", 1, 1, 10, {0, 1}, StatisticSet<uint16_t>(10, 10, 10, 10, 10, 10),
{"testTalent"}, {"testSecretTalent"}, new LearnableAttacks(100)),
0.5f, "testGrowthRate", 5, 100));
0.5f, "testGrowthRate", 5));
return l;
}