Support flags for species and formes.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-08-10 18:03:01 +02:00
parent de3ad4a9c8
commit 88971dce37
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
5 changed files with 20 additions and 14 deletions

View File

@ -129,6 +129,7 @@ Standard: c++20
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
- Try
TabWidth: 8
UseCRLF: false
UseTab: Never

View File

@ -5,15 +5,19 @@ using namespace PkmnLib::Library;
export uint8_t PkmnLib_PokemonSpecies_Construct(const PokemonSpecies*& out, uint16_t id, const char* name,
const PokemonForme* defaultForme, float genderRatio,
const char* growthRate, uint8_t captureRate, uint8_t baseHappiness,
const char* const* eggGroupsRaw, size_t eggGroupsLength) {
const char* const* eggGroupsRaw, size_t eggGroupsLength,
const char* flags[], size_t flagsCount) {
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);
std::unordered_set<uint32_t> conversedFlags(flagsCount); for (size_t i = 0; i < flagsCount; i++) {
conversedFlags.insert(ArbUt::StringView::CalculateHash(flags[i]));
} 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);)
eggGroups, conversedFlags);)
}
export void PkmnLib_PokemonSpecies_Destruct(const PokemonSpecies* p) { delete p; }
@ -31,9 +35,7 @@ export uint8_t PkmnLib_PokemonSpecies_GetEvolutions(const PokemonSpecies* p, con
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){
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();
}

View File

@ -1,8 +1,11 @@
#include "PokemonForme.hpp"
#include <utility>
PkmnLib::Library::PokemonForme::PokemonForme(const ArbUt::StringView& name, float height, float weight,
uint32_t baseExperience, const ArbUt::List<uint8_t>& types,
CreatureLib::Library::StatisticSet<uint16_t> baseStats,
const ArbUt::List<ArbUt::StringView>& talents,
const ArbUt::List<ArbUt::StringView>& secretTalents,
const CreatureLib::Library::LearnableAttacks* attacks)
: SpeciesVariant(name, height, weight, baseExperience, types, baseStats, talents, secretTalents, attacks) {}
const CreatureLib::Library::LearnableAttacks* attacks,
std::unordered_set<uint32_t> flags)
: SpeciesVariant(name, height, weight, baseExperience, types, baseStats, talents, secretTalents, attacks, std::move(flags)) {}

View File

@ -10,7 +10,7 @@ namespace PkmnLib::Library {
PokemonForme(const ArbUt::StringView& name, float height, float weight, uint32_t baseExperience,
const ArbUt::List<uint8_t>& types, CreatureLib::Library::StatisticSet<uint16_t> baseStats,
const ArbUt::List<ArbUt::StringView>& talents, const ArbUt::List<ArbUt::StringView>& secretTalents,
const CreatureLib::Library::LearnableAttacks* attacks);
const CreatureLib::Library::LearnableAttacks* attacks, std::unordered_set<uint32_t> flags = {});
private:
public:

View File

@ -15,8 +15,8 @@ namespace PkmnLib::Library {
public:
PokemonSpecies(uint16_t id, const ArbUt::StringView& name, const PokemonForme* defaultForme, float genderRatio,
const ArbUt::StringView& growthRate, uint8_t captureRate, uint8_t baseHappiness,
const ArbUt::List<ArbUt::StringView>& eggGroups) noexcept
: CreatureSpecies(id, name, defaultForme, genderRatio, growthRate, captureRate),
const ArbUt::List<ArbUt::StringView>& eggGroups, std::unordered_set<uint32_t> flags = {}) noexcept
: CreatureSpecies(id, name, defaultForme, genderRatio, growthRate, captureRate, flags),
_baseHappiness(baseHappiness), _eggGroups(eggGroups) {}
~PokemonSpecies() override = default;