CreatureLib/CInterface/Battling/TurnChoices.cpp

54 lines
3.0 KiB
C++
Raw Normal View History

2020-03-11 11:22:13 +00:00
#include "../../src/Battling/TurnChoices/AttackTurnChoice.hpp"
#include "../../src/Battling/TurnChoices/FleeTurnChoice.hpp"
2022-04-23 16:26:46 +00:00
#include "../../src/Battling/TurnChoices/ItemTurnChoice.hpp"
2020-03-11 11:22:13 +00:00
#include "../../src/Battling/TurnChoices/PassTurnChoice.hpp"
#include "../../src/Battling/TurnChoices/SwitchTurnChoice.hpp"
#include "../Core.hpp"
2020-03-11 11:22:13 +00:00
using namespace CreatureLib::Battling;
2022-04-02 10:33:26 +00:00
export_func AttackTurnChoice* CreatureLib_AttackTurnChoice_Construct(Creature* user, LearnedAttack* attack,
u8 sideIndex, u8 targetIndex) {
2020-03-11 11:22:13 +00:00
return new AttackTurnChoice(user, attack, CreatureIndex(sideIndex, targetIndex));
}
2022-04-02 10:33:26 +00:00
export_func void CreatureLib_AttackTurnChoice_Destruct(AttackTurnChoice* p) { delete p; }
export_func FleeTurnChoice* CreatureLib_FleeTurnChoice_Construct(Creature* user) { return new FleeTurnChoice(user); }
2022-04-23 16:26:46 +00:00
export_func void CreatureLib_FleeTurnChoice_Destruct(FleeTurnChoice* p) { delete p; }
2022-04-02 10:33:26 +00:00
export_func PassTurnChoice* CreatureLib_PassTurnChoice_Construct(Creature* user) { return new PassTurnChoice(user); }
2022-04-23 16:26:46 +00:00
export_func void CreatureLib_PassTurnChoice_Destruct(PassTurnChoice* p) { delete p; }
2022-04-02 10:33:26 +00:00
export_func SwitchTurnChoice* CreatureLib_SwitchTurnChoice_Construct(Creature* user, Creature* newCreature) {
2020-03-11 11:22:13 +00:00
return new SwitchTurnChoice(user, newCreature);
}
2022-04-23 16:26:46 +00:00
export_func void CreatureLib_SwitchTurnChoice_Destruct(SwitchTurnChoice* p) { delete p; }
export_func ItemTurnChoice* CreatureLib_ItemTurnChoice_ConstructWithoutTarget(Creature* user,
CreatureLib::Library::Item* item) {
return new ItemTurnChoice(user, item, {});
}
export_func ItemTurnChoice* CreatureLib_ItemTurnChoice_ConstructWithTarget(Creature* user,
const CreatureLib::Library::Item* item,
u8 targetSide, u8 targetIndex) {
auto index = std::optional(CreatureIndex(targetSide, targetIndex));
return new ItemTurnChoice(user, item, index);
}
export_func void CreatureLib_ItemTurnChoice_Destruct(SwitchTurnChoice* p) { delete p; }
2020-03-11 11:22:13 +00:00
SIMPLE_GET_FUNC(BaseTurnChoice, GetKind, TurnChoiceKind)
BORROWED_GET_FUNC(BaseTurnChoice, GetUser, Creature*)
2020-03-11 11:22:13 +00:00
BORROWED_GET_FUNC(AttackTurnChoice, GetAttack, LearnedAttack*)
2020-03-11 11:22:13 +00:00
SIMPLE_GET_FUNC(AttackTurnChoice, GetKind, TurnChoiceKind)
2022-04-02 10:33:26 +00:00
export_func u8 CreatureLib_AttackTurnChoice_GetPriority(i8& out, AttackTurnChoice* p) { Try(out = p->GetPriority()); }
SMART_GET_FUNC(AttackTurnChoice, GetAttackScript, BattleScript*)
2022-04-02 10:33:26 +00:00
export_func u8 CreatureLib_AttackTurnChoice_GetTargetSideIndex(const AttackTurnChoice* p) {
2020-03-11 11:22:13 +00:00
return p->GetTarget().GetSideIndex();
}
2022-04-02 10:33:26 +00:00
export_func u8 CreatureLib_AttackTurnChoice_GetTargetCreatureIndex(const AttackTurnChoice* p) {
2020-03-11 11:22:13 +00:00
return p->GetTarget().GetCreatureIndex();
}
2022-04-23 16:26:46 +00:00
OPTIONAL_GET_FUNC(SwitchTurnChoice, GetNewCreature, Creature*)
SIMPLE_GET_FUNC(ItemTurnChoice, GetKind, TurnChoiceKind)
BORROWED_GET_FUNC(ItemTurnChoice, GetItem, const CreatureLib::Library::Item*)