diff --git a/src/Tester/AngelScript/BattleFunctions.hpp b/src/Tester/AngelScript/BattleFunctions.hpp index c924799..c9c4ab6 100644 --- a/src/Tester/AngelScript/BattleFunctions.hpp +++ b/src/Tester/AngelScript/BattleFunctions.hpp @@ -136,6 +136,15 @@ class BattleFunctions { 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: static void Register(AngelScriptResolver* scriptResolver) { auto engine = scriptResolver->GetBuilder().GetEngine(); @@ -152,6 +161,8 @@ public: asFUNCTION(UseMove), asCALL_CDECL_OBJFIRST) >= 0); Ensure(engine->RegisterObjectMethod("Pokemon", "bool PassTurn()", asFUNCTION(PassTurn), asCALL_CDECL_OBJFIRST) >= 0); + Ensure(engine->RegisterObjectMethod("Pokemon", "bool LearnMove(const constString&in move)", + asFUNCTION(LearnMove), asCALL_CDECL_OBJFIRST) >= 0); } };