Support for new version of CreatureLib.
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
dba8ae2b83
commit
29a82a5e75
|
@ -1,7 +1,7 @@
|
|||
#include "PokemonForme.hpp"
|
||||
PkmnLib::Library::PokemonForme::PokemonForme(std::string name, float height, float weight, uint32_t baseExperience,
|
||||
PkmnLib::Library::PokemonForme::PokemonForme(ConstString name, float height, float weight, uint32_t baseExperience,
|
||||
std::vector<uint8_t> types,
|
||||
CreatureLib::Core::StatisticSet<uint16_t> baseStats,
|
||||
std::vector<std::string> talents, std::vector<std::string> secretTalents,
|
||||
std::vector<ConstString> talents, std::vector<ConstString> secretTalents,
|
||||
const CreatureLib::Library::LearnableAttacks* attacks)
|
||||
: SpeciesVariant(name, height, weight, baseExperience, types, baseStats, talents, secretTalents, attacks) {}
|
||||
|
|
|
@ -6,13 +6,13 @@
|
|||
namespace PkmnLib::Library {
|
||||
class PokemonForme : public CreatureLib::Library::SpeciesVariant {
|
||||
public:
|
||||
PokemonForme(std::string name, float height, float weight, uint32_t baseExperience, std::vector<uint8_t> types,
|
||||
CreatureLib::Core::StatisticSet<uint16_t> baseStats, std::vector<std::string> talents,
|
||||
std::vector<std::string> secretTalents, const CreatureLib::Library::LearnableAttacks* attacks);
|
||||
PokemonForme(ConstString name, float height, float weight, uint32_t baseExperience, std::vector<uint8_t> types,
|
||||
CreatureLib::Core::StatisticSet<uint16_t> baseStats, std::vector<ConstString> talents,
|
||||
std::vector<ConstString> secretTalents, const CreatureLib::Library::LearnableAttacks* attacks);
|
||||
|
||||
private:
|
||||
public:
|
||||
inline const std::string& GetAbility(int index) const { return GetTalent(index); }
|
||||
inline const ConstString& GetAbility(int index) const { return GetTalent(index); }
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -85,18 +85,18 @@ void AngelScripResolver::RegisterTypes() {
|
|||
BasicScriptClass::Register(_engine);
|
||||
}
|
||||
|
||||
AngelScriptTypeInfo* AngelScripResolver::GetTypeInfo(const std::string& name, const std::string& decl) {
|
||||
auto find = _types.find(decl);
|
||||
AngelScriptTypeInfo* AngelScripResolver::GetTypeInfo(const ConstString& name, const std::string& decl) {
|
||||
auto find = _types.find(name);
|
||||
if (find != _types.end()) {
|
||||
return find->second;
|
||||
}
|
||||
auto type = _mainModule->GetTypeInfoByDecl(decl.c_str());
|
||||
if (type == nullptr) {
|
||||
_types.insert({decl, nullptr});
|
||||
_types.insert({name, nullptr});
|
||||
return nullptr;
|
||||
}
|
||||
auto typeinfo = new AngelScriptTypeInfo(name, type);
|
||||
_types.insert({decl, typeinfo});
|
||||
_types.insert({name, typeinfo});
|
||||
return typeinfo;
|
||||
}
|
||||
void AngelScripResolver::MessageCallback(const asSMessageInfo* msg, void* param) {
|
||||
|
@ -120,9 +120,9 @@ static constexpr const char* GetCategoryNamespace(ScriptCategory category) {
|
|||
}
|
||||
}
|
||||
|
||||
CreatureLib::Battling::Script* AngelScripResolver::LoadScript(ScriptCategory category, const std::string& scriptName) {
|
||||
CreatureLib::Battling::Script* AngelScripResolver::LoadScript(ScriptCategory category, const ConstString& scriptName) {
|
||||
std::stringstream decl;
|
||||
decl << GetCategoryNamespace(category) << "::" << scriptName;
|
||||
decl << GetCategoryNamespace(category) << "::" << scriptName.c_str();
|
||||
auto typeInfo = GetTypeInfo(scriptName, decl.str());
|
||||
if (typeInfo == nullptr)
|
||||
return nullptr;
|
||||
|
|
|
@ -17,11 +17,11 @@ private:
|
|||
asIScriptModule* _mainModule = nullptr;
|
||||
ContextPool* _contextPool = nullptr;
|
||||
CScriptBuilder _builder;
|
||||
std::unordered_map<std::string, AngelScriptTypeInfo*> _types;
|
||||
std::unordered_map<ConstString, AngelScriptTypeInfo*> _types;
|
||||
|
||||
static void MessageCallback(const asSMessageInfo* msg, void* param);
|
||||
static void Print(const std::string& str) { std::cout << str << std::endl; }
|
||||
AngelScriptTypeInfo* GetTypeInfo(const std::string& name, const std::string& decl);
|
||||
AngelScriptTypeInfo* GetTypeInfo(const ConstString& name, const std::string& decl);
|
||||
|
||||
void RegisterTypes();
|
||||
|
||||
|
@ -40,6 +40,6 @@ public:
|
|||
|
||||
void FinalizeModule();
|
||||
|
||||
CreatureLib::Battling::Script* LoadScript(ScriptCategory category, const std::string& scriptName) override;
|
||||
CreatureLib::Battling::Script* LoadScript(ScriptCategory category, const ConstString& scriptName) override;
|
||||
};
|
||||
#endif // PKMNLIB_ANGELSCRIPRESOLVER_HPP
|
||||
|
|
|
@ -21,7 +21,7 @@ public:
|
|||
|
||||
~AngelScriptScript() override { _obj->Release(); }
|
||||
|
||||
[[nodiscard]] const std::string& GetName() const override { return _type->GetName(); }
|
||||
[[nodiscard]] const ConstString& GetName() const override { return _type->GetName(); }
|
||||
|
||||
asIScriptFunction* PrepareMethod(const char* name, asIScriptContext* ctx) {
|
||||
auto func = _type->GetFunction(name);
|
||||
|
@ -51,7 +51,7 @@ public:
|
|||
if (scriptResult != asEXECUTION_FINISHED) { \
|
||||
if (scriptResult == asEXECUTION_EXCEPTION) { \
|
||||
std::stringstream err; \
|
||||
err << "Script exception in script '" << GetName() << "', line " << ctx->GetExceptionLineNumber() \
|
||||
err << "Script exception in script '" << GetName().c_str() << "', line " << ctx->GetExceptionLineNumber() \
|
||||
<< ". Message: '" << ctx->GetExceptionString() << "'."; \
|
||||
throw CreatureException(err.str()); \
|
||||
} \
|
||||
|
|
|
@ -2,17 +2,20 @@
|
|||
#define PKMNLIB_ANGELSCRIPTTYPEINFO_HPP
|
||||
|
||||
#define ANGELSCRIPT_DLL_LIBRARY_IMPORT
|
||||
#include <Arbutils/ConstString.hpp>
|
||||
#include <CreatureLib/Core/Exceptions/CreatureException.hpp>
|
||||
#include <angelscript.h>
|
||||
#include <cstring>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
|
||||
using ConstString = Arbutils::CaseInsensitiveConstString;
|
||||
|
||||
class AngelScriptTypeInfo {
|
||||
private:
|
||||
asITypeInfo* _type = nullptr;
|
||||
std::unordered_map<std::string, asIScriptFunction*> _functions;
|
||||
std::string _name;
|
||||
ConstString _name;
|
||||
|
||||
struct FunctionInfo {
|
||||
bool Exists = false;
|
||||
|
@ -31,7 +34,7 @@ private:
|
|||
}
|
||||
|
||||
public:
|
||||
explicit AngelScriptTypeInfo(std::string name, asITypeInfo* type) : _type(type), _name(std::move(name)) {}
|
||||
explicit AngelScriptTypeInfo(const ConstString& name, asITypeInfo* type) : _type(type), _name(name) {}
|
||||
~AngelScriptTypeInfo() {
|
||||
for (const auto& f : _functions) {
|
||||
f.second->Release();
|
||||
|
@ -39,7 +42,7 @@ public:
|
|||
_functions.clear();
|
||||
}
|
||||
|
||||
const std::string& GetName() const{
|
||||
const ConstString& GetName() const{
|
||||
return _name;
|
||||
}
|
||||
|
||||
|
|
|
@ -62,10 +62,10 @@ void RegisterBattleClass::RegisterBattle(asIScriptEngine* engine) {
|
|||
assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod(
|
||||
"Battle", "void AddVolatile(const string &in name) const",
|
||||
asMETHODPR(CreatureLib::Battling::Battle, AddVolatileScript, (const std::string&), void), asCALL_THISCALL);
|
||||
asMETHODPR(CreatureLib::Battling::Battle, AddVolatileScript, (const ConstString&), void), asCALL_THISCALL);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod(
|
||||
"Battle", "void RemoveVolatile(const string &in name) const",
|
||||
asMETHODPR(CreatureLib::Battling::Battle, RemoveVolatileScript, (const std::string&), void), asCALL_THISCALL);
|
||||
asMETHODPR(CreatureLib::Battling::Battle, RemoveVolatileScript, (const ConstString&), void), asCALL_THISCALL);
|
||||
assert(r >= 0);
|
||||
}
|
||||
|
|
|
@ -179,10 +179,10 @@ void RegisterPokemonClass::RegisterPokemonType(asIScriptEngine* engine) {
|
|||
assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod(
|
||||
"Pokemon", "void AddVolatile(const string &in name) const",
|
||||
asMETHODPR(PkmnLib::Battling::Pokemon, AddVolatileScript, (const std::string&), void), asCALL_THISCALL);
|
||||
asMETHODPR(PkmnLib::Battling::Pokemon, AddVolatileScript, (const ConstString&), void), asCALL_THISCALL);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod(
|
||||
"Pokemon", "void RemoveVolatile(const string &in name) const",
|
||||
asMETHODPR(PkmnLib::Battling::Pokemon, RemoveVolatileScript, (const std::string&), void), asCALL_THISCALL);
|
||||
asMETHODPR(PkmnLib::Battling::Pokemon, RemoveVolatileScript, (const ConstString&), void), asCALL_THISCALL);
|
||||
assert(r >= 0);
|
||||
}
|
|
@ -14,9 +14,9 @@ TEST_CASE("Able to build, destroy and insert library", "library") {
|
|||
new PkmnLib::Library::PokemonSpecies(
|
||||
1, "foo"_cnc,
|
||||
new PkmnLib::Library::PokemonForme(
|
||||
"default", 1.0f, 1.0f, 100, {0},
|
||||
CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"},
|
||||
{"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||
"default"_cnc, 1.0f, 1.0f, 100, {0},
|
||||
CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
|
||||
{"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100));
|
||||
delete lib;
|
||||
}
|
||||
|
@ -27,9 +27,9 @@ TEST_CASE("Able to insert and retrieve from library", "library") {
|
|||
new PkmnLib::Library::PokemonSpecies(
|
||||
1, "foo"_cnc,
|
||||
new PkmnLib::Library::PokemonForme(
|
||||
"default", 1.0f, 1.0f, 100, {0},
|
||||
CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"},
|
||||
{"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||
"default"_cnc, 1.0f, 1.0f, 100, {0},
|
||||
CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
|
||||
{"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100));
|
||||
auto val = lib->Get("foo"_cnc);
|
||||
REQUIRE(val->GetName() == "foo");
|
||||
|
|
|
@ -5,9 +5,10 @@
|
|||
TEST_CASE("Able to create and destroy species", "library") {
|
||||
auto species = new PkmnLib::Library::PokemonSpecies(
|
||||
1, "foo"_cnc,
|
||||
new PkmnLib::Library::PokemonForme(
|
||||
"default", 1.0f, 1.0f, 100, {0}, CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"}, {"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||
new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0},
|
||||
CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||
new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||
delete species;
|
||||
}
|
||||
|
@ -15,9 +16,10 @@ TEST_CASE("Able to create and destroy species", "library") {
|
|||
TEST_CASE("Able to get default forme", "library") {
|
||||
auto species = new PkmnLib::Library::PokemonSpecies(
|
||||
1, "foo"_cnc,
|
||||
new PkmnLib::Library::PokemonForme(
|
||||
"default", 1.0f, 1.0f, 100, {0}, CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"}, {"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||
new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0},
|
||||
CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||
new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||
|
||||
auto forme = species->GetDefaultForme();
|
||||
|
@ -29,9 +31,10 @@ TEST_CASE("Able to get default forme", "library") {
|
|||
TEST_CASE("Able to get default forme name", "library") {
|
||||
auto species = new PkmnLib::Library::PokemonSpecies(
|
||||
1, "foo"_cnc,
|
||||
new PkmnLib::Library::PokemonForme(
|
||||
"default", 1.0f, 1.0f, 100, {0}, CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"}, {"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||
new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0},
|
||||
CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||
new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||
|
||||
auto forme = species->GetDefaultForme();
|
||||
|
@ -44,9 +47,10 @@ TEST_CASE("Able to get default forme name", "library") {
|
|||
TEST_CASE("Able to get species name", "library") {
|
||||
auto species = new PkmnLib::Library::PokemonSpecies(
|
||||
1, "foo"_cnc,
|
||||
new PkmnLib::Library::PokemonForme(
|
||||
"default", 1.0f, 1.0f, 100, {0}, CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"}, {"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||
new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0},
|
||||
CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||
new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||
|
||||
REQUIRE(species->GetName() == "foo");
|
||||
|
@ -57,9 +61,10 @@ TEST_CASE("Able to get species name", "library") {
|
|||
TEST_CASE("Able to get species id", "library") {
|
||||
auto species = new PkmnLib::Library::PokemonSpecies(
|
||||
1, "foo"_cnc,
|
||||
new PkmnLib::Library::PokemonForme(
|
||||
"default", 1.0f, 1.0f, 100, {0}, CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"}, {"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||
new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0},
|
||||
CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||
new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||
|
||||
REQUIRE(species->GetId() == 1);
|
||||
|
@ -70,9 +75,10 @@ TEST_CASE("Able to get species id", "library") {
|
|||
TEST_CASE("Able to get species gender ratio", "library") {
|
||||
auto species = new PkmnLib::Library::PokemonSpecies(
|
||||
1, "foo"_cnc,
|
||||
new PkmnLib::Library::PokemonForme(
|
||||
"default", 1.0f, 1.0f, 100, {0}, CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"}, {"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||
new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0},
|
||||
CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||
new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||
|
||||
REQUIRE(species->GetGenderRate() == 0.5f);
|
||||
|
@ -83,9 +89,10 @@ TEST_CASE("Able to get species gender ratio", "library") {
|
|||
TEST_CASE("Able to get species growth rate", "library") {
|
||||
auto species = new PkmnLib::Library::PokemonSpecies(
|
||||
1, "foo"_cnc,
|
||||
new PkmnLib::Library::PokemonForme(
|
||||
"default", 1.0f, 1.0f, 100, {0}, CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"}, {"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||
new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0},
|
||||
CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||
new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||
|
||||
REQUIRE(species->GetGrowthRate() == "testGrowthRate");
|
||||
|
@ -96,9 +103,10 @@ TEST_CASE("Able to get species growth rate", "library") {
|
|||
TEST_CASE("Able to get species capture rate", "library") {
|
||||
auto species = new PkmnLib::Library::PokemonSpecies(
|
||||
1, "foo"_cnc,
|
||||
new PkmnLib::Library::PokemonForme(
|
||||
"default", 1.0f, 1.0f, 100, {0}, CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"}, {"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||
new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0},
|
||||
CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||
new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||
|
||||
REQUIRE(species->GetCaptureRate() == 100);
|
||||
|
@ -109,9 +117,10 @@ TEST_CASE("Able to get species capture rate", "library") {
|
|||
TEST_CASE("Able to get species base happiness", "library") {
|
||||
auto species = new PkmnLib::Library::PokemonSpecies(
|
||||
1, "foo"_cnc,
|
||||
new PkmnLib::Library::PokemonForme(
|
||||
"default", 1.0f, 1.0f, 100, {0}, CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"}, {"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||
new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0},
|
||||
CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||
new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||
|
||||
REQUIRE(species->GetBaseHappiness() == 100);
|
||||
|
@ -122,15 +131,17 @@ TEST_CASE("Able to get species base happiness", "library") {
|
|||
TEST_CASE("Able to set and get evolution", "library") {
|
||||
auto species = new PkmnLib::Library::PokemonSpecies(
|
||||
1, "foo"_cnc,
|
||||
new PkmnLib::Library::PokemonForme(
|
||||
"default", 1.0f, 1.0f, 100, {0}, CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"}, {"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||
new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0},
|
||||
CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||
new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||
auto species2 = new PkmnLib::Library::PokemonSpecies(
|
||||
2, "bar"_cnc,
|
||||
new PkmnLib::Library::PokemonForme(
|
||||
"default", 1.0f, 1.0f, 100, {0}, CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"}, {"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||
new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0},
|
||||
CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||
new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||
|
||||
species->AddEvolution(PkmnLib::Library::EvolutionData::CreateLevelEvolution(16, species2));
|
||||
|
@ -145,5 +156,4 @@ TEST_CASE("Able to set and get evolution", "library") {
|
|||
delete species2;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
|
@ -75,7 +75,7 @@ static AngelScripResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* m
|
|||
return _resolverCache;
|
||||
}
|
||||
|
||||
static AngelScriptScript* GetScript(PkmnLib::Battling::BattleLibrary* mainLib, const char* scriptName) {
|
||||
static AngelScriptScript* GetScript(PkmnLib::Battling::BattleLibrary* mainLib, const ConstString& scriptName) {
|
||||
auto lib = GetScriptResolver(mainLib);
|
||||
auto s = lib->LoadScript(ScriptCategory::Creature, scriptName);
|
||||
auto script = dynamic_cast<AngelScriptScript*>(s);
|
||||
|
@ -84,14 +84,14 @@ static AngelScriptScript* GetScript(PkmnLib::Battling::BattleLibrary* mainLib, c
|
|||
|
||||
TEST_CASE("Invoke non-implemented script function") {
|
||||
auto mainLib = TestLibrary::GetLibrary();
|
||||
auto script = GetScript(mainLib, "blankScript");
|
||||
auto script = GetScript(mainLib, "blankScript"_cnc);
|
||||
script->Stack();
|
||||
delete script;
|
||||
}
|
||||
|
||||
TEST_CASE("Invoke Stack script function") {
|
||||
auto mainLib = TestLibrary::GetLibrary();
|
||||
auto script = GetScript(mainLib, "stackScript");
|
||||
auto script = GetScript(mainLib, "stackScript"_cnc);
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
script->Stack();
|
||||
|
||||
|
@ -108,7 +108,7 @@ TEST_CASE("Invoke Stack script function") {
|
|||
|
||||
TEST_CASE("Invoke OnRemove script function") {
|
||||
auto mainLib = TestLibrary::GetLibrary();
|
||||
auto script = GetScript(mainLib, "onRemoveScript");
|
||||
auto script = GetScript(mainLib, "onRemoveScript"_cnc);
|
||||
script->OnRemove();
|
||||
|
||||
auto ctxPool = script->GetContextPool();
|
||||
|
@ -124,7 +124,7 @@ TEST_CASE("Invoke OnRemove script function") {
|
|||
|
||||
TEST_CASE("Invoke Stack script function with implementation in base class") {
|
||||
auto mainLib = TestLibrary::GetLibrary();
|
||||
auto script = GetScript(mainLib, "doubleInheritanceScript");
|
||||
auto script = GetScript(mainLib, "doubleInheritanceScript"_cnc);
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
script->Stack();
|
||||
|
||||
|
@ -141,7 +141,7 @@ TEST_CASE("Invoke Stack script function with implementation in base class") {
|
|||
|
||||
TEST_CASE("Invoke preventAttackScript script function") {
|
||||
auto mainLib = TestLibrary::GetLibrary();
|
||||
auto script = GetScript(mainLib, "preventAttackScript");
|
||||
auto script = GetScript(mainLib, "preventAttackScript"_cnc);
|
||||
bool b = false;
|
||||
script->PreventAttack(nullptr, &b);
|
||||
REQUIRE(b);
|
||||
|
@ -151,7 +151,7 @@ TEST_CASE("Invoke preventAttackScript script function") {
|
|||
|
||||
TEST_CASE("Invoke StopBeforeAttack script function") {
|
||||
auto mainLib = TestLibrary::GetLibrary();
|
||||
auto script = GetScript(mainLib, "stopBeforeAttackScript");
|
||||
auto script = GetScript(mainLib, "stopBeforeAttackScript"_cnc);
|
||||
bool b = false;
|
||||
script->StopBeforeAttack(nullptr, &b);
|
||||
REQUIRE(b);
|
||||
|
@ -161,7 +161,7 @@ TEST_CASE("Invoke StopBeforeAttack script function") {
|
|||
|
||||
TEST_CASE("Invoke OnBeforeAttack script function") {
|
||||
auto mainLib = TestLibrary::GetLibrary();
|
||||
auto script = GetScript(mainLib, "OnBeforeAttackScript");
|
||||
auto script = GetScript(mainLib, "OnBeforeAttackScript"_cnc);
|
||||
|
||||
script->OnBeforeAttack(nullptr);
|
||||
|
||||
|
@ -177,7 +177,7 @@ TEST_CASE("Invoke OnBeforeAttack script function") {
|
|||
|
||||
TEST_CASE("Invoke FailIncomingAttack script function") {
|
||||
auto mainLib = TestLibrary::GetLibrary();
|
||||
auto script = GetScript(mainLib, "FailIncomingAttackScript");
|
||||
auto script = GetScript(mainLib, "FailIncomingAttackScript"_cnc);
|
||||
bool b = false;
|
||||
script->FailIncomingAttack(nullptr, nullptr, &b);
|
||||
REQUIRE(b);
|
||||
|
@ -187,7 +187,7 @@ TEST_CASE("Invoke FailIncomingAttack script function") {
|
|||
|
||||
TEST_CASE("Invoke OnAttackMiss script function") {
|
||||
auto mainLib = TestLibrary::GetLibrary();
|
||||
auto script = GetScript(mainLib, "OnAttackMissScript");
|
||||
auto script = GetScript(mainLib, "OnAttackMissScript"_cnc);
|
||||
|
||||
script->OnAttackMiss(nullptr, nullptr);
|
||||
|
||||
|
@ -203,7 +203,7 @@ TEST_CASE("Invoke OnAttackMiss script function") {
|
|||
|
||||
TEST_CASE("Invoke ChangeAttackType script function") {
|
||||
auto mainLib = TestLibrary::GetLibrary();
|
||||
auto script = GetScript(mainLib, "ChangeAttackTypeScript");
|
||||
auto script = GetScript(mainLib, "ChangeAttackTypeScript"_cnc);
|
||||
uint8_t b = 0;
|
||||
script->ChangeAttackType(nullptr, nullptr, 0, &b);
|
||||
REQUIRE(b == 1);
|
||||
|
@ -213,7 +213,7 @@ TEST_CASE("Invoke ChangeAttackType script function") {
|
|||
|
||||
TEST_CASE("Invoke OnStatusMove script function") {
|
||||
auto mainLib = TestLibrary::GetLibrary();
|
||||
auto script = GetScript(mainLib, "OnStatusMoveScript");
|
||||
auto script = GetScript(mainLib, "OnStatusMoveScript"_cnc);
|
||||
|
||||
script->OnStatusMove(nullptr, nullptr, 0);
|
||||
|
||||
|
@ -229,7 +229,7 @@ TEST_CASE("Invoke OnStatusMove script function") {
|
|||
|
||||
TEST_CASE("Invoke PreventSecondaryEffects script function") {
|
||||
auto mainLib = TestLibrary::GetLibrary();
|
||||
auto script = GetScript(mainLib, "PreventSecondaryEffectsScript");
|
||||
auto script = GetScript(mainLib, "PreventSecondaryEffectsScript"_cnc);
|
||||
bool b = false;
|
||||
script->PreventSecondaryEffects(nullptr, nullptr, 0, &b);
|
||||
REQUIRE(b);
|
||||
|
@ -239,7 +239,7 @@ TEST_CASE("Invoke PreventSecondaryEffects script function") {
|
|||
|
||||
TEST_CASE("Invoke OnSecondaryEffect script function") {
|
||||
auto mainLib = TestLibrary::GetLibrary();
|
||||
auto script = GetScript(mainLib, "OnSecondaryEffectScript");
|
||||
auto script = GetScript(mainLib, "OnSecondaryEffectScript"_cnc);
|
||||
|
||||
script->OnSecondaryEffect(nullptr, nullptr, 0);
|
||||
|
||||
|
@ -255,7 +255,7 @@ TEST_CASE("Invoke OnSecondaryEffect script function") {
|
|||
|
||||
TEST_CASE("Invoke OnAfterHits script function") {
|
||||
auto mainLib = TestLibrary::GetLibrary();
|
||||
auto script = GetScript(mainLib, "OnAfterHitsScript");
|
||||
auto script = GetScript(mainLib, "OnAfterHitsScript"_cnc);
|
||||
|
||||
script->OnAfterHits(nullptr, nullptr);
|
||||
|
||||
|
@ -271,7 +271,7 @@ TEST_CASE("Invoke OnAfterHits script function") {
|
|||
|
||||
TEST_CASE("Handle script exceptions.") {
|
||||
auto mainLib = TestLibrary::GetLibrary();
|
||||
auto script = GetScript(mainLib, "throwScript");
|
||||
auto script = GetScript(mainLib, "throwScript"_cnc);
|
||||
bool b = false;
|
||||
bool hasThrown = false;
|
||||
try{
|
||||
|
|
|
@ -40,7 +40,7 @@ TEST_CASE("Build script resolver, then create object") {
|
|||
lib->CreateScript("testScript1" , _scripts["testScript1"]);
|
||||
lib->FinalizeModule();
|
||||
|
||||
auto obj = lib->LoadScript(ScriptCategory::Creature, "testScript1");
|
||||
auto obj = lib->LoadScript(ScriptCategory::Creature, "testScript1"_cnc);
|
||||
|
||||
delete obj;
|
||||
delete lib;
|
||||
|
@ -53,7 +53,7 @@ TEST_CASE("Build script resolver, create object, invoke addition method") {
|
|||
lib->FinalizeModule();
|
||||
|
||||
auto obj =
|
||||
dynamic_cast<AngelScriptScript*>(lib->LoadScript(ScriptCategory::Creature, "testScript1"));
|
||||
dynamic_cast<AngelScriptScript*>(lib->LoadScript(ScriptCategory::Creature, "testScript1"_cnc));
|
||||
auto ctxPool = obj->GetContextPool();
|
||||
auto ctx = ctxPool->RequestContext();
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ static AngelScripResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* m
|
|||
|
||||
static ScriptData GetScript(PkmnLib::Battling::BattleLibrary* mainLib, const char* funcName) {
|
||||
auto lib = GetScriptResolver(mainLib);
|
||||
auto s = lib->LoadScript(ScriptCategory::Creature, "testScript1");
|
||||
auto s = lib->LoadScript(ScriptCategory::Creature, "testScript1"_cnc);
|
||||
auto script = dynamic_cast<AngelScriptScript*>(s);
|
||||
auto ctxPool = script->GetContextPool();
|
||||
auto ctx = ctxPool->RequestContext();
|
||||
|
|
|
@ -43,7 +43,7 @@ static AngelScripResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* m
|
|||
|
||||
static ScriptData GetScript(PkmnLib::Battling::BattleLibrary* mainLib, const char* funcName) {
|
||||
auto lib = GetScriptResolver(mainLib);
|
||||
auto s = lib->LoadScript(ScriptCategory::Creature, "testScript1");
|
||||
auto s = lib->LoadScript(ScriptCategory::Creature, "testScript1"_cnc);
|
||||
auto script = dynamic_cast<AngelScriptScript*>(s);
|
||||
auto ctxPool = script->GetContextPool();
|
||||
auto ctx = ctxPool->RequestContext();
|
||||
|
|
|
@ -39,7 +39,7 @@ static AngelScripResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* m
|
|||
|
||||
static ScriptData GetScript(PkmnLib::Battling::BattleLibrary* mainLib, const char* funcName) {
|
||||
auto lib = GetScriptResolver(mainLib);
|
||||
auto s = lib->LoadScript(ScriptCategory::Creature, "testScript1");
|
||||
auto s = lib->LoadScript(ScriptCategory::Creature, "testScript1"_cnc);
|
||||
auto script = dynamic_cast<AngelScriptScript*>(s);
|
||||
auto ctxPool = script->GetContextPool();
|
||||
auto ctx = ctxPool->RequestContext();
|
||||
|
|
|
@ -43,7 +43,7 @@ static AngelScripResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* m
|
|||
|
||||
static ScriptData GetScript(PkmnLib::Battling::BattleLibrary* mainLib, const char* funcName) {
|
||||
auto lib = GetScriptResolver(mainLib);
|
||||
auto s = lib->LoadScript(ScriptCategory::Creature, "testScript1");
|
||||
auto s = lib->LoadScript(ScriptCategory::Creature, "testScript1"_cnc);
|
||||
auto script = dynamic_cast<AngelScriptScript*>(s);
|
||||
auto ctxPool = script->GetContextPool();
|
||||
auto ctx = ctxPool->RequestContext();
|
||||
|
|
|
@ -41,7 +41,7 @@ static AngelScripResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* m
|
|||
|
||||
static ScriptData GetScript(PkmnLib::Battling::BattleLibrary* mainLib, const char* funcName) {
|
||||
auto lib = GetScriptResolver(mainLib);
|
||||
auto s = lib->LoadScript(ScriptCategory::Creature, "testScript1");
|
||||
auto s = lib->LoadScript(ScriptCategory::Creature, "testScript1"_cnc);
|
||||
auto script = dynamic_cast<AngelScriptScript*>(s);
|
||||
auto ctxPool = script->GetContextPool();
|
||||
auto ctx = ctxPool->RequestContext();
|
||||
|
|
|
@ -42,7 +42,7 @@ static AngelScripResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* m
|
|||
|
||||
static ScriptData GetScript(PkmnLib::Battling::BattleLibrary* mainLib, const char* funcName) {
|
||||
auto lib = GetScriptResolver(mainLib);
|
||||
auto s = lib->LoadScript(ScriptCategory::Creature, "testScript1");
|
||||
auto s = lib->LoadScript(ScriptCategory::Creature, "testScript1"_cnc);
|
||||
auto script = dynamic_cast<AngelScriptScript*>(s);
|
||||
auto ctxPool = script->GetContextPool();
|
||||
auto ctx = ctxPool->RequestContext();
|
||||
|
|
|
@ -8,33 +8,33 @@ PkmnLib::Library::SpeciesLibrary* TestLibrary::BuildSpeciesLibrary() {
|
|||
new PkmnLib::Library::PokemonSpecies(
|
||||
1, "testSpecies"_cnc,
|
||||
new PkmnLib::Library::PokemonForme(
|
||||
"default", 1.0f, 1.0f, 100, {0},
|
||||
CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"},
|
||||
{"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||
"default"_cnc, 1.0f, 1.0f, 100, {0},
|
||||
CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
|
||||
{"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100));
|
||||
lib->Insert("testSpecies2"_cnc,
|
||||
new PkmnLib::Library::PokemonSpecies(
|
||||
2, "testSpecies2"_cnc,
|
||||
new PkmnLib::Library::PokemonForme(
|
||||
"default", 1.0f, 1.0f, 100, {0},
|
||||
CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"},
|
||||
{"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||
"default"_cnc, 1.0f, 1.0f, 100, {0},
|
||||
CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
|
||||
{"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100));
|
||||
lib->Insert("statTestSpecies1"_cnc,
|
||||
new PkmnLib::Library::PokemonSpecies(
|
||||
3, "statTestSpecies1"_cnc,
|
||||
new PkmnLib::Library::PokemonForme(
|
||||
"default", 1.0f, 1.0f, 100, {0},
|
||||
CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"},
|
||||
{"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||
"default"_cnc, 1.0f, 1.0f, 100, {0},
|
||||
CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
|
||||
{"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100));
|
||||
lib->Insert("testSpecies3"_cnc,
|
||||
new PkmnLib::Library::PokemonSpecies(
|
||||
2, "testSpecies3"_cnc,
|
||||
new PkmnLib::Library::PokemonForme(
|
||||
"default", 1.0f, 1.0f, 100, {0, 4},
|
||||
CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"},
|
||||
{"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||
"default"_cnc, 1.0f, 1.0f, 100, {0, 4},
|
||||
CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
|
||||
{"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100));
|
||||
|
||||
return lib;
|
||||
|
|
Loading…
Reference in New Issue