CreatureLib/CInterface/Battling/Battle.cpp

67 lines
3.6 KiB
C++

#include "../../src/Battling/Models/Battle.hpp"
#define export extern "C"
using namespace CreatureLib::Battling;
export Battle* CreatureLib_Battle_Construct(const BattleLibrary* library, BattleParty* partyArr[],
size_t numberOfParties, bool canFlee, uint8_t numberOfSides,
uint8_t creaturesPerSide) {
List<BattleParty*> parties(partyArr, partyArr + numberOfParties);
return new Battle(library, parties, canFlee, numberOfSides, creaturesPerSide);
}
export void CreatureLib_Battle_Destruct(const Battle* p) { delete p; }
export const BattleLibrary* CreatureLib_Battle_GetLibrary(const Battle* p) { return p->GetLibrary(); }
export bool CreatureLib_Battle_CanUse(Battle* p, const BaseTurnChoice* turnChoice) { return p->CanUse(turnChoice); }
export bool CreatureLib_Battle_TrySetChoice(Battle* p, BaseTurnChoice* turnChoice) {
return p->TrySetChoice(turnChoice);
}
export bool CreatureLib_Battle_CanFlee(const Battle* p) { return p->CanFlee(); }
export void CreatureLib_Battle_CheckChoicesSetAndRun(Battle* p) { p->CheckChoicesSetAndRun(); }
export ChoiceQueue* CreatureLib_Battle_GetCurrentTurnQueue(const Battle* p) { return p->GetCurrentTurnQueue(); }
export BattleRandom* CreatureLib_Battle_GetRandom(Battle* p) { return p->GetRandom(); }
export bool CreatureLib_Battle_CreatureInField(const Battle* p, Creature* c) { return p->CreatureInField(c); }
export Creature* CreatureLib_Battle_GetCreature(const Battle* p, uint8_t side, uint8_t target) {
return p->GetCreature(side, target);
}
export void CreatureLib_Battle_ForceRecall(Battle* p, uint8_t side, uint8_t target) { p->ForceRecall(side, target); }
export void CreatureLib_Battle_SwitchCreature(Battle* p, uint8_t side, uint8_t target, Creature* c) {
p->SwitchCreature(side, target, c);
}
export bool CreatureLib_Battle_CanSlotBeFilled(const Battle* p, uint8_t side, uint8_t target) {
return p->CanSlotBeFilled(side, target);
}
export void CreatureLib_Battle_ValidateBattleState(Battle* p) { p->ValidateBattleState(); }
export bool CreatureLib_Battle_HasEnded(const Battle* p) { return p->HasEnded(); }
export bool CreatureLib_Battle_HasConclusiveResult(const Battle* p) { return p->GetResult().IsConclusiveResult(); }
export bool CreatureLib_Battle_GetWinningSide(const Battle* p) { return p->GetResult().GetWinningSide(); }
export size_t CreatureLib_Battle_GetSidesCount(const Battle* p) { return p->GetSides().Count(); }
export BattleSide* const* CreatureLib_Battle_GetSides(const Battle* p) { return p->GetSides().RawData(); }
export Script* CreatureLib_Battle_GetVolatileScript(Battle* p, const char* key) {
return p->GetVolatileScript(ConstString::GetHash(key));
}
export void CreatureLib_Battle_AddVolatileScriptByName(Battle* p, const char* key) {
p->AddVolatileScript(ConstString(key));
}
export void CreatureLib_Battle_AddVolatileScript(Battle* p, Script* script) { p->AddVolatileScript(script); }
export void CreatureLib_Battle_RemoveVolatileScript(Battle* p, const char* key) {
p->RemoveVolatileScript(ConstString::GetHash(key));
}
export void CreatureLib_Battle_RemoveVolatileScriptWithScript(Battle* p, Script* script) {
p->RemoveVolatileScript(script);
}
export bool CreatureLib_Battle_HasVolatileScript(Battle* p, const char* key) {
return p->HasVolatileScript(ConstString::GetHash(key));
}
export void CreatureLib_Battle_RegisterEventListener(Battle* p, void (*func)(const EventData*)) {
p->RegisterEventListener(func);
}
export void CreatureLib_Battle_TriggerEventListener(Battle* p, EventData* data) { p->TriggerEventListener(data); }