diff --git a/conanfile.py b/conanfile.py index a2bcd45..7e27b05 100644 --- a/conanfile.py +++ b/conanfile.py @@ -26,4 +26,4 @@ class PkmnLibConan(ConanFile): self.copy("*.dll", "bin", "bin") def requirements(self): - self.requires("PkmnLib/b1f101d646de65a56837a80302e85ff88c2fa04d@pkmnlib/master") + self.requires("PkmnLib/latest@epsilon/master") diff --git a/src/BuildData/BuildItems.cpp b/src/BuildData/BuildItems.cpp index 63a3a65..36ed37c 100644 --- a/src/BuildData/BuildItems.cpp +++ b/src/BuildData/BuildItems.cpp @@ -12,16 +12,23 @@ using json = nlohmann::json; return nullptr; \ } -static CreatureLib::Library::ItemCategory ParseItemCategory(std::string& in){ - std::transform(in.begin(),in.end(),in.end(), tolower); - if (in == "item") return CreatureLib::Library::ItemCategory::MiscItem; - if (in == "medicine") return CreatureLib::Library::ItemCategory::Medicine; - if (in == "berry") return CreatureLib::Library::ItemCategory::Berry; - if (in == "mail") return CreatureLib::Library::ItemCategory::Mail; - if (in == "key") return CreatureLib::Library::ItemCategory::KeyItem; - if (in == "pokeball") return CreatureLib::Library::ItemCategory::CaptureDevice; - if (in == "tm") return CreatureLib::Library::ItemCategory::MoveLearner; - std::cout << "Unknown Item Type: '" << in <<"'\n"; +static CreatureLib::Library::ItemCategory ParseItemCategory(std::string& in) { + std::transform(in.begin(), in.end(), in.end(), tolower); + if (in == "item") + return CreatureLib::Library::ItemCategory::MiscItem; + if (in == "medicine") + return CreatureLib::Library::ItemCategory::Medicine; + if (in == "berry") + return CreatureLib::Library::ItemCategory::Berry; + if (in == "mail") + return CreatureLib::Library::ItemCategory::Mail; + if (in == "key") + return CreatureLib::Library::ItemCategory::KeyItem; + if (in == "pokeball") + return CreatureLib::Library::ItemCategory::CaptureDevice; + if (in == "tm") + return CreatureLib::Library::ItemCategory::MoveLearner; + std::cout << "Unknown Item Type: '" << in << "'\n"; return static_cast(255); } @@ -43,12 +50,18 @@ PkmnLib::Library::ItemLibrary* BuildItems::Build(const std::string& path) { GET(val, flingPower, i); auto itemTypeStr = _itemType.get(); CreatureLib::Library::ItemCategory itemType = ParseItemCategory(itemTypeStr); - if (static_cast(itemType) == 255) return nullptr; + if (static_cast(itemType) == 255) + return nullptr; - auto item = new PkmnLib::Library::Item( - _name.get(), itemType, CreatureLib::Library::BattleItemCategory::None, _price.get(), - _flags.get>(), _flingPower.get()); - lib->Insert(item->GetName().c_str(), item); + auto flags = std::unordered_set(); + for (auto flagIndex : _flags.items()) { + flags.insert(Arbutils::CaseInsensitiveConstString(flagIndex.value().get())); + } + + auto item = new PkmnLib::Library::Item(Arbutils::CaseInsensitiveConstString(_name.get()), itemType, + CreatureLib::Library::BattleItemCategory::None, _price.get(), + flags, _flingPower.get()); + lib->Insert(item->GetName(), item); } return lib; } diff --git a/src/BuildData/BuildMoves.cpp b/src/BuildData/BuildMoves.cpp index a2de94d..3343c1b 100644 --- a/src/BuildData/BuildMoves.cpp +++ b/src/BuildData/BuildMoves.cpp @@ -51,16 +51,21 @@ PkmnLib::Library::MoveLibrary* BuildMoves::Build(const std::string& path, if (static_cast(category) == 255) return nullptr; CreatureLib::Library::AttackTarget target; - if (!CreatureLib::Library::AttackTargetHelper::TryParse(_target.get().c_str(), target)){ + if (!CreatureLib::Library::AttackTargetHelper::TryParse(_target.get().c_str(), target)) { std::cout << "Invalid target: '" << _target.get() << "' for move with name '" << _name.get() << "'\n"; return nullptr; } + auto flags = std::unordered_set(); + for (auto flagIndex : _flags.items()) { + flags.insert(Arbutils::CaseInsensitiveConstString(flagIndex.value().get())); + } + auto move = new PkmnLib::Library::MoveData( _name.get(), type, category, _power.get(), _accuracy.get(), - _pp.get(), target, _priority.get(), _flags.get>()); + _pp.get(), target, _priority.get(), flags); - lib->Insert(move->GetName().c_str(), move); + lib->Insert(Arbutils::CaseInsensitiveConstString(move->GetName()), move); } return lib; diff --git a/src/BuildData/BuildSpecies.cpp b/src/BuildData/BuildSpecies.cpp index 710b664..5fdb496 100644 --- a/src/BuildData/BuildSpecies.cpp +++ b/src/BuildData/BuildSpecies.cpp @@ -41,10 +41,11 @@ PkmnLib::Library::SpeciesLibrary* BuildSpecies::BuildLibrary(const std::string& auto defaultForme = _formes["default"]; if (!defaultForme.is_null()) { auto forme = BuildForme("default", defaultForme, it.key(), path, types); - species = new PkmnLib::Library::PokemonSpecies(_id.get(), _species.get(), forme, - _genderRatio.get() / static_cast(100), - _growthRate.get(), _catchRate.get(), - _baseHappiness.get()); + species = new PkmnLib::Library::PokemonSpecies( + _id.get(), Arbutils::CaseInsensitiveConstString(_species.get()), forme, + _genderRatio.get() / static_cast(100), + Arbutils::CaseInsensitiveConstString(_growthRate.get()), _catchRate.get(), + _baseHappiness.get()); } for (json::iterator formeIt = _formes.begin(); formeIt != _formes.end(); ++formeIt) { @@ -56,23 +57,25 @@ PkmnLib::Library::SpeciesLibrary* BuildSpecies::BuildLibrary(const std::string& return nullptr; if (species == nullptr) { species = new PkmnLib::Library::PokemonSpecies( - _id.get(), _species.get(), forme, + _id.get(), Arbutils::CaseInsensitiveConstString(_species.get()), forme, static_cast(_genderRatio.get()) / static_cast(100), - _growthRate.get(), _catchRate.get(), _baseHappiness.get()); + Arbutils::CaseInsensitiveConstString(_growthRate.get()), _catchRate.get(), + _baseHappiness.get()); } else { - if (species->HasForme(formeIt.key())){ - std::cout << "Species '" << it.key() << "' has duplicate forme '" << formeIt.key() << "'. Skipping.\n"; + if (species->HasForme(Arbutils::CaseInsensitiveConstString(formeIt.key()))) { + std::cout << "Species '" << it.key() << "' has duplicate forme '" << formeIt.key() + << "'. Skipping.\n"; delete forme; continue; } - species->SetVariant(formeIt.key(), forme); + species->SetVariant(Arbutils::CaseInsensitiveConstString(formeIt.key()), forme); } } if (species == nullptr) { std::cout << "Pokemon with key '" << it.key() << "' does not have any formes.\n"; return nullptr; } - lib->Insert(it.key().c_str(), species); + lib->Insert(Arbutils::CaseInsensitiveConstString(it.key()), species); } return lib; } diff --git a/src/BuildData/GrowthRatesBuilder.cpp b/src/BuildData/GrowthRatesBuilder.cpp index a14607a..dae98bb 100644 --- a/src/BuildData/GrowthRatesBuilder.cpp +++ b/src/BuildData/GrowthRatesBuilder.cpp @@ -4,7 +4,6 @@ #include "../../extern/json.hpp" using json = nlohmann::json; - CreatureLib::Library::GrowthRateLibrary* GrowthRatesBuilder::Build(const std::string& path) { std::ifstream fileStream(path.c_str()); if (fileStream.fail()) { @@ -18,7 +17,8 @@ CreatureLib::Library::GrowthRateLibrary* GrowthRatesBuilder::Build(const std::st for (const auto& i : j.items()) { const auto& name = i.key(); auto values = i.value(); - lib->AddGrowthRate(name, new LookupGrowthRate(values.get>())); + lib->AddGrowthRate(Arbutils::CaseInsensitiveConstString(name), + new LookupGrowthRate(values.get>())); } return lib; diff --git a/src/LibraryTests/SpeciesTests.cpp b/src/LibraryTests/SpeciesTests.cpp index 8afba2c..ddcf49b 100644 --- a/src/LibraryTests/SpeciesTests.cpp +++ b/src/LibraryTests/SpeciesTests.cpp @@ -2,7 +2,7 @@ #include "../Library.hpp" #define ENSURE_SPECIES_EXISTS(species) \ - CHECK(library->GetSpeciesLibrary()->Get(#species)->GetName() == #species); + CHECK(library->GetSpeciesLibrary()->Get(Arbutils::CaseInsensitiveConstString(#species))->GetName() == #species); TEST_CASE("Species - Ensure relevant species exist", "[species]") { @@ -21,8 +21,8 @@ TEST_CASE("Species - Ensure each species has a default forme", "[species]") { auto iterator = library->GetSpeciesLibrary()->GetIterator(); size_t i = 0; for (const auto& v: iterator){ - REQUIRE(v.second->HasVariant("default")); - CHECK(v.second->GetVariant("default")->GetName() == "default"); + REQUIRE(v.second->HasVariant("default"_cnc)); + CHECK(v.second->GetVariant("default"_cnc)->GetName() == "default"); i++; } REQUIRE(i == 802); diff --git a/src/ScriptTests/Macros/MoveMacros.hpp b/src/ScriptTests/Macros/MoveMacros.hpp index a98eb3f..3fe30b5 100644 --- a/src/ScriptTests/Macros/MoveMacros.hpp +++ b/src/ScriptTests/Macros/MoveMacros.hpp @@ -8,10 +8,11 @@ #define SETUP_MOVE_TEST(move) \ auto library = Library::GetLibrary(); \ - auto userMon = PkmnLib::Battling::CreatePokemon(library, "charizard", 50) \ - .LearnMove(#move, CreatureLib::Battling::AttackLearnMethod::Unknown) \ - ->Build(); \ - auto targetMon = PkmnLib::Battling::CreatePokemon(library, "venusaur", 50).Build(); \ + auto userMon = \ + PkmnLib::Battling::CreatePokemon(library, "charizard"_cnc, 50) \ + .LearnMove(Arbutils::CaseInsensitiveConstString(#move), CreatureLib::Battling::AttackLearnMethod::Unknown) \ + ->Build(); \ + auto targetMon = PkmnLib::Battling::CreatePokemon(library, "venusaur"_cnc, 50).Build(); \ \ auto userParty = new CreatureLib::Battling::CreatureParty({userMon}); \ auto targetParty = new CreatureLib::Battling::CreatureParty({targetMon}); \ @@ -83,13 +84,35 @@ MOVE_EFFECT_CHANCE(moveName, chance) #define INCREASED_CRITICAL_RATE(moveName, expectedStage) \ - TEST_CASE(#moveName " - Increased critical ratio", "[moves]") { \ - SETUP_MOVE_TEST(moveName) \ + TEST_CASE(#moveName " - Increased critical ratio", "[moves]") { \ + SETUP_MOVE_TEST(moveName) \ \ auto pkmnScript = dynamic_cast(script); \ uint8_t critStage = 0; \ pkmnScript->ModifyCriticalStage(executingMove, userMon, 0, &critStage); \ - CHECK(critStage == expectedStage); \ + CHECK(critStage == expectedStage); \ + \ + CLEANUP_MOVE_TEST \ + } + +#define CHANGE_USER_STAT_MOVE(moveName, stat, stage, function) \ + TEST_CASE(#moveName " - Change " #stat " by " #stage, "[moves]") { \ + SETUP_MOVE_TEST(moveName) \ + \ + CHECK(userMon->GetStatBoost(PkmnLib::Library::Statistic::stat) == 0); \ + script->function(executingMove, userMon, 0); \ + CHECK(userMon->GetStatBoost(PkmnLib::Library::Statistic::stat) == stage); \ + \ + CLEANUP_MOVE_TEST \ + } + +#define CHANGE_TARGET_STAT_MOVE(moveName, stat, stage, function) \ + TEST_CASE(#moveName " - Change " #stat " by " #stage, "[moves]") { \ + SETUP_MOVE_TEST(moveName) \ + \ + CHECK(targetMon->GetStatBoost(PkmnLib::Library::Statistic::stat) == 0); \ + script->function(executingMove, targetMon, 0); \ + CHECK(targetMon->GetStatBoost(PkmnLib::Library::Statistic::stat) == stage); \ \ CLEANUP_MOVE_TEST \ } diff --git a/src/ScriptTests/Moves/AMoves/Absorb.cpp b/src/ScriptTests/Moves/AMoves/Absorb.cpp index 256e328..579df4d 100644 --- a/src/ScriptTests/Moves/AMoves/Absorb.cpp +++ b/src/ScriptTests/Moves/AMoves/Absorb.cpp @@ -20,7 +20,7 @@ TEST_CASE("Absorb - Heals more with big root", "[moves]") { userMon->Damage(50, CreatureLib::Battling::DamageSource::AttackDamage); executingMove->GetAttackDataForTarget(targetMon)->GetHit(0)->SetDamage(50); - userMon->SetHeldItem("big_root"); + userMon->SetHeldItem("big_root"_cnc); script->OnSecondaryEffect(executingMove, targetMon, 0); CHECK(userMon->GetCurrentHealth() == userMon->GetMaxHealth() - 18); diff --git a/src/ScriptTests/Moves/AMoves/AcidArmor.cpp b/src/ScriptTests/Moves/AMoves/AcidArmor.cpp index 8df45c3..8ab7684 100644 --- a/src/ScriptTests/Moves/AMoves/AcidArmor.cpp +++ b/src/ScriptTests/Moves/AMoves/AcidArmor.cpp @@ -1,12 +1,3 @@ #include "../../Macros/MoveMacros.hpp" -using Stats = PkmnLib::Library::Statistic; -TEST_CASE("AcidArmor - Increases defense by 2", "[moves]") { - SETUP_MOVE_TEST(Acid_Armor) - - CHECK(userMon->GetStatBoost(Stats::PhysicalDefense) == 0); - script->OnStatusMove(executingMove, userMon, 0); - CHECK(userMon->GetStatBoost(Stats::PhysicalDefense) == 2); - - CLEANUP_MOVE_TEST -} +CHANGE_USER_STAT_MOVE(Acid_Armor, PhysicalDefense, 2, OnStatusMove); \ No newline at end of file diff --git a/src/ScriptTests/Moves/AMoves/AcidSpray.cpp b/src/ScriptTests/Moves/AMoves/AcidSpray.cpp index 5e42683..7a6788b 100644 --- a/src/ScriptTests/Moves/AMoves/AcidSpray.cpp +++ b/src/ScriptTests/Moves/AMoves/AcidSpray.cpp @@ -1,12 +1,3 @@ #include "../../Macros/MoveMacros.hpp" -using Stats = PkmnLib::Library::Statistic; -TEST_CASE("AcidSpray - Increases defense by 2", "[moves]") { - SETUP_MOVE_TEST(Acid_Spray) - - CHECK(userMon->GetStatBoost(Stats::SpecialDefense) == 0); - script->OnSecondaryEffect(executingMove, userMon, 0); - CHECK(userMon->GetStatBoost(Stats::SpecialDefense) == -2); - - CLEANUP_MOVE_TEST -} +CHANGE_TARGET_STAT_MOVE(Acid_Spray, SpecialDefense, -2, OnSecondaryEffect); \ No newline at end of file diff --git a/src/ScriptTests/Moves/AMoves/Acrobatics.cpp b/src/ScriptTests/Moves/AMoves/Acrobatics.cpp index f91561f..e85c34f 100644 --- a/src/ScriptTests/Moves/AMoves/Acrobatics.cpp +++ b/src/ScriptTests/Moves/AMoves/Acrobatics.cpp @@ -25,7 +25,7 @@ TEST_CASE("Acrobatics - doesn't overflow", "[moves]") { TEST_CASE("Acrobatics - doesn't double base power when no held item", "[moves]") { SETUP_MOVE_TEST(Acrobatics) - userMon->SetHeldItem("poke_ball"); + userMon->SetHeldItem("poke_ball"_cnc); uint8_t basePower = 40; script->OverrideBasePower(executingMove, userMon, 0, &basePower); REQUIRE(basePower == 40); diff --git a/src/ScriptTests/Moves/AMoves/AfterYou.cpp b/src/ScriptTests/Moves/AMoves/AfterYou.cpp new file mode 100644 index 0000000..f183e3c --- /dev/null +++ b/src/ScriptTests/Moves/AMoves/AfterYou.cpp @@ -0,0 +1 @@ +// TODO: After You tests \ No newline at end of file diff --git a/src/ScriptTests/Moves/AMoves/Agility.cpp b/src/ScriptTests/Moves/AMoves/Agility.cpp new file mode 100644 index 0000000..c1d4534 --- /dev/null +++ b/src/ScriptTests/Moves/AMoves/Agility.cpp @@ -0,0 +1,3 @@ +#include "../../Macros/MoveMacros.hpp" + +CHANGE_USER_STAT_MOVE(Agility, Speed, 2, OnStatusMove); \ No newline at end of file diff --git a/src/ScriptTests/Moves/AMoves/AirCutter.cpp b/src/ScriptTests/Moves/AMoves/AirCutter.cpp new file mode 100644 index 0000000..70e68ee --- /dev/null +++ b/src/ScriptTests/Moves/AMoves/AirCutter.cpp @@ -0,0 +1,3 @@ +#include "../../Macros/MoveMacros.hpp" + +INCREASED_CRITICAL_RATE(Air_Cutter, 1)