2020-03-09 09:16:57 +00:00
|
|
|
#include "../../src/Battling/Models/Battle.hpp"
|
2020-07-31 08:51:03 +00:00
|
|
|
#include "../Core.hpp"
|
2020-03-09 09:16:57 +00:00
|
|
|
using namespace CreatureLib::Battling;
|
|
|
|
|
2022-04-02 10:33:26 +00:00
|
|
|
export_func u8 CreatureLib_Battle_Construct(Battle*& out, const BattleLibrary* library, BattleParty* partyArr[],
|
|
|
|
size_t numberOfParties, bool canFlee, u8 numberOfSides, u8 creaturesPerSide,
|
|
|
|
uint_fast32_t randomSeed) {
|
2020-05-26 16:31:06 +00:00
|
|
|
Try(ArbUt::List<BattleParty*> parties(partyArr, partyArr + numberOfParties);
|
2020-07-26 08:16:25 +00:00
|
|
|
out = new Battle(library, parties, canFlee, numberOfSides, creaturesPerSide, randomSeed);)
|
2020-03-09 09:16:57 +00:00
|
|
|
}
|
|
|
|
|
2022-04-02 10:33:26 +00:00
|
|
|
export_func void CreatureLib_Battle_Destruct(const Battle* p) { delete p; }
|
2020-03-09 09:16:57 +00:00
|
|
|
|
2022-04-02 10:33:26 +00:00
|
|
|
export_func const BattleLibrary* CreatureLib_Battle_GetLibrary(const Battle* p) { return p->GetLibrary().GetRaw(); }
|
|
|
|
export_func u8 CreatureLib_Battle_CanUse(bool& out, Battle* p, BaseTurnChoice* turnChoice) {
|
2020-03-25 18:07:36 +00:00
|
|
|
Try(out = p->CanUse(turnChoice);)
|
|
|
|
}
|
2022-04-02 10:33:26 +00:00
|
|
|
export_func u8 CreatureLib_Battle_TrySetChoice(bool& out, Battle* p, BaseTurnChoice* turnChoice) {
|
2020-03-25 18:07:36 +00:00
|
|
|
Try(out = p->TrySetChoice(turnChoice);)
|
2020-03-09 09:49:15 +00:00
|
|
|
}
|
2022-04-02 10:33:26 +00:00
|
|
|
export_func bool CreatureLib_Battle_CanFlee(const Battle* p) { return p->CanFlee(); }
|
|
|
|
export_func u8 CreatureLib_Battle_CheckChoicesSetAndRun(Battle* p) { Try(p->CheckChoicesSetAndRun();) }
|
|
|
|
export_func u32 CreatureLib_Battle_GetCurrentTurn(Battle* p) { return p->GetCurrentTurn(); }
|
|
|
|
export_func u32 CreatureLib_Battle_GetCreaturesPerSide(Battle* p) { return p->GetCreaturesPerSide(); }
|
2020-03-09 09:49:15 +00:00
|
|
|
|
2022-04-02 10:33:26 +00:00
|
|
|
export_func ChoiceQueue* CreatureLib_Battle_GetCurrentTurnQueue(const Battle* p) {
|
2020-07-07 13:33:43 +00:00
|
|
|
return p->GetCurrentTurnQueue().GetRaw();
|
2020-05-31 17:01:45 +00:00
|
|
|
}
|
2022-04-02 10:33:26 +00:00
|
|
|
export_func BattleRandom* CreatureLib_Battle_GetRandom(Battle* p) { return p->GetRandom(); }
|
|
|
|
export_func u8 CreatureLib_Battle_CreatureInField(bool& out, const Battle* p, Creature* c) {
|
2020-03-25 18:07:36 +00:00
|
|
|
Try(out = p->CreatureInField(c);)
|
|
|
|
}
|
2022-04-02 10:33:26 +00:00
|
|
|
export_func u8 CreatureLib_Battle_GetCreature(Creature*& out, const Battle* p, u8 side, u8 target) {
|
2020-12-12 11:22:48 +00:00
|
|
|
Try(out = p->GetCreature(side, target).GetValue();)
|
2020-03-09 09:16:57 +00:00
|
|
|
}
|
|
|
|
|
2022-04-02 10:33:26 +00:00
|
|
|
export_func u8 CreatureLib_Battle_ForceRecall(Battle* p, u8 side, u8 target) { Try(p->ForceRecall(side, target);) }
|
|
|
|
export_func u8 CreatureLib_Battle_SwitchCreature(Battle* p, u8 side, u8 target, Creature* c) {
|
2020-03-25 18:07:36 +00:00
|
|
|
Try(p->SwitchCreature(side, target, c);)
|
2020-03-09 09:16:57 +00:00
|
|
|
}
|
2022-04-02 10:33:26 +00:00
|
|
|
export_func u8 CreatureLib_Battle_CanSlotBeFilled(bool& out, const Battle* p, u8 side, u8 target) {
|
2020-03-25 18:07:36 +00:00
|
|
|
Try(out = p->CanSlotBeFilled(side, target);)
|
|
|
|
}
|
2022-04-02 10:33:26 +00:00
|
|
|
export_func u8 CreatureLib_Battle_ValidateBattleState(Battle* p) { Try(p->ValidateBattleState();) }
|
|
|
|
export_func bool CreatureLib_Battle_HasEnded(const Battle* p) { return p->HasEnded(); }
|
2020-03-09 09:16:57 +00:00
|
|
|
|
2022-04-02 10:33:26 +00:00
|
|
|
export_func bool CreatureLib_Battle_HasConclusiveResult(const Battle* p) { return p->GetResult().IsConclusiveResult(); }
|
|
|
|
export_func bool CreatureLib_Battle_GetWinningSide(const Battle* p) { return p->GetResult().GetWinningSide(); }
|
2020-03-09 09:16:57 +00:00
|
|
|
|
2022-04-02 10:33:26 +00:00
|
|
|
export_func size_t CreatureLib_Battle_GetSidesCount(const Battle* p) { return p->GetSides().Count(); }
|
|
|
|
export_func BattleSide* const* CreatureLib_Battle_GetSides(const Battle* p) { return p->GetSides().RawData(); }
|
2020-03-09 09:16:57 +00:00
|
|
|
|
2022-04-02 10:33:26 +00:00
|
|
|
export_func size_t CreatureLib_Battle_GetPartiesCount(const Battle* p) { return p->GetParties().Count(); }
|
|
|
|
export_func BattleParty* const* CreatureLib_Battle_GetParties(const Battle* p) {
|
2020-05-26 16:31:06 +00:00
|
|
|
return reinterpret_cast<BattleParty* const*>(p->GetParties().RawData());
|
|
|
|
}
|
2020-05-24 10:57:12 +00:00
|
|
|
|
2022-04-02 10:33:26 +00:00
|
|
|
export_func BattleScript* CreatureLib_Battle_GetVolatileScript(Battle* p, const char* key) {
|
2020-12-12 11:22:48 +00:00
|
|
|
auto v = p->GetVolatileScript(ArbUt::StringView::CalculateHash(key));
|
2021-03-27 19:20:49 +00:00
|
|
|
if (!v.HasValue()) {
|
2020-12-12 11:22:48 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
2021-03-27 19:20:49 +00:00
|
|
|
return v.GetValue();
|
2020-03-09 09:16:57 +00:00
|
|
|
}
|
2022-04-02 10:33:26 +00:00
|
|
|
export_func u8 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
|
|
|
}
|
2022-04-02 10:33:26 +00:00
|
|
|
export_func u8 CreatureLib_Battle_AddVolatileScript(Battle* p, BattleScript* script) {
|
|
|
|
Try(p->AddVolatileScript(script);)
|
|
|
|
}
|
2020-03-09 09:16:57 +00:00
|
|
|
|
2022-04-02 10:33:26 +00:00
|
|
|
export_func u8 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
|
|
|
}
|
2022-04-02 10:33:26 +00:00
|
|
|
export_func u8 CreatureLib_Battle_RemoveVolatileScriptWithScript(Battle* p, BattleScript* script) {
|
2020-03-25 18:07:36 +00:00
|
|
|
Try(p->RemoveVolatileScript(script);)
|
2020-03-09 09:49:15 +00:00
|
|
|
}
|
2022-04-02 10:33:26 +00:00
|
|
|
export_func 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
|
|
|
}
|
|
|
|
|
2022-04-02 10:33:26 +00:00
|
|
|
export_func u8 CreatureLib_Battle_RegisterEventListener(Battle* p, void (*func)(const EventData*)) {
|
2020-03-25 18:07:36 +00:00
|
|
|
Try(p->RegisterEventListener(func);)
|
2020-08-14 15:24:12 +00:00
|
|
|
}
|
2022-04-02 10:33:26 +00:00
|
|
|
export_func const HistoryHolder* CreatureLib_Battle_GetHistory(Battle* p) { return p->GetHistory(); }
|
2020-08-28 10:24:10 +00:00
|
|
|
|
2022-04-02 10:33:26 +00:00
|
|
|
export_func u8 CreatureLib_Battle_EndBattle(Battle* p) { Try(p->EndBattle()) }
|
|
|
|
export_func u8 CreatureLib_Battle_ClearBattle(Battle* p) { Try(p->ClearBattle()) }
|
2020-12-28 12:40:39 +00:00
|
|
|
|
2020-08-28 10:24:10 +00:00
|
|
|
SIMPLE_GET_FUNC(Battle, GetLastTurnTimeMicroseconds, long);
|