Deukhoofd 46538092bf
All checks were successful
continuous-integration/drone/push Build is passing
Support for failing a MoveTurnChoice in Angelscript.
2021-11-12 13:00:34 +01:00

104 lines
5.4 KiB
C++

#include "RegisterTurnChoices.hpp"
#include <CreatureLib/Battling/TurnChoices/AttackTurnChoice.hpp>
#include <CreatureLib/Battling/TurnChoices/BaseTurnChoice.hpp>
#include <CreatureLib/Battling/TurnChoices/SwitchTurnChoice.hpp>
#include "../HelperFile.hpp"
#include "../RefCast.hpp"
void RegisterTurnChoices::Register(asIScriptEngine* engine) {
RegisterTurnChoiceKindEnum(engine);
RegisterBaseTurnChoice(engine);
RegisterMoveTurnChoice(engine);
RegisterSwitchTurnChoice(engine);
RegisterFleeTurnChoice(engine);
}
void RegisterTurnChoices::RegisterTurnChoiceKindEnum(asIScriptEngine* engine) {
REGISTER_ENUM(CreatureLib::Battling::TurnChoiceKind, "TurnChoiceKind");
}
void RegisterTurnChoices::RegisterBaseTurnChoice(asIScriptEngine* engine) {
Ensure(engine->RegisterObjectType("BaseTurnChoice", 0, asOBJ_REF | asOBJ_NOCOUNT) >= 0);
REGISTER_EXPLICIT_GETTER("BaseTurnChoice", "TurnChoiceKind get_Kind() const property",
CreatureLib::Battling::BaseTurnChoice, GetKind, CreatureLib::Battling::TurnChoiceKind);
REGISTER_EXPLICIT_GETTER("BaseTurnChoice", "const Pokemon@ get_User() const property",
CreatureLib::Battling::BaseTurnChoice, GetUser,
const ArbUt::BorrowedPtr<CreatureLib::Battling::Creature>&);
}
void RegisterTurnChoices::RegisterMoveTurnChoice(asIScriptEngine* engine) {
int r = engine->RegisterObjectType("MoveTurnChoice", 0, asOBJ_REF | asOBJ_NOCOUNT);
Ensure(r >= 0);
REGISTER_GETTER("MoveTurnChoice", "TurnChoiceKind get_Kind() const property",
CreatureLib::Battling::AttackTurnChoice, GetKind);
REGISTER_EXPLICIT_GETTER("MoveTurnChoice", "Pokemon@ get_User() const property",
CreatureLib::Battling::BaseTurnChoice, GetUser,
const ArbUt::BorrowedPtr<CreatureLib::Battling::Creature>&);
REGISTER_GETTER("MoveTurnChoice", "LearnedMove@ get_Move() const property", CreatureLib::Battling::AttackTurnChoice,
GetAttack);
REGISTER_GETTER("MoveTurnChoice", "int8 get_Priority() const property", CreatureLib::Battling::AttackTurnChoice,
GetPriority);
REGISTER_GETTER("MoveTurnChoice", "bool get_HasFailed() const property", CreatureLib::Battling::AttackTurnChoice,
HasFailed);
r = engine->RegisterObjectMethod("MoveTurnChoice", "void Fail()",
asMETHOD(CreatureLib::Battling::AttackTurnChoice, Fail), asCALL_THISCALL);
Ensure(r >= 0);
r = engine->RegisterObjectMethod(
"BaseTurnChoice", "MoveTurnChoice@ opCast()",
asFUNCTION((refCast<CreatureLib::Battling::BaseTurnChoice, CreatureLib::Battling::AttackTurnChoice>)),
asCALL_CDECL_OBJLAST);
Ensure(r >= 0);
r = engine->RegisterObjectMethod(
"MoveTurnChoice", "BaseTurnChoice@ opImplCast()",
asFUNCTION((refCast<CreatureLib::Battling::AttackTurnChoice, CreatureLib::Battling::BaseTurnChoice>)),
asCALL_CDECL_OBJLAST);
Ensure(r >= 0);
}
void RegisterTurnChoices::RegisterSwitchTurnChoice(asIScriptEngine* engine) {
int r = engine->RegisterObjectType("SwitchTurnChoice", 0, asOBJ_REF | asOBJ_NOCOUNT);
Ensure(r >= 0);
REGISTER_GETTER("SwitchTurnChoice", "TurnChoiceKind get_Kind() const property",
CreatureLib::Battling::SwitchTurnChoice, GetKind);
REGISTER_EXPLICIT_GETTER("SwitchTurnChoice", "const Pokemon@ get_User() const property",
CreatureLib::Battling::BaseTurnChoice, GetUser,
const ArbUt::BorrowedPtr<CreatureLib::Battling::Creature>&);
REGISTER_GETTER("SwitchTurnChoice", "Pokemon@ get_NewPokemon() const property",
CreatureLib::Battling::SwitchTurnChoice, GetNewCreature);
r = engine->RegisterObjectMethod(
"BaseTurnChoice", "SwitchTurnChoice@ opCast()",
asFUNCTION((refCast<CreatureLib::Battling::BaseTurnChoice, CreatureLib::Battling::SwitchTurnChoice>)),
asCALL_CDECL_OBJLAST);
Ensure(r >= 0);
r = engine->RegisterObjectMethod(
"SwitchTurnChoice", "BaseTurnChoice@ opImplCast()",
asFUNCTION((refCast<CreatureLib::Battling::AttackTurnChoice, CreatureLib::Battling::BaseTurnChoice>)),
asCALL_CDECL_OBJLAST);
Ensure(r >= 0);
}
void RegisterTurnChoices::RegisterFleeTurnChoice(asIScriptEngine* engine) {
int r = engine->RegisterObjectType("FleeTurnChoice", 0, asOBJ_REF | asOBJ_NOCOUNT);
Ensure(r >= 0);
REGISTER_GETTER("FleeTurnChoice", "TurnChoiceKind get_Kind() const property", CreatureLib::Battling::FleeTurnChoice,
GetKind);
REGISTER_EXPLICIT_GETTER("FleeTurnChoice", "const Pokemon@ get_User() const property",
CreatureLib::Battling::BaseTurnChoice, GetUser,
const ArbUt::BorrowedPtr<CreatureLib::Battling::Creature>&);
r = engine->RegisterObjectMethod(
"BaseTurnChoice", "FleeTurnChoice@ opCast()",
asFUNCTION((refCast<CreatureLib::Battling::BaseTurnChoice, CreatureLib::Battling::FleeTurnChoice>)),
asCALL_CDECL_OBJLAST);
Ensure(r >= 0);
r = engine->RegisterObjectMethod(
"FleeTurnChoice", "BaseTurnChoice@ opImplCast()",
asFUNCTION((refCast<CreatureLib::Battling::FleeTurnChoice, CreatureLib::Battling::BaseTurnChoice>)),
asCALL_CDECL_OBJLAST);
Ensure(r >= 0);
}