Test for Struggle.
This commit is contained in:
parent
27556e30e3
commit
4f50a738a7
|
@ -0,0 +1,40 @@
|
|||
#include <CreatureLib/Battling/Models/ExecutingAttack.hpp>
|
||||
#include <CreatureLib/Battling/TurnChoices/AttackTurnChoice.hpp>
|
||||
#include <PkmnLib/Battling/Battle/Battle.hpp>
|
||||
#include <PkmnLib/Battling/Pokemon/CreatePokemon.hpp>
|
||||
#include "../../../extern/catch.hpp"
|
||||
#include "../Macros/MoveMacros.hpp"
|
||||
|
||||
TEST_CASE("Struggle - Damages by 1/4th of users max health", "[moves]") {
|
||||
auto library = Library::GetLibrary();
|
||||
auto userMon = PkmnLib::Battling::CreatePokemon(library, "charizard"_cnc, 50).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});
|
||||
auto battle = new PkmnLib::Battling::Battle(
|
||||
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, "Struggle"_cnc);
|
||||
REQUIRE(script != nullptr);
|
||||
|
||||
auto choice = (CreatureLib::Battling::AttackTurnChoice*)library->GetMiscLibrary()->ReplacementAttack(
|
||||
userMon, CreatureLib::Battling::CreatureIndex(1, 0));
|
||||
auto executingMove = new CreatureLib::Battling::ExecutingAttack({targetMon}, 1, userMon, choice->GetAttack(),
|
||||
choice->GetAttackScript());
|
||||
|
||||
script->OnSecondaryEffect(executingMove, targetMon, 0);
|
||||
CHECK(userMon->GetCurrentHealth() == userMon->GetMaxHealth() - (userMon->GetMaxHealth() / 4));
|
||||
delete choice;
|
||||
delete script;
|
||||
delete executingMove;
|
||||
delete targetParty;
|
||||
delete userParty;
|
||||
delete battle;
|
||||
}
|
Loading…
Reference in New Issue