PkmnLib/CInterface/Library/PokemonForme.cpp

35 lines
1.9 KiB
C++
Raw Normal View History

2020-08-17 16:23:25 +00:00
#include "../../src/Library/Species/PokemonForme.hpp"
#include "../../src/Library/Species/LearnableMoves.hpp"
#include "../Core.hpp"
using namespace PkmnLib::Library;
2022-04-02 11:03:11 +00:00
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) {
2020-08-17 16:23:25 +00:00
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);
2020-08-17 16:23:25 +00:00
for (size_t i = 0; i < talentsLength; i++) {
talentsWrapped.Append(talents[i]);
2020-08-17 16:23:25 +00:00
}
auto secretTalentsWrapped =
ArbUt::List<ArbUt::BorrowedPtr<const CreatureLib::Library::Talent>>(secretTalentsLength);
2020-08-17 16:23:25 +00:00
for (size_t i = 0; i < secretTalentsLength; i++) {
secretTalentsWrapped.Append(secretTalents[i]);
2020-08-17 16:23:25 +00:00
}
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);
}