2021-04-11 13:20:50 +00:00
|
|
|
#ifdef TESTS_BUILD
|
|
|
|
|
2022-02-05 12:59:15 +00:00
|
|
|
#include <doctest.h>
|
2021-04-11 13:20:50 +00:00
|
|
|
#include "../../src/Battling/History/HistoryElements/AttackUseHistory.hpp"
|
|
|
|
#include "../../src/Battling/Models/Battle.hpp"
|
|
|
|
#include "../../src/Battling/Models/BattleSide.hpp"
|
|
|
|
#include "../../src/Battling/Models/CreateCreature.hpp"
|
|
|
|
#include "../../src/Battling/TurnChoices/PassTurnChoice.hpp"
|
|
|
|
#include "../TestLibrary/TestLibrary.hpp"
|
|
|
|
|
|
|
|
using namespace CreatureLib::Battling;
|
|
|
|
|
|
|
|
TEST_CASE("Clone battle, test basic functionality") {
|
|
|
|
auto lib = TestLibrary::Get();
|
|
|
|
|
|
|
|
auto creature = CreateCreature(lib, "testSpecies1"_cnc, 1).Create();
|
|
|
|
auto party = CreatureParty(6);
|
|
|
|
party.SwapInto(0, creature);
|
|
|
|
|
|
|
|
auto bp = ArbUt::List<BattleParty*>();
|
|
|
|
bp.Append(new BattleParty(&party, {CreatureIndex(0, 0)}));
|
|
|
|
auto battle = Battle(lib, bp);
|
|
|
|
battle.SwitchCreature(0, 0, creature);
|
|
|
|
|
|
|
|
auto clone = battle.Clone();
|
|
|
|
|
|
|
|
REQUIRE_NE(battle.GetCreature(0, 0), clone->GetCreature(0, 0));
|
|
|
|
REQUIRE(battle.GetCreature(0, 0).GetValue()->GetSpecies() == clone->GetCreature(0, 0).GetValue()->GetSpecies());
|
|
|
|
|
|
|
|
auto clonedParty = clone->GetParties().At(0)->GetParty().GetRaw();
|
|
|
|
delete clone;
|
|
|
|
delete clonedParty;
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE("Clone battle, test history history holder") {
|
|
|
|
auto lib = TestLibrary::Get();
|
|
|
|
auto battle = Battle(lib, {});
|
|
|
|
auto clone = battle.Clone();
|
2021-04-11 14:03:08 +00:00
|
|
|
|
2021-04-11 13:20:50 +00:00
|
|
|
clone->RegisterHistoryElement<AttackUseHistory>(nullptr);
|
|
|
|
clone->RegisterHistoryElement<AttackUseHistory>(nullptr);
|
|
|
|
|
2021-04-11 14:03:08 +00:00
|
|
|
delete clone;
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE("Clone battle, test randomness") {
|
|
|
|
auto lib = TestLibrary::Get();
|
|
|
|
auto battle = Battle(lib, {});
|
|
|
|
auto clone = battle.Clone();
|
|
|
|
|
|
|
|
REQUIRE_EQ(battle.GetRandom()->Get(), clone->GetRandom()->Get());
|
|
|
|
REQUIRE_EQ(battle.GetRandom()->Get(), clone->GetRandom()->Get());
|
|
|
|
REQUIRE_EQ(battle.GetRandom()->Get(), clone->GetRandom()->Get());
|
|
|
|
|
2021-04-11 13:20:50 +00:00
|
|
|
delete clone;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|