61 lines
6.0 KiB
C++
61 lines
6.0 KiB
C++
#include <CreatureLib/Battling/Models/Battle.hpp>
|
|
#include <CreatureLib/Battling/Models/ExecutingAttack.hpp>
|
|
#include <PkmnLib/Battling/Pokemon/CreatePokemon.hpp>
|
|
#include "../../../extern/catch.hpp"
|
|
#include "../../Library.hpp"
|
|
|
|
#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 userParty = new CreatureLib::Battling::CreatureParty({userMon}); \
|
|
auto targetParty = new CreatureLib::Battling::CreatureParty({targetMon}); \
|
|
auto battle = new CreatureLib::Battling::Battle( \
|
|
library, { \
|
|
CreatureLib::Battling::BattleParty(userParty, {CreatureLib::Battling::CreatureIndex(0, 0)}), \
|
|
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(CreatureLib::Battling::ScriptResolver::ScriptCategory::Attack, #move); \
|
|
REQUIRE(script != nullptr); \
|
|
\
|
|
auto executingMove = \
|
|
new CreatureLib::Battling::ExecutingAttack({targetMon}, 1, userMon, userMon->GetMoves()[0], script);
|
|
|
|
#define ON_MOVE_EFFECT_TRIGGER(move, onAfterCheck) \
|
|
TEST_CASE(#move " - On Effect Trigger", "[moves]") { \
|
|
SETUP_MOVE_TEST(move) \
|
|
executingMove->GetAttackDataForTarget(targetMon)->GetHit(0)->SetDamage(50); \
|
|
\
|
|
battle->AddVolatileScript("TriggerEffectChance"); \
|
|
script->OnSecondaryEffect(executingMove, targetMon, 0); \
|
|
onAfterCheck; \
|
|
\
|
|
delete executingMove; \
|
|
delete targetParty; \
|
|
delete userParty; \
|
|
}
|
|
|
|
#define ON_MOVE_EFFECT_NO_TRIGGER(move, onAfterCheck) \
|
|
TEST_CASE(#move " - On Effect No Trigger", "[moves]") { \
|
|
SETUP_MOVE_TEST(move) \
|
|
executingMove->GetAttackDataForTarget(targetMon)->GetHit(0)->SetDamage(50); \
|
|
\
|
|
battle->AddVolatileScript("BlockEffectChance"); \
|
|
script->OnSecondaryEffect(executingMove, targetMon, 0); \
|
|
onAfterCheck; \
|
|
\
|
|
delete executingMove; \
|
|
delete targetParty; \
|
|
delete userParty; \
|
|
}
|
|
|
|
ON_MOVE_EFFECT_TRIGGER(Acid, { CHECK(targetMon->GetStatBoost(PkmnLib::Library::Statistic::SpecialDefense) == -1); })
|
|
ON_MOVE_EFFECT_NO_TRIGGER(Acid, { CHECK(targetMon->GetStatBoost(PkmnLib::Library::Statistic::SpecialDefense) == 0); })
|