Add support for Egg Groups.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
2a884a0a8b
commit
ca087a7ed8
|
@ -4,9 +4,16 @@ 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,
|
||||||
Try(auto cName = ArbUt::StringView(name); auto cGrowthRate = ArbUt::StringView(growthRate);
|
const char* const* eggGroupsRaw, size_t eggGroupsLength) {
|
||||||
out = new PokemonSpecies(id, cName, defaultForme, genderRatio, cGrowthRate, captureRate, baseHappiness);)
|
|
||||||
|
Try(
|
||||||
|
ArbUt::List<ArbUt::StringView> eggGroups(eggGroupsLength);
|
||||||
|
for (size_t i = 0; i < eggGroupsLength; i++) { eggGroups.Append(ArbUt::StringView(eggGroupsRaw[i])); }
|
||||||
|
auto cName = ArbUt::StringView(name);
|
||||||
|
auto cGrowthRate = ArbUt::StringView(growthRate);
|
||||||
|
out = new PokemonSpecies(id, cName, defaultForme, genderRatio, cGrowthRate, captureRate, baseHappiness,
|
||||||
|
eggGroups);)
|
||||||
}
|
}
|
||||||
|
|
||||||
export void PkmnLib_PokemonSpecies_Destruct(const PokemonSpecies* p) { delete p; }
|
export void PkmnLib_PokemonSpecies_Destruct(const PokemonSpecies* p) { delete p; }
|
||||||
|
@ -22,4 +29,11 @@ export uint8_t PkmnLib_PokemonSpecies_GetEvolution(const PokemonSpecies* p, size
|
||||||
|
|
||||||
export uint8_t PkmnLib_PokemonSpecies_GetEvolutions(const PokemonSpecies* p, const EvolutionData* const*& out) {
|
export uint8_t PkmnLib_PokemonSpecies_GetEvolutions(const PokemonSpecies* p, const EvolutionData* const*& out) {
|
||||||
Try(out = p->GetEvolutions().RawData());
|
Try(out = p->GetEvolutions().RawData());
|
||||||
|
}
|
||||||
|
|
||||||
|
export size_t PkmnLib_PokemonSpecies_GetEggGroupCount(const PokemonSpecies* p) {
|
||||||
|
return p->GetEggGroups().Count();
|
||||||
|
}
|
||||||
|
export const char* PkmnLib_PokemonSpecies_GetEggGroup(const PokemonSpecies* p, size_t index){
|
||||||
|
return p->GetEggGroups()[index].c_str();
|
||||||
}
|
}
|
|
@ -10,12 +10,14 @@ namespace PkmnLib::Library {
|
||||||
private:
|
private:
|
||||||
uint8_t _baseHappiness;
|
uint8_t _baseHappiness;
|
||||||
ArbUt::UniquePtrList<const EvolutionData> _evolutions;
|
ArbUt::UniquePtrList<const EvolutionData> _evolutions;
|
||||||
|
ArbUt::List<ArbUt::StringView> _eggGroups;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PokemonSpecies(uint16_t id, const ArbUt::StringView& name, const PokemonForme* defaultForme, float genderRatio,
|
PokemonSpecies(uint16_t id, const ArbUt::StringView& name, const PokemonForme* defaultForme, float genderRatio,
|
||||||
const ArbUt::StringView& growthRate, uint8_t captureRate, uint8_t baseHappiness) noexcept
|
const ArbUt::StringView& growthRate, uint8_t captureRate, uint8_t baseHappiness,
|
||||||
|
const ArbUt::List<ArbUt::StringView>& eggGroups) noexcept
|
||||||
: CreatureSpecies(id, name, defaultForme, genderRatio, growthRate, captureRate),
|
: CreatureSpecies(id, name, defaultForme, genderRatio, growthRate, captureRate),
|
||||||
_baseHappiness(baseHappiness) {}
|
_baseHappiness(baseHappiness), _eggGroups(eggGroups) {}
|
||||||
|
|
||||||
~PokemonSpecies() override = default;
|
~PokemonSpecies() override = default;
|
||||||
|
|
||||||
|
@ -41,6 +43,9 @@ namespace PkmnLib::Library {
|
||||||
|
|
||||||
inline void AddEvolution(const EvolutionData* data) noexcept { _evolutions.Append(data); }
|
inline void AddEvolution(const EvolutionData* data) noexcept { _evolutions.Append(data); }
|
||||||
const ArbUt::UniquePtrList<const EvolutionData>& GetEvolutions() const noexcept { return _evolutions; }
|
const ArbUt::UniquePtrList<const EvolutionData>& GetEvolutions() const noexcept { return _evolutions; }
|
||||||
|
|
||||||
|
bool HasEggGroup(const ArbUt::StringView& sv) const noexcept { return _eggGroups.Contains(sv); }
|
||||||
|
const ArbUt::List<ArbUt::StringView>& GetEggGroups() const noexcept { return _eggGroups; }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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));
|
0.5f, "testGrowthRate"_cnc, 100, 100, {"testEggGroup"_cnc}));
|
||||||
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));
|
0.5f, "testGrowthRate"_cnc, 100, 100, {"testEggGroup"_cnc}));
|
||||||
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);
|
0.5f, "testGrowthRate"_cnc, 100, 100, {"testEggGroup"_cnc});
|
||||||
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);
|
0.5f, "testGrowthRate"_cnc, 100, 100, {"testEggGroup"_cnc});
|
||||||
|
|
||||||
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);
|
0.5f, "testGrowthRate"_cnc, 100, 100, {"testEggGroup"_cnc});
|
||||||
|
|
||||||
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);
|
0.5f, "testGrowthRate"_cnc, 100, 100, {"testEggGroup"_cnc});
|
||||||
|
|
||||||
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);
|
0.5f, "testGrowthRate"_cnc, 100, 100, {"testEggGroup"_cnc});
|
||||||
|
|
||||||
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);
|
0.5f, "testGrowthRate"_cnc, 100, 100, {"testEggGroup"_cnc});
|
||||||
|
|
||||||
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);
|
0.5f, "testGrowthRate"_cnc, 100, 100, {"testEggGroup"_cnc});
|
||||||
|
|
||||||
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);
|
0.5f, "testGrowthRate"_cnc, 100, 100, {"testEggGroup"_cnc});
|
||||||
|
|
||||||
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);
|
0.5f, "testGrowthRate"_cnc, 100, 100, {"testEggGroup"_cnc});
|
||||||
|
|
||||||
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);
|
0.5f, "testGrowthRate"_cnc, 100, 100, {"testEggGroup"_cnc});
|
||||||
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);
|
0.5f, "testGrowthRate"_cnc, 100, 100, {"testEggGroup"_cnc});
|
||||||
|
|
||||||
species->AddEvolution(PkmnLib::Library::EvolutionData::CreateLevelEvolution(16, species2));
|
species->AddEvolution(PkmnLib::Library::EvolutionData::CreateLevelEvolution(16, species2));
|
||||||
auto& evolutions = species->GetEvolutions();
|
auto& evolutions = species->GetEvolutions();
|
||||||
|
|
|
@ -11,7 +11,7 @@ PkmnLib::Library::SpeciesLibrary* TestLibrary::BuildSpeciesLibrary() {
|
||||||
"default"_cnc, 1.0f, 1.0f, 236, {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));
|
0.5f, "testGrowthRate"_cnc, 100, 100, {"testEggGroup"_cnc}));
|
||||||
lib->Insert("testSpecies2"_cnc,
|
lib->Insert("testSpecies2"_cnc,
|
||||||
new PkmnLib::Library::PokemonSpecies(
|
new PkmnLib::Library::PokemonSpecies(
|
||||||
2, "testSpecies2"_cnc,
|
2, "testSpecies2"_cnc,
|
||||||
|
@ -19,7 +19,7 @@ PkmnLib::Library::SpeciesLibrary* TestLibrary::BuildSpeciesLibrary() {
|
||||||
"default"_cnc, 1.0f, 1.0f, 306, {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));
|
0.5f, "testGrowthRate"_cnc, 100, 100, {"testEggGroup"_cnc}));
|
||||||
lib->Insert("statTestSpecies1"_cnc,
|
lib->Insert("statTestSpecies1"_cnc,
|
||||||
new PkmnLib::Library::PokemonSpecies(
|
new PkmnLib::Library::PokemonSpecies(
|
||||||
3, "statTestSpecies1"_cnc,
|
3, "statTestSpecies1"_cnc,
|
||||||
|
@ -27,7 +27,7 @@ PkmnLib::Library::SpeciesLibrary* TestLibrary::BuildSpeciesLibrary() {
|
||||||
"default"_cnc, 1.0f, 1.0f, 236, {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));
|
0.5f, "testGrowthRate"_cnc, 100, 100, {"testEggGroup"_cnc}));
|
||||||
lib->Insert("testSpecies3"_cnc,
|
lib->Insert("testSpecies3"_cnc,
|
||||||
new PkmnLib::Library::PokemonSpecies(
|
new PkmnLib::Library::PokemonSpecies(
|
||||||
2, "testSpecies3"_cnc,
|
2, "testSpecies3"_cnc,
|
||||||
|
@ -35,7 +35,7 @@ PkmnLib::Library::SpeciesLibrary* TestLibrary::BuildSpeciesLibrary() {
|
||||||
"default"_cnc, 1.0f, 1.0f, 236, {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));
|
0.5f, "testGrowthRate"_cnc, 100, 100, {"testEggGroup"_cnc}));
|
||||||
|
|
||||||
return lib;
|
return lib;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue