Implements creature switching as turn choice.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include "../../src/Battling/Models/CreateCreature.hpp"
|
||||
#include "../../src/Battling/TurnChoices/AttackTurnChoice.hpp"
|
||||
#include "../../src/Battling/TurnChoices/PassTurnChoice.hpp"
|
||||
#include "../../src/Battling/TurnChoices/SwitchTurnChoice.hpp"
|
||||
#include "../TestLibrary/TestLibrary.hpp"
|
||||
|
||||
using namespace CreatureLib;
|
||||
@@ -139,4 +140,49 @@ TEST_CASE("When another creature is available on faint, make sure the battle has
|
||||
REQUIRE(battle.GetResult() == 0);
|
||||
}
|
||||
|
||||
TEST_CASE("Switch Creature in", "[Integrations]") {
|
||||
auto library = TestLibrary::Get();
|
||||
auto c1 = CreateCreature(library, "testSpecies1", 100).WithAttack("standard", AttackLearnMethod::Unknown)->Create();
|
||||
auto c2 = CreateCreature(library, "testSpecies1", 1).WithAttack("standard", AttackLearnMethod::Unknown)->Create();
|
||||
CreatureParty party1{c1, c2};
|
||||
auto battleParty1 = BattleParty(&party1, {CreatureIndex(0, 0)});
|
||||
auto c3 = CreateCreature(library, "testSpecies1", 1).WithAttack("standard", AttackLearnMethod::Unknown)->Create();
|
||||
CreatureParty party2{c3};
|
||||
auto battleParty2 = BattleParty(&party2, {CreatureIndex(1, 0)});
|
||||
|
||||
auto battle = Battle(library, {battleParty1, battleParty2});
|
||||
|
||||
battle.SwitchCreature(0, 0, c1);
|
||||
battle.SwitchCreature(1, 0, c3);
|
||||
|
||||
REQUIRE(battle.GetTarget(CreatureIndex(0, 0)) == c1);
|
||||
|
||||
battle.TrySetChoice(new SwitchTurnChoice(c1, c2));
|
||||
battle.TrySetChoice(new PassTurnChoice(c3));
|
||||
|
||||
REQUIRE(battle.GetTarget(CreatureIndex(0, 0)) == c2);
|
||||
}
|
||||
|
||||
TEST_CASE("Switch Creature in, but have attack aimed at it. Attack should hit new creature", "[Integrations]") {
|
||||
auto library = TestLibrary::Get();
|
||||
auto c1 = CreateCreature(library, "testSpecies1", 50).WithAttack("standard", AttackLearnMethod::Unknown)->Create();
|
||||
auto c2 = CreateCreature(library, "testSpecies1", 50).WithAttack("standard", AttackLearnMethod::Unknown)->Create();
|
||||
CreatureParty party1{c1, c2};
|
||||
auto battleParty1 = BattleParty(&party1, {CreatureIndex(0, 0)});
|
||||
auto c3 = CreateCreature(library, "testSpecies1", 50).WithAttack("standard", AttackLearnMethod::Unknown)->Create();
|
||||
CreatureParty party2{c3};
|
||||
auto battleParty2 = BattleParty(&party2, {CreatureIndex(1, 0)});
|
||||
|
||||
auto battle = Battle(library, {battleParty1, battleParty2});
|
||||
|
||||
battle.SwitchCreature(0, 0, c1);
|
||||
battle.SwitchCreature(1, 0, c3);
|
||||
|
||||
battle.TrySetChoice(new SwitchTurnChoice(c1, c2));
|
||||
battle.TrySetChoice(new AttackTurnChoice(c3, c3->GetAttacks()[0], CreatureIndex(0, 0)));
|
||||
|
||||
REQUIRE(c2->GetCurrentHealth() < c2->GetBoostedStat(Core::Statistic::Health));
|
||||
REQUIRE(c1->GetCurrentHealth() == c1->GetBoostedStat(Core::Statistic::Health));
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user