From 287d57e14000c5f53feaba6a81653ce4bc9d5d79 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Thu, 20 Feb 2020 14:11:19 +0100 Subject: [PATCH] Add test for Acupressure, Acrobatics. --- conanfile.py | 2 +- src/ScriptTests/Macros/MoveMacros.hpp | 9 ++-- src/ScriptTests/Moves/AMoves/Acrobatics.cpp | 34 +++++++++++++ src/ScriptTests/Moves/AMoves/Acupressure.cpp | 52 ++++++++++++++++++++ 4 files changed, 92 insertions(+), 5 deletions(-) create mode 100644 src/ScriptTests/Moves/AMoves/Acrobatics.cpp create mode 100644 src/ScriptTests/Moves/AMoves/Acupressure.cpp diff --git a/conanfile.py b/conanfile.py index f76450f..a2bcd45 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/93be2ee8a1a11cd106136f703ac0c2b2e0cb9e60@pkmnlib/master") + self.requires("PkmnLib/b1f101d646de65a56837a80302e85ff88c2fa04d@pkmnlib/master") diff --git a/src/ScriptTests/Macros/MoveMacros.hpp b/src/ScriptTests/Macros/MoveMacros.hpp index 0a7d9fd..8738583 100644 --- a/src/ScriptTests/Macros/MoveMacros.hpp +++ b/src/ScriptTests/Macros/MoveMacros.hpp @@ -1,9 +1,10 @@ -#include #include +#include +#include #include #include -#include "../../Library.hpp" #include "../../../extern/catch.hpp" +#include "../../Library.hpp" #define SETUP_MOVE_TEST(move) \ auto library = Library::GetLibrary(); \ @@ -14,7 +15,7 @@ \ auto userParty = new CreatureLib::Battling::CreatureParty({userMon}); \ auto targetParty = new CreatureLib::Battling::CreatureParty({targetMon}); \ - auto battle = new PkmnLib::Battling::Battle( \ + 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)}), \ @@ -23,7 +24,7 @@ userMon->SetBattleData(battle, battle->GetSides()[0]); \ targetMon->SetBattleData(battle, battle->GetSides()[1]); \ \ - auto script = library->LoadScript(CreatureLib::Battling::ScriptResolver::ScriptCategory::Attack, #move); \ + auto script = library->LoadScript(ScriptCategory::Attack, #move); \ REQUIRE(script != nullptr); \ \ auto executingMove = \ diff --git a/src/ScriptTests/Moves/AMoves/Acrobatics.cpp b/src/ScriptTests/Moves/AMoves/Acrobatics.cpp new file mode 100644 index 0000000..f91561f --- /dev/null +++ b/src/ScriptTests/Moves/AMoves/Acrobatics.cpp @@ -0,0 +1,34 @@ +#include "../../Macros/MoveMacros.hpp" +using Stats = PkmnLib::Library::Statistic; + +TEST_CASE("Acrobatics - doubles base power when no held item", "[moves]") { + SETUP_MOVE_TEST(Acrobatics) + + uint8_t basePower = 40; + script->OverrideBasePower(executingMove, userMon, 0, &basePower); + REQUIRE(basePower == 80); + + CLEANUP_MOVE_TEST +} + +TEST_CASE("Acrobatics - doesn't overflow", "[moves]") { + SETUP_MOVE_TEST(Acrobatics) + + uint8_t basePower = 200; + script->OverrideBasePower(executingMove, userMon, 0, &basePower); + REQUIRE(basePower == 255); + + CLEANUP_MOVE_TEST +} + + +TEST_CASE("Acrobatics - doesn't double base power when no held item", "[moves]") { + SETUP_MOVE_TEST(Acrobatics) + + userMon->SetHeldItem("poke_ball"); + uint8_t basePower = 40; + script->OverrideBasePower(executingMove, userMon, 0, &basePower); + REQUIRE(basePower == 40); + + CLEANUP_MOVE_TEST +} diff --git a/src/ScriptTests/Moves/AMoves/Acupressure.cpp b/src/ScriptTests/Moves/AMoves/Acupressure.cpp new file mode 100644 index 0000000..d87fdd4 --- /dev/null +++ b/src/ScriptTests/Moves/AMoves/Acupressure.cpp @@ -0,0 +1,52 @@ +#include +#include +#include +#include "../../../../extern/catch.hpp" +#include "../../Macros/MoveMacros.hpp" + +TEST_CASE("Acupressure - increases random stat by 2", "[moves]") { + SETUP_MOVE_TEST(Acupressure) + + script->OnStatusMove(executingMove, targetMon, 0); + bool hasDoubleIncreasedStat = false; + for (auto stat: CreatureLib::Core::StatisticHelper::GetValues()){ + auto statBoost = targetMon->GetStatBoost(stat); + + if (statBoost == 0) + continue; + else if (statBoost == 2){ + if (hasDoubleIncreasedStat){ + FAIL("We already had an increased stat."); + } + hasDoubleIncreasedStat = true; + } + else{ + FAIL("A stat did not have either 0 or 2 for a stat boost."); + } + } + REQUIRE(hasDoubleIncreasedStat); + + CLEANUP_MOVE_TEST +} + +TEST_CASE("Acupressure - fails if user is target", "[moves]") { + SETUP_MOVE_TEST(Acupressure) + + script->OnStatusMove(executingMove, userMon, 0); + bool hasDoubleIncreasedStat = false; + for (auto stat: CreatureLib::Core::StatisticHelper::GetValues()){ + auto statBoost = userMon->GetStatBoost(stat); + + if (statBoost == 0) + continue; + else if (statBoost == 2){ + hasDoubleIncreasedStat = true; + } + else{ + FAIL("A stat did not have either 0 or 2 for a stat boost."); + } + } + REQUIRE_FALSE(hasDoubleIncreasedStat); + + CLEANUP_MOVE_TEST +}