Adds function to learn move.
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Deukhoofd 2021-08-29 11:42:20 +02:00
parent b32639cc1a
commit 021b3a4802
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
1 changed files with 11 additions and 0 deletions

View File

@ -136,6 +136,15 @@ class BattleFunctions {
return b; return b;
} }
static void LearnMove(PkmnLib::Battling::Pokemon* user, const ArbUt::StringView& moveName) {
auto move = Globals::Library.GetValue()->GetMoveLibrary()->TryGet(moveName);
if (!move.has_value()) {
THROW("Unknown move: " << moveName);
}
user->AddAttack(
new PkmnLib::Battling::LearnedMove(move.value(), CreatureLib::Battling::AttackLearnMethod::Unknown));
}
public: public:
static void Register(AngelScriptResolver* scriptResolver) { static void Register(AngelScriptResolver* scriptResolver) {
auto engine = scriptResolver->GetBuilder().GetEngine(); auto engine = scriptResolver->GetBuilder().GetEngine();
@ -152,6 +161,8 @@ public:
asFUNCTION(UseMove), asCALL_CDECL_OBJFIRST) >= 0); asFUNCTION(UseMove), asCALL_CDECL_OBJFIRST) >= 0);
Ensure(engine->RegisterObjectMethod("Pokemon", "bool PassTurn()", asFUNCTION(PassTurn), Ensure(engine->RegisterObjectMethod("Pokemon", "bool PassTurn()", asFUNCTION(PassTurn),
asCALL_CDECL_OBJFIRST) >= 0); asCALL_CDECL_OBJFIRST) >= 0);
Ensure(engine->RegisterObjectMethod("Pokemon", "bool LearnMove(const constString&in move)",
asFUNCTION(LearnMove), asCALL_CDECL_OBJFIRST) >= 0);
} }
}; };