2020-02-22 13:16:38 +00:00
|
|
|
#ifdef TESTS_BUILD
|
|
|
|
|
|
|
|
#include "../../extern/catch.hpp"
|
|
|
|
#include "../../src/Battling/Flow/ChoiceQueue.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("Move creature choice up next.", "[Battling]") {
|
|
|
|
auto lib = TestLibrary::Get();
|
2020-04-10 14:44:25 +00:00
|
|
|
auto c1 = CreateCreature(lib, "testSpecies1"_cnc, 1).Create();
|
|
|
|
auto c2 = CreateCreature(lib, "testSpecies1"_cnc, 1).Create();
|
|
|
|
auto c3 = CreateCreature(lib, "testSpecies1"_cnc, 1).Create();
|
|
|
|
auto c4 = CreateCreature(lib, "testSpecies1"_cnc, 1).Create();
|
2020-02-22 13:16:38 +00:00
|
|
|
|
2020-06-02 11:06:24 +00:00
|
|
|
std::vector<std::shared_ptr<BaseTurnChoice>> choices = {
|
|
|
|
std::make_shared<PassTurnChoice>(c1),
|
|
|
|
std::make_shared<PassTurnChoice>(c2),
|
|
|
|
std::make_shared<PassTurnChoice>(c3),
|
|
|
|
std::make_shared<PassTurnChoice>(c4),
|
2020-02-22 13:16:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
auto choiceQueue = ChoiceQueue(choices);
|
|
|
|
CHECK(choiceQueue.MoveCreatureChoiceNext(c4));
|
2020-05-31 16:00:39 +00:00
|
|
|
auto& currentChoices = choiceQueue.GetInnerQueue();
|
2020-02-22 13:16:38 +00:00
|
|
|
CHECK(currentChoices[0]->GetUser() == c4);
|
|
|
|
CHECK(currentChoices[1]->GetUser() == c1);
|
|
|
|
CHECK(currentChoices[2]->GetUser() == c2);
|
|
|
|
CHECK(currentChoices[3]->GetUser() == c3);
|
|
|
|
|
|
|
|
CHECK_FALSE(choiceQueue.MoveCreatureChoiceNext(c4));
|
2020-05-31 16:00:39 +00:00
|
|
|
choiceQueue.Dequeue();
|
|
|
|
choiceQueue.Dequeue();
|
2020-02-22 13:16:38 +00:00
|
|
|
CHECK_FALSE(choiceQueue.MoveCreatureChoiceNext(c1));
|
|
|
|
delete c1;
|
|
|
|
delete c2;
|
|
|
|
delete c3;
|
|
|
|
delete c4;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|