#ifndef POKEMONSCRIPTTESTER_MISCMOCKFUNCTIONS_HPP #define POKEMONSCRIPTTESTER_MISCMOCKFUNCTIONS_HPP #include class MiscMockFunctions { static CScriptHandle CreateMoveScript(const ArbUt::StringView& name) { auto script = Globals::Library.GetValue()->GetScriptResolver()->LoadScript(nullptr, ScriptCategory::Attack, name); if (script != nullptr) { auto* ctx = asGetActiveContext(); TestEnvironment* env = static_cast(ctx->GetUserData(684)); env->AddGarbage(script); } auto p = dynamic_cast(script); EnsureNotNull(p); auto handle = CScriptHandle(p->GetRawAngelscriptObject(), p->GetRawAngelscriptObject()->GetObjectType()); return handle; } static CreatureLib::Battling::ExecutingAttack* CreateExecutingMove(const ArbUt::StringView& moveName, PkmnLib::Battling::Pokemon* user, PkmnLib::Battling::Pokemon* target) { auto* ctx = asGetActiveContext(); TestEnvironment* env = static_cast(ctx->GetUserData(684)); auto move = Globals::Library.GetValue()->GetMoveLibrary()->TryGet(moveName); if (!move.has_value()) { THROW("Unknown move: ", moveName); } auto learnedMove = new PkmnLib::Battling::LearnedMove(move.value(), CreatureLib::Battling::AttackLearnMethod::Unknown); env->AddGarbage(learnedMove); auto executingMove = new CreatureLib::Battling::ExecutingAttack( {target}, 1, user, learnedMove, move.value().As(), nullptr); env->AddGarbage(executingMove); return executingMove; } static CreatureLib::Battling::AttackTurnChoice* CreateMoveTurnChoice(const ArbUt::StringView& moveName, PkmnLib::Battling::Pokemon* user, u8 targetSide, u8 target) { auto* ctx = asGetActiveContext(); TestEnvironment* env = static_cast(ctx->GetUserData(684)); auto move = Globals::Library.GetValue()->GetMoveLibrary()->TryGet(moveName); if (!move.has_value()) { return {}; } auto learnedMove = new PkmnLib::Battling::LearnedMove(move.value(), CreatureLib::Battling::AttackLearnMethod::Unknown); env->AddGarbage(learnedMove); auto moveTurnChoice = new CreatureLib::Battling::AttackTurnChoice( user, learnedMove, CreatureLib::Battling::CreatureIndex(targetSide, target)); env->AddGarbage(moveTurnChoice); return moveTurnChoice; } public: static void Register(AngelScriptResolver* scriptResolver) { auto engine = scriptResolver->GetBuilder().GetEngine(); Ensure(engine->RegisterGlobalFunction("ref@ CreateMoveScript(const constString&in name)", asFUNCTION(CreateMoveScript), asCALL_CDECL) >= 0); Ensure(engine->RegisterGlobalFunction( "ExecutingMove@ CreateExecutingMove(const constString&in moveName, Pokemon@ user, Pokemon@ target)", asFUNCTION(CreateExecutingMove), asCALL_CDECL) >= 0); Ensure(engine->RegisterGlobalFunction("MoveTurnChoice@ CreateMoveTurnChoice(const constString&in moveName, " "Pokemon@ user, uint8 targetSide, uint8 target)", asFUNCTION(CreateMoveTurnChoice), asCALL_CDECL) >= 0); } }; #endif // POKEMONSCRIPTTESTER_MISCMOCKFUNCTIONS_HPP