CreatureLib/CInterface/Library/AttackData.cpp

50 lines
2.4 KiB
C++
Raw Permalink Normal View History

#include "../../src/Library/Attacks/AttackData.hpp"
#include "../Core.hpp"
using namespace CreatureLib::Library;
2022-04-02 10:33:26 +00:00
export_func u8 CreatureLib_AttackData_Construct(AttackData*& out, const char* name, u8 type, AttackCategory category,
u8 power, u8 accuracy, u8 baseUsage, AttackTarget target, i8 priority,
float effectChance, const char* effectName,
EffectParameter* effectParameters[], size_t effectParameterCount,
const char* flags[], size_t flagsCount) {
Try({
std::unordered_set<u32> conversedFlags(flagsCount);
for (size_t i = 0; i < flagsCount; i++) {
2020-06-26 15:08:23 +00:00
conversedFlags.insert(ArbUt::StringView::CalculateHash(flags[i]));
}
2020-05-26 16:31:06 +00:00
ArbUt::List<EffectParameter*> effectParameterList(effectParameterCount);
for (size_t i = 0; i < effectParameterCount; i++) {
effectParameterList.Append(effectParameters[i]);
}
2020-06-26 15:08:23 +00:00
auto effect = new SecondaryEffect(effectChance, ArbUt::StringView(effectName), effectParameterList);
2020-06-26 15:08:23 +00:00
out = new AttackData(ArbUt::StringView(name), type, category, power, accuracy, baseUsage, target, priority,
effect, conversedFlags);
})
};
2022-04-02 10:33:26 +00:00
export_func void CreatureLib_AttackData_Destruct(const AttackData* p) { delete p; }
2022-04-02 10:33:26 +00:00
export_func const char* CreatureLib_AttackData_GetName(const AttackData* p) { return p->GetName().c_str(); }
SIMPLE_GET_FUNC(AttackData, GetType, u8);
SIMPLE_GET_FUNC(AttackData, GetCategory, AttackCategory);
SIMPLE_GET_FUNC(AttackData, GetBasePower, u8);
SIMPLE_GET_FUNC(AttackData, GetAccuracy, u8);
SIMPLE_GET_FUNC(AttackData, GetBaseUsages, u8);
SIMPLE_GET_FUNC(AttackData, GetTarget, AttackTarget);
SIMPLE_GET_FUNC(AttackData, GetPriority, i8);
2022-04-02 10:33:26 +00:00
export_func bool CreatureLib_AttackData_HasSecondaryEffect(const AttackData* p) { return p->HasSecondaryEffect(); }
2022-04-02 10:33:26 +00:00
export_func float CreatureLib_AttackData_GetSecondaryEffectChance(const AttackData* p) {
return p->GetSecondaryEffect()->GetChance();
}
2022-04-02 10:33:26 +00:00
export_func const char* CreatureLib_AttackData_GetSecondaryEffectName(const AttackData* p) {
return p->GetSecondaryEffect()->GetEffectName().c_str();
}
2022-04-02 10:33:26 +00:00
export_func bool CreatureLib_AttackData_HasFlag(const AttackData* p, const char* key) {
2020-06-26 15:08:23 +00:00
return p->HasFlag(ArbUt::StringView::CalculateHash(key));
}