From 45662cb29b8c255a948d3ecfeb3ea91f73be5a53 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sat, 15 Feb 2020 19:04:06 +0100 Subject: [PATCH] Update to new CreatureLib version, updated libraries in accordance. --- conanfile.py | 2 +- src/Battling/Pokemon/CreatePokemon.cpp | 6 +++--- src/Library/Items/ItemLibrary.hpp | 16 +++++++++------- src/Library/Moves/MoveLibrary.hpp | 19 +++++-------------- src/Library/Species/SpeciesLibrary.hpp | 16 ++++++++-------- .../Library/RegisterItemTypes.cpp | 4 ++-- .../Library/RegisterMoveTypes.cpp | 4 ++-- .../Library/RegisterSpeciesTypes.cpp | 4 ++-- tests/LibraryTests/SpeciesLibraryTests.cpp | 6 +++--- .../ScriptTypeTests/Library/FormesTests.cpp | 16 ++++++++-------- .../ScriptTypeTests/Library/ItemDataTests.cpp | 8 ++++---- .../ScriptTypeTests/Library/MoveTests.cpp | 16 ++++++++-------- .../ScriptTypeTests/Library/SpeciesTests.cpp | 12 ++++++------ tests/TestLibrary/TestLibrary.cpp | 14 +++++++------- 14 files changed, 68 insertions(+), 75 deletions(-) diff --git a/conanfile.py b/conanfile.py index 1ff2f0a..bc319f8 100644 --- a/conanfile.py +++ b/conanfile.py @@ -44,7 +44,7 @@ class PkmnLibConan(ConanFile): self.options["AngelScript"].link_std_statically = True def requirements(self): - self.requires("CreatureLib/a6f91faba45b39b716510b4348e3f747eab9bb2d@creaturelib/master") + self.requires("CreatureLib/d6ea16b467c23ad532b548007df4ec52d58265b3@creaturelib/master") if self.options.script_handler == "angelscript": self.requires("AngelScript/2.34@AngelScript/Deukhoofd") else: diff --git a/src/Battling/Pokemon/CreatePokemon.cpp b/src/Battling/Pokemon/CreatePokemon.cpp index b4249a1..7b51a0d 100644 --- a/src/Battling/Pokemon/CreatePokemon.cpp +++ b/src/Battling/Pokemon/CreatePokemon.cpp @@ -40,7 +40,7 @@ PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::WithEffortVa PkmnLib::Battling::Pokemon* PkmnLib::Battling::CreatePokemon::Build() { auto rand = CreatureLib::Core::Random(); const PkmnLib::Library::PokemonSpecies* species = nullptr; - if (!this->_library->GetSpeciesLibrary()->TryGetPkmnSpecies(this->_species, species)) { + if (!this->_library->GetSpeciesLibrary()->TryGet(this->_species.c_str(), species)) { std::stringstream err; err << "Invalid species '" << _species << "'."; throw CreatureException(err.str()); @@ -67,7 +67,7 @@ PkmnLib::Battling::Pokemon* PkmnLib::Battling::CreatePokemon::Build() { } const Library::Item* heldItem = nullptr; if (!this->_heldItem.empty()) { - if (!_library->GetItemLibrary()->TryGetItem(this->_heldItem, heldItem)) { + if (!_library->GetItemLibrary()->TryGet(this->_heldItem.c_str(), heldItem)) { throw CreatureException("Unknown Item: " + this->_heldItem); } } @@ -143,7 +143,7 @@ PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::WithHeldItem PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::LearnMove(const std::string& moveName, CreatureLib::Battling::AttackLearnMethod method) { const PkmnLib::Library::MoveData* move; - if (!_library->GetMoveLibrary()->TryGetMove(moveName, move)){ + if (!_library->GetMoveLibrary()->TryGet(moveName.c_str(), move)){ throw CreatureException("Invalid Move given: " + moveName); } if (_attacks.size() >= _library->GetSettings()->GetMaximalMoves()){ diff --git a/src/Library/Items/ItemLibrary.hpp b/src/Library/Items/ItemLibrary.hpp index 86aebf7..d26f082 100644 --- a/src/Library/Items/ItemLibrary.hpp +++ b/src/Library/Items/ItemLibrary.hpp @@ -6,15 +6,17 @@ namespace PkmnLib::Library { class ItemLibrary : public CreatureLib::Library::ItemLibrary { public: - inline bool TryGetItem(const std::string& name, const Item*& item) const { - return CreatureLib::Library::ItemLibrary::TryGetItem(name, (const CreatureLib::Library::Item*&)item); + inline bool TryGet(const char* name, const Item*& item) const{ + return CreatureLib::Library::ItemLibrary::TryGet(name, (const CreatureLib::Library::Item*&)item); } - const Item* GetItem(const std::string& name) const { - return reinterpret_cast(CreatureLib::Library::ItemLibrary::GetItem(name)); + + inline const Item* Get(const char* name) const{ + return reinterpret_cast(CreatureLib::Library::ItemLibrary::Get(name)); } - const Item* operator[](const std::string& name) const { return GetItem(name); } - void LoadItem(const std::string& name, const Item* item) { - CreatureLib::Library::ItemLibrary::LoadItem(name, item); + const Item* operator[](const char* name) const { return Get(name); } + + void Insert(const char* name, const Item* item) { + CreatureLib::Library::ItemLibrary::Insert(name, item); } }; } diff --git a/src/Library/Moves/MoveLibrary.hpp b/src/Library/Moves/MoveLibrary.hpp index eaa2679..18b42d4 100644 --- a/src/Library/Moves/MoveLibrary.hpp +++ b/src/Library/Moves/MoveLibrary.hpp @@ -8,22 +8,13 @@ namespace PkmnLib::Library { public: MoveLibrary(size_t initialCapacity = 32) : CreatureLib::Library::AttackLibrary(initialCapacity) {} - virtual const MoveData* operator[](const std::string& name) const { return GetAttack(name); } + virtual const MoveData* operator[](const char* name) const { return Get(name); } - inline bool TryGetMove(const std::string& name, const MoveData*& move) const{ - return TryGetAttack(name, (const CreatureLib::Library::AttackData*&)move); + inline bool TryGet(const char* name, const MoveData*& move) const { + return CreatureLib::Library::AttackLibrary::TryGet(name, (const CreatureLib::Library::AttackData*&)move); } - const MoveData* GetMove(const std::string& name) const { return GetAttack(name); } - - const MoveData* GetAttack(const std::string& name) const { - return reinterpret_cast(CreatureLib::Library::AttackLibrary::GetAttack(name)); - } - void LoadAttack(const std::string& name, const MoveData* attack) { - CreatureLib::Library::AttackLibrary::LoadAttack(name, attack); - } - - void LoadMove(const std::string& name, const MoveData* attack) { - CreatureLib::Library::AttackLibrary::LoadAttack(name, attack); + const MoveData* Get(const char* name) const { + return dynamic_cast(CreatureLib::Library::AttackLibrary::Get(name)); } }; } diff --git a/src/Library/Species/SpeciesLibrary.hpp b/src/Library/Species/SpeciesLibrary.hpp index 88a4580..13b0c29 100644 --- a/src/Library/Species/SpeciesLibrary.hpp +++ b/src/Library/Species/SpeciesLibrary.hpp @@ -7,19 +7,19 @@ namespace PkmnLib::Library { class SpeciesLibrary : public CreatureLib::Library::SpeciesLibrary { public: - - inline bool TryGetPkmnSpecies(const std::string& name, const PokemonSpecies*& outSpecies) const{ - return TryGetSpecies(name, (const CreatureLib::Library::CreatureSpecies*&)outSpecies); + inline bool TryGet(const char* name, const PokemonSpecies*& outSpecies) const { + return CreatureLib::Library::SpeciesLibrary::TryGet( + name, (const CreatureLib::Library::CreatureSpecies*&)outSpecies); } - inline const PokemonSpecies* GetPkmnSpecies(const std::string& name) const { - return dynamic_cast(CreatureLib::Library::SpeciesLibrary::GetSpecies(name)); + inline const PokemonSpecies* Get(const char* name) const { + return dynamic_cast(CreatureLib::Library::SpeciesLibrary::Get(name)); } - const PokemonSpecies* operator[](const std::string& name) const { return GetPkmnSpecies(name); } + const PokemonSpecies* operator[](const char* name) const { return Get(name); } - void LoadSpecies(const std::string& name, const PokemonSpecies* species){ - CreatureLib::Library::SpeciesLibrary::LoadSpecies(name, species); + void Insert(const char* name, const PokemonSpecies* species) { + CreatureLib::Library::SpeciesLibrary::Insert(name, species); } }; } diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterItemTypes.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterItemTypes.cpp index c65d4e6..f2c6c3b 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterItemTypes.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterItemTypes.cpp @@ -77,7 +77,7 @@ void RegisterItemTypes::RegisterItemType(asIScriptEngine* engine) { void RegisterItemTypes::RegisterItemLibrary(asIScriptEngine* engine) { [[maybe_unused]] int r = engine->RegisterObjectType("ItemLibrary", 0, asOBJ_REF | asOBJ_NOCOUNT); assert(r >= 0); - r = engine->RegisterObjectMethod("ItemLibrary", "const Item@ GetItem(const string &in name) const", - asMETHOD(PkmnLib::Library::ItemLibrary, GetItem), asCALL_THISCALL); + r = engine->RegisterObjectMethod("ItemLibrary", "const Item@ Get(const string &in name) const", + asMETHOD(PkmnLib::Library::ItemLibrary, Get), asCALL_THISCALL); assert(r >= 0); } diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterMoveTypes.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterMoveTypes.cpp index 23459a7..2022748 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterMoveTypes.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterMoveTypes.cpp @@ -80,8 +80,8 @@ 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 name) const", - asMETHOD(PkmnLib::Library::MoveLibrary, GetMove), asCALL_THISCALL); + r = engine->RegisterObjectMethod("MoveLibrary", "const MoveData@ Get(const string &in name) const", + asMETHOD(PkmnLib::Library::MoveLibrary, Get), asCALL_THISCALL); assert(r >= 0); } diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterSpeciesTypes.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterSpeciesTypes.cpp index 734401a..bac3a7d 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterSpeciesTypes.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterSpeciesTypes.cpp @@ -99,7 +99,7 @@ void RegisterSpeciesTypes::RegisterFormeType(asIScriptEngine* engine) { 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); + r = engine->RegisterObjectMethod("SpeciesLibrary", "const Species@ Get(const string &in name) const", + asMETHOD(PkmnLib::Library::SpeciesLibrary, Get), asCALL_THISCALL); assert(r >= 0); } diff --git a/tests/LibraryTests/SpeciesLibraryTests.cpp b/tests/LibraryTests/SpeciesLibraryTests.cpp index 550b3cc..02e83c8 100644 --- a/tests/LibraryTests/SpeciesLibraryTests.cpp +++ b/tests/LibraryTests/SpeciesLibraryTests.cpp @@ -10,7 +10,7 @@ TEST_CASE("Able to build and destroy empty library", "library") { TEST_CASE("Able to build, destroy and insert library", "library") { auto lib = new PkmnLib::Library::SpeciesLibrary(); - lib->LoadSpecies("foo", + lib->Insert("foo", new PkmnLib::Library::PokemonSpecies( 1, "foo", new PkmnLib::Library::PokemonForme( @@ -23,7 +23,7 @@ TEST_CASE("Able to build, destroy and insert library", "library") { TEST_CASE("Able to insert and retrieve from library", "library") { auto lib = new PkmnLib::Library::SpeciesLibrary(); - lib->LoadSpecies("foo", + lib->Insert("foo", new PkmnLib::Library::PokemonSpecies( 1, "foo", new PkmnLib::Library::PokemonForme( @@ -31,7 +31,7 @@ TEST_CASE("Able to insert and retrieve from library", "library") { CreatureLib::Core::StatisticSet(100, 100, 100, 100, 100, 100), {"testAbility"}, {"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)), 0.5f, "testGrowthRate", 100, 100)); - auto val = lib->GetPkmnSpecies("foo"); + auto val = lib->Get("foo"); REQUIRE(val->GetName() == "foo"); delete lib; } diff --git a/tests/ScriptTests/ScriptTypeTests/Library/FormesTests.cpp b/tests/ScriptTests/ScriptTypeTests/Library/FormesTests.cpp index 777f564..3dae182 100644 --- a/tests/ScriptTests/ScriptTypeTests/Library/FormesTests.cpp +++ b/tests/ScriptTests/ScriptTypeTests/Library/FormesTests.cpp @@ -62,7 +62,7 @@ TEST_CASE("Validate Forme Name in Script") { auto mainLib = TestLibrary::GetLibrary(); auto data = GetScript(mainLib, "testName"); - auto forme = mainLib->GetSpeciesLibrary()->GetPkmnSpecies("testSpecies2")->GetDefaultForme(); + auto forme = mainLib->GetSpeciesLibrary()->Get("testSpecies2")->GetDefaultForme(); data.Context->SetArgObject(0, const_cast(forme)); auto name = forme->GetName(); data.Context->SetArgAddress(1, &name); @@ -77,7 +77,7 @@ TEST_CASE("Validate Forme Weight in Script") { auto mainLib = TestLibrary::GetLibrary(); auto data = GetScript(mainLib, "testWeight"); - auto forme = mainLib->GetSpeciesLibrary()->GetPkmnSpecies("testSpecies2")->GetDefaultForme(); + auto forme = mainLib->GetSpeciesLibrary()->Get("testSpecies2")->GetDefaultForme(); data.Context->SetArgObject(0, const_cast(forme)); data.Context->SetArgFloat(1, forme->GetWeight()); @@ -91,7 +91,7 @@ TEST_CASE("Validate Forme Height in Script") { auto mainLib = TestLibrary::GetLibrary(); auto data = GetScript(mainLib, "testHeight"); - auto forme = mainLib->GetSpeciesLibrary()->GetPkmnSpecies("testSpecies2")->GetDefaultForme(); + auto forme = mainLib->GetSpeciesLibrary()->Get("testSpecies2")->GetDefaultForme(); data.Context->SetArgObject(0, const_cast(forme)); data.Context->SetArgFloat(1, forme->GetHeight()); @@ -105,7 +105,7 @@ TEST_CASE("Validate Forme Base Experience in Script") { auto mainLib = TestLibrary::GetLibrary(); auto data = GetScript(mainLib, "testBaseExperience"); - auto forme = mainLib->GetSpeciesLibrary()->GetPkmnSpecies("testSpecies2")->GetDefaultForme(); + auto forme = mainLib->GetSpeciesLibrary()->Get("testSpecies2")->GetDefaultForme(); data.Context->SetArgObject(0, const_cast(forme)); data.Context->SetArgDWord(1, forme->GetBaseExperience()); @@ -119,7 +119,7 @@ TEST_CASE("Validate Forme Type Count in Script") { auto mainLib = TestLibrary::GetLibrary(); auto data = GetScript(mainLib, "testTypeCount"); - auto forme = mainLib->GetSpeciesLibrary()->GetPkmnSpecies("testSpecies2")->GetDefaultForme(); + auto forme = mainLib->GetSpeciesLibrary()->Get("testSpecies2")->GetDefaultForme(); data.Context->SetArgObject(0, const_cast(forme)); data.Context->SetArgDWord(1, forme->GetTypeCount()); @@ -133,7 +133,7 @@ TEST_CASE("Validate Forme GetType in Script") { auto mainLib = TestLibrary::GetLibrary(); auto data = GetScript(mainLib, "testGetType"); - auto forme = mainLib->GetSpeciesLibrary()->GetPkmnSpecies("testSpecies2")->GetDefaultForme(); + auto forme = mainLib->GetSpeciesLibrary()->Get("testSpecies2")->GetDefaultForme(); data.Context->SetArgObject(0, const_cast(forme)); data.Context->SetArgByte(1, forme->GetType(0)); @@ -152,7 +152,7 @@ TEST_CASE("Validate Forme GetStatistic in Script") { auto stat = static_cast(statInt); auto data = GetScript(mainLib, "testGetStatistic"); - auto forme = mainLib->GetSpeciesLibrary()->GetPkmnSpecies("testSpecies2")->GetDefaultForme(); + auto forme = mainLib->GetSpeciesLibrary()->Get("testSpecies2")->GetDefaultForme(); data.Context->SetArgObject(0, const_cast(forme)); data.Context->SetArgDWord(1, static_cast(stat)); data.Context->SetArgDWord(2, forme->GetStatistic(stat)); @@ -165,7 +165,7 @@ TEST_CASE("Validate Forme GetAbility in Script") { auto mainLib = TestLibrary::GetLibrary(); auto data = GetScript(mainLib, "testGetAbility"); - auto forme = mainLib->GetSpeciesLibrary()->GetPkmnSpecies("testSpecies2")->GetDefaultForme(); + auto forme = mainLib->GetSpeciesLibrary()->Get("testSpecies2")->GetDefaultForme(); data.Context->SetArgObject(0, const_cast(forme)); auto ability = forme->GetAbility(0); data.Context->SetArgAddress(1, &ability); diff --git a/tests/ScriptTests/ScriptTypeTests/Library/ItemDataTests.cpp b/tests/ScriptTests/ScriptTypeTests/Library/ItemDataTests.cpp index 8027d1c..8875330 100644 --- a/tests/ScriptTests/ScriptTypeTests/Library/ItemDataTests.cpp +++ b/tests/ScriptTests/ScriptTypeTests/Library/ItemDataTests.cpp @@ -58,7 +58,7 @@ TEST_CASE("Validate Item Name in Script") { auto mainLib = TestLibrary::GetLibrary(); auto data = GetScript(mainLib, "testName"); - auto item = mainLib->GetItemLibrary()->GetItem("testItem"); + auto item = mainLib->GetItemLibrary()->Get("testItem"); data.Context->SetArgObject(0, const_cast(item)); auto name = item->GetName(); data.Context->SetArgAddress(1, &name); @@ -71,7 +71,7 @@ TEST_CASE("Validate Item Category in Script") { auto mainLib = TestLibrary::GetLibrary(); auto data = GetScript(mainLib, "testCategory"); - auto item = mainLib->GetItemLibrary()->GetItem("testItem"); + auto item = mainLib->GetItemLibrary()->Get("testItem"); data.Context->SetArgObject(0, const_cast(item)); data.Context->SetArgDWord(1, static_cast(item->GetCategory())); @@ -83,7 +83,7 @@ TEST_CASE("Validate Item Battle Category in Script") { auto mainLib = TestLibrary::GetLibrary(); auto data = GetScript(mainLib, "testBattleCategory"); - auto item = mainLib->GetItemLibrary()->GetItem("testItem"); + auto item = mainLib->GetItemLibrary()->Get("testItem"); data.Context->SetArgObject(0, const_cast(item)); data.Context->SetArgDWord(1, static_cast(item->GetBattleCategory())); @@ -95,7 +95,7 @@ TEST_CASE("Validate Item Price in Script") { auto mainLib = TestLibrary::GetLibrary(); auto data = GetScript(mainLib, "testPrice"); - auto item = mainLib->GetItemLibrary()->GetItem("testItem"); + auto item = mainLib->GetItemLibrary()->Get("testItem"); data.Context->SetArgObject(0, const_cast(item)); data.Context->SetArgDWord(1, static_cast(item->GetPrice())); diff --git a/tests/ScriptTests/ScriptTypeTests/Library/MoveTests.cpp b/tests/ScriptTests/ScriptTypeTests/Library/MoveTests.cpp index 8803579..7b08c3f 100644 --- a/tests/ScriptTests/ScriptTypeTests/Library/MoveTests.cpp +++ b/tests/ScriptTests/ScriptTypeTests/Library/MoveTests.cpp @@ -62,7 +62,7 @@ TEST_CASE("Validate Move Name in Script") { auto mainLib = TestLibrary::GetLibrary(); auto data = GetScript(mainLib, "testName"); - auto move = mainLib->GetMoveLibrary()->GetAttack("testMove"); + auto move = mainLib->GetMoveLibrary()->Get("testMove"); data.Context->SetArgObject(0, (void*)move); auto name = move->GetName(); data.Context->SetArgAddress(1, &name); @@ -75,7 +75,7 @@ TEST_CASE("Validate Move Type in Script") { auto mainLib = TestLibrary::GetLibrary(); auto data = GetScript(mainLib, "testType"); - auto move = mainLib->GetMoveLibrary()->GetAttack("testMove"); + auto move = mainLib->GetMoveLibrary()->Get("testMove"); data.Context->SetArgObject(0, const_cast(move)); data.Context->SetArgByte(1, move->GetType()); @@ -87,7 +87,7 @@ TEST_CASE("Validate Move Category in Script") { auto mainLib = TestLibrary::GetLibrary(); auto data = GetScript(mainLib, "testCategory"); - auto move = mainLib->GetMoveLibrary()->GetAttack("testMove"); + auto move = mainLib->GetMoveLibrary()->Get("testMove"); data.Context->SetArgObject(0, const_cast(move)); data.Context->SetArgDWord(1, (asDWORD)move->GetCategory()); @@ -102,7 +102,7 @@ TEST_CASE("Validate Move BasePower in Script") { auto mainLib = TestLibrary::GetLibrary(); auto data = GetScript(mainLib, "testBasePower"); - auto move = mainLib->GetMoveLibrary()->GetAttack("testMove"); + auto move = mainLib->GetMoveLibrary()->Get("testMove"); data.Context->SetArgObject(0, const_cast(move)); data.Context->SetArgByte(1, move->GetBasePower()); @@ -114,7 +114,7 @@ TEST_CASE("Validate Move Accuracy in Script") { auto mainLib = TestLibrary::GetLibrary(); auto data = GetScript(mainLib, "testAccuracy"); - auto move = mainLib->GetMoveLibrary()->GetAttack("testMove"); + auto move = mainLib->GetMoveLibrary()->Get("testMove"); data.Context->SetArgObject(0, const_cast(move)); data.Context->SetArgByte(1, move->GetAccuracy()); @@ -126,7 +126,7 @@ TEST_CASE("Validate Move BaseUsages in Script") { auto mainLib = TestLibrary::GetLibrary(); auto data = GetScript(mainLib, "testBaseUsages"); - auto move = mainLib->GetMoveLibrary()->GetAttack("testMove"); + auto move = mainLib->GetMoveLibrary()->Get("testMove"); data.Context->SetArgObject(0, const_cast(move)); data.Context->SetArgByte(1, move->GetBaseUsages()); @@ -138,7 +138,7 @@ TEST_CASE("Validate Move Target in Script") { auto mainLib = TestLibrary::GetLibrary(); auto data = GetScript(mainLib, "testTarget"); - auto move = mainLib->GetMoveLibrary()->GetAttack("testMove"); + auto move = mainLib->GetMoveLibrary()->Get("testMove"); data.Context->SetArgObject(0, const_cast(move)); data.Context->SetArgDWord(1, (uint32_t)move->GetTarget()); @@ -150,7 +150,7 @@ TEST_CASE("Validate Move Priority in Script") { auto mainLib = TestLibrary::GetLibrary(); auto data = GetScript(mainLib, "testPriority"); - auto move = mainLib->GetMoveLibrary()->GetAttack("testMove"); + auto move = mainLib->GetMoveLibrary()->Get("testMove"); data.Context->SetArgObject(0, const_cast(move)); data.Context->SetArgByte(1, move->GetPriority()); diff --git a/tests/ScriptTests/ScriptTypeTests/Library/SpeciesTests.cpp b/tests/ScriptTests/ScriptTypeTests/Library/SpeciesTests.cpp index 906db7d..7c524bc 100644 --- a/tests/ScriptTests/ScriptTypeTests/Library/SpeciesTests.cpp +++ b/tests/ScriptTests/ScriptTypeTests/Library/SpeciesTests.cpp @@ -60,7 +60,7 @@ TEST_CASE("Validate Species Name in Script") { auto mainLib = TestLibrary::GetLibrary(); auto data = GetScript(mainLib, "testName"); - auto species = mainLib->GetSpeciesLibrary()->GetPkmnSpecies("testSpecies2"); + auto species = mainLib->GetSpeciesLibrary()->Get("testSpecies2"); data.Context->SetArgObject( 0, const_cast(species)); auto name = species->GetName(); @@ -76,7 +76,7 @@ TEST_CASE("Validate Species Id in Script") { auto mainLib = TestLibrary::GetLibrary(); auto data = GetScript(mainLib, "testId"); - auto species = mainLib->GetSpeciesLibrary()->GetPkmnSpecies("testSpecies2"); + auto species = mainLib->GetSpeciesLibrary()->Get("testSpecies2"); data.Context->SetArgObject( 0, const_cast(species)); data.Context->SetArgWord(1, species->GetId()); @@ -91,7 +91,7 @@ TEST_CASE("Validate Species Gender Rate in Script") { auto mainLib = TestLibrary::GetLibrary(); auto data = GetScript(mainLib, "testGenderRate"); - auto species = mainLib->GetSpeciesLibrary()->GetPkmnSpecies("testSpecies2"); + auto species = mainLib->GetSpeciesLibrary()->Get("testSpecies2"); data.Context->SetArgObject( 0, const_cast(species)); data.Context->SetArgFloat(1, species->GetGenderRate()); @@ -106,7 +106,7 @@ TEST_CASE("Validate Species Capture Rate in Script") { auto mainLib = TestLibrary::GetLibrary(); auto data = GetScript(mainLib, "testCaptureRate"); - auto species = mainLib->GetSpeciesLibrary()->GetPkmnSpecies("testSpecies2"); + auto species = mainLib->GetSpeciesLibrary()->Get("testSpecies2"); data.Context->SetArgObject( 0, const_cast(species)); data.Context->SetArgByte(1, species->GetCaptureRate()); @@ -121,7 +121,7 @@ TEST_CASE("Validate Species Get Forme in Script") { auto mainLib = TestLibrary::GetLibrary(); auto data = GetScript(mainLib, "testGetForme"); - auto species = mainLib->GetSpeciesLibrary()->GetPkmnSpecies("testSpecies2"); + auto species = mainLib->GetSpeciesLibrary()->Get("testSpecies2"); data.Context->SetArgObject( 0, const_cast(species)); data.Context->SetArgObject(1, const_cast(species->GetForme("default"))); @@ -136,7 +136,7 @@ TEST_CASE("Validate Species Get Default Forme in Script") { auto mainLib = TestLibrary::GetLibrary(); auto data = GetScript(mainLib, "testGetDefaultForme"); - auto species = mainLib->GetSpeciesLibrary()->GetPkmnSpecies("testSpecies2"); + auto species = mainLib->GetSpeciesLibrary()->Get("testSpecies2"); data.Context->SetArgObject(0, const_cast(species)); data.Context->SetArgObject(1, const_cast(species->GetDefaultForme())); diff --git a/tests/TestLibrary/TestLibrary.cpp b/tests/TestLibrary/TestLibrary.cpp index bb07781..ce68ba0 100644 --- a/tests/TestLibrary/TestLibrary.cpp +++ b/tests/TestLibrary/TestLibrary.cpp @@ -2,7 +2,7 @@ PkmnLib::Battling::BattleLibrary* TestLibrary::_library = nullptr; PkmnLib::Library::SpeciesLibrary* TestLibrary::BuildSpeciesLibrary() { auto lib = new PkmnLib::Library::SpeciesLibrary(); - lib->LoadSpecies("testSpecies", + lib->Insert("testSpecies", new PkmnLib::Library::PokemonSpecies( 1, "testSpecies", new PkmnLib::Library::PokemonForme( @@ -10,7 +10,7 @@ PkmnLib::Library::SpeciesLibrary* TestLibrary::BuildSpeciesLibrary() { CreatureLib::Core::StatisticSet(100, 100, 100, 100, 100, 100), {"testAbility"}, {"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)), 0.5f, "testGrowthRate", 100, 100)); - lib->LoadSpecies("testSpecies2", + lib->Insert("testSpecies2", new PkmnLib::Library::PokemonSpecies( 2, "testSpecies2", new PkmnLib::Library::PokemonForme( @@ -18,7 +18,7 @@ PkmnLib::Library::SpeciesLibrary* TestLibrary::BuildSpeciesLibrary() { CreatureLib::Core::StatisticSet(100, 100, 100, 100, 100, 100), {"testAbility"}, {"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)), 0.5f, "testGrowthRate", 100, 100)); - lib->LoadSpecies("statTestSpecies1", + lib->Insert("statTestSpecies1", new PkmnLib::Library::PokemonSpecies( 3, "statTestSpecies1", new PkmnLib::Library::PokemonForme( @@ -26,7 +26,7 @@ PkmnLib::Library::SpeciesLibrary* TestLibrary::BuildSpeciesLibrary() { CreatureLib::Core::StatisticSet(100, 100, 100, 100, 100, 100), {"testAbility"}, {"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)), 0.5f, "testGrowthRate", 100, 100)); - lib->LoadSpecies("testSpecies3", + lib->Insert("testSpecies3", new PkmnLib::Library::PokemonSpecies( 2, "testSpecies3", new PkmnLib::Library::PokemonForme( @@ -40,17 +40,17 @@ PkmnLib::Library::SpeciesLibrary* TestLibrary::BuildSpeciesLibrary() { } PkmnLib::Library::MoveLibrary* TestLibrary::BuildMoveLibrary() { auto lib = new PkmnLib::Library::MoveLibrary(); - lib->LoadMove("testMove", + lib->Insert("testMove", new PkmnLib::Library::MoveData("testMove", 0, PkmnLib::Library::MoveCategory::Physical, 50, 100, 20, CreatureLib::Library::AttackTarget::Adjacent, 0, {})); - lib->LoadMove("testMove2", + lib->Insert("testMove2", new PkmnLib::Library::MoveData("testMove2", 0, PkmnLib::Library::MoveCategory::Special, 30, 100, 10, CreatureLib::Library::AttackTarget::Adjacent, 0, {})); return lib; } PkmnLib::Library::ItemLibrary* TestLibrary::BuildItemLibrary() { auto lib = new PkmnLib::Library::ItemLibrary(); - lib->LoadItem("testItem", new PkmnLib::Library::Item("testItem", CreatureLib::Library::ItemCategory::MiscItem, + lib->Insert("testItem", new PkmnLib::Library::Item("testItem", CreatureLib::Library::ItemCategory::MiscItem, CreatureLib::Library::BattleItemCategory::None, 0, {}, 0)); return lib; }