CreatureLib/CInterface/Battling/ExecutingAttack.cpp

52 lines
2.5 KiB
C++
Raw Normal View History

2020-04-06 15:05:32 +00:00
#include "../../src/Battling/Models/ExecutingAttack.hpp"
#include "../Core.hpp"
using namespace CreatureLib::Battling;
export uint8_t CreatureLib_ExecutingAttack_Construct(ExecutingAttack*& out, Creature* const* targets,
size_t targetCount, uint8_t numberHits, Creature* user,
LearnedAttack* attack, Script* script) {
Try(auto ls = List<Creature*>(targets, targets + targetCount);
out = new ExecutingAttack(ls, numberHits, user, attack, script);)
}
export void CreatureLib_ExecutingAttack_Destruct(ExecutingAttack* p) { delete p; }
export uint8_t CreatureLib_ExecutingAttack_GetAttackDataForTarget(ExecutingAttack::TargetData*& out, ExecutingAttack* p,
Creature* target) {
Try(out = p->GetAttackDataForTarget(target);)
}
export bool CreatureLib_ExecutingAttack_IsCreatureTarget(ExecutingAttack* p, Creature* target) {
return p->IsCreatureTarget(target);
}
export Creature* CreatureLib_ExecutingAttack_GetUser(ExecutingAttack* p) { return p->GetUser(); }
export LearnedAttack* CreatureLib_ExecutingAttack_GetAttack(ExecutingAttack* p) { return p->GetAttack(); }
export uint8_t CreatureLib_TargetData_GetHit(ExecutingAttack::HitData*& out, ExecutingAttack::TargetData* p,
uint8_t hit) {
Try(out = p->GetHit(hit);)
}
export uint8_t CreatureLib_TargetData_GetNumberOfHits(ExecutingAttack::TargetData* p) { return p->GetNumberOfHits(); }
export bool CreatureLib_TargetData_IsHit(ExecutingAttack::TargetData* p) { return p->IsHit(); }
#define HITDATA_GET_FUNC(name, returnType) \
export returnType CreatureLib_HitData##_##name(const ExecutingAttack::HitData* p) { return p->name(); }
HITDATA_GET_FUNC(IsCritical, bool);
HITDATA_GET_FUNC(GetBasePower, uint8_t);
HITDATA_GET_FUNC(GetEffectiveness, float);
HITDATA_GET_FUNC(GetDamage, uint32_t);
HITDATA_GET_FUNC(GetType, uint8_t);
#define HITDATA_SET_FUNC(name, type) \
export void CreatureLib_HitData##_##name(ExecutingAttack::HitData* p, type val) { p->name(val); }
HITDATA_SET_FUNC(SetCritical, bool);
HITDATA_SET_FUNC(SetBasePower, uint8_t);
HITDATA_SET_FUNC(SetEffectiveness, float);
HITDATA_SET_FUNC(SetDamage, uint32_t);
HITDATA_SET_FUNC(SetType, uint8_t);
#undef HITDATA_GET_FUNC
#undef HITDATA_SET_FUNC