diff --git a/src/Battling/ScriptHandling/Script.hpp b/src/Battling/ScriptHandling/Script.hpp index 5ee4962..34baddb 100644 --- a/src/Battling/ScriptHandling/Script.hpp +++ b/src/Battling/ScriptHandling/Script.hpp @@ -1,11 +1,13 @@ #ifndef CREATURELIB_SCRIPT_HPP #define CREATURELIB_SCRIPT_HPP +#include #include #include #include #include -#include "../../Library/CreatureData/CreatureSpecies.hpp" + +using ConstString = Arbutils::CaseInsensitiveConstString; namespace CreatureLib::Battling { class BaseTurnChoice; diff --git a/src/Battling/ScriptHandling/ScriptSet.hpp b/src/Battling/ScriptHandling/ScriptSet.hpp index dbd331f..17d9a7e 100644 --- a/src/Battling/ScriptHandling/ScriptSet.hpp +++ b/src/Battling/ScriptHandling/ScriptSet.hpp @@ -1,8 +1,9 @@ #ifndef CREATURELIB_SCRIPTSET_HPP #define CREATURELIB_SCRIPTSET_HPP +#include +#include #include -#include #include "Script.hpp" namespace CreatureLib::Battling { diff --git a/src/Library/Attacks/SecondaryEffect.hpp b/src/Library/Attacks/SecondaryEffect.hpp index e60d002..9c605c4 100644 --- a/src/Library/Attacks/SecondaryEffect.hpp +++ b/src/Library/Attacks/SecondaryEffect.hpp @@ -10,7 +10,7 @@ namespace CreatureLib::Library { public: constexpr SecondaryEffect() noexcept : _chance(0), _effectName(""_cnc) {} - constexpr SecondaryEffect(float chance, const Arbutils::CaseInsensitiveConstString& effectName) noexcept + SecondaryEffect(float chance, const Arbutils::CaseInsensitiveConstString& effectName) noexcept : _chance(chance), _effectName(effectName) {} constexpr float GetChance() const noexcept { return _chance; } diff --git a/tests/BattleTests/ScriptTests/ScriptSetTests.cpp b/tests/BattleTests/ScriptTests/ScriptSetTests.cpp index 842169b..b15efe5 100644 --- a/tests/BattleTests/ScriptTests/ScriptSetTests.cpp +++ b/tests/BattleTests/ScriptTests/ScriptSetTests.cpp @@ -64,7 +64,7 @@ TEST_CASE("Add script to script set, then remove it", "[Battling, Scripting]") { auto s = new TestScript("foobar"); set.Add(s); REQUIRE(set.Count() == 1); - set.Remove("foobar"_cnc); + set.Remove("foobar"_cnc.GetHash()); REQUIRE(set.Count() == 0); auto it = set.GetIterator(); REQUIRE(it->Count() == 0); @@ -77,7 +77,7 @@ TEST_CASE("Add two scripts to script set, then remove them", "[Battling, Scripti set.Add(s); set.Add(s2); REQUIRE(set.Count() == 2); - set.Remove("foobar"_cnc); + set.Remove("foobar"_cnc.GetHash()); REQUIRE(set.Count() == 1); auto it = set.GetIterator(); REQUIRE(it->At(0)->GetName() == "foobar2"); diff --git a/tests/BattleTests/TurnOrderTests.cpp b/tests/BattleTests/TurnOrderTests.cpp index 5e5da82..de12ba2 100644 --- a/tests/BattleTests/TurnOrderTests.cpp +++ b/tests/BattleTests/TurnOrderTests.cpp @@ -11,7 +11,8 @@ using namespace CreatureLib::Battling; TEST_CASE("Turn ordering: Attack before pass", "[Battling]") { auto lib = TestLibrary::Get(); - auto learnedAttack = LearnedAttack(lib->GetAttackLibrary()->Get("standard"_cnc), AttackLearnMethod::Unknown); + auto learnedAttack = + LearnedAttack(lib->GetAttackLibrary()->Get("standard"_cnc.GetHash()), AttackLearnMethod::Unknown); auto choice1 = new PassTurnChoice(nullptr); auto choice2 = new AttackTurnChoice(nullptr, &learnedAttack, CreatureIndex(0, 0)); auto vec = std::vector{choice1, choice2}; @@ -30,8 +31,8 @@ TEST_CASE("Turn ordering: Attack before pass", "[Battling]") { TEST_CASE("Turn ordering: High priority goes before no priority", "[Battling]") { auto l = TestLibrary::Get()->GetAttackLibrary(); - auto a1 = new LearnedAttack(l->Get("standard"_cnc), AttackLearnMethod::Unknown); - auto a2 = new LearnedAttack(l->Get("highPriority"_cnc), AttackLearnMethod::Unknown); + auto a1 = new LearnedAttack(l->Get("standard"_cnc.GetHash()), AttackLearnMethod::Unknown); + auto a2 = new LearnedAttack(l->Get("highPriority"_cnc.GetHash()), AttackLearnMethod::Unknown); auto choice1 = new AttackTurnChoice(nullptr, a1, CreatureIndex(0, 0)); auto choice2 = new AttackTurnChoice(nullptr, a2, CreatureIndex(0, 0)); auto vec = std::vector{choice1, choice2}; @@ -52,8 +53,8 @@ TEST_CASE("Turn ordering: High priority goes before no priority", "[Battling]") TEST_CASE("Turn ordering: Higher priority goes before high priority", "[Battling]") { auto l = TestLibrary::Get()->GetAttackLibrary(); - auto a1 = new LearnedAttack(l->Get("highPriority"_cnc), AttackLearnMethod::Unknown); - auto a2 = new LearnedAttack(l->Get("higherPriority"_cnc), AttackLearnMethod::Unknown); + auto a1 = new LearnedAttack(l->Get("highPriority"_cnc.GetHash()), AttackLearnMethod::Unknown); + auto a2 = new LearnedAttack(l->Get("higherPriority"_cnc.GetHash()), AttackLearnMethod::Unknown); auto choice1 = new AttackTurnChoice(nullptr, a1, CreatureIndex(0, 0)); auto choice2 = new AttackTurnChoice(nullptr, a2, CreatureIndex(0, 0)); auto vec = std::vector{choice1, choice2}; @@ -74,8 +75,8 @@ TEST_CASE("Turn ordering: Higher priority goes before high priority", "[Battling TEST_CASE("Turn ordering: High priority goes before low priority", "[Battling]") { auto l = TestLibrary::Get()->GetAttackLibrary(); - auto a1 = new LearnedAttack(l->Get("lowPriority"_cnc), AttackLearnMethod::Unknown); - auto a2 = new LearnedAttack(l->Get("higherPriority"_cnc), AttackLearnMethod::Unknown); + auto a1 = new LearnedAttack(l->Get("lowPriority"_cnc.GetHash()), AttackLearnMethod::Unknown); + auto a2 = new LearnedAttack(l->Get("higherPriority"_cnc.GetHash()), AttackLearnMethod::Unknown); auto choice1 = new AttackTurnChoice(nullptr, a1, CreatureIndex(0, 0)); auto choice2 = new AttackTurnChoice(nullptr, a2, CreatureIndex(0, 0)); auto vec = std::vector{choice1, choice2}; @@ -96,8 +97,8 @@ TEST_CASE("Turn ordering: High priority goes before low priority", "[Battling]") TEST_CASE("Turn ordering: No priority goes before low priority", "[Battling]") { auto l = TestLibrary::Get()->GetAttackLibrary(); - auto a1 = new LearnedAttack(l->Get("lowPriority"_cnc), AttackLearnMethod::Unknown); - auto a2 = new LearnedAttack(l->Get("standard"_cnc), AttackLearnMethod::Unknown); + auto a1 = new LearnedAttack(l->Get("lowPriority"_cnc.GetHash()), AttackLearnMethod::Unknown); + auto a2 = new LearnedAttack(l->Get("standard"_cnc.GetHash()), AttackLearnMethod::Unknown); auto choice1 = new AttackTurnChoice(nullptr, a1, CreatureIndex(0, 0)); auto choice2 = new AttackTurnChoice(nullptr, a2, CreatureIndex(0, 0)); auto vec = std::vector{choice1, choice2}; diff --git a/tests/TestLibrary/TestLibrary.cpp b/tests/TestLibrary/TestLibrary.cpp index 0765d4f..e442d1b 100644 --- a/tests/TestLibrary/TestLibrary.cpp +++ b/tests/TestLibrary/TestLibrary.cpp @@ -21,7 +21,7 @@ BattleLibrary* TestLibrary::Get() { SpeciesLibrary* TestLibrary::BuildSpeciesLibrary() { auto l = new SpeciesLibrary(); - l->Insert("testSpecies1"_cnc, + l->Insert("testSpecies1"_cnc.GetHash(), new CreatureSpecies(0, "testSpecies1"_cnc, new SpeciesVariant("default"_cnc, 1, 1, 10, {0, 1}, StatisticSet(10, 10, 10, 10, 10, 10), {"testTalent"_cnc}, @@ -32,14 +32,15 @@ SpeciesLibrary* TestLibrary::BuildSpeciesLibrary() { AttackLibrary* TestLibrary::BuildAttackLibrary() { auto l = new AttackLibrary(); - l->Insert("standard"_cnc, new AttackData("standard"_cnc, 0, AttackCategory::Physical, 20, 100, 30, - AttackTarget::AdjacentOpponent, 0, SecondaryEffect(), {})); - l->Insert("highPriority"_cnc, new AttackData("highPriority"_cnc, 0, AttackCategory::Physical, 20, 100, 30, - AttackTarget::AdjacentOpponent, 1, SecondaryEffect(), {})); - l->Insert("higherPriority"_cnc, new AttackData("higherPriority"_cnc, 0, AttackCategory::Physical, 20, 100, 30, - AttackTarget::AdjacentOpponent, 2, SecondaryEffect(), {})); - l->Insert("lowPriority"_cnc, new AttackData("lowPriority"_cnc, 0, AttackCategory::Physical, 20, 100, 30, - AttackTarget::AdjacentOpponent, -1, SecondaryEffect(), {})); + l->Insert("standard"_cnc.GetHash(), new AttackData("standard"_cnc, 0, AttackCategory::Physical, 20, 100, 30, + AttackTarget::AdjacentOpponent, 0, SecondaryEffect(), {})); + l->Insert("highPriority"_cnc.GetHash(), new AttackData("highPriority"_cnc, 0, AttackCategory::Physical, 20, 100, 30, + AttackTarget::AdjacentOpponent, 1, SecondaryEffect(), {})); + l->Insert("higherPriority"_cnc.GetHash(), + new AttackData("higherPriority"_cnc, 0, AttackCategory::Physical, 20, 100, 30, + AttackTarget::AdjacentOpponent, 2, SecondaryEffect(), {})); + l->Insert("lowPriority"_cnc.GetHash(), new AttackData("lowPriority"_cnc, 0, AttackCategory::Physical, 20, 100, 30, + AttackTarget::AdjacentOpponent, -1, SecondaryEffect(), {})); return l; } @@ -51,7 +52,7 @@ ItemLibrary* TestLibrary::BuildItemLibrary() { GrowthRateLibrary* TestLibrary::BuildGrowthRateLibrary() { auto l = new GrowthRateLibrary(); l->AddGrowthRate( - "testGrowthRate"_cnc, + "testGrowthRate"_cnc.GetHash(), new 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, @@ -66,9 +67,9 @@ GrowthRateLibrary* TestLibrary::BuildGrowthRateLibrary() { TypeLibrary* TestLibrary::BuildTypeLibrary() { auto l = new TypeLibrary(); - l->RegisterType("testType1"_cnc); - l->RegisterType("testType2"_cnc); - l->RegisterType("testType3"_cnc); + l->RegisterType("testType1"_cnc.GetHash()); + l->RegisterType("testType2"_cnc.GetHash()); + l->RegisterType("testType3"_cnc.GetHash()); return l; }