PokemonScriptTester/src/Tester/AngelScript/PokemonBuilder.hpp

84 lines
5.0 KiB
C++

#ifndef POKEMONSCRIPTTESTER_POKEMONBUILDER_HPP
#define POKEMONSCRIPTTESTER_POKEMONBUILDER_HPP
#include <PkmnLib/Battling/Pokemon/CreatePokemon.hpp>
#include <angelscript.h>
class PokemonBuilderRegistration {
public:
static PkmnLib::Battling::CreatePokemon* CreatePokemonBuilder(const ArbUt::StringView& species, uint8_t level) {
auto* ctx = asGetActiveContext();
TestEnvironment* env = static_cast<TestEnvironment*>(ctx->GetUserData(684));
auto lib = Globals::Library.GetValue();
auto builder = new PkmnLib::Battling::CreatePokemon(lib, species, level);
env->AddGarbage(builder);
return builder;
}
static PkmnLib::Battling::CreatePokemon& WithGenderWrapper(PkmnLib::Battling::CreatePokemon* builder, i32 gender) {
return builder->WithGender((CreatureLib::Library::Gender)gender);
}
static PkmnLib::Battling::Pokemon* BuildWrapper(PkmnLib::Battling::CreatePokemon* builder, u32 seed) {
auto rand = ArbUt::Random(seed);
auto p = builder->Build(rand);
auto* ctx = asGetActiveContext();
TestEnvironment* env = static_cast<TestEnvironment*>(ctx->GetUserData(684));
env->AddGarbage(p);
return p;
}
static void Register(AngelScriptResolver* resolver) {
auto engine = resolver->GetEngine();
Ensure(engine->RegisterObjectType("PokemonBuilder", 0, asOBJ_REF | asOBJ_NOCOUNT) >= 0);
Ensure(engine->RegisterGlobalFunction(
"PokemonBuilder@ CreatePokemonBuilder(const constString&in species, uint8 level)",
asFUNCTION(CreatePokemonBuilder), asCALL_CDECL) >= 0);
Ensure(engine->RegisterObjectMethod("PokemonBuilder", "PokemonBuilder@ WithForme(const constString&in forme)",
asMETHODPR(PkmnLib::Battling::CreatePokemon, WithForme,
(const ArbUt::StringView&), PkmnLib::Battling::CreatePokemon&),
asCALL_THISCALL));
Ensure(engine->RegisterObjectMethod("PokemonBuilder", "PokemonBuilder@ WithGender(Gender gender)",
asFUNCTION(WithGenderWrapper), asCALL_CDECL_OBJFIRST));
Ensure(engine->RegisterObjectMethod(
"PokemonBuilder", "PokemonBuilder@ IsShiny(bool value)",
asMETHODPR(PkmnLib::Battling::CreatePokemon, IsShiny, (bool), PkmnLib::Battling::CreatePokemon&),
asCALL_THISCALL));
Ensure(engine->RegisterObjectMethod("PokemonBuilder", "PokemonBuilder@ WithHeldItem(const constString&in item)",
asMETHODPR(PkmnLib::Battling::CreatePokemon, WithHeldItem,
(const ArbUt::StringView&), PkmnLib::Battling::CreatePokemon&),
asCALL_THISCALL));
Ensure(engine->RegisterObjectMethod(
"PokemonBuilder", "PokemonBuilder@ LearnMove(const constString&in move, MoveLearnMethod method)",
asMETHODPR(PkmnLib::Battling::CreatePokemon, LearnMove,
(const ArbUt::StringView&, CreatureLib::Battling::AttackLearnMethod),
PkmnLib::Battling::CreatePokemon&),
asCALL_THISCALL));
Ensure(engine->RegisterObjectMethod(
"PokemonBuilder",
"PokemonBuilder@ WithIndividualValues(uint8 hp,uint8 att,uint8 def,uint8 spa,uint8 spd,uint8 speed)",
asMETHODPR(PkmnLib::Battling::CreatePokemon, WithIndividualValues, (u8, u8, u8, u8, u8, u8),
PkmnLib::Battling::CreatePokemon&),
asCALL_THISCALL));
Ensure(engine->RegisterObjectMethod(
"PokemonBuilder",
"PokemonBuilder@ WithEffortValues(uint8 hp,uint8 att,uint8 def,uint8 spa,uint8 spd,uint8 speed)",
asMETHODPR(PkmnLib::Battling::CreatePokemon, WithEffortValues, (u8, u8, u8, u8, u8, u8),
PkmnLib::Battling::CreatePokemon&),
asCALL_THISCALL));
Ensure(engine->RegisterObjectMethod("PokemonBuilder", "PokemonBuilder@ WithNature(const constString&in nature)",
asMETHODPR(PkmnLib::Battling::CreatePokemon, WithNature,
(const ArbUt::StringView&), PkmnLib::Battling::CreatePokemon&),
asCALL_THISCALL));
Ensure(engine->RegisterObjectMethod("PokemonBuilder", "PokemonBuilder@ WithNickname(const string&in name)",
asMETHODPR(PkmnLib::Battling::CreatePokemon, WithNickname,
(const std::string&), PkmnLib::Battling::CreatePokemon&),
asCALL_THISCALL));
Ensure(engine->RegisterObjectMethod("PokemonBuilder", "Pokemon@ Build(uint seed = 0)", asFUNCTION(BuildWrapper),
asCALL_CDECL_OBJFIRST));
}
};
#endif // POKEMONSCRIPTTESTER_POKEMONBUILDER_HPP