Register Species Library for AngelScript.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-01-13 20:05:03 +01:00
parent dbc8aa2675
commit c1d865d366
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
4 changed files with 24 additions and 14 deletions

View File

@ -4,7 +4,7 @@
#include "TypeRegistry/Library/RegisterGrowthRateTypes.hpp"
#include "TypeRegistry/Library/RegisterItemTypes.hpp"
#include "TypeRegistry/Library/RegisterMoveTypes.hpp"
#include "TypeRegistry/Library/RegisterPokemonTypes.hpp"
#include "TypeRegistry/Library/RegisterSpeciesTypes.hpp"
CreatureLib::Battling::ScriptResolver* PkmnLib::Battling::BattleLibrary::CreateScriptResolver() {
return new AngelScripResolver();
@ -29,7 +29,7 @@ void AngelScripResolver::Initialize(CreatureLib::Battling::BattleLibrary* librar
RegisterExceptionRoutines(_engine);
RegisterPokemonTypes::Register(_engine);
RegisterSpeciesTypes::Register(_engine);
RegisterItemTypes::Register(_engine);
RegisterMoveTypes::Register(_engine);
RegisterGrowthRateTypes::Register(_engine);

View File

@ -73,7 +73,7 @@ void RegisterMoveTypes::RegisterMoveType(asIScriptEngine* engine) {
void RegisterMoveTypes::RegisterMoveLibrary(asIScriptEngine* engine) {
[[maybe_unused]] int r = engine->RegisterObjectType("MoveLibrary", 0, asOBJ_REF | asOBJ_NOCOUNT);
assert(r >= 0);
r = engine->RegisterObjectMethod("MoveLibrary", "const MoveData@ GetMove(const string &in flag) const",
r = engine->RegisterObjectMethod("MoveLibrary", "const MoveData@ GetMove(const string &in name) const",
asMETHOD(PkmnLib::Library::MoveLibrary, GetMove), asCALL_THISCALL);
assert(r >= 0);

View File

@ -1,16 +1,18 @@
#include "RegisterPokemonTypes.hpp"
#include "RegisterSpeciesTypes.hpp"
#include <cassert>
#include "../../../Library/Species/PokemonSpecies.hpp"
#include "../../../Library/Species/SpeciesLibrary.hpp"
#include "../../../Library/Statistic.hpp"
void RegisterPokemonTypes::Register(asIScriptEngine* engine) {
void RegisterSpeciesTypes::Register(asIScriptEngine* engine) {
RegisterGenderEnum(engine);
RegisterStatisticEnum(engine);
RegisterFormeType(engine);
RegisterSpeciesType(engine);
RegisterSpeciesLibrary(engine);
}
void RegisterPokemonTypes::RegisterGenderEnum(asIScriptEngine* engine) {
void RegisterSpeciesTypes::RegisterGenderEnum(asIScriptEngine* engine) {
[[maybe_unused]] int r = engine->RegisterEnum("Gender");
assert(r >= 0);
r = engine->RegisterEnumValue("Gender", "Male", (int)CreatureLib::Library::Gender::Male);
@ -21,7 +23,7 @@ void RegisterPokemonTypes::RegisterGenderEnum(asIScriptEngine* engine) {
assert(r >= 0);
}
void RegisterPokemonTypes::RegisterStatisticEnum(asIScriptEngine* engine) {
void RegisterSpeciesTypes::RegisterStatisticEnum(asIScriptEngine* engine) {
[[maybe_unused]] int r = engine->RegisterEnum("Statistic");
assert(r >= 0);
r = engine->RegisterEnumValue("Statistic", "HP", PkmnLib::Library::Statistic::HealthPoints);
@ -38,7 +40,7 @@ void RegisterPokemonTypes::RegisterStatisticEnum(asIScriptEngine* engine) {
assert(r >= 0);
}
void RegisterPokemonTypes::RegisterSpeciesType(asIScriptEngine* engine) {
void RegisterSpeciesTypes::RegisterSpeciesType(asIScriptEngine* engine) {
[[maybe_unused]] int r = engine->RegisterObjectType("Species", 0, asOBJ_REF | asOBJ_NOCOUNT);
assert(r >= 0);
r = engine->RegisterObjectMethod("Species", "const string& get_Name() const property",
@ -65,7 +67,7 @@ void RegisterPokemonTypes::RegisterSpeciesType(asIScriptEngine* engine) {
}
void RegisterPokemonTypes::RegisterFormeType(asIScriptEngine* engine) {
void RegisterSpeciesTypes::RegisterFormeType(asIScriptEngine* engine) {
[[maybe_unused]] int r = engine->RegisterObjectType("Forme", 0, asOBJ_REF | asOBJ_NOCOUNT);
assert(r >= 0);
r = engine->RegisterObjectMethod("Forme", "const string& get_Name() const property",
@ -94,3 +96,10 @@ void RegisterPokemonTypes::RegisterFormeType(asIScriptEngine* engine) {
assert(r >= 0);
}
void RegisterSpeciesTypes::RegisterSpeciesLibrary(asIScriptEngine* engine) {
[[maybe_unused]] int r = engine->RegisterObjectType("SpeciesLibrary", 0, asOBJ_REF | asOBJ_NOCOUNT);
assert(r >= 0);
r = engine->RegisterObjectMethod("SpeciesLibrary", "const Species@ GetSpecies(const string &in name) const",
asMETHOD(PkmnLib::Library::SpeciesLibrary, GetPkmnSpecies), asCALL_THISCALL);
assert(r >= 0);
}

View File

@ -1,8 +1,8 @@
#ifndef PKMNLIB_REGISTERPOKEMONTYPES_HPP
#define PKMNLIB_REGISTERPOKEMONTYPES_HPP
#ifndef PKMNLIB_REGISTERSPECIESTYPES_HPP
#define PKMNLIB_REGISTERSPECIESTYPES_HPP
#include <angelscript.h>
class RegisterPokemonTypes {
class RegisterSpeciesTypes {
public:
static void Register(asIScriptEngine* engine);
@ -11,6 +11,7 @@ private:
static void RegisterStatisticEnum(asIScriptEngine* engine);
static void RegisterSpeciesType(asIScriptEngine* engine);
static void RegisterFormeType(asIScriptEngine* engine);
static void RegisterSpeciesLibrary(asIScriptEngine* engine);
};
#endif // PKMNLIB_REGISTERPOKEMONTYPES_HPP
#endif // PKMNLIB_REGISTERSPECIESTYPES_HPP