Used ClangFormat style guide I'm happy with.
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:
@@ -1,13 +1,13 @@
|
||||
#ifdef TESTS_BUILD
|
||||
|
||||
#include "../TestLibrary/TestLibrary.cpp"
|
||||
#include "../../src/Battling/Models/BattleSide.hpp"
|
||||
#include "../../src/Battling/Models/CreateCreature.hpp"
|
||||
#include "../../src/Battling/TurnChoices/PassTurnChoice.hpp"
|
||||
#include "../TestLibrary/TestLibrary.cpp"
|
||||
|
||||
using namespace CreatureLib::Battling;
|
||||
|
||||
TEST_CASE( "Set Choice one-sized side", "[Battling]" ) {
|
||||
TEST_CASE("Set Choice one-sized side", "[Battling]") {
|
||||
auto side = BattleSide(nullptr, 1);
|
||||
auto c = CreateCreature(GetLibrary(), "testSpecies1", 5).Create();
|
||||
side.SetCreature(c, 0);
|
||||
@@ -17,7 +17,7 @@ TEST_CASE( "Set Choice one-sized side", "[Battling]" ) {
|
||||
delete c;
|
||||
}
|
||||
|
||||
TEST_CASE( "Set Choice one-sized side, validate all choices set", "[Battling]" ) {
|
||||
TEST_CASE("Set Choice one-sized side, validate all choices set", "[Battling]") {
|
||||
auto side = BattleSide(nullptr, 1);
|
||||
auto c = CreateCreature(GetLibrary(), "testSpecies1", 5).Create();
|
||||
side.SetCreature(c, 0);
|
||||
@@ -29,7 +29,7 @@ TEST_CASE( "Set Choice one-sized side, validate all choices set", "[Battling]" )
|
||||
delete c;
|
||||
}
|
||||
|
||||
TEST_CASE( "Set Choice two-sized side", "[Battling]" ) {
|
||||
TEST_CASE("Set Choice two-sized side", "[Battling]") {
|
||||
auto side = BattleSide(nullptr, 2);
|
||||
auto c1 = CreateCreature(GetLibrary(), "testSpecies1", 5).Create();
|
||||
auto c2 = CreateCreature(GetLibrary(), "testSpecies1", 5).Create();
|
||||
@@ -45,7 +45,7 @@ TEST_CASE( "Set Choice two-sized side", "[Battling]" ) {
|
||||
delete c2;
|
||||
}
|
||||
|
||||
TEST_CASE( "Set Choice two-sized side, validate all choices set", "[Battling]" ) {
|
||||
TEST_CASE("Set Choice two-sized side, validate all choices set", "[Battling]") {
|
||||
auto side = BattleSide(nullptr, 2);
|
||||
auto c1 = CreateCreature(GetLibrary(), "testSpecies1", 5).Create();
|
||||
auto c2 = CreateCreature(GetLibrary(), "testSpecies1", 5).Create();
|
||||
@@ -64,5 +64,4 @@ TEST_CASE( "Set Choice two-sized side, validate all choices set", "[Battling]" )
|
||||
delete c2;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,31 +1,25 @@
|
||||
#ifdef TESTS_BUILD
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "../../../extern/catch.hpp"
|
||||
#include "../../../src/Battling/ScriptHandling/ScriptAggregator.hpp"
|
||||
|
||||
|
||||
|
||||
using namespace CreatureLib;
|
||||
using namespace CreatureLib::Battling;
|
||||
|
||||
class TestScript : public Script{
|
||||
class TestScript : public Script {
|
||||
public:
|
||||
explicit TestScript(std::string name) : Script(std::move(name)){};
|
||||
|
||||
void TestMethod(int& runCount) {
|
||||
runCount++;
|
||||
}
|
||||
|
||||
void TestMethod(int& runCount) { runCount++; }
|
||||
};
|
||||
|
||||
TEST_CASE( "Script Aggregator properly iterates containing script.", "[Battling, Scripting]" ) {
|
||||
TEST_CASE("Script Aggregator properly iterates containing script.", "[Battling, Scripting]") {
|
||||
Script* script = new TestScript("test");
|
||||
auto ran = 0;
|
||||
auto vec = std::vector<ScriptWrapper>{&script};
|
||||
auto aggr = ScriptAggregator(vec);
|
||||
while (aggr.HasNext()){
|
||||
auto aggr = ScriptAggregator(vec);
|
||||
while (aggr.HasNext()) {
|
||||
auto next = aggr.GetNext();
|
||||
REQUIRE(next != nullptr);
|
||||
dynamic_cast<TestScript*>(next)->TestMethod(ran);
|
||||
@@ -34,14 +28,14 @@ TEST_CASE( "Script Aggregator properly iterates containing script.", "[Battling,
|
||||
delete script;
|
||||
}
|
||||
|
||||
TEST_CASE( "Script Aggregator properly iterates multiple scripts.", "[Battling, Scripting]" ) {
|
||||
TEST_CASE("Script Aggregator properly iterates multiple scripts.", "[Battling, Scripting]") {
|
||||
Script* script = new TestScript("test");
|
||||
Script* script2 = new TestScript("test2");
|
||||
Script* script3 = new TestScript("test3");
|
||||
auto ran = 0;
|
||||
auto vec = std::vector<ScriptWrapper>{&script, &script2, &script3};
|
||||
auto aggr = ScriptAggregator(vec);
|
||||
while (aggr.HasNext()){
|
||||
auto aggr = ScriptAggregator(vec);
|
||||
while (aggr.HasNext()) {
|
||||
auto next = aggr.GetNext();
|
||||
REQUIRE(next != nullptr);
|
||||
dynamic_cast<TestScript*>(next)->TestMethod(ran);
|
||||
@@ -52,7 +46,7 @@ TEST_CASE( "Script Aggregator properly iterates multiple scripts.", "[Battling,
|
||||
delete script3;
|
||||
}
|
||||
|
||||
TEST_CASE( "Script Aggregator properly iterates Script Set.", "[Battling, Scripting]" ) {
|
||||
TEST_CASE("Script Aggregator properly iterates Script Set.", "[Battling, Scripting]") {
|
||||
Script* script = new TestScript("test");
|
||||
Script* script2 = new TestScript("test2");
|
||||
Script* script3 = new TestScript("test3");
|
||||
@@ -62,8 +56,8 @@ TEST_CASE( "Script Aggregator properly iterates Script Set.", "[Battling, Script
|
||||
set.Add(script2);
|
||||
set.Add(script3);
|
||||
auto vec = std::vector<ScriptWrapper>{&set};
|
||||
auto aggr = ScriptAggregator(vec);
|
||||
while (aggr.HasNext()){
|
||||
auto aggr = ScriptAggregator(vec);
|
||||
while (aggr.HasNext()) {
|
||||
auto next = aggr.GetNext();
|
||||
REQUIRE(next != nullptr);
|
||||
dynamic_cast<TestScript*>(next)->TestMethod(ran);
|
||||
@@ -74,7 +68,7 @@ TEST_CASE( "Script Aggregator properly iterates Script Set.", "[Battling, Script
|
||||
delete script3;
|
||||
}
|
||||
|
||||
TEST_CASE( "Script Aggregator properly iterates data of Script Set and Script.", "[Battling, Scripting]" ) {
|
||||
TEST_CASE("Script Aggregator properly iterates data of Script Set and Script.", "[Battling, Scripting]") {
|
||||
Script* script = new TestScript("test");
|
||||
Script* script2 = new TestScript("test2");
|
||||
Script* script3 = new TestScript("test3");
|
||||
@@ -83,8 +77,8 @@ TEST_CASE( "Script Aggregator properly iterates data of Script Set and Script.",
|
||||
set.Add(script2);
|
||||
set.Add(script3);
|
||||
auto vec = std::vector<ScriptWrapper>{&set, &script};
|
||||
auto aggr = ScriptAggregator(vec);
|
||||
while (aggr.HasNext()){
|
||||
auto aggr = ScriptAggregator(vec);
|
||||
while (aggr.HasNext()) {
|
||||
auto next = aggr.GetNext();
|
||||
REQUIRE(next != nullptr);
|
||||
dynamic_cast<TestScript*>(next)->TestMethod(ran);
|
||||
@@ -95,7 +89,7 @@ TEST_CASE( "Script Aggregator properly iterates data of Script Set and Script.",
|
||||
delete script3;
|
||||
}
|
||||
|
||||
TEST_CASE( "Script Aggregator properly iterates data of Script and Script Set.", "[Battling, Scripting]" ) {
|
||||
TEST_CASE("Script Aggregator properly iterates data of Script and Script Set.", "[Battling, Scripting]") {
|
||||
Script* script = new TestScript("test");
|
||||
Script* script2 = new TestScript("test2");
|
||||
Script* script3 = new TestScript("test3");
|
||||
@@ -104,8 +98,8 @@ TEST_CASE( "Script Aggregator properly iterates data of Script and Script Set.",
|
||||
set.Add(script2);
|
||||
set.Add(script3);
|
||||
auto vec = std::vector<ScriptWrapper>{&script, &set};
|
||||
auto aggr = ScriptAggregator(vec);
|
||||
while (aggr.HasNext()){
|
||||
auto aggr = ScriptAggregator(vec);
|
||||
while (aggr.HasNext()) {
|
||||
auto next = aggr.GetNext();
|
||||
REQUIRE(next != nullptr);
|
||||
dynamic_cast<TestScript*>(next)->TestMethod(ran);
|
||||
@@ -116,7 +110,7 @@ TEST_CASE( "Script Aggregator properly iterates data of Script and Script Set.",
|
||||
delete script3;
|
||||
}
|
||||
|
||||
TEST_CASE( "Script Aggregator properly iterates data of Script, Script Set and Script.", "[Battling, Scripting]" ) {
|
||||
TEST_CASE("Script Aggregator properly iterates data of Script, Script Set and Script.", "[Battling, Scripting]") {
|
||||
Script* script = new TestScript("test");
|
||||
Script* script2 = new TestScript("test2");
|
||||
Script* script3 = new TestScript("test3");
|
||||
@@ -126,8 +120,8 @@ TEST_CASE( "Script Aggregator properly iterates data of Script, Script Set and S
|
||||
set.Add(script2);
|
||||
set.Add(script3);
|
||||
auto vec = std::vector<ScriptWrapper>{&script, &set, &script4};
|
||||
auto aggr = ScriptAggregator(vec);
|
||||
while (aggr.HasNext()){
|
||||
auto aggr = ScriptAggregator(vec);
|
||||
while (aggr.HasNext()) {
|
||||
auto next = aggr.GetNext();
|
||||
REQUIRE(next != nullptr);
|
||||
dynamic_cast<TestScript*>(next)->TestMethod(ran);
|
||||
@@ -139,22 +133,22 @@ TEST_CASE( "Script Aggregator properly iterates data of Script, Script Set and S
|
||||
delete script4;
|
||||
}
|
||||
|
||||
TEST_CASE( "Script Aggregator properly iterates when empty.", "[Battling, Scripting]" ) {
|
||||
TEST_CASE("Script Aggregator properly iterates when empty.", "[Battling, Scripting]") {
|
||||
auto ran = 0;
|
||||
auto vec = std::vector<ScriptWrapper>{};
|
||||
auto aggr = ScriptAggregator(vec);
|
||||
while (aggr.HasNext()){
|
||||
auto aggr = ScriptAggregator(vec);
|
||||
while (aggr.HasNext()) {
|
||||
throw CreatureException("Aggregator returned a script, but should have been empty.");
|
||||
}
|
||||
CHECK(ran == 0);
|
||||
}
|
||||
|
||||
TEST_CASE( "Script Aggregator properly iterates empty Script Set.", "[Battling, Scripting]" ) {
|
||||
TEST_CASE("Script Aggregator properly iterates empty Script Set.", "[Battling, Scripting]") {
|
||||
auto ran = 0;
|
||||
auto set = ScriptSet();
|
||||
auto vec = std::vector<ScriptWrapper>{&set};
|
||||
auto aggr = ScriptAggregator(vec);
|
||||
while (aggr.HasNext()){
|
||||
auto aggr = ScriptAggregator(vec);
|
||||
while (aggr.HasNext()) {
|
||||
auto next = aggr.GetNext();
|
||||
REQUIRE(next == nullptr);
|
||||
ran++;
|
||||
@@ -162,8 +156,4 @@ TEST_CASE( "Script Aggregator properly iterates empty Script Set.", "[Battling,
|
||||
CHECK(ran == 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,20 +1,18 @@
|
||||
#ifdef TESTS_BUILD
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "../../../extern/catch.hpp"
|
||||
#include "../../../src/Battling/ScriptHandling/ScriptSet.hpp"
|
||||
|
||||
using namespace CreatureLib;
|
||||
using namespace CreatureLib::Battling;
|
||||
|
||||
|
||||
TEST_CASE( "Empty script set count == 0", "[Battling, Scripting]" ) {
|
||||
TEST_CASE("Empty script set count == 0", "[Battling, Scripting]") {
|
||||
auto set = ScriptSet();
|
||||
REQUIRE(set.Count() == 0);
|
||||
}
|
||||
|
||||
TEST_CASE( "Add script to script set", "[Battling, Scripting]" ) {
|
||||
TEST_CASE("Add script to script set", "[Battling, Scripting]") {
|
||||
auto set = ScriptSet();
|
||||
auto s = new Script("foobar");
|
||||
set.Add(s);
|
||||
@@ -22,7 +20,7 @@ TEST_CASE( "Add script to script set", "[Battling, Scripting]" ) {
|
||||
delete s;
|
||||
}
|
||||
|
||||
TEST_CASE( "Add script to script set, then retrieve it", "[Battling, Scripting]" ) {
|
||||
TEST_CASE("Add script to script set, then retrieve it", "[Battling, Scripting]") {
|
||||
auto set = ScriptSet();
|
||||
auto s = new Script("foobar");
|
||||
set.Add(s);
|
||||
@@ -32,7 +30,7 @@ TEST_CASE( "Add script to script set, then retrieve it", "[Battling, Scripting]"
|
||||
delete s;
|
||||
}
|
||||
|
||||
TEST_CASE( "Add two scripts to script set", "[Battling, Scripting]" ) {
|
||||
TEST_CASE("Add two scripts to script set", "[Battling, Scripting]") {
|
||||
auto set = ScriptSet();
|
||||
auto s = new Script("foobar");
|
||||
auto s2 = new Script("foobar2");
|
||||
@@ -43,7 +41,7 @@ TEST_CASE( "Add two scripts to script set", "[Battling, Scripting]" ) {
|
||||
delete s2;
|
||||
}
|
||||
|
||||
TEST_CASE( "Add two scripts to script set, then retrieve them", "[Battling, Scripting]" ) {
|
||||
TEST_CASE("Add two scripts to script set, then retrieve them", "[Battling, Scripting]") {
|
||||
auto set = ScriptSet();
|
||||
auto s = new Script("foobar");
|
||||
auto s2 = new Script("foobar2");
|
||||
@@ -58,7 +56,7 @@ TEST_CASE( "Add two scripts to script set, then retrieve them", "[Battling, Scri
|
||||
delete s2;
|
||||
}
|
||||
|
||||
TEST_CASE( "Add script to script set, then remove it", "[Battling, Scripting]" ) {
|
||||
TEST_CASE("Add script to script set, then remove it", "[Battling, Scripting]") {
|
||||
auto set = ScriptSet();
|
||||
auto s = new Script("foobar");
|
||||
set.Add(s);
|
||||
@@ -70,7 +68,7 @@ TEST_CASE( "Add script to script set, then remove it", "[Battling, Scripting]" )
|
||||
delete s;
|
||||
}
|
||||
|
||||
TEST_CASE( "Add two scripts to script set, then remove them", "[Battling, Scripting]" ) {
|
||||
TEST_CASE("Add two scripts to script set, then remove them", "[Battling, Scripting]") {
|
||||
auto set = ScriptSet();
|
||||
auto s = new Script("foobar");
|
||||
auto s2 = new Script("foobar2");
|
||||
@@ -85,9 +83,4 @@ TEST_CASE( "Add two scripts to script set, then remove them", "[Battling, Script
|
||||
delete s2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,50 +1,44 @@
|
||||
#ifdef TESTS_BUILD
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "../../../extern/catch.hpp"
|
||||
#include "../../../src/Battling/ScriptHandling/ScriptSource.hpp"
|
||||
#include <utility>
|
||||
#include "../../../extern/catch.hpp"
|
||||
#include "../../../src/Battling/ScriptHandling/ScriptAggregator.hpp"
|
||||
|
||||
using namespace CreatureLib;
|
||||
using namespace CreatureLib::Battling;
|
||||
|
||||
class TestScript : public Script{
|
||||
class TestScript : public Script {
|
||||
public:
|
||||
explicit TestScript(std::string name) : Script(std::move(name)){};
|
||||
|
||||
void TestMethod(int& runCount) {
|
||||
runCount++;
|
||||
}
|
||||
void TestMethod(int& runCount) { runCount++; }
|
||||
};
|
||||
|
||||
class ScriptSourceWithScriptPtr : public ScriptSource{
|
||||
class ScriptSourceWithScriptPtr : public ScriptSource {
|
||||
public:
|
||||
Script* ScriptPtr = nullptr;
|
||||
|
||||
protected:
|
||||
void GetActiveScripts(std::vector<ScriptWrapper> &scripts) override {
|
||||
scripts.emplace_back(&ScriptPtr);
|
||||
}
|
||||
void GetActiveScripts(std::vector<ScriptWrapper>& scripts) override { scripts.emplace_back(&ScriptPtr); }
|
||||
};
|
||||
|
||||
class ScriptSourceWithScriptSet : public ScriptSource{
|
||||
class ScriptSourceWithScriptSet : public ScriptSource {
|
||||
public:
|
||||
ScriptSet Set;
|
||||
|
||||
protected:
|
||||
void GetActiveScripts(std::vector<ScriptWrapper> &scripts) override {
|
||||
scripts.emplace_back(&Set);
|
||||
}
|
||||
void GetActiveScripts(std::vector<ScriptWrapper>& scripts) override { scripts.emplace_back(&Set); }
|
||||
};
|
||||
|
||||
|
||||
TEST_CASE( "Script source with unset script ptr.", "[Battling, Scripting]" ) {
|
||||
TEST_CASE("Script source with unset script ptr.", "[Battling, Scripting]") {
|
||||
auto source = ScriptSourceWithScriptPtr();
|
||||
auto scripts = source.GetScriptIterator();
|
||||
auto first = scripts.GetNext();
|
||||
CHECK(first == nullptr);
|
||||
}
|
||||
|
||||
TEST_CASE( "Script source with script ptr being set.", "[Battling, Scripting]" ) {
|
||||
TEST_CASE("Script source with script ptr being set.", "[Battling, Scripting]") {
|
||||
auto source = ScriptSourceWithScriptPtr();
|
||||
source.ScriptPtr = new Script("foobar");
|
||||
auto scripts = source.GetScriptIterator();
|
||||
@@ -53,7 +47,7 @@ TEST_CASE( "Script source with script ptr being set.", "[Battling, Scripting]" )
|
||||
delete source.ScriptPtr;
|
||||
}
|
||||
|
||||
TEST_CASE( "Script source with script ptr being set after first iteration.", "[Battling, Scripting]" ) {
|
||||
TEST_CASE("Script source with script ptr being set after first iteration.", "[Battling, Scripting]") {
|
||||
auto source = ScriptSourceWithScriptPtr();
|
||||
auto scripts = source.GetScriptIterator();
|
||||
auto first = scripts.GetNext();
|
||||
@@ -65,25 +59,25 @@ TEST_CASE( "Script source with script ptr being set after first iteration.", "[B
|
||||
delete source.ScriptPtr;
|
||||
}
|
||||
|
||||
TEST_CASE( "Script source with empty script set.", "[Battling, Scripting]" ) {
|
||||
TEST_CASE("Script source with empty script set.", "[Battling, Scripting]") {
|
||||
auto source = ScriptSourceWithScriptSet();
|
||||
auto scripts = source.GetScriptIterator();
|
||||
auto first = scripts.GetNext();
|
||||
CHECK(first == nullptr);
|
||||
}
|
||||
|
||||
TEST_CASE( "Script source with single item script set.", "[Battling, Scripting]" ) {
|
||||
TEST_CASE("Script source with single item script set.", "[Battling, Scripting]") {
|
||||
auto source = ScriptSourceWithScriptSet();
|
||||
auto s = new Script("foobar");
|
||||
source.Set.Add(s);
|
||||
auto scripts = source.GetScriptIterator();
|
||||
auto first = scripts.GetNext();
|
||||
CHECK(first != nullptr);
|
||||
CHECK (first->GetName() == "foobar");
|
||||
CHECK(first->GetName() == "foobar");
|
||||
delete s;
|
||||
}
|
||||
|
||||
TEST_CASE( "Script source with multiple item script set.", "[Battling, Scripting]" ) {
|
||||
TEST_CASE("Script source with multiple item script set.", "[Battling, Scripting]") {
|
||||
auto source = ScriptSourceWithScriptSet();
|
||||
auto s = new Script("foobar");
|
||||
auto s2 = new Script("foobar2");
|
||||
@@ -92,14 +86,12 @@ TEST_CASE( "Script source with multiple item script set.", "[Battling, Scripting
|
||||
auto scripts = source.GetScriptIterator();
|
||||
auto first = scripts.GetNext();
|
||||
CHECK(first != nullptr);
|
||||
CHECK (first->GetName() == "foobar");
|
||||
CHECK(first->GetName() == "foobar");
|
||||
auto second = scripts.GetNext();
|
||||
CHECK(second != nullptr);
|
||||
CHECK (second->GetName() == "foobar2");
|
||||
CHECK(second->GetName() == "foobar2");
|
||||
delete s;
|
||||
delete s2;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
#ifdef TESTS_BUILD
|
||||
|
||||
#include "../TestLibrary/TestLibrary.cpp"
|
||||
#include "../../src/Battling/TurnChoices/PassTurnChoice.hpp"
|
||||
#include "../../src/Battling/TurnChoices/AttackTurnChoice.hpp"
|
||||
#include "../../src/Battling/Flow/TurnOrdering.hpp"
|
||||
#include "../../src/Battling/TurnChoices/AttackTurnChoice.hpp"
|
||||
#include "../../src/Battling/TurnChoices/PassTurnChoice.hpp"
|
||||
#include "../TestLibrary/TestLibrary.cpp"
|
||||
|
||||
using namespace CreatureLib;
|
||||
using namespace CreatureLib::Battling;
|
||||
|
||||
TEST_CASE( "Turn ordering: Attack before pass", "[Battling]" ) {
|
||||
TEST_CASE("Turn ordering: Attack before pass", "[Battling]") {
|
||||
auto choice1 = new PassTurnChoice(nullptr);
|
||||
auto choice2 = new AttackTurnChoice(nullptr, nullptr, Target(0,0));
|
||||
auto choice2 = new AttackTurnChoice(nullptr, nullptr, Target(0, 0));
|
||||
auto vec = std::vector<BaseTurnChoice*>{choice1, choice2};
|
||||
auto rand = Core::Random();
|
||||
TurnOrdering::OrderChoices(vec,rand);
|
||||
TurnOrdering::OrderChoices(vec, rand);
|
||||
CHECK(vec[0] == choice2);
|
||||
CHECK(vec[1] == choice1);
|
||||
vec = std::vector<BaseTurnChoice*>{choice2, choice1};
|
||||
TurnOrdering::OrderChoices(vec,rand);
|
||||
TurnOrdering::OrderChoices(vec, rand);
|
||||
CHECK(vec[0] == choice2);
|
||||
CHECK(vec[1] == choice1);
|
||||
|
||||
@@ -25,19 +25,19 @@ TEST_CASE( "Turn ordering: Attack before pass", "[Battling]" ) {
|
||||
delete choice2;
|
||||
}
|
||||
|
||||
TEST_CASE( "Turn ordering: High priority goes before no priority", "[Battling]" ) {
|
||||
TEST_CASE("Turn ordering: High priority goes before no priority", "[Battling]") {
|
||||
auto l = GetLibrary()->GetAttackLibrary();
|
||||
auto a1 = new LearnedAttack(l->GetAttack("standard"), AttackLearnMethod::Unknown);
|
||||
auto a2 = new LearnedAttack(l->GetAttack("highPriority"), AttackLearnMethod::Unknown);
|
||||
auto choice1 = new AttackTurnChoice(nullptr, a1, Target(0,0));
|
||||
auto choice2 = new AttackTurnChoice(nullptr, a2, Target(0,0));
|
||||
auto choice1 = new AttackTurnChoice(nullptr, a1, Target(0, 0));
|
||||
auto choice2 = new AttackTurnChoice(nullptr, a2, Target(0, 0));
|
||||
auto vec = std::vector<BaseTurnChoice*>{choice1, choice2};
|
||||
auto rand = Core::Random();
|
||||
TurnOrdering::OrderChoices(vec,rand);
|
||||
TurnOrdering::OrderChoices(vec, rand);
|
||||
CHECK(vec[0] == choice2);
|
||||
CHECK(vec[1] == choice1);
|
||||
vec = std::vector<BaseTurnChoice*>{choice2, choice1};
|
||||
TurnOrdering::OrderChoices(vec,rand);
|
||||
TurnOrdering::OrderChoices(vec, rand);
|
||||
CHECK(vec[0] == choice2);
|
||||
CHECK(vec[1] == choice1);
|
||||
|
||||
@@ -47,19 +47,19 @@ TEST_CASE( "Turn ordering: High priority goes before no priority", "[Battling]"
|
||||
delete a2;
|
||||
}
|
||||
|
||||
TEST_CASE( "Turn ordering: Higher priority goes before high priority", "[Battling]" ) {
|
||||
TEST_CASE("Turn ordering: Higher priority goes before high priority", "[Battling]") {
|
||||
auto l = GetLibrary()->GetAttackLibrary();
|
||||
auto a1 = new LearnedAttack(l->GetAttack("highPriority"), AttackLearnMethod::Unknown);
|
||||
auto a2 = new LearnedAttack(l->GetAttack("higherPriority"), AttackLearnMethod::Unknown);
|
||||
auto choice1 = new AttackTurnChoice(nullptr, a1, Target(0,0));
|
||||
auto choice2 = new AttackTurnChoice(nullptr, a2, Target(0,0));
|
||||
auto choice1 = new AttackTurnChoice(nullptr, a1, Target(0, 0));
|
||||
auto choice2 = new AttackTurnChoice(nullptr, a2, Target(0, 0));
|
||||
auto vec = std::vector<BaseTurnChoice*>{choice1, choice2};
|
||||
auto rand = Core::Random();
|
||||
TurnOrdering::OrderChoices(vec,rand);
|
||||
TurnOrdering::OrderChoices(vec, rand);
|
||||
CHECK(vec[0] == choice2);
|
||||
CHECK(vec[1] == choice1);
|
||||
vec = std::vector<BaseTurnChoice*>{choice2, choice1};
|
||||
TurnOrdering::OrderChoices(vec,rand);
|
||||
TurnOrdering::OrderChoices(vec, rand);
|
||||
CHECK(vec[0] == choice2);
|
||||
CHECK(vec[1] == choice1);
|
||||
|
||||
@@ -69,19 +69,19 @@ TEST_CASE( "Turn ordering: Higher priority goes before high priority", "[Battlin
|
||||
delete a2;
|
||||
}
|
||||
|
||||
TEST_CASE( "Turn ordering: High priority goes before low priority", "[Battling]" ) {
|
||||
TEST_CASE("Turn ordering: High priority goes before low priority", "[Battling]") {
|
||||
auto l = GetLibrary()->GetAttackLibrary();
|
||||
auto a1 = new LearnedAttack(l->GetAttack("lowPriority"), AttackLearnMethod::Unknown);
|
||||
auto a2 = new LearnedAttack(l->GetAttack("higherPriority"), AttackLearnMethod::Unknown);
|
||||
auto choice1 = new AttackTurnChoice(nullptr, a1, Target(0,0));
|
||||
auto choice2 = new AttackTurnChoice(nullptr, a2, Target(0,0));
|
||||
auto choice1 = new AttackTurnChoice(nullptr, a1, Target(0, 0));
|
||||
auto choice2 = new AttackTurnChoice(nullptr, a2, Target(0, 0));
|
||||
auto vec = std::vector<BaseTurnChoice*>{choice1, choice2};
|
||||
auto rand = Core::Random();
|
||||
TurnOrdering::OrderChoices(vec,rand);
|
||||
TurnOrdering::OrderChoices(vec, rand);
|
||||
CHECK(vec[0] == choice2);
|
||||
CHECK(vec[1] == choice1);
|
||||
vec = std::vector<BaseTurnChoice*>{choice2, choice1};
|
||||
TurnOrdering::OrderChoices(vec,rand);
|
||||
TurnOrdering::OrderChoices(vec, rand);
|
||||
CHECK(vec[0] == choice2);
|
||||
CHECK(vec[1] == choice1);
|
||||
|
||||
@@ -91,19 +91,19 @@ TEST_CASE( "Turn ordering: High priority goes before low priority", "[Battling]"
|
||||
delete a2;
|
||||
}
|
||||
|
||||
TEST_CASE( "Turn ordering: No priority goes before low priority", "[Battling]" ) {
|
||||
TEST_CASE("Turn ordering: No priority goes before low priority", "[Battling]") {
|
||||
auto l = GetLibrary()->GetAttackLibrary();
|
||||
auto a1 = new LearnedAttack(l->GetAttack("lowPriority"), AttackLearnMethod::Unknown);
|
||||
auto a2 = new LearnedAttack(l->GetAttack("standard"), AttackLearnMethod::Unknown);
|
||||
auto choice1 = new AttackTurnChoice(nullptr, a1, Target(0,0));
|
||||
auto choice2 = new AttackTurnChoice(nullptr, a2, Target(0,0));
|
||||
auto choice1 = new AttackTurnChoice(nullptr, a1, Target(0, 0));
|
||||
auto choice2 = new AttackTurnChoice(nullptr, a2, Target(0, 0));
|
||||
auto vec = std::vector<BaseTurnChoice*>{choice1, choice2};
|
||||
auto rand = Core::Random();
|
||||
TurnOrdering::OrderChoices(vec,rand);
|
||||
TurnOrdering::OrderChoices(vec, rand);
|
||||
CHECK(vec[0] == choice2);
|
||||
CHECK(vec[1] == choice1);
|
||||
vec = std::vector<BaseTurnChoice*>{choice2, choice1};
|
||||
TurnOrdering::OrderChoices(vec,rand);
|
||||
TurnOrdering::OrderChoices(vec, rand);
|
||||
CHECK(vec[0] == choice2);
|
||||
CHECK(vec[1] == choice1);
|
||||
|
||||
@@ -113,6 +113,4 @@ TEST_CASE( "Turn ordering: No priority goes before low priority", "[Battling]" )
|
||||
delete a2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user