CreatureLib/CInterface/Battling/BattleSide.cpp

70 lines
2.9 KiB
C++
Raw Normal View History

2020-04-04 15:03:06 +00:00
#include "../../src/Battling/Models/BattleSide.hpp"
#include "../Core.hpp"
2020-04-04 15:03:06 +00:00
using namespace CreatureLib::Battling;
2022-04-02 10:33:26 +00:00
export_func BattleSide* CreatureLib_BattleSide_Construct(u8 index, Battle* battle, u8 creaturesPerSide) {
2020-04-04 15:03:06 +00:00
return new BattleSide(index, battle, creaturesPerSide);
}
2022-04-02 10:33:26 +00:00
export_func void CreatureLib_BattleSide_Destruct(BattleSide* p) { delete p; }
2020-04-04 15:03:06 +00:00
2022-04-02 10:33:26 +00:00
export_func Battle* CreatureLib_BattleSide_GetBattle(BattleSide* p) { return p->GetBattle(); }
export_func bool CreatureLib_BattleSide_AllChoicesSet(BattleSide* p) { return p->AllChoicesSet(); }
2020-04-04 15:03:06 +00:00
2022-04-02 10:33:26 +00:00
export_func u8 CreatureLib_BattleSide_AllPossibleSlotsFilled(bool& out, BattleSide* p) {
2020-04-04 15:03:06 +00:00
Try(out = p->AllPossibleSlotsFilled());
}
2022-04-02 10:33:26 +00:00
export_func u8 CreatureLib_BattleSide_SetChoice(BattleSide* p, BaseTurnChoice* choice) { Try(p->SetChoice(choice);) }
2020-04-04 15:03:06 +00:00
2022-04-02 10:33:26 +00:00
export_func void CreatureLib_BattleSide_ResetChoices(BattleSide* p) { p->ResetChoices(); }
2020-04-04 15:03:06 +00:00
2022-04-02 10:33:26 +00:00
export_func u8 CreatureLib_BattleSide_SetCreature(BattleSide* p, Creature* creature, u8 index) {
2020-04-04 15:03:06 +00:00
Try(p->SetCreature(creature, index));
}
2022-04-02 10:33:26 +00:00
export_func u8 CreatureLib_BattleSide_GetCreature(Creature*& out, BattleSide* p, u8 index) {
Try(out = p->GetCreature(index).GetValue());
2020-04-04 15:03:06 +00:00
}
2022-04-02 10:33:26 +00:00
export_func u8 CreatureLib_BattleSide_GetSideIndex(BattleSide* p) { return p->GetSideIndex(); }
export_func u8 CreatureLib_BattleSide_GetCreatureIndex(u8& out, BattleSide* p, Creature* c) {
2020-04-04 15:03:06 +00:00
Try(out = p->GetCreatureIndex(c));
}
2022-04-02 10:33:26 +00:00
export_func u8 CreatureLib_BattleSide_MarkSlotAsUnfillable(BattleSide* p, Creature* c) {
Try(p->MarkSlotAsUnfillable(c));
}
2020-04-04 15:03:06 +00:00
2022-04-02 10:33:26 +00:00
export_func bool CreatureLib_BattleSide_IsDefeated(BattleSide* p) { return p->IsDefeated(); }
export_func bool CreatureLib_BattleSide_HasFled(BattleSide* p) { return p->HasFled(); }
export_func void CreatureLib_BattleSide_MarkAsFled(BattleSide* p) { p->MarkAsFled(); }
2022-04-02 10:33:26 +00:00
export_func u8 CreatureLib_BattleSide_SwapPositions(u8& out, BattleSide* p, u8 a, u8 b) {
Try(out = p->SwapPositions(a, b);)
}
2022-04-02 10:33:26 +00:00
export_func BattleScript* CreatureLib_BattleSide_GetVolatileScript(BattleSide* p, const char* key) {
auto v = p->GetVolatileScript(ArbUt::StringView::CalculateHash(key));
if (!v.HasValue()) {
return nullptr;
}
return v.GetValue();
}
2022-04-02 10:33:26 +00:00
export_func u8 CreatureLib_BattleSide_AddVolatileScriptByName(BattleSide* p, const char* key) {
Try(p->AddVolatileScript(ArbUt::StringView(key));)
}
2022-04-02 10:33:26 +00:00
export_func u8 CreatureLib_BattleSide_AddVolatileScript(BattleSide* p, BattleScript* script) {
Try(p->AddVolatileScript(script);)
}
2022-04-02 10:33:26 +00:00
export_func u8 CreatureLib_BattleSide_RemoveVolatileScript(BattleSide* p, const char* key) {
Try(p->RemoveVolatileScript(ArbUt::StringView::CalculateHash(key));)
}
2022-04-02 10:33:26 +00:00
export_func u8 CreatureLib_BattleSide_RemoveVolatileScriptWithScript(BattleSide* p, BattleScript* script) {
Try(p->RemoveVolatileScript(script);)
}
2022-04-02 10:33:26 +00:00
export_func bool CreatureLib_BattleSide_HasVolatileScript(BattleSide* p, const char* key) {
return p->HasVolatileScript(ArbUt::StringView::CalculateHash(key));
}