CreatureLib/CInterface/Library/SpeciesVariant.cpp

53 lines
2.9 KiB
C++
Raw Normal View History

#include "../../src/Library/CreatureData/SpeciesVariant.hpp"
#include "../Core.hpp"
using namespace CreatureLib::Library;
export SpeciesVariant* CreatureLib_SpeciesVariant_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 LearnableAttacks* attacks) {
2020-05-26 16:31:06 +00:00
auto talentsWrapped = ArbUt::List<ArbUt::CaseInsensitiveConstString>(talentsLength);
for (size_t i = 0; i < talentsLength; i++) {
2020-05-26 16:31:06 +00:00
talentsWrapped.Append(ArbUt::CaseInsensitiveConstString(talents[i]));
}
2020-05-26 16:31:06 +00:00
auto secretTalentsWrapped = ArbUt::List<ArbUt::CaseInsensitiveConstString>(secretTalentsLength);
for (size_t i = 0; i < secretTalentsLength; i++) {
2020-05-26 16:31:06 +00:00
secretTalentsWrapped.Append(ArbUt::CaseInsensitiveConstString(secretTalents[i]));
}
2020-05-26 16:31:06 +00:00
return new SpeciesVariant(ArbUt::CaseInsensitiveConstString(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);
}
export void CreatureLib_SpeciesVariant_Destruct(SpeciesVariant* p) { delete p; }
#define SIMPLE_GET_FUNC(type, name, returnType) \
export returnType CreatureLib_##type##_##name(const CreatureLib::Library::type* p) { return p->name(); }
export const char* CreatureLib_SpeciesVariant_GetName(SpeciesVariant* p) { return p->GetName().c_str(); }
SIMPLE_GET_FUNC(SpeciesVariant, GetHeight, float);
SIMPLE_GET_FUNC(SpeciesVariant, GetWeight, float);
SIMPLE_GET_FUNC(SpeciesVariant, GetBaseExperience, uint32_t);
SIMPLE_GET_FUNC(SpeciesVariant, GetTypeCount, size_t);
export uint8_t CreatureLib_SpeciesVariant_GetType(SpeciesVariant* p, size_t index) { return p->GetType(index); }
2020-05-02 18:03:18 +00:00
export uint16_t CreatureLib_SpeciesVariant_GetStatistic(SpeciesVariant* p, CreatureLib::Library::Statistic stat) {
return p->GetStatistic(stat);
}
SIMPLE_GET_FUNC(SpeciesVariant, GetTalentCount, size_t);
SIMPLE_GET_FUNC(SpeciesVariant, GetSecretTalentCount, size_t);
export uint8_t CreatureLib_SpeciesVariant_GetTalent(SpeciesVariant* p, bool secret, uint8_t index, const char*& out) {
Try(out = p->GetTalent(TalentIndex(secret, index)).c_str();)
2020-03-02 13:01:56 +00:00
}
export const LearnableAttacks* CreatureLib_SpeciesVariant_GetLearnableAttacks(SpeciesVariant* p) {
return p->GetLearnableAttacks().get();
}
#undef SIMPLE_GET_FUNC