2019-10-29 10:19:25 +00:00
|
|
|
#ifdef TESTS_BUILD
|
|
|
|
|
2020-09-25 10:43:08 +00:00
|
|
|
#include "../../extern/doctest.hpp"
|
2020-12-12 11:22:48 +00:00
|
|
|
#include "../../src/Battling/Models/Battle.hpp"
|
2019-10-29 10:19:25 +00:00
|
|
|
#include "../../src/Battling/Models/BattleSide.hpp"
|
|
|
|
#include "../../src/Battling/Models/CreateCreature.hpp"
|
|
|
|
#include "../../src/Battling/TurnChoices/PassTurnChoice.hpp"
|
2020-04-28 14:36:03 +00:00
|
|
|
#include "../TestLibrary/TestLibrary.hpp"
|
2019-10-29 10:19:25 +00:00
|
|
|
|
|
|
|
using namespace CreatureLib::Battling;
|
|
|
|
|
2020-09-25 10:43:08 +00:00
|
|
|
TEST_CASE("Set Choice one-sized side") {
|
2020-12-12 11:22:48 +00:00
|
|
|
auto lib = TestLibrary::Get();
|
|
|
|
auto battle = Battle(lib, {});
|
|
|
|
auto side = BattleSide(0, &battle, 1);
|
2020-04-10 14:44:25 +00:00
|
|
|
auto c = CreateCreature(TestLibrary::Get(), "testSpecies1"_cnc, 5).Create();
|
2019-10-29 10:19:25 +00:00
|
|
|
side.SetCreature(c, 0);
|
|
|
|
auto choice = new PassTurnChoice(c);
|
|
|
|
side.SetChoice(choice);
|
|
|
|
delete c;
|
|
|
|
}
|
|
|
|
|
2020-09-25 10:43:08 +00:00
|
|
|
TEST_CASE("Set Choice one-sized side, validate all choices set") {
|
2020-12-12 11:22:48 +00:00
|
|
|
auto lib = TestLibrary::Get();
|
|
|
|
auto battle = Battle(lib, {});
|
|
|
|
auto side = BattleSide(0, &battle, 1);
|
2020-04-10 14:44:25 +00:00
|
|
|
auto c = CreateCreature(TestLibrary::Get(), "testSpecies1"_cnc, 5).Create();
|
2019-10-29 10:19:25 +00:00
|
|
|
side.SetCreature(c, 0);
|
|
|
|
auto choice = new PassTurnChoice(c);
|
|
|
|
REQUIRE_FALSE(side.AllChoicesSet());
|
|
|
|
side.SetChoice(choice);
|
|
|
|
REQUIRE(side.AllChoicesSet());
|
|
|
|
delete c;
|
|
|
|
}
|
|
|
|
|
2020-09-25 10:43:08 +00:00
|
|
|
TEST_CASE("Set Choice two-sized side") {
|
2020-12-12 11:22:48 +00:00
|
|
|
auto lib = TestLibrary::Get();
|
|
|
|
auto battle = Battle(lib, {});
|
|
|
|
auto side = BattleSide(0, &battle, 2);
|
2020-04-10 14:44:25 +00:00
|
|
|
auto c1 = CreateCreature(TestLibrary::Get(), "testSpecies1"_cnc, 5).Create();
|
|
|
|
auto c2 = CreateCreature(TestLibrary::Get(), "testSpecies1"_cnc, 5).Create();
|
2019-10-29 10:19:25 +00:00
|
|
|
side.SetCreature(c1, 0);
|
|
|
|
side.SetCreature(c2, 1);
|
|
|
|
auto choice1 = new PassTurnChoice(c1);
|
|
|
|
auto choice2 = new PassTurnChoice(c2);
|
|
|
|
side.SetChoice(choice1);
|
|
|
|
side.SetChoice(choice2);
|
|
|
|
delete c1;
|
|
|
|
delete c2;
|
|
|
|
}
|
|
|
|
|
2020-09-25 10:43:08 +00:00
|
|
|
TEST_CASE("Set Choice two-sized side, validate all choices set") {
|
2020-12-12 11:22:48 +00:00
|
|
|
auto lib = TestLibrary::Get();
|
|
|
|
auto battle = Battle(lib, {});
|
|
|
|
auto side = BattleSide(0, &battle, 2);
|
2020-04-10 14:44:25 +00:00
|
|
|
auto c1 = CreateCreature(TestLibrary::Get(), "testSpecies1"_cnc, 5).Create();
|
|
|
|
auto c2 = CreateCreature(TestLibrary::Get(), "testSpecies1"_cnc, 5).Create();
|
2019-10-29 10:19:25 +00:00
|
|
|
side.SetCreature(c1, 0);
|
|
|
|
side.SetCreature(c2, 1);
|
|
|
|
auto choice1 = new PassTurnChoice(c1);
|
|
|
|
auto choice2 = new PassTurnChoice(c2);
|
|
|
|
REQUIRE_FALSE(side.AllChoicesSet());
|
|
|
|
side.SetChoice(choice1);
|
|
|
|
REQUIRE_FALSE(side.AllChoicesSet());
|
|
|
|
side.SetChoice(choice2);
|
|
|
|
REQUIRE(side.AllChoicesSet());
|
|
|
|
delete c1;
|
|
|
|
delete c2;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|