2020-03-09 09:16:57 +00:00
|
|
|
#include "../../src/Battling/Models/Battle.hpp"
|
2020-03-25 18:07:36 +00:00
|
|
|
#include "../Core.hpp"
|
2020-03-09 09:16:57 +00:00
|
|
|
using namespace CreatureLib::Battling;
|
|
|
|
|
2020-03-25 18:07:36 +00:00
|
|
|
export uint8_t CreatureLib_Battle_Construct(Battle*& out, const BattleLibrary* library, BattleParty* partyArr[],
|
2020-03-09 09:16:57 +00:00
|
|
|
size_t numberOfParties, bool canFlee, uint8_t numberOfSides,
|
|
|
|
uint8_t creaturesPerSide) {
|
2020-05-26 16:31:06 +00:00
|
|
|
Try(ArbUt::List<BattleParty*> parties(partyArr, partyArr + numberOfParties);
|
2020-03-25 18:07:36 +00:00
|
|
|
out = new Battle(library, parties, canFlee, numberOfSides, creaturesPerSide);)
|
2020-03-09 09:16:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export void CreatureLib_Battle_Destruct(const Battle* p) { delete p; }
|
|
|
|
|
2020-05-26 16:31:06 +00:00
|
|
|
export const BattleLibrary* CreatureLib_Battle_GetLibrary(const Battle* p) { return p->GetLibrary().GetRaw(); }
|
2020-05-31 16:00:39 +00:00
|
|
|
export uint8_t CreatureLib_Battle_CanUse(bool& out, Battle* p, BaseTurnChoice* turnChoice) {
|
2020-03-25 18:07:36 +00:00
|
|
|
Try(out = p->CanUse(turnChoice);)
|
|
|
|
}
|
|
|
|
export uint8_t CreatureLib_Battle_TrySetChoice(bool& out, Battle* p, BaseTurnChoice* turnChoice) {
|
|
|
|
Try(out = p->TrySetChoice(turnChoice);)
|
2020-03-09 09:49:15 +00:00
|
|
|
}
|
|
|
|
export bool CreatureLib_Battle_CanFlee(const Battle* p) { return p->CanFlee(); }
|
2020-03-25 18:07:36 +00:00
|
|
|
export uint8_t CreatureLib_Battle_CheckChoicesSetAndRun(Battle* p) { Try(p->CheckChoicesSetAndRun();) }
|
2020-03-09 09:49:15 +00:00
|
|
|
|
2020-05-31 17:01:45 +00:00
|
|
|
export ChoiceQueue* CreatureLib_Battle_GetCurrentTurnQueue(const Battle* p) {
|
|
|
|
return p->GetCurrentTurnQueue().operator->();
|
|
|
|
}
|
2020-03-09 09:49:15 +00:00
|
|
|
export BattleRandom* CreatureLib_Battle_GetRandom(Battle* p) { return p->GetRandom(); }
|
2020-03-25 18:07:36 +00:00
|
|
|
export uint8_t CreatureLib_Battle_CreatureInField(bool& out, const Battle* p, Creature* c) {
|
|
|
|
Try(out = p->CreatureInField(c);)
|
|
|
|
}
|
|
|
|
export uint8_t CreatureLib_Battle_GetCreature(Creature*& out, const Battle* p, uint8_t side, uint8_t target) {
|
2020-06-02 11:06:24 +00:00
|
|
|
Try(out = p->GetCreature(side, target).operator->();)
|
2020-03-09 09:16:57 +00:00
|
|
|
}
|
|
|
|
|
2020-03-25 18:07:36 +00:00
|
|
|
export uint8_t CreatureLib_Battle_ForceRecall(Battle* p, uint8_t side, uint8_t target) {
|
|
|
|
Try(p->ForceRecall(side, target);)
|
2020-03-09 09:16:57 +00:00
|
|
|
}
|
2020-03-25 18:07:36 +00:00
|
|
|
export uint8_t CreatureLib_Battle_SwitchCreature(Battle* p, uint8_t side, uint8_t target, Creature* c) {
|
|
|
|
Try(p->SwitchCreature(side, target, c);)
|
2020-03-09 09:16:57 +00:00
|
|
|
}
|
2020-03-25 18:07:36 +00:00
|
|
|
export uint8_t CreatureLib_Battle_CanSlotBeFilled(bool& out, const Battle* p, uint8_t side, uint8_t target) {
|
|
|
|
Try(out = p->CanSlotBeFilled(side, target);)
|
|
|
|
}
|
|
|
|
export uint8_t CreatureLib_Battle_ValidateBattleState(Battle* p) { Try(p->ValidateBattleState();) }
|
2020-03-09 09:49:15 +00:00
|
|
|
export bool CreatureLib_Battle_HasEnded(const Battle* p) { return p->HasEnded(); }
|
2020-03-09 09:16:57 +00:00
|
|
|
|
2020-03-09 09:49:15 +00:00
|
|
|
export bool CreatureLib_Battle_HasConclusiveResult(const Battle* p) { return p->GetResult().IsConclusiveResult(); }
|
|
|
|
export bool CreatureLib_Battle_GetWinningSide(const Battle* p) { return p->GetResult().GetWinningSide(); }
|
2020-03-09 09:16:57 +00:00
|
|
|
|
2020-03-22 18:21:40 +00:00
|
|
|
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(); }
|
2020-03-09 09:16:57 +00:00
|
|
|
|
2020-05-24 10:57:12 +00:00
|
|
|
export size_t CreatureLib_Battle_GetPartiesCount(const Battle* p) { return p->GetParties().Count(); }
|
2020-05-26 16:31:06 +00:00
|
|
|
export BattleParty* const* CreatureLib_Battle_GetParties(const Battle* p) {
|
|
|
|
return reinterpret_cast<BattleParty* const*>(p->GetParties().RawData());
|
|
|
|
}
|
2020-05-24 10:57:12 +00:00
|
|
|
|
2020-03-09 09:49:15 +00:00
|
|
|
export Script* CreatureLib_Battle_GetVolatileScript(Battle* p, const char* key) {
|
2020-06-26 15:08:23 +00:00
|
|
|
return p->GetVolatileScript(ArbUt::StringView::CalculateHash(key)).GetRaw();
|
2020-03-09 09:16:57 +00:00
|
|
|
}
|
2020-03-25 18:07:36 +00:00
|
|
|
export uint8_t CreatureLib_Battle_AddVolatileScriptByName(Battle* p, const char* key) {
|
2020-06-26 15:08:23 +00:00
|
|
|
Try(p->AddVolatileScript(ArbUt::StringView(key));)
|
2020-03-09 09:49:15 +00:00
|
|
|
}
|
2020-03-25 18:07:36 +00:00
|
|
|
export uint8_t CreatureLib_Battle_AddVolatileScript(Battle* p, Script* script) { Try(p->AddVolatileScript(script);) }
|
2020-03-09 09:16:57 +00:00
|
|
|
|
2020-03-25 18:07:36 +00:00
|
|
|
export uint8_t CreatureLib_Battle_RemoveVolatileScript(Battle* p, const char* key) {
|
2020-06-26 15:08:23 +00:00
|
|
|
Try(p->RemoveVolatileScript(ArbUt::StringView::CalculateHash(key));)
|
2020-03-09 09:16:57 +00:00
|
|
|
}
|
2020-03-25 18:07:36 +00:00
|
|
|
export uint8_t CreatureLib_Battle_RemoveVolatileScriptWithScript(Battle* p, Script* script) {
|
|
|
|
Try(p->RemoveVolatileScript(script);)
|
2020-03-09 09:49:15 +00:00
|
|
|
}
|
|
|
|
export bool CreatureLib_Battle_HasVolatileScript(Battle* p, const char* key) {
|
2020-06-26 15:08:23 +00:00
|
|
|
return p->HasVolatileScript(ArbUt::StringView::CalculateHash(key));
|
2020-03-09 09:16:57 +00:00
|
|
|
}
|
|
|
|
|
2020-03-25 18:07:36 +00:00
|
|
|
export uint8_t CreatureLib_Battle_RegisterEventListener(Battle* p, void (*func)(const EventData*)) {
|
|
|
|
Try(p->RegisterEventListener(func);)
|
|
|
|
}
|
|
|
|
export uint8_t CreatureLib_Battle_TriggerEventListener(Battle* p, EventData* data) {
|
|
|
|
Try(p->TriggerEventListener(data);)
|
2020-05-24 10:57:12 +00:00
|
|
|
}
|