Add test for Acupressure, Acrobatics.

This commit is contained in:
Deukhoofd 2020-02-20 14:11:19 +01:00
parent f0738f8cf3
commit 287d57e140
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
4 changed files with 92 additions and 5 deletions

View File

@ -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")

View File

@ -1,9 +1,10 @@
#include <PkmnLib/Battling/Battle/Battle.hpp>
#include <CreatureLib/Battling/Models/ExecutingAttack.hpp>
#include <CreatureLib/Battling/ScriptHandling/ScriptCategory.hpp>
#include <PkmnLib/Battling/Battle/Battle.hpp>
#include <PkmnLib/Battling/Pokemon/CreatePokemon.hpp>
#include <PkmnLib/ScriptResolving/AngelScript/AngelScriptScript.hpp>
#include "../../Library.hpp"
#include "../../../extern/catch.hpp"
#include "../../Library.hpp"
#define SETUP_MOVE_TEST(move) \
auto library = Library::GetLibrary(); \
@ -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 = \

View File

@ -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
}

View File

@ -0,0 +1,52 @@
#include <CreatureLib/Battling/Models/ExecutingAttack.hpp>
#include <PkmnLib/Battling/Battle/Battle.hpp>
#include <PkmnLib/Battling/Pokemon/CreatePokemon.hpp>
#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
}