From 149b0f08f6752d28f1bcd6403ae694dcbad60f23 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Fri, 10 Apr 2020 14:57:20 +0200 Subject: [PATCH] Rework AngelScript effect names to be not based on script names, but on attributes instead. --- src/Battling/Pokemon/CreatePokemon.hpp | 2 +- src/Library/Species/PokemonSpecies.hpp | 2 +- .../AngelScript/AngelScripResolver.cpp | 100 ++++++++++++------ .../AngelScript/AngelScripResolver.hpp | 11 +- .../AngelScript/AngelScriptTypeInfo.hpp | 2 +- tests/ScriptTests/BaseScriptClassTests.cpp | 28 ++++- tests/ScriptTests/ScriptResolverTests.cpp | 2 + .../ScriptTypeTests/Battle/PokemonTests.cpp | 3 + .../ScriptTypeTests/Library/FormesTests.cpp | 3 + .../ScriptTypeTests/Library/ItemDataTests.cpp | 3 + .../ScriptTypeTests/Library/MoveTests.cpp | 3 + .../ScriptTypeTests/Library/SpeciesTests.cpp | 3 + .../Library/StaticLibraryTests.cpp | 3 + tests/TestLibrary/TestLibrary.cpp | 4 +- tests/TestLibrary/TestLibrary.hpp | 10 +- 15 files changed, 131 insertions(+), 48 deletions(-) diff --git a/src/Battling/Pokemon/CreatePokemon.hpp b/src/Battling/Pokemon/CreatePokemon.hpp index fc8b628..63507fd 100644 --- a/src/Battling/Pokemon/CreatePokemon.hpp +++ b/src/Battling/Pokemon/CreatePokemon.hpp @@ -7,7 +7,7 @@ namespace PkmnLib::Battling { class CreatePokemon { private: const BattleLibrary* _library; - Arbutils::CaseInsensitiveConstString _species; + Arbutils::CaseInsensitiveConstString _species = ""_cnc; Arbutils::CaseInsensitiveConstString _forme = "default"_cnc; uint8_t _level; std::string _nickname = ""; diff --git a/src/Library/Species/PokemonSpecies.hpp b/src/Library/Species/PokemonSpecies.hpp index cd05714..f8ff163 100644 --- a/src/Library/Species/PokemonSpecies.hpp +++ b/src/Library/Species/PokemonSpecies.hpp @@ -23,7 +23,7 @@ namespace PkmnLib::Library { inline uint8_t GetBaseHappiness() const { return _baseHappiness; } inline const PokemonForme* GetDefaultForme() const { - return reinterpret_cast(CreatureSpecies::GetVariant("default"_cnc)); + return reinterpret_cast(CreatureSpecies::GetVariant("default"_cnc.GetHash())); } inline bool HasForme(const Arbutils::CaseInsensitiveConstString& key) const { return HasVariant(key); } diff --git a/src/ScriptResolving/AngelScript/AngelScripResolver.cpp b/src/ScriptResolving/AngelScript/AngelScripResolver.cpp index 5da871c..f22b0bc 100644 --- a/src/ScriptResolving/AngelScript/AngelScripResolver.cpp +++ b/src/ScriptResolving/AngelScript/AngelScripResolver.cpp @@ -1,6 +1,7 @@ #include "AngelScripResolver.hpp" #include #include +#include #include "../../../extern/angelscript_addons/scriptarray/scriptarray.h" #include "../../../extern/angelscript_addons/scripthandle/scripthandle.h" #include "../../../extern/angelscript_addons/scripthelper/scripthelper.h" @@ -24,6 +25,10 @@ CreatureLib::Battling::ScriptResolver* PkmnLib::Battling::BattleLibrary::CreateS } void AngelScripResolver::Initialize(CreatureLib::Battling::BattleLibrary* arg) { + for (auto scriptCategory : ScriptCategoryHelper::GetValues()) { + _typeDatabase.Insert(scriptCategory, {}); + } + auto library = (PkmnLib::Battling::BattleLibrary*)arg; _engine = asCreateScriptEngine(); @@ -87,20 +92,6 @@ void AngelScripResolver::RegisterTypes() { BasicScriptClass::Register(_engine); } -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({name, nullptr}); - return nullptr; - } - auto typeinfo = new AngelScriptTypeInfo(name, type); - _types.insert({name, typeinfo}); - return typeinfo; -} void AngelScripResolver::MessageCallback(const asSMessageInfo* msg, void* param) { const char* type = "ERR "; if (msg->type == asMSGTYPE_WARNING) @@ -110,33 +101,78 @@ void AngelScripResolver::MessageCallback(const asSMessageInfo* msg, void* param) printf("%s (%d, %d) : %s : %s\n", msg->section, msg->row, msg->col, type, msg->message); } -static constexpr const char* GetCategoryNamespace(ScriptCategory category) { - switch (category) { - case ScriptCategory::Attack: return "Moves"; - case ScriptCategory::Talent: return "Abilities"; - case ScriptCategory::Status: return "Status"; - case ScriptCategory::Creature: return "Pokemon"; - case ScriptCategory::Battle: return "Battle"; - case ScriptCategory::Side: return "Side"; - default: throw CreatureException("Unknown script category"); - } -} - CreatureLib::Battling::Script* AngelScripResolver::LoadScript(ScriptCategory category, const ConstString& scriptName) { - std::stringstream decl; - decl << GetCategoryNamespace(category) << "::" << scriptName.c_str(); - auto typeInfo = GetTypeInfo(scriptName, decl.str()); - if (typeInfo == nullptr) + Dictionary innerDb; + if (!_typeDatabase.TryGet(category, innerDb)) { + _typeDatabase.Insert(category, innerDb); return nullptr; + } + AngelScriptTypeInfo* t; + if (!innerDb.TryGet(scriptName, t)) { + innerDb.Insert(scriptName, nullptr); + return nullptr; + } + if (t == nullptr) { + return nullptr; + } auto ctx = _contextPool->RequestContext(); - auto obj = typeInfo->Instantiate(ctx); + auto obj = t->Instantiate(ctx); _contextPool->ReturnContextToPool(ctx); - return new AngelScriptScript(typeInfo, obj, _contextPool); + return new AngelScriptScript(t, obj, _contextPool); } void AngelScripResolver::FinalizeModule() { int r = _builder.BuildModule(); if (r < 0) throw CreatureException("Building Script Module failed."); + int count = _mainModule->GetObjectTypeCount(); + std::regex metadataMatcher("^\\s*(\\w+)([\\w\\s=]*)$", std::regex_constants::icase); + std::regex variableMatcher("\\s*(\\w+)=(\\w+)", std::regex_constants::icase); + std::smatch base_match; + + for (int n = 0; n < count; n++) { + auto typeInfo = _mainModule->GetObjectTypeByIndex(n); + auto metadata = _builder.GetMetadataForType(typeInfo->GetTypeId()); + for (int m = 0; m < metadata.size(); m++) { + auto data = metadata[m]; + if (std::regex_match(data, base_match, metadataMatcher)) { + auto metadataKind = base_match[1].str(); + auto metadataVariables = base_match[2].str(); + if (!std::regex_match(metadataVariables, base_match, variableMatcher)) { + continue; + } + ConstString effectName; + for (size_t variableIndex = 1; variableIndex < base_match.size(); variableIndex += 2) { + if (base_match[variableIndex] == "effect") { + auto val = base_match[variableIndex + 1].str(); + effectName = ConstString(val); + } + } + if (effectName.Empty()) { + continue; + } + + if (metadataKind == "Move") { + _typeDatabase[ScriptCategory::Attack].Insert(effectName, + new AngelScriptTypeInfo(effectName, typeInfo)); + } else if (metadataKind == "Pokemon") { + _typeDatabase[ScriptCategory::Creature].Insert(effectName, + new AngelScriptTypeInfo(effectName, typeInfo)); + } else if (metadataKind == "Ability") { + _typeDatabase[ScriptCategory::Talent].Insert(effectName, + new AngelScriptTypeInfo(effectName, typeInfo)); + } else if (metadataKind == "Status") { + _typeDatabase[ScriptCategory::Status].Insert(effectName, + new AngelScriptTypeInfo(effectName, typeInfo)); + } else if (metadataKind == "Battle") { + _typeDatabase[ScriptCategory::Battle].Insert(effectName, + new AngelScriptTypeInfo(effectName, typeInfo)); + } else if (metadataKind == "Side") { + _typeDatabase[ScriptCategory::Side].Insert(effectName, + new AngelScriptTypeInfo(effectName, typeInfo)); + } + } + } + } } void AngelScripResolver::CreateScript(const char* name, const char* script) { _builder.AddSectionFromMemory(name, script); diff --git a/src/ScriptResolving/AngelScript/AngelScripResolver.hpp b/src/ScriptResolving/AngelScript/AngelScripResolver.hpp index de9543c..67a084f 100644 --- a/src/ScriptResolving/AngelScript/AngelScripResolver.hpp +++ b/src/ScriptResolving/AngelScript/AngelScripResolver.hpp @@ -10,6 +10,7 @@ #include #include "AngelScriptScript.hpp" #include "AngelScriptTypeInfo.hpp" +using namespace Arbutils::Collections; class AngelScripResolver : public CreatureLib::Battling::ScriptResolver { private: @@ -17,21 +18,21 @@ private: asIScriptModule* _mainModule = nullptr; ContextPool* _contextPool = nullptr; CScriptBuilder _builder; - std::unordered_map _types; static void MessageCallback(const asSMessageInfo* msg, void* param); static void Print(const std::string& str) { std::cout << str << std::endl; } - AngelScriptTypeInfo* GetTypeInfo(const ConstString& name, const std::string& decl); + Dictionary> _typeDatabase; void RegisterTypes(); public: ~AngelScripResolver() override { delete _contextPool; - for (const auto& type : _types) { - delete type.second; + for (const auto& category : _typeDatabase) { + for (const auto& type : category.second){ + delete type.second; + } } - _types.clear(); _engine->ShutDownAndRelease(); } diff --git a/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp b/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp index 03590fe..0d33064 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp +++ b/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp @@ -15,7 +15,7 @@ using ConstString = Arbutils::CaseInsensitiveConstString; class AngelScriptTypeInfo { private: asITypeInfo* _type = nullptr; - Arbutils::Collections::Dictionary _functions; + Arbutils::Collections::Dictionary _functions; ConstString _name; struct FunctionInfo { diff --git a/tests/ScriptTests/BaseScriptClassTests.cpp b/tests/ScriptTests/BaseScriptClassTests.cpp index 30bdbe0..5e222ad 100644 --- a/tests/ScriptTests/BaseScriptClassTests.cpp +++ b/tests/ScriptTests/BaseScriptClassTests.cpp @@ -5,7 +5,7 @@ #include "../TestLibrary/TestLibrary.hpp" #define AS_CLASS(name, contents) \ - { #name, "namespace Pokemon{ class " #name " : PkmnScript { " contents "}}" } + { #name, "namespace Pokemon{ [Pokemon effect=" #name "] class " #name " : PkmnScript { " contents "}}" } static std::unordered_map _scripts = std::unordered_map{ AS_CLASS(blankScript, ), @@ -20,6 +20,7 @@ class doubleInheritanceScriptBase : PkmnScript { int GetValue(){ return value; } } +[Pokemon effect=doubleInheritanceScript] class doubleInheritanceScript : doubleInheritanceScriptBase {} )"}, AS_CLASS(preventAttackScript, @@ -78,12 +79,16 @@ static AngelScriptScript* GetScript(PkmnLib::Battling::BattleLibrary* mainLib, c auto lib = GetScriptResolver(mainLib); auto s = lib->LoadScript(ScriptCategory::Creature, scriptName); auto script = dynamic_cast(s); + REQUIRE(script != nullptr); + return script; } TEST_CASE("Invoke non-implemented script function") { auto mainLib = TestLibrary::GetLibrary(); auto script = GetScript(mainLib, "blankScript"_cnc); + REQUIRE(script != nullptr); + script->Stack(); delete script; } @@ -91,6 +96,8 @@ TEST_CASE("Invoke non-implemented script function") { TEST_CASE("Invoke Stack script function") { auto mainLib = TestLibrary::GetLibrary(); auto script = GetScript(mainLib, "stackScript"_cnc); + REQUIRE(script != nullptr); + for (int i = 1; i <= 10; i++) { script->Stack(); @@ -108,6 +115,8 @@ TEST_CASE("Invoke Stack script function") { TEST_CASE("Invoke OnRemove script function") { auto mainLib = TestLibrary::GetLibrary(); auto script = GetScript(mainLib, "onRemoveScript"_cnc); + REQUIRE(script != nullptr); + script->OnRemove(); auto ctxPool = script->GetContextPool(); @@ -160,6 +169,7 @@ TEST_CASE("Invoke StopBeforeAttack script function") { TEST_CASE("Invoke OnBeforeAttack script function") { auto mainLib = TestLibrary::GetLibrary(); auto script = GetScript(mainLib, "OnBeforeAttackScript"_cnc); + REQUIRE(script != nullptr); script->OnBeforeAttack(nullptr); @@ -176,6 +186,7 @@ TEST_CASE("Invoke OnBeforeAttack script function") { TEST_CASE("Invoke FailIncomingAttack script function") { auto mainLib = TestLibrary::GetLibrary(); auto script = GetScript(mainLib, "FailIncomingAttackScript"_cnc); + REQUIRE(script != nullptr); bool b = false; script->FailIncomingAttack(nullptr, nullptr, &b); REQUIRE(b); @@ -186,6 +197,7 @@ TEST_CASE("Invoke FailIncomingAttack script function") { TEST_CASE("Invoke OnAttackMiss script function") { auto mainLib = TestLibrary::GetLibrary(); auto script = GetScript(mainLib, "OnAttackMissScript"_cnc); + REQUIRE(script != nullptr); script->OnAttackMiss(nullptr, nullptr); @@ -202,6 +214,7 @@ TEST_CASE("Invoke OnAttackMiss script function") { TEST_CASE("Invoke ChangeAttackType script function") { auto mainLib = TestLibrary::GetLibrary(); auto script = GetScript(mainLib, "ChangeAttackTypeScript"_cnc); + REQUIRE(script != nullptr); uint8_t b = 0; script->ChangeAttackType(nullptr, nullptr, 0, &b); REQUIRE(b == 1); @@ -254,6 +267,7 @@ TEST_CASE("Invoke OnSecondaryEffect script function") { TEST_CASE("Invoke OnAfterHits script function") { auto mainLib = TestLibrary::GetLibrary(); auto script = GetScript(mainLib, "OnAfterHitsScript"_cnc); + REQUIRE(script != nullptr); script->OnAfterHits(nullptr, nullptr); @@ -272,9 +286,21 @@ void TryException(AngelScriptScript* script) { script->PreventAttack(nullptr, &b); } +TEST_CASE("Get script name.") { + auto mainLib = TestLibrary::GetLibrary(); + auto script = GetScript(mainLib, "throwScript"_cnc); + REQUIRE(script != nullptr); + INFO(script->GetName().c_str()); + INFO(script->GetName().std_str()); + CHECK(strcmp(script->GetName().c_str(), "throwScript") == 0); + delete script; +} + + TEST_CASE("Handle script exceptions.") { auto mainLib = TestLibrary::GetLibrary(); auto script = GetScript(mainLib, "throwScript"_cnc); + REQUIRE(script != nullptr); CHECK_THROWS_WITH( TryException(script), Catch::Matchers::Equals("Script exception in script 'throwScript', line 1. Message: 'test exception'.")); diff --git a/tests/ScriptTests/ScriptResolverTests.cpp b/tests/ScriptTests/ScriptResolverTests.cpp index 38c9117..0ecdcb2 100644 --- a/tests/ScriptTests/ScriptResolverTests.cpp +++ b/tests/ScriptTests/ScriptResolverTests.cpp @@ -6,6 +6,7 @@ static std::unordered_map _scripts = std::unordered_map{{"testScript1", R"( namespace Pokemon{ +[Pokemon effect=testScript1] class testScript1 { int add(int a, int b) { return a + b; @@ -54,6 +55,7 @@ TEST_CASE("Build script resolver, create object, invoke addition method") { auto obj = dynamic_cast(lib->LoadScript(ScriptCategory::Creature, "testScript1"_cnc)); + REQUIRE(obj != nullptr); auto ctxPool = obj->GetContextPool(); auto ctx = ctxPool->RequestContext(); diff --git a/tests/ScriptTests/ScriptTypeTests/Battle/PokemonTests.cpp b/tests/ScriptTests/ScriptTypeTests/Battle/PokemonTests.cpp index 64ae51e..f568b05 100644 --- a/tests/ScriptTests/ScriptTypeTests/Battle/PokemonTests.cpp +++ b/tests/ScriptTests/ScriptTypeTests/Battle/PokemonTests.cpp @@ -7,6 +7,7 @@ static std::unordered_map _scripts = std::unordered_map{{"testScript1", R"( namespace Pokemon{ +[Pokemon effect=testScript1] class testScript1 { bool testSpecies(Pokemon@ p, const Species@ species){ return p.Species is species; } bool testForme(Pokemon@ p, const Forme@ forme){ return p.Forme is forme; } @@ -55,6 +56,8 @@ static ScriptData GetScript(PkmnLib::Battling::BattleLibrary* mainLib, const Con auto lib = GetScriptResolver(mainLib); auto s = lib->LoadScript(ScriptCategory::Creature, "testScript1"_cnc); auto script = dynamic_cast(s); + REQUIRE(script != nullptr); + auto ctxPool = script->GetContextPool(); auto ctx = ctxPool->RequestContext(); diff --git a/tests/ScriptTests/ScriptTypeTests/Library/FormesTests.cpp b/tests/ScriptTests/ScriptTypeTests/Library/FormesTests.cpp index 36c52db..03121e9 100644 --- a/tests/ScriptTests/ScriptTypeTests/Library/FormesTests.cpp +++ b/tests/ScriptTests/ScriptTypeTests/Library/FormesTests.cpp @@ -6,6 +6,7 @@ static std::unordered_map _scripts = std::unordered_map{{"testScript1", R"( namespace Pokemon{ +[Pokemon effect=testScript1] class testScript1 { bool testName(const Forme@ s, const constString &in name){ return s.Name == name; } bool testWeight(const Forme@ s, float weight){ return s.Weight == weight; } @@ -45,6 +46,8 @@ static ScriptData GetScript(PkmnLib::Battling::BattleLibrary* mainLib, const Con auto lib = GetScriptResolver(mainLib); auto s = lib->LoadScript(ScriptCategory::Creature, "testScript1"_cnc); auto script = dynamic_cast(s); + REQUIRE(script != nullptr); + auto ctxPool = script->GetContextPool(); auto ctx = ctxPool->RequestContext(); diff --git a/tests/ScriptTests/ScriptTypeTests/Library/ItemDataTests.cpp b/tests/ScriptTests/ScriptTypeTests/Library/ItemDataTests.cpp index d8cec8b..0d15a02 100644 --- a/tests/ScriptTests/ScriptTypeTests/Library/ItemDataTests.cpp +++ b/tests/ScriptTests/ScriptTypeTests/Library/ItemDataTests.cpp @@ -6,6 +6,7 @@ static std::unordered_map _scripts = std::unordered_map{{"testScript1", R"( namespace Pokemon{ +[Pokemon effect=testScript1] class testScript1 { bool testName(const Item@ i, const constString &in name){ return i.Name == name; } bool testCategory(const Item@ i, ItemCategory category){ return i.Category == category; } @@ -41,6 +42,8 @@ static ScriptData GetScript(PkmnLib::Battling::BattleLibrary* mainLib, const Con auto lib = GetScriptResolver(mainLib); auto s = lib->LoadScript(ScriptCategory::Creature, "testScript1"_cnc); auto script = dynamic_cast(s); + REQUIRE(script != nullptr); + auto ctxPool = script->GetContextPool(); auto ctx = ctxPool->RequestContext(); diff --git a/tests/ScriptTests/ScriptTypeTests/Library/MoveTests.cpp b/tests/ScriptTests/ScriptTypeTests/Library/MoveTests.cpp index e4eeb7c..c65e3a6 100644 --- a/tests/ScriptTests/ScriptTypeTests/Library/MoveTests.cpp +++ b/tests/ScriptTests/ScriptTypeTests/Library/MoveTests.cpp @@ -6,6 +6,7 @@ static std::unordered_map _scripts = std::unordered_map{{"testScript1", R"( namespace Pokemon{ +[Pokemon effect=testScript1] class testScript1 { bool testName(const MoveData@ s, const constString &in name){ return s.Name == name; } bool testType(const MoveData@ s, uint8 type){ return s.Type == type; } @@ -45,6 +46,8 @@ static ScriptData GetScript(PkmnLib::Battling::BattleLibrary* mainLib, const Con auto lib = GetScriptResolver(mainLib); auto s = lib->LoadScript(ScriptCategory::Creature, "testScript1"_cnc); auto script = dynamic_cast(s); + REQUIRE(script != nullptr); + auto ctxPool = script->GetContextPool(); auto ctx = ctxPool->RequestContext(); diff --git a/tests/ScriptTests/ScriptTypeTests/Library/SpeciesTests.cpp b/tests/ScriptTests/ScriptTypeTests/Library/SpeciesTests.cpp index 3268ae5..645945c 100644 --- a/tests/ScriptTests/ScriptTypeTests/Library/SpeciesTests.cpp +++ b/tests/ScriptTests/ScriptTypeTests/Library/SpeciesTests.cpp @@ -6,6 +6,7 @@ static std::unordered_map _scripts = std::unordered_map{{"testScript1", R"( namespace Pokemon{ +[Pokemon effect=testScript1] class testScript1 { bool testName(const Species@ s, const constString &in name){ return s.Name == name; } bool testId(const Species@ s, uint16 id){ return s.Id == id; } @@ -43,6 +44,8 @@ static ScriptData GetScript(PkmnLib::Battling::BattleLibrary* mainLib, const Con auto lib = GetScriptResolver(mainLib); auto s = lib->LoadScript(ScriptCategory::Creature, "testScript1"_cnc); auto script = dynamic_cast(s); + REQUIRE(script != nullptr); + auto ctxPool = script->GetContextPool(); auto ctx = ctxPool->RequestContext(); diff --git a/tests/ScriptTests/ScriptTypeTests/Library/StaticLibraryTests.cpp b/tests/ScriptTests/ScriptTypeTests/Library/StaticLibraryTests.cpp index 64b6d53..b700ce6 100644 --- a/tests/ScriptTests/ScriptTypeTests/Library/StaticLibraryTests.cpp +++ b/tests/ScriptTests/ScriptTypeTests/Library/StaticLibraryTests.cpp @@ -6,6 +6,7 @@ static std::unordered_map _scripts = std::unordered_map{{"testScript1", R"( namespace Pokemon{ +[Pokemon effect=testScript1] class testScript1 { bool testMaximumLevel(const StaticLibrary@ s, uint8 level){ return s.Settings.MaximalLevel == level; } bool testMaximumMoves(const StaticLibrary@ s, uint8 moveCount){ return s.Settings.MaximalMoves == moveCount; } @@ -44,6 +45,8 @@ static ScriptData GetScript(PkmnLib::Battling::BattleLibrary* mainLib, const Con auto lib = GetScriptResolver(mainLib); auto s = lib->LoadScript(ScriptCategory::Creature, "testScript1"_cnc); auto script = dynamic_cast(s); + REQUIRE(script != nullptr); + auto ctxPool = script->GetContextPool(); auto ctx = ctxPool->RequestContext(); diff --git a/tests/TestLibrary/TestLibrary.cpp b/tests/TestLibrary/TestLibrary.cpp index 5569f51..ac58127 100644 --- a/tests/TestLibrary/TestLibrary.cpp +++ b/tests/TestLibrary/TestLibrary.cpp @@ -41,11 +41,11 @@ PkmnLib::Library::SpeciesLibrary* TestLibrary::BuildSpeciesLibrary() { } PkmnLib::Library::MoveLibrary* TestLibrary::BuildMoveLibrary() { auto lib = new PkmnLib::Library::MoveLibrary(); - lib->Insert("testMove"_cnc, + lib->Insert("testMove"_cnc.GetHash(), new PkmnLib::Library::MoveData("testMove"_cnc, 0, PkmnLib::Library::MoveCategory::Physical, 50, 100, 20, CreatureLib::Library::AttackTarget::Adjacent, 0, CreatureLib::Library::SecondaryEffect(), {})); - lib->Insert("testMove2"_cnc, + lib->Insert("testMove2"_cnc.GetHash(), new PkmnLib::Library::MoveData("testMove2"_cnc, 0, PkmnLib::Library::MoveCategory::Special, 30, 100, 10, CreatureLib::Library::AttackTarget::Adjacent, 0, CreatureLib::Library::SecondaryEffect(), {})); diff --git a/tests/TestLibrary/TestLibrary.hpp b/tests/TestLibrary/TestLibrary.hpp index 992b765..d4bf492 100644 --- a/tests/TestLibrary/TestLibrary.hpp +++ b/tests/TestLibrary/TestLibrary.hpp @@ -24,8 +24,7 @@ public: auto scriptResolver = PkmnLib::Battling::BattleLibrary::CreateScriptResolver(); auto lib = new PkmnLib::Battling::BattleLibrary( BuildStaticLibrary(), statCalc, new PkmnLib::Battling::DamageLibrary(), - new CreatureLib::Battling::ExperienceLibrary(), scriptResolver, - new CreatureLib::Battling::MiscLibrary()); + new CreatureLib::Battling::ExperienceLibrary(), scriptResolver, new CreatureLib::Battling::MiscLibrary()); scriptResolver->Initialize(lib); return lib; } @@ -45,7 +44,7 @@ public: static CreatureLib::Library::GrowthRateLibrary* BuildGrowthRateLibrary() { auto lib = new CreatureLib::Library::GrowthRateLibrary(); lib->AddGrowthRate( - "testGrowthRate"_cnc, + "testGrowthRate"_cnc.GetHash(), new CreatureLib::Library::LookupGrowthRate( {0, 15, 52, 122, 237, 406, 637, 942, 1326, 1800, 2369, 3041, 3822, 4719, 5737, 6881, 8155, 9564, 11111, 12800, 14632, 16610, 18737, 21012, 23437, 26012, @@ -67,8 +66,9 @@ public: auto lib = new PkmnLib::Library::NatureLibrary(); lib->LoadNature("neutralNature", PkmnLib::Library::Nature(PkmnLib::Library::Statistic::PhysicalAttack, PkmnLib::Library::Statistic::PhysicalDefense, 1, 1)); - lib->LoadNature("buffsAttackNerfsSpeed", PkmnLib::Library::Nature(PkmnLib::Library::Statistic::PhysicalAttack, - PkmnLib::Library::Statistic::Speed, 1.1, 0.9)); + lib->LoadNature("buffsAttackNerfsSpeed", + PkmnLib::Library::Nature(PkmnLib::Library::Statistic::PhysicalAttack, + PkmnLib::Library::Statistic::Speed, 1.1, 0.9)); return lib; } };