Implements running from battle.
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:
@@ -79,7 +79,9 @@ TEST_CASE("Finish battle when all battle of one side have fainted", "[Integratio
|
||||
c2->Damage(c2->GetCurrentHealth(), DamageSource::AttackDamage);
|
||||
|
||||
REQUIRE(battle.HasEnded());
|
||||
REQUIRE(battle.GetResult() == 0);
|
||||
auto result = battle.GetResult();
|
||||
REQUIRE(result.IsConclusiveResult());
|
||||
REQUIRE(result.GetWinningSide() == 0);
|
||||
}
|
||||
|
||||
TEST_CASE("When creature is dealt enough damage, faint it and mark battle as ended", "[Integrations]") {
|
||||
@@ -104,7 +106,9 @@ TEST_CASE("When creature is dealt enough damage, faint it and mark battle as end
|
||||
battle.TrySetChoice(new PassTurnChoice(c2));
|
||||
|
||||
REQUIRE(battle.HasEnded());
|
||||
REQUIRE(battle.GetResult() == 0);
|
||||
auto result = battle.GetResult();
|
||||
REQUIRE(result.IsConclusiveResult());
|
||||
REQUIRE(result.GetWinningSide() == 0);
|
||||
}
|
||||
|
||||
TEST_CASE("When another creature is available on faint, make sure the battle hasn't ended", "[Integrations]") {
|
||||
@@ -137,7 +141,9 @@ TEST_CASE("When another creature is available on faint, make sure the battle has
|
||||
battle.TrySetChoice(new PassTurnChoice(c3));
|
||||
|
||||
REQUIRE(battle.HasEnded());
|
||||
REQUIRE(battle.GetResult() == 0);
|
||||
auto result = battle.GetResult();
|
||||
REQUIRE(result.IsConclusiveResult());
|
||||
REQUIRE(result.GetWinningSide() == 0);
|
||||
}
|
||||
|
||||
TEST_CASE("Switch Creature in", "[Integrations]") {
|
||||
@@ -221,4 +227,26 @@ TEST_CASE("Switch Creature in, mark as seen opponent for opponent", "[Integratio
|
||||
REQUIRE(seen.find(c2) != seen.end());
|
||||
}
|
||||
|
||||
TEST_CASE("Flee Battle", "[Integrations]") {
|
||||
auto library = TestLibrary::Get();
|
||||
auto c1 = CreateCreature(library, "testSpecies1", 100).WithAttack("standard", AttackLearnMethod::Unknown)->Create();
|
||||
CreatureParty party1{c1};
|
||||
auto battleParty1 = BattleParty(&party1, {CreatureIndex(0, 0)});
|
||||
auto c2 = CreateCreature(library, "testSpecies1", 1).WithAttack("standard", AttackLearnMethod::Unknown)->Create();
|
||||
CreatureParty party2{c2};
|
||||
auto battleParty2 = BattleParty(&party2, {CreatureIndex(1, 0)});
|
||||
|
||||
auto battle = Battle(library, {battleParty1, battleParty2});
|
||||
|
||||
battle.SwitchCreature(0, 0, c1);
|
||||
battle.SwitchCreature(1, 0, c2);
|
||||
|
||||
battle.TrySetChoice(new FleeTurnChoice(c1));
|
||||
battle.TrySetChoice(new PassTurnChoice(c2));
|
||||
|
||||
REQUIRE(battle.HasEnded());
|
||||
auto result = battle.GetResult();
|
||||
REQUIRE_FALSE(result.IsConclusiveResult());
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -13,8 +13,8 @@ BattleLibrary* TestLibrary::Get() {
|
||||
auto l = new DataLibrary(LibrarySettings(100, 4), BuildSpeciesLibrary(), BuildAttackLibrary(),
|
||||
BuildItemLibrary(), BuildGrowthRateLibrary(), BuildTypeLibrary());
|
||||
auto statCalc = new BattleStatCalculator();
|
||||
auto battleLib = new BattleLibrary(l, statCalc, new DamageLibrary(), new CriticalLibrary(),
|
||||
new ExperienceLibrary(), new ScriptResolver());
|
||||
auto battleLib = new BattleLibrary(l, statCalc, new DamageLibrary(), new ExperienceLibrary(),
|
||||
new ScriptResolver(), new MiscLibrary());
|
||||
TestLibrary::_library = battleLib;
|
||||
}
|
||||
return TestLibrary::_library;
|
||||
|
||||
Reference in New Issue
Block a user