PkmnLib/CInterface/Library/PokemonSpecies.cpp

41 lines
2.3 KiB
C++
Raw Normal View History

2020-04-16 13:04:53 +00:00
#include "../../src/Library/Species/PokemonSpecies.hpp"
#include "../Core.hpp"
using namespace PkmnLib::Library;
2022-04-02 11:03:11 +00:00
export_func uint8_t PkmnLib_PokemonSpecies_Construct(const PokemonSpecies*& out, uint16_t id, const char* name,
const PokemonForme* defaultForme, float genderRatio,
2020-08-08 16:41:27 +00:00
const char* growthRate, uint8_t captureRate, uint8_t baseHappiness,
2020-08-10 16:03:01 +00:00
const char* const* eggGroupsRaw, size_t eggGroupsLength,
const char* flags[], size_t flagsCount) {
2020-08-08 16:41:27 +00:00
Try(
2020-08-10 16:03:01 +00:00
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);
2020-08-08 16:41:27 +00:00
auto cGrowthRate = ArbUt::StringView(growthRate);
out = new PokemonSpecies(id, cName, defaultForme, genderRatio, cGrowthRate, captureRate, baseHappiness,
2020-08-10 16:03:01 +00:00
eggGroups, conversedFlags);)
2020-04-16 13:04:53 +00:00
}
2022-04-02 11:03:11 +00:00
export_func void PkmnLib_PokemonSpecies_Destruct(const PokemonSpecies* p) { delete p; }
2020-04-16 13:04:53 +00:00
SIMPLE_GET_FUNC(PokemonSpecies, GetBaseHappiness, uint8_t);
2022-04-02 11:03:11 +00:00
export_func void PkmnLib_PokemonSpecies_AddEvolution(PokemonSpecies* p, EvolutionData* evo) { p->AddEvolution(evo); }
2020-04-16 13:04:53 +00:00
2022-04-02 11:03:11 +00:00
export_func size_t PkmnLib_PokemonSpecies_GetEvolutionCount(const PokemonSpecies* p) { return p->GetEvolutions().Count(); }
2020-04-16 13:04:53 +00:00
2022-04-02 11:03:11 +00:00
export_func uint8_t PkmnLib_PokemonSpecies_GetEvolution(const PokemonSpecies* p, size_t index, const EvolutionData*& out) {
Try(out = p->GetEvolutions().At(index).GetRaw());
}
2022-04-02 11:03:11 +00:00
export_func uint8_t PkmnLib_PokemonSpecies_GetEvolutions(const PokemonSpecies* p, const EvolutionData* const*& out) {
Try(out = p->GetEvolutions().RawData());
2020-08-08 16:41:27 +00:00
}
2022-04-02 11:03:11 +00:00
export_func size_t PkmnLib_PokemonSpecies_GetEggGroupCount(const PokemonSpecies* p) { return p->GetEggGroups().Count(); }
export_func const char* PkmnLib_PokemonSpecies_GetEggGroup(const PokemonSpecies* p, size_t index) {
2020-08-08 16:41:27 +00:00
return p->GetEggGroups()[index].c_str();
2020-04-16 13:04:53 +00:00
}