Support for packing party.
All checks were successful
continuous-integration/drone/push Build is passing

Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
2020-08-10 17:37:30 +02:00
parent 3a75a40671
commit 1807e720dd
3 changed files with 65 additions and 5 deletions

View File

@@ -0,0 +1,46 @@
#ifdef TESTS_BUILD
#include "../../extern/catch.hpp"
#include "../../src/Battling/Models/CreateCreature.hpp"
#include "../../src/Battling/Models/CreatureParty.hpp"
#include "../TestLibrary/TestLibrary.hpp"
using namespace CreatureLib::Battling;
TEST_CASE("Pack party tests with single creature", "[Library]") {
auto library = TestLibrary::Get();
auto creature = CreateCreature(library, "testSpecies1"_cnc, 1).Create();
auto party = CreatureParty(6);
party.SwapInto(1, creature);
REQUIRE(party.GetAtIndex(1) == creature);
party.PackParty();
REQUIRE(party.GetAtIndex(0) == creature);
REQUIRE(party.GetAtIndex(1) == nullptr);
party.Switch(0, 5);
REQUIRE(party.GetAtIndex(0) == nullptr);
REQUIRE(party.GetAtIndex(5) == creature);
party.PackParty();
REQUIRE(party.GetAtIndex(0) == creature);
REQUIRE(party.GetAtIndex(1) == nullptr);
REQUIRE(party.GetAtIndex(2) == nullptr);
REQUIRE(party.GetAtIndex(3) == nullptr);
REQUIRE(party.GetAtIndex(4) == nullptr);
REQUIRE(party.GetAtIndex(5) == nullptr);
}
TEST_CASE("Pack party tests with two creatures", "[Library]") {
auto library = TestLibrary::Get();
auto creature1 = CreateCreature(library, "testSpecies1"_cnc, 1).Create();
auto creature2 = CreateCreature(library, "testSpecies1"_cnc, 1).Create();
auto party = CreatureParty(6);
party.SwapInto(1, creature1);
party.SwapInto(5, creature2);
REQUIRE(party.GetAtIndex(1) == creature1);
REQUIRE(party.GetAtIndex(5) == creature2);
party.PackParty();
REQUIRE(party.GetAtIndex(0) == creature1);
REQUIRE(party.GetAtIndex(1) == creature2);
}
#endif