From 292ca78b47f66aaf6115a2b60ad462920d81d707 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sat, 11 Apr 2020 00:22:34 +0200 Subject: [PATCH] Updates to new PkmnLib, many many changes. --- CMakeLists.txt | 2 +- src/BuildData/BuildItems.cpp | 4 +- src/BuildData/BuildMoves.cpp | 51 +++++++++++++++++--- src/BuildData/BuildNatures.cpp | 16 +++--- src/BuildData/BuildSpecies.cpp | 25 +++++++--- src/BuildData/BuildTypes.cpp | 9 ++-- src/LibraryTests/SpeciesTests.cpp | 6 +-- src/LibraryTests/TypeTests.cpp | 8 ++- src/ScriptTests/Macros/MoveMacros.hpp | 41 +++++++--------- src/ScriptTests/Moves/AMoves/Absorb.cpp | 2 +- src/ScriptTests/Moves/AMoves/Acid.cpp | 6 +-- src/ScriptTests/Moves/AMoves/AcidArmor.cpp | 2 +- src/ScriptTests/Moves/AMoves/Acrobatics.cpp | 3 +- src/ScriptTests/Moves/AMoves/Acupressure.cpp | 8 +-- src/ScriptTests/Moves/AMoves/Agility.cpp | 2 +- src/ScriptTests/Moves/AMoves/AirSlash.cpp | 6 +++ src/main.cpp | 12 +++-- 17 files changed, 125 insertions(+), 78 deletions(-) create mode 100644 src/ScriptTests/Moves/AMoves/AirSlash.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 26bcbff..617759a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,7 +39,7 @@ SET(FILE_SOURCE file(GLOB_RECURSE CORE_SRC_FILES ${FILE_SOURCE}) add_executable(Gen7Tests ${CORE_SRC_FILES}) -SET(_LINKS CreatureLibCore CreatureLibLibrary CreatureLibBattling pkmnLib) +SET(_LINKS CreatureLibLibrary CreatureLibBattling pkmnLib) target_link_libraries(Gen7Tests PUBLIC ${_LINKS}) diff --git a/src/BuildData/BuildItems.cpp b/src/BuildData/BuildItems.cpp index 36ed37c..ee8a479 100644 --- a/src/BuildData/BuildItems.cpp +++ b/src/BuildData/BuildItems.cpp @@ -53,9 +53,9 @@ PkmnLib::Library::ItemLibrary* BuildItems::Build(const std::string& path) { if (static_cast(itemType) == 255) return nullptr; - auto flags = std::unordered_set(); + auto flags = std::unordered_set(); for (auto flagIndex : _flags.items()) { - flags.insert(Arbutils::CaseInsensitiveConstString(flagIndex.value().get())); + flags.insert(Arbutils::CaseInsensitiveConstString::GetHash(flagIndex.value().get())); } auto item = new PkmnLib::Library::Item(Arbutils::CaseInsensitiveConstString(_name.get()), itemType, diff --git a/src/BuildData/BuildMoves.cpp b/src/BuildData/BuildMoves.cpp index 3343c1b..7da4ac0 100644 --- a/src/BuildData/BuildMoves.cpp +++ b/src/BuildData/BuildMoves.cpp @@ -46,7 +46,7 @@ PkmnLib::Library::MoveLibrary* BuildMoves::Build(const std::string& path, GET(val, flags, i); if (_pp.get() == 0) continue; - auto type = types->GetTypeId(_type.get()); + auto type = types->GetTypeId(Arbutils::CaseInsensitiveConstString::GetHash(_type.get())); auto category = ParseCategory(_category.get()); if (static_cast(category) == 255) return nullptr; @@ -56,14 +56,53 @@ PkmnLib::Library::MoveLibrary* BuildMoves::Build(const std::string& path, << _name.get() << "'\n"; return nullptr; } - auto flags = std::unordered_set(); + auto flags = std::unordered_set(); for (auto flagIndex : _flags.items()) { - flags.insert(Arbutils::CaseInsensitiveConstString(flagIndex.value().get())); + flags.insert(Arbutils::CaseInsensitiveConstString::GetHash(flagIndex.value().get())); + } + CreatureLib::Library::SecondaryEffect* effect = nullptr; + auto jsonEffect = val["effect"]; + if (jsonEffect != nullptr) { + auto name = jsonEffect["name"]; + auto chanceJson = jsonEffect["chance"]; + auto parametersJson = jsonEffect["parameters"]; + if (name != nullptr) { + List parameters; + auto chance = -1.0f; + if (chanceJson != nullptr) { + chance = chanceJson.get(); + } + + if (parametersJson != nullptr) { + for (auto& kv : parametersJson.items()) { + auto& p = kv.value(); + auto t = p.type(); + switch (t) { + case json::value_t::boolean: + parameters.Append(new CreatureLib::Library::EffectParameter(p.get())); + break; + case json::value_t::number_integer: + case json::value_t::number_unsigned: + parameters.Append(new CreatureLib::Library::EffectParameter(p.get())); + break; + case json::value_t::number_float: + parameters.Append(new CreatureLib::Library::EffectParameter(p.get())); + break; + default: continue; + } + } + } + effect = new CreatureLib::Library::SecondaryEffect( + chance, Arbutils::CaseInsensitiveConstString(name.get()), parameters); + } + } + if (effect == nullptr) { + effect = new CreatureLib::Library::SecondaryEffect(); } - auto move = new PkmnLib::Library::MoveData( - _name.get(), type, category, _power.get(), _accuracy.get(), - _pp.get(), target, _priority.get(), flags); + auto move = new PkmnLib::Library::MoveData(Arbutils::CaseInsensitiveConstString(_name.get()), type, + category, _power.get(), _accuracy.get(), + _pp.get(), target, _priority.get(), effect, flags); lib->Insert(Arbutils::CaseInsensitiveConstString(move->GetName()), move); } diff --git a/src/BuildData/BuildNatures.cpp b/src/BuildData/BuildNatures.cpp index 26054b1..d9b8c52 100644 --- a/src/BuildData/BuildNatures.cpp +++ b/src/BuildData/BuildNatures.cpp @@ -3,21 +3,21 @@ #include #include -static CreatureLib::Core::Statistic ParseStatistic(const std::string& stat) { +static CreatureLib::Library::Statistic ParseStatistic(const std::string& stat) { if (stat.empty()) - return static_cast(255); + return static_cast(255); if (stat == "Attack") - return CreatureLib::Core::Statistic::PhysicalAttack; + return CreatureLib::Library::Statistic::PhysicalAttack; if (stat == "Defense") - return CreatureLib::Core::Statistic::PhysicalDefense; + return CreatureLib::Library::Statistic::PhysicalDefense; if (stat == "SpecialAttack") - return CreatureLib::Core::Statistic::MagicalAttack; + return CreatureLib::Library::Statistic::MagicalAttack; if (stat == "SpecialDefense") - return CreatureLib::Core::Statistic::MagicalDefense; + return CreatureLib::Library::Statistic::MagicalDefense; if (stat == "Speed") - return CreatureLib::Core::Statistic::Speed; + return CreatureLib::Library::Statistic::Speed; std::cout << "Invalid stat was given: '" << stat << "'.\n"; - return static_cast(254); + return static_cast(254); } PkmnLib::Library::NatureLibrary* BuildNatures::Build(const std::string& path) { diff --git a/src/BuildData/BuildSpecies.cpp b/src/BuildData/BuildSpecies.cpp index 5fdb496..19fac0f 100644 --- a/src/BuildData/BuildSpecies.cpp +++ b/src/BuildData/BuildSpecies.cpp @@ -80,8 +80,8 @@ PkmnLib::Library::SpeciesLibrary* BuildSpecies::BuildLibrary(const std::string& return lib; } -static CreatureLib::Core::StatisticSet ParseStatistics(json& json) { - return CreatureLib::Core::StatisticSet( +static CreatureLib::Library::StatisticSet ParseStatistics(json& json) { + return CreatureLib::Library::StatisticSet( json["hp"].get(), json["attack"].get(), json["defense"].get(), json["specialAttack"].get(), json["specialDefense"].get(), json["speed"].get()); } @@ -100,15 +100,26 @@ const PkmnLib::Library::PokemonForme* BuildSpecies::BuildForme(const std::string GET(forme, moves, baseKeyName << " -> " << name); auto typeStrings = _types.get>(); - auto types = std::vector(typeStrings.size()); + auto types = List(typeStrings.size()); for (auto i = 0; i < typeStrings.size(); i++) { - types[i] = typeLibrary->GetTypeId(typeStrings[i]); + types[i] = typeLibrary->GetTypeId(Arbutils::CaseInsensitiveConstString::GetHash(typeStrings[i])); } auto stats = ParseStatistics(_baseStats); - return new PkmnLib::Library::PokemonForme( - name, _height.get(), _weight.get(), _baseExp.get(), types, stats, - _abilities.get>(), _hiddenAbilities.get>(), nullptr); + auto abilityStrings = _abilities.get>(); + auto abilities = List(abilityStrings.size()); + for (auto i = 0; i < abilityStrings.size(); i++) { + abilities[i] = Arbutils::CaseInsensitiveConstString(abilityStrings[i]); + } + auto hiddenAbilityStrings = _abilities.get>(); + auto hiddenAbilities = List(hiddenAbilityStrings.size()); + for (auto i = 0; i < hiddenAbilityStrings.size(); i++) { + hiddenAbilities[i] = Arbutils::CaseInsensitiveConstString(abilityStrings[i]); + } + + return new PkmnLib::Library::PokemonForme(Arbutils::CaseInsensitiveConstString(name), _height.get(), + _weight.get(), _baseExp.get(), types, stats, abilities, + hiddenAbilities, nullptr); } #undef GET \ No newline at end of file diff --git a/src/BuildData/BuildTypes.cpp b/src/BuildData/BuildTypes.cpp index 262f010..3869bb2 100644 --- a/src/BuildData/BuildTypes.cpp +++ b/src/BuildData/BuildTypes.cpp @@ -20,14 +20,14 @@ CreatureLib::Library::TypeLibrary* BuildTypes::Build(const std::string& path) { bool hasSkippedFirst = false; size_t lastStart = 0; - std::vector types; + std::vector types; for (size_t i = 0; i < line.length(); i++) { if (line[i] == divider) { auto substr = line.substr(lastStart, i - lastStart); lastStart = i + 1; if (hasSkippedFirst) { std::cout << "Registered type: " << substr << "\n"; - auto val = library->RegisterType(substr); + auto val = library->RegisterType(Arbutils::CaseInsensitiveConstString::GetHash(substr)); types.push_back(val); } else { hasSkippedFirst = true; @@ -37,10 +37,9 @@ CreatureLib::Library::TypeLibrary* BuildTypes::Build(const std::string& path) { } auto substr = line.substr(lastStart, line.length() - lastStart); std::cout << "Registered type: " << substr << "\n"; - auto val = library->RegisterType(substr); + auto val = library->RegisterType(Arbutils::CaseInsensitiveConstString::GetHash(substr)); types.push_back(val); - while (std::getline(file, line)) { uint8_t attackingType = 0; bool gotType = false; @@ -56,7 +55,7 @@ CreatureLib::Library::TypeLibrary* BuildTypes::Build(const std::string& path) { current++; } else { gotType = true; - attackingType = library->GetTypeId(substr); + attackingType = library->GetTypeId(Arbutils::CaseInsensitiveConstString::GetHash(substr)); } i++; } diff --git a/src/LibraryTests/SpeciesTests.cpp b/src/LibraryTests/SpeciesTests.cpp index ddcf49b..f37c97c 100644 --- a/src/LibraryTests/SpeciesTests.cpp +++ b/src/LibraryTests/SpeciesTests.cpp @@ -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"_cnc)); - CHECK(v.second->GetVariant("default"_cnc)->GetName() == "default"); + REQUIRE(v.second->HasVariant("default"_cnc.GetHash())); + CHECK(v.second->GetVariant("default"_cnc.GetHash())->GetName() == "default"); i++; } REQUIRE(i == 802); @@ -35,7 +35,7 @@ TEST_CASE("Species - Ensure each forme has abilities", "[species]") { for (const auto& v: iterator){ for (const auto& forme: v.second->GetVariantsIterator()){ auto abilities = forme.second->GetTalents(); - CHECK(!abilities.empty()); + CHECK(abilities.Count() != 0); } i++; } diff --git a/src/LibraryTests/TypeTests.cpp b/src/LibraryTests/TypeTests.cpp index ced4baa..a19e6c3 100644 --- a/src/LibraryTests/TypeTests.cpp +++ b/src/LibraryTests/TypeTests.cpp @@ -2,7 +2,9 @@ #include "../Library.hpp" #define CHECK_EFFECTIVENESS(attack, defense, expected) \ - CHECK(typeLib->GetSingleEffectiveness(typeLib->GetTypeId(#attack), typeLib->GetTypeId(#defense)) == expected); + CHECK(typeLib->GetSingleEffectiveness( \ + typeLib->GetTypeId(Arbutils::CaseInsensitiveConstString::GetHash(#attack)), \ + typeLib->GetTypeId(Arbutils::CaseInsensitiveConstString::GetHash(#defense))) == expected); TEST_CASE("Type Effectiveness - Normal Attacking", "[type]") { auto typeLib = Library::GetStaticLib()->GetTypeLibrary(); @@ -400,8 +402,4 @@ TEST_CASE("Type Effectiveness - Fairy Attacking", "[type]") { CHECK_EFFECTIVENESS(Fairy, Fairy, 1); } - - - - #undef CHECK_EFFECTIVENESS \ No newline at end of file diff --git a/src/ScriptTests/Macros/MoveMacros.hpp b/src/ScriptTests/Macros/MoveMacros.hpp index 3fe30b5..c8d6879 100644 --- a/src/ScriptTests/Macros/MoveMacros.hpp +++ b/src/ScriptTests/Macros/MoveMacros.hpp @@ -17,16 +17,21 @@ auto userParty = new CreatureLib::Battling::CreatureParty({userMon}); \ auto targetParty = new CreatureLib::Battling::CreatureParty({targetMon}); \ auto battle = new PkmnLib::Battling::Battle( \ - library, { \ - CreatureLib::Battling::BattleParty(userParty, {CreatureLib::Battling::CreatureIndex(0, 0)}), \ - CreatureLib::Battling::BattleParty(targetParty, {CreatureLib::Battling::CreatureIndex(1, 0)}), \ - }); \ + library, \ + { \ + new CreatureLib::Battling::BattleParty(userParty, {CreatureLib::Battling::CreatureIndex(0, 0)}), \ + new CreatureLib::Battling::BattleParty(targetParty, {CreatureLib::Battling::CreatureIndex(1, 0)}), \ + }); \ \ userMon->SetBattleData(battle, battle->GetSides()[0]); \ targetMon->SetBattleData(battle, battle->GetSides()[1]); \ \ - auto script = library->LoadScript(ScriptCategory::Attack, #move); \ + auto moveData = library->GetMoveLibrary()->Get(Arbutils::CaseInsensitiveConstString(#move)); \ + REQUIRE(moveData->HasSecondaryEffect()); \ + auto effect = moveData->GetSecondaryEffect(); \ + auto script = library->LoadScript(ScriptCategory::Attack, effect->GetEffectName()); \ REQUIRE(script != nullptr); \ + script->OnInitialize(effect->GetParameters()); \ \ auto executingMove = \ new CreatureLib::Battling::ExecutingAttack({targetMon}, 1, userMon, userMon->GetMoves()[0], script); @@ -41,7 +46,7 @@ TEST_CASE(#move " - On Effect Trigger", "[moves]") { \ SETUP_MOVE_TEST(move) \ \ - battle->AddVolatileScript("TriggerEffectChance"); \ + battle->AddVolatileScript("TriggerEffectChance"_cnc); \ script->OnSecondaryEffect(executingMove, targetMon, 0); \ onAfterCheck; \ \ @@ -52,7 +57,7 @@ TEST_CASE(#move " - On Effect No Trigger", "[moves]") { \ SETUP_MOVE_TEST(move) \ \ - battle->AddVolatileScript("BlockEffectChance"); \ + battle->AddVolatileScript("BlockEffectChance"_cnc); \ script->OnSecondaryEffect(executingMove, targetMon, 0); \ onAfterCheck; \ \ @@ -61,26 +66,14 @@ #define MOVE_EFFECT_CHANCE(move, chance) \ TEST_CASE(#move " - Effect Chance = " #chance, "[moves]") { \ - SETUP_MOVE_TEST(move) \ - \ - battle->AddVolatileScript("SaveEffectChance"); \ - script->OnSecondaryEffect(executingMove, targetMon, 0); \ - \ - auto saveScript = dynamic_cast(battle->GetVolatileScript("SaveEffectChance")); \ - \ - auto ctx = saveScript->GetContextPool()->RequestContext(); \ - saveScript->PrepareMethod("GetChance", ctx); \ - ctx->Execute(); \ - auto result = ctx->GetReturnFloat(); \ - CHECK(result == Approx(chance)); \ - saveScript->GetContextPool()->ReturnContextToPool(ctx); \ - \ - CLEANUP_MOVE_TEST \ + auto library = Library::GetLibrary(); \ + auto move = library->GetMoveLibrary()->Get(Arbutils::CaseInsensitiveConstString(#move)); \ + REQUIRE(move->HasSecondaryEffect()); \ + CHECK(move->GetSecondaryEffect()->GetChance() == chance); \ } -#define CHANCE_BASED_MOVE(moveName, chance, onEffectCheck, onNoEffectCheck) \ +#define CHANCE_BASED_MOVE(moveName, chance, onEffectCheck) \ ON_MOVE_EFFECT_TRIGGER(moveName, onEffectCheck) \ - ON_MOVE_EFFECT_NO_TRIGGER(moveName, onNoEffectCheck) \ MOVE_EFFECT_CHANCE(moveName, chance) #define INCREASED_CRITICAL_RATE(moveName, expectedStage) \ diff --git a/src/ScriptTests/Moves/AMoves/Absorb.cpp b/src/ScriptTests/Moves/AMoves/Absorb.cpp index 579df4d..0e113fe 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"_cnc); + userMon->SetHeldItem("big_root"_cnc.GetHash()); script->OnSecondaryEffect(executingMove, targetMon, 0); CHECK(userMon->GetCurrentHealth() == userMon->GetMaxHealth() - 18); diff --git a/src/ScriptTests/Moves/AMoves/Acid.cpp b/src/ScriptTests/Moves/AMoves/Acid.cpp index 61d69e9..56c7dae 100644 --- a/src/ScriptTests/Moves/AMoves/Acid.cpp +++ b/src/ScriptTests/Moves/AMoves/Acid.cpp @@ -2,8 +2,4 @@ using Stats = PkmnLib::Library::Statistic; -CHANCE_BASED_MOVE( - Acid, 10, - { CHECK(targetMon->GetStatBoost(Stats::SpecialDefense) == -1); }, - { CHECK(targetMon->GetStatBoost(Stats::SpecialDefense) == 0); } -); \ No newline at end of file +CHANCE_BASED_MOVE(Acid, 10, { CHECK(targetMon->GetStatBoost(Stats::SpecialDefense) == -1); }); \ No newline at end of file diff --git a/src/ScriptTests/Moves/AMoves/AcidArmor.cpp b/src/ScriptTests/Moves/AMoves/AcidArmor.cpp index 8ab7684..0fa5198 100644 --- a/src/ScriptTests/Moves/AMoves/AcidArmor.cpp +++ b/src/ScriptTests/Moves/AMoves/AcidArmor.cpp @@ -1,3 +1,3 @@ #include "../../Macros/MoveMacros.hpp" -CHANGE_USER_STAT_MOVE(Acid_Armor, PhysicalDefense, 2, OnStatusMove); \ No newline at end of file +CHANGE_USER_STAT_MOVE(Acid_Armor, PhysicalDefense, 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 e85c34f..272174e 100644 --- a/src/ScriptTests/Moves/AMoves/Acrobatics.cpp +++ b/src/ScriptTests/Moves/AMoves/Acrobatics.cpp @@ -21,11 +21,10 @@ TEST_CASE("Acrobatics - doesn't overflow", "[moves]") { CLEANUP_MOVE_TEST } - TEST_CASE("Acrobatics - doesn't double base power when no held item", "[moves]") { SETUP_MOVE_TEST(Acrobatics) - userMon->SetHeldItem("poke_ball"_cnc); + userMon->SetHeldItem("poke_ball"_cnc.GetHash()); uint8_t basePower = 40; script->OverrideBasePower(executingMove, userMon, 0, &basePower); REQUIRE(basePower == 40); diff --git a/src/ScriptTests/Moves/AMoves/Acupressure.cpp b/src/ScriptTests/Moves/AMoves/Acupressure.cpp index d87fdd4..e5a768a 100644 --- a/src/ScriptTests/Moves/AMoves/Acupressure.cpp +++ b/src/ScriptTests/Moves/AMoves/Acupressure.cpp @@ -7,9 +7,9 @@ TEST_CASE("Acupressure - increases random stat by 2", "[moves]") { SETUP_MOVE_TEST(Acupressure) - script->OnStatusMove(executingMove, targetMon, 0); + script->OnSecondaryEffect(executingMove, targetMon, 0); bool hasDoubleIncreasedStat = false; - for (auto stat: CreatureLib::Core::StatisticHelper::GetValues()){ + for (auto stat: CreatureLib::Library::StatisticHelper::GetValues()){ auto statBoost = targetMon->GetStatBoost(stat); if (statBoost == 0) @@ -32,9 +32,9 @@ TEST_CASE("Acupressure - increases random stat by 2", "[moves]") { TEST_CASE("Acupressure - fails if user is target", "[moves]") { SETUP_MOVE_TEST(Acupressure) - script->OnStatusMove(executingMove, userMon, 0); + script->OnSecondaryEffect(executingMove, userMon, 0); bool hasDoubleIncreasedStat = false; - for (auto stat: CreatureLib::Core::StatisticHelper::GetValues()){ + for (auto stat: CreatureLib::Library::StatisticHelper::GetValues()){ auto statBoost = userMon->GetStatBoost(stat); if (statBoost == 0) diff --git a/src/ScriptTests/Moves/AMoves/Agility.cpp b/src/ScriptTests/Moves/AMoves/Agility.cpp index c1d4534..318efd9 100644 --- a/src/ScriptTests/Moves/AMoves/Agility.cpp +++ b/src/ScriptTests/Moves/AMoves/Agility.cpp @@ -1,3 +1,3 @@ #include "../../Macros/MoveMacros.hpp" -CHANGE_USER_STAT_MOVE(Agility, Speed, 2, OnStatusMove); \ No newline at end of file +CHANGE_USER_STAT_MOVE(Agility, Speed, 2, OnSecondaryEffect); \ No newline at end of file diff --git a/src/ScriptTests/Moves/AMoves/AirSlash.cpp b/src/ScriptTests/Moves/AMoves/AirSlash.cpp new file mode 100644 index 0000000..3e839ec --- /dev/null +++ b/src/ScriptTests/Moves/AMoves/AirSlash.cpp @@ -0,0 +1,6 @@ +#include "../../Macros/MoveMacros.hpp" + +CHANCE_BASED_MOVE( + Air_Slash, 30, + { CHECK(targetMon->HasVolatileScript("flinch"_cnc)); } +); \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 1d880cc..24097e9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -106,15 +106,21 @@ int main(int argc, char* argv[]) { } asScriptResolver->CreateScript("TriggerEffectChance", R"( -namespace Battle{ class TriggerEffectChance : PkmnScript { +namespace Battle{ +[Battle effect=TriggerEffectChance] +class TriggerEffectChance : PkmnScript { void ModifyEffectChance(ExecutingMove@ attack, Pokemon@ target, float& chance) override{chance = 10000;} } })"); asScriptResolver->CreateScript("BlockEffectChance", R"( -namespace Battle{ class BlockEffectChance : PkmnScript { +namespace Battle{ +[Battle effect=BlockEffectChance] +class BlockEffectChance : PkmnScript { void ModifyEffectChance(ExecutingMove@ attack, Pokemon@ target, float& chance) override{chance = -10000;} } })"); asScriptResolver->CreateScript("SaveEffectChance", R"( -namespace Battle{ class SaveEffectChance : PkmnScript { +namespace Battle{ +[Battle effect=SaveEffectChance] +class SaveEffectChance : PkmnScript { float _chance = 0; void ModifyEffectChance(ExecutingMove@ attack, Pokemon@ target, float& chance) override{_chance = chance;} float GetChance() { return _chance; }