Adds C Interface for Item choice
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
0e7b9ae1fd
commit
a8c80a3c66
|
@ -1,5 +1,6 @@
|
||||||
#include "../../src/Battling/TurnChoices/AttackTurnChoice.hpp"
|
#include "../../src/Battling/TurnChoices/AttackTurnChoice.hpp"
|
||||||
#include "../../src/Battling/TurnChoices/FleeTurnChoice.hpp"
|
#include "../../src/Battling/TurnChoices/FleeTurnChoice.hpp"
|
||||||
|
#include "../../src/Battling/TurnChoices/ItemTurnChoice.hpp"
|
||||||
#include "../../src/Battling/TurnChoices/PassTurnChoice.hpp"
|
#include "../../src/Battling/TurnChoices/PassTurnChoice.hpp"
|
||||||
#include "../../src/Battling/TurnChoices/SwitchTurnChoice.hpp"
|
#include "../../src/Battling/TurnChoices/SwitchTurnChoice.hpp"
|
||||||
#include "../Core.hpp"
|
#include "../Core.hpp"
|
||||||
|
@ -11,13 +12,24 @@ export_func AttackTurnChoice* CreatureLib_AttackTurnChoice_Construct(Creature* u
|
||||||
}
|
}
|
||||||
export_func void CreatureLib_AttackTurnChoice_Destruct(AttackTurnChoice* p) { delete p; }
|
export_func void CreatureLib_AttackTurnChoice_Destruct(AttackTurnChoice* p) { delete p; }
|
||||||
export_func FleeTurnChoice* CreatureLib_FleeTurnChoice_Construct(Creature* user) { return new FleeTurnChoice(user); }
|
export_func FleeTurnChoice* CreatureLib_FleeTurnChoice_Construct(Creature* user) { return new FleeTurnChoice(user); }
|
||||||
export_func void CreatureLib_FleeTurnChoice_Destruct(AttackTurnChoice* p) { delete p; }
|
export_func void CreatureLib_FleeTurnChoice_Destruct(FleeTurnChoice* p) { delete p; }
|
||||||
export_func PassTurnChoice* CreatureLib_PassTurnChoice_Construct(Creature* user) { return new PassTurnChoice(user); }
|
export_func PassTurnChoice* CreatureLib_PassTurnChoice_Construct(Creature* user) { return new PassTurnChoice(user); }
|
||||||
export_func void CreatureLib_PassTurnChoice_Destruct(AttackTurnChoice* p) { delete p; }
|
export_func void CreatureLib_PassTurnChoice_Destruct(PassTurnChoice* p) { delete p; }
|
||||||
export_func SwitchTurnChoice* CreatureLib_SwitchTurnChoice_Construct(Creature* user, Creature* newCreature) {
|
export_func SwitchTurnChoice* CreatureLib_SwitchTurnChoice_Construct(Creature* user, Creature* newCreature) {
|
||||||
return new SwitchTurnChoice(user, newCreature);
|
return new SwitchTurnChoice(user, newCreature);
|
||||||
}
|
}
|
||||||
export_func void CreatureLib_SwitchTurnChoice_Destruct(AttackTurnChoice* p) { delete p; }
|
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; }
|
||||||
|
|
||||||
SIMPLE_GET_FUNC(BaseTurnChoice, GetKind, TurnChoiceKind)
|
SIMPLE_GET_FUNC(BaseTurnChoice, GetKind, TurnChoiceKind)
|
||||||
BORROWED_GET_FUNC(BaseTurnChoice, GetUser, Creature*)
|
BORROWED_GET_FUNC(BaseTurnChoice, GetUser, Creature*)
|
||||||
|
@ -35,4 +47,7 @@ export_func u8 CreatureLib_AttackTurnChoice_GetTargetCreatureIndex(const AttackT
|
||||||
return p->GetTarget().GetCreatureIndex();
|
return p->GetTarget().GetCreatureIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
OPTIONAL_GET_FUNC(SwitchTurnChoice, GetNewCreature, Creature*)
|
OPTIONAL_GET_FUNC(SwitchTurnChoice, GetNewCreature, Creature*)
|
||||||
|
|
||||||
|
SIMPLE_GET_FUNC(ItemTurnChoice, GetKind, TurnChoiceKind)
|
||||||
|
BORROWED_GET_FUNC(ItemTurnChoice, GetItem, const CreatureLib::Library::Item*)
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace CreatureLib::Battling {
|
||||||
std::optional<CreatureIndex> _target;
|
std::optional<CreatureIndex> _target;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ItemTurnChoice(ArbUt::BorrowedPtr<Creature> user, const ArbUt::BorrowedPtr<Library::Item>& item,
|
ItemTurnChoice(ArbUt::BorrowedPtr<Creature> user, const ArbUt::BorrowedPtr<const Library::Item>& item,
|
||||||
const std::optional<CreatureIndex>& target)
|
const std::optional<CreatureIndex>& target)
|
||||||
: BaseTurnChoice(user), _item(item), _target(target) {}
|
: BaseTurnChoice(user), _item(item), _target(target) {}
|
||||||
~ItemTurnChoice() override = default;
|
~ItemTurnChoice() override = default;
|
||||||
|
@ -19,6 +19,14 @@ namespace CreatureLib::Battling {
|
||||||
|
|
||||||
[[nodiscard]] const ArbUt::BorrowedPtr<const Library::Item>& GetItem() const noexcept { return _item; }
|
[[nodiscard]] const ArbUt::BorrowedPtr<const Library::Item>& GetItem() const noexcept { return _item; }
|
||||||
[[nodiscard]] const std::optional<CreatureIndex>& GetTarget() const noexcept { return _target; }
|
[[nodiscard]] const std::optional<CreatureIndex>& GetTarget() const noexcept { return _target; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
size_t ScriptCount() const override { return GetUser()->ScriptCount(); }
|
||||||
|
void GetActiveScripts(ArbUt::List<ScriptWrapper>& scripts) override {
|
||||||
|
GetOwnScripts(scripts);
|
||||||
|
GetUser()->GetActiveScripts(scripts);
|
||||||
|
}
|
||||||
|
void GetOwnScripts(ArbUt::List<ScriptWrapper>&) override {}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue