53 lines
2.1 KiB
C++
53 lines
2.1 KiB
C++
#ifndef POKEMONSCRIPTTESTER_BATTLEBUILDER_HPP
|
|
#define POKEMONSCRIPTTESTER_BATTLEBUILDER_HPP
|
|
|
|
#include <PkmnLib/Battling/Battle/Battle.hpp>
|
|
#include <PkmnLib/Battling/Pokemon/CreatePokemon.hpp>
|
|
#include <angelscript.h>
|
|
#include "../TestEnvironment.hpp"
|
|
|
|
class BattleBuilder {
|
|
static PkmnLib::Battling::Battle* CreateSimpleBattle(u32 seed, const ArbUt::StringView& species1,
|
|
const ArbUt::StringView& species2, u8 level) {
|
|
auto* ctx = asGetActiveContext();
|
|
TestEnvironment* env = static_cast<TestEnvironment*>(ctx->GetUserData());
|
|
auto lib = Globals::Library.GetValue();
|
|
|
|
auto mon1 = PkmnLib::Battling::CreatePokemon(lib, species1, level).Build();
|
|
auto p1 = new CreatureLib::Battling::CreatureParty(1);
|
|
p1->SwapInto(0, mon1);
|
|
|
|
auto mon2 = PkmnLib::Battling::CreatePokemon(lib, species2, level).Build();
|
|
auto p2 = new CreatureLib::Battling::CreatureParty(1);
|
|
p1->SwapInto(0, mon2);
|
|
|
|
auto battle = new PkmnLib::Battling::Battle(
|
|
lib,
|
|
{new CreatureLib::Battling::BattleParty(p1, {CreatureLib::Battling::CreatureIndex(0, 0)}),
|
|
new CreatureLib::Battling::BattleParty(p2, {CreatureLib::Battling::CreatureIndex(1, 0)})},
|
|
true, // can flee
|
|
2, // 2 sides
|
|
1, // 1 mon per side
|
|
seed // with seed
|
|
);
|
|
battle->SwitchCreature(0, 0, mon1);
|
|
battle->SwitchCreature(1, 0, mon2);
|
|
|
|
env->AddGarbage(battle);
|
|
env->AddGarbage(p1);
|
|
env->AddGarbage(p2);
|
|
|
|
return battle;
|
|
}
|
|
|
|
public:
|
|
static void Register(AngelScriptResolver* scriptResolver) {
|
|
auto engine = scriptResolver->GetBuilder().GetEngine();
|
|
Ensure(engine->RegisterGlobalFunction("Battle@ CreateSimpleBattle(uint seed, const constString&in species1, "
|
|
"const constString&in species2, uint8 level)",
|
|
asFUNCTION(CreateSimpleBattle), asCALL_CDECL) >= 0);
|
|
}
|
|
};
|
|
|
|
#endif // POKEMONSCRIPTTESTER_BATTLEBUILDER_HPP
|