Move experience gain from species to forme.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
d3b0fc1cec
commit
92135a88eb
|
@ -4,12 +4,10 @@ using namespace PkmnLib::Library;
|
||||||
|
|
||||||
export uint8_t PkmnLib_PokemonSpecies_Construct(const PokemonSpecies*& out, uint16_t id, const char* name,
|
export uint8_t PkmnLib_PokemonSpecies_Construct(const PokemonSpecies*& out, uint16_t id, const char* name,
|
||||||
const PokemonForme* defaultForme, float genderRatio,
|
const PokemonForme* defaultForme, float genderRatio,
|
||||||
const char* growthRate, uint8_t captureRate, uint8_t baseHappiness,
|
const char* growthRate, uint8_t captureRate, uint8_t baseHappiness) {
|
||||||
uint16_t experienceGain) {
|
|
||||||
Try(auto cName = Arbutils::CaseInsensitiveConstString(name);
|
Try(auto cName = Arbutils::CaseInsensitiveConstString(name);
|
||||||
auto cGrowthRate = Arbutils::CaseInsensitiveConstString(growthRate);
|
auto cGrowthRate = Arbutils::CaseInsensitiveConstString(growthRate);
|
||||||
out = new PokemonSpecies(id, cName, defaultForme, genderRatio, cGrowthRate, captureRate, baseHappiness,
|
out = new PokemonSpecies(id, cName, defaultForme, genderRatio, cGrowthRate, captureRate, baseHappiness);)
|
||||||
experienceGain);)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export void PkmnLib_PokemonSpecies_Destruct(const PokemonSpecies* p) { delete p; }
|
export void PkmnLib_PokemonSpecies_Destruct(const PokemonSpecies* p) { delete p; }
|
||||||
|
|
|
@ -7,7 +7,7 @@ void PkmnLib::Battling::ExperienceLibrary::HandleExperienceGain(
|
||||||
const std::unordered_set<CreatureLib::Battling::Creature*>& opponents) const {
|
const std::unordered_set<CreatureLib::Battling::Creature*>& opponents) const {
|
||||||
|
|
||||||
auto fainted = dynamic_cast<Pokemon*>(faintedMon);
|
auto fainted = dynamic_cast<Pokemon*>(faintedMon);
|
||||||
auto expGain = fainted->GetPokemonSpecies()->GetExperienceGains();
|
auto expGain = fainted->GetForme()->GetBaseExperience();
|
||||||
auto level = fainted->GetLevel();
|
auto level = fainted->GetLevel();
|
||||||
// TODO exp share
|
// TODO exp share
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define PKMNLIB_POKEMONFORME_HPP
|
#define PKMNLIB_POKEMONFORME_HPP
|
||||||
|
|
||||||
#include <CreatureLib/Library/CreatureData/SpeciesVariant.hpp>
|
#include <CreatureLib/Library/CreatureData/SpeciesVariant.hpp>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
namespace PkmnLib::Library {
|
namespace PkmnLib::Library {
|
||||||
class PokemonForme : public CreatureLib::Library::SpeciesVariant {
|
class PokemonForme : public CreatureLib::Library::SpeciesVariant {
|
||||||
|
|
|
@ -9,14 +9,13 @@ namespace PkmnLib::Library {
|
||||||
private:
|
private:
|
||||||
uint8_t _baseHappiness;
|
uint8_t _baseHappiness;
|
||||||
Arbutils::Collections::List<const EvolutionData*> _evolutions;
|
Arbutils::Collections::List<const EvolutionData*> _evolutions;
|
||||||
uint16_t _experienceGain;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PokemonSpecies(uint16_t id, const Arbutils::CaseInsensitiveConstString& name, const PokemonForme* defaultForme,
|
PokemonSpecies(uint16_t id, const Arbutils::CaseInsensitiveConstString& name, const PokemonForme* defaultForme,
|
||||||
float genderRatio, const Arbutils::CaseInsensitiveConstString& growthRate, uint8_t captureRate,
|
float genderRatio, const Arbutils::CaseInsensitiveConstString& growthRate, uint8_t captureRate,
|
||||||
uint8_t baseHappiness, uint16_t experienceGain) noexcept
|
uint8_t baseHappiness) noexcept
|
||||||
: CreatureSpecies(id, name, defaultForme, genderRatio, growthRate, captureRate),
|
: CreatureSpecies(id, name, defaultForme, genderRatio, growthRate, captureRate),
|
||||||
_baseHappiness(baseHappiness), _experienceGain(experienceGain) {}
|
_baseHappiness(baseHappiness) {}
|
||||||
|
|
||||||
~PokemonSpecies() override {
|
~PokemonSpecies() override {
|
||||||
for (auto evo : _evolutions) {
|
for (auto evo : _evolutions) {
|
||||||
|
@ -42,8 +41,6 @@ namespace PkmnLib::Library {
|
||||||
|
|
||||||
inline void AddEvolution(const EvolutionData* data) noexcept { _evolutions.Append(data); }
|
inline void AddEvolution(const EvolutionData* data) noexcept { _evolutions.Append(data); }
|
||||||
const Arbutils::Collections::List<const EvolutionData*>& GetEvolutions() const noexcept { return _evolutions; }
|
const Arbutils::Collections::List<const EvolutionData*>& GetEvolutions() const noexcept { return _evolutions; }
|
||||||
|
|
||||||
inline uint16_t GetExperienceGains() const noexcept { return _experienceGain; }
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ TEST_CASE("Able to build, destroy and insert library", "library") {
|
||||||
"default"_cnc, 1.0f, 1.0f, 100, {0},
|
"default"_cnc, 1.0f, 1.0f, 100, {0},
|
||||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
|
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
|
||||||
{"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)),
|
{"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||||
0.5f, "testGrowthRate"_cnc, 100, 100, 100));
|
0.5f, "testGrowthRate"_cnc, 100, 100));
|
||||||
delete lib;
|
delete lib;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ TEST_CASE("Able to insert and retrieve from library", "library") {
|
||||||
"default"_cnc, 1.0f, 1.0f, 100, {0},
|
"default"_cnc, 1.0f, 1.0f, 100, {0},
|
||||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
|
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
|
||||||
{"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)),
|
{"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||||
0.5f, "testGrowthRate"_cnc, 100, 100, 100));
|
0.5f, "testGrowthRate"_cnc, 100, 100));
|
||||||
auto val = lib->Get("foo"_cnc);
|
auto val = lib->Get("foo"_cnc);
|
||||||
REQUIRE(val->GetName() == "foo");
|
REQUIRE(val->GetName() == "foo");
|
||||||
delete lib;
|
delete lib;
|
||||||
|
|
|
@ -9,7 +9,7 @@ TEST_CASE("Able to create and destroy species", "library") {
|
||||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||||
new CreatureLib::Library::LearnableAttacks(100)),
|
new CreatureLib::Library::LearnableAttacks(100)),
|
||||||
0.5f, "testGrowthRate"_cnc, 100, 100, 100);
|
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||||
delete species;
|
delete species;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ TEST_CASE("Able to get default forme", "library") {
|
||||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||||
new CreatureLib::Library::LearnableAttacks(100)),
|
new CreatureLib::Library::LearnableAttacks(100)),
|
||||||
0.5f, "testGrowthRate"_cnc, 100, 100, 100);
|
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||||
|
|
||||||
auto forme = species->GetDefaultForme();
|
auto forme = species->GetDefaultForme();
|
||||||
REQUIRE(forme != nullptr);
|
REQUIRE(forme != nullptr);
|
||||||
|
@ -35,7 +35,7 @@ TEST_CASE("Able to get default forme name", "library") {
|
||||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||||
new CreatureLib::Library::LearnableAttacks(100)),
|
new CreatureLib::Library::LearnableAttacks(100)),
|
||||||
0.5f, "testGrowthRate"_cnc, 100, 100, 100);
|
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||||
|
|
||||||
auto forme = species->GetDefaultForme();
|
auto forme = species->GetDefaultForme();
|
||||||
REQUIRE(forme != nullptr);
|
REQUIRE(forme != nullptr);
|
||||||
|
@ -51,7 +51,7 @@ TEST_CASE("Able to get species name", "library") {
|
||||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||||
new CreatureLib::Library::LearnableAttacks(100)),
|
new CreatureLib::Library::LearnableAttacks(100)),
|
||||||
0.5f, "testGrowthRate"_cnc, 100, 100, 100);
|
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||||
|
|
||||||
REQUIRE(species->GetName() == "foo");
|
REQUIRE(species->GetName() == "foo");
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ TEST_CASE("Able to get species id", "library") {
|
||||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||||
new CreatureLib::Library::LearnableAttacks(100)),
|
new CreatureLib::Library::LearnableAttacks(100)),
|
||||||
0.5f, "testGrowthRate"_cnc, 100, 100, 100);
|
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||||
|
|
||||||
REQUIRE(species->GetId() == 1);
|
REQUIRE(species->GetId() == 1);
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ TEST_CASE("Able to get species gender ratio", "library") {
|
||||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||||
new CreatureLib::Library::LearnableAttacks(100)),
|
new CreatureLib::Library::LearnableAttacks(100)),
|
||||||
0.5f, "testGrowthRate"_cnc, 100, 100, 100);
|
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||||
|
|
||||||
REQUIRE(species->GetGenderRate() == 0.5f);
|
REQUIRE(species->GetGenderRate() == 0.5f);
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ TEST_CASE("Able to get species growth rate", "library") {
|
||||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||||
new CreatureLib::Library::LearnableAttacks(100)),
|
new CreatureLib::Library::LearnableAttacks(100)),
|
||||||
0.5f, "testGrowthRate"_cnc, 100, 100, 100);
|
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||||
|
|
||||||
REQUIRE(species->GetGrowthRate() == "testGrowthRate");
|
REQUIRE(species->GetGrowthRate() == "testGrowthRate");
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ TEST_CASE("Able to get species capture rate", "library") {
|
||||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||||
new CreatureLib::Library::LearnableAttacks(100)),
|
new CreatureLib::Library::LearnableAttacks(100)),
|
||||||
0.5f, "testGrowthRate"_cnc, 100, 100, 100);
|
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||||
|
|
||||||
REQUIRE(species->GetCaptureRate() == 100);
|
REQUIRE(species->GetCaptureRate() == 100);
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ TEST_CASE("Able to get species base happiness", "library") {
|
||||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||||
new CreatureLib::Library::LearnableAttacks(100)),
|
new CreatureLib::Library::LearnableAttacks(100)),
|
||||||
0.5f, "testGrowthRate"_cnc, 100, 100, 100);
|
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||||
|
|
||||||
REQUIRE(species->GetBaseHappiness() == 100);
|
REQUIRE(species->GetBaseHappiness() == 100);
|
||||||
|
|
||||||
|
@ -135,14 +135,14 @@ TEST_CASE("Able to set and get evolution", "library") {
|
||||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||||
new CreatureLib::Library::LearnableAttacks(100)),
|
new CreatureLib::Library::LearnableAttacks(100)),
|
||||||
0.5f, "testGrowthRate"_cnc, 100, 100, 100);
|
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||||
auto species2 = new PkmnLib::Library::PokemonSpecies(
|
auto species2 = new PkmnLib::Library::PokemonSpecies(
|
||||||
2, "bar"_cnc,
|
2, "bar"_cnc,
|
||||||
new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0},
|
new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0},
|
||||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||||
new CreatureLib::Library::LearnableAttacks(100)),
|
new CreatureLib::Library::LearnableAttacks(100)),
|
||||||
0.5f, "testGrowthRate"_cnc, 100, 100, 100);
|
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||||
|
|
||||||
species->AddEvolution(PkmnLib::Library::EvolutionData::CreateLevelEvolution(16, species2));
|
species->AddEvolution(PkmnLib::Library::EvolutionData::CreateLevelEvolution(16, species2));
|
||||||
auto evolutions = species->GetEvolutions();
|
auto evolutions = species->GetEvolutions();
|
||||||
|
|
|
@ -8,34 +8,34 @@ PkmnLib::Library::SpeciesLibrary* TestLibrary::BuildSpeciesLibrary() {
|
||||||
new PkmnLib::Library::PokemonSpecies(
|
new PkmnLib::Library::PokemonSpecies(
|
||||||
1, "testSpecies"_cnc,
|
1, "testSpecies"_cnc,
|
||||||
new PkmnLib::Library::PokemonForme(
|
new PkmnLib::Library::PokemonForme(
|
||||||
"default"_cnc, 1.0f, 1.0f, 100, {0},
|
"default"_cnc, 1.0f, 1.0f, 236, {0},
|
||||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
|
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
|
||||||
{"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)),
|
{"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||||
0.5f, "testGrowthRate"_cnc, 100, 100, 236));
|
0.5f, "testGrowthRate"_cnc, 100, 100));
|
||||||
lib->Insert("testSpecies2"_cnc,
|
lib->Insert("testSpecies2"_cnc,
|
||||||
new PkmnLib::Library::PokemonSpecies(
|
new PkmnLib::Library::PokemonSpecies(
|
||||||
2, "testSpecies2"_cnc,
|
2, "testSpecies2"_cnc,
|
||||||
new PkmnLib::Library::PokemonForme(
|
new PkmnLib::Library::PokemonForme(
|
||||||
"default"_cnc, 1.0f, 1.0f, 100, {0},
|
"default"_cnc, 1.0f, 1.0f, 306, {0},
|
||||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
|
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
|
||||||
{"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)),
|
{"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||||
0.5f, "testGrowthRate"_cnc, 100, 100, 306));
|
0.5f, "testGrowthRate"_cnc, 100, 100));
|
||||||
lib->Insert("statTestSpecies1"_cnc,
|
lib->Insert("statTestSpecies1"_cnc,
|
||||||
new PkmnLib::Library::PokemonSpecies(
|
new PkmnLib::Library::PokemonSpecies(
|
||||||
3, "statTestSpecies1"_cnc,
|
3, "statTestSpecies1"_cnc,
|
||||||
new PkmnLib::Library::PokemonForme(
|
new PkmnLib::Library::PokemonForme(
|
||||||
"default"_cnc, 1.0f, 1.0f, 100, {0},
|
"default"_cnc, 1.0f, 1.0f, 236, {0},
|
||||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
|
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
|
||||||
{"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)),
|
{"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||||
0.5f, "testGrowthRate"_cnc, 100, 100, 236));
|
0.5f, "testGrowthRate"_cnc, 100, 100));
|
||||||
lib->Insert("testSpecies3"_cnc,
|
lib->Insert("testSpecies3"_cnc,
|
||||||
new PkmnLib::Library::PokemonSpecies(
|
new PkmnLib::Library::PokemonSpecies(
|
||||||
2, "testSpecies3"_cnc,
|
2, "testSpecies3"_cnc,
|
||||||
new PkmnLib::Library::PokemonForme(
|
new PkmnLib::Library::PokemonForme(
|
||||||
"default"_cnc, 1.0f, 1.0f, 100, {0, 4},
|
"default"_cnc, 1.0f, 1.0f, 236, {0, 4},
|
||||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
|
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
|
||||||
{"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)),
|
{"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||||
0.5f, "testGrowthRate"_cnc, 100, 100, 236));
|
0.5f, "testGrowthRate"_cnc, 100, 100));
|
||||||
|
|
||||||
return lib;
|
return lib;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue