PkmnLib/CInterface/Library/PokemonForme.cpp

35 lines
1.9 KiB
C++

#include "../../src/Library/Species/PokemonForme.hpp"
#include "../../src/Library/Species/LearnableMoves.hpp"
#include "../Core.hpp"
using namespace PkmnLib::Library;
export_func PokemonForme*
PkmnLib_PokemonForme_Construct(const char* name, float height, float weight, uint32_t baseExperience, uint8_t types[],
size_t typeLength, uint16_t baseHealth, uint16_t baseAttack, uint16_t baseDefense,
uint16_t baseMagicalAttack, uint16_t baseMagicalDefense, uint16_t baseSpeed,
const CreatureLib::Library::Talent* talents[], size_t talentsLength,
const CreatureLib::Library::Talent* secretTalents[], size_t secretTalentsLength,
const LearnableMoves* attacks, const char* flags[], size_t flagsCount) {
std::unordered_set<uint32_t> conversedFlags(flagsCount);
for (size_t i = 0; i < flagsCount; i++) {
conversedFlags.insert(ArbUt::StringView::CalculateHash(flags[i]));
}
auto talentsWrapped = ArbUt::List<ArbUt::BorrowedPtr<const CreatureLib::Library::Talent>>(talentsLength);
for (size_t i = 0; i < talentsLength; i++) {
talentsWrapped.Append(talents[i]);
}
auto secretTalentsWrapped =
ArbUt::List<ArbUt::BorrowedPtr<const CreatureLib::Library::Talent>>(secretTalentsLength);
for (size_t i = 0; i < secretTalentsLength; i++) {
secretTalentsWrapped.Append(secretTalents[i]);
}
return new PokemonForme(ArbUt::StringView(name), height, weight, baseExperience,
ArbUt::List<uint8_t>(types, types + typeLength),
CreatureLib::Library::StatisticSet<uint16_t>(
baseHealth, baseAttack, baseDefense, baseMagicalAttack, baseMagicalDefense, baseSpeed),
talentsWrapped, secretTalentsWrapped, attacks, conversedFlags);
}