Defensive programming.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
34
CInterface/Library/PokemonForme.cpp
Normal file
34
CInterface/Library/PokemonForme.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
#include "../../src/Library/Species/PokemonForme.hpp"
|
||||
#include "../../src/Library/Species/LearnableMoves.hpp"
|
||||
#include "../Core.hpp"
|
||||
using namespace PkmnLib::Library;
|
||||
|
||||
export 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 char* talents[], size_t talentsLength,
|
||||
const char* 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::StringView>(talentsLength);
|
||||
for (size_t i = 0; i < talentsLength; i++) {
|
||||
talentsWrapped.Append(ArbUt::StringView(talents[i]));
|
||||
}
|
||||
auto secretTalentsWrapped = ArbUt::List<ArbUt::StringView>(secretTalentsLength);
|
||||
for (size_t i = 0; i < secretTalentsLength; i++) {
|
||||
secretTalentsWrapped.Append(ArbUt::StringView(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);
|
||||
}
|
||||
Reference in New Issue
Block a user