Implements ConstString in several core places in the library, improving performance.
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:
@@ -28,8 +28,8 @@ TEST_CASE("Turn ordering: Attack before pass", "[Battling]") {
|
||||
|
||||
TEST_CASE("Turn ordering: High priority goes before no priority", "[Battling]") {
|
||||
auto l = TestLibrary::Get()->GetAttackLibrary();
|
||||
auto a1 = new LearnedAttack(l->Get("standard"), AttackLearnMethod::Unknown);
|
||||
auto a2 = new LearnedAttack(l->Get("highPriority"), AttackLearnMethod::Unknown);
|
||||
auto a1 = new LearnedAttack(l->Get("standard"_cnc), AttackLearnMethod::Unknown);
|
||||
auto a2 = new LearnedAttack(l->Get("highPriority"_cnc), AttackLearnMethod::Unknown);
|
||||
auto choice1 = new AttackTurnChoice(nullptr, a1, CreatureIndex(0, 0));
|
||||
auto choice2 = new AttackTurnChoice(nullptr, a2, CreatureIndex(0, 0));
|
||||
auto vec = std::vector<BaseTurnChoice*>{choice1, choice2};
|
||||
@@ -50,8 +50,8 @@ TEST_CASE("Turn ordering: High priority goes before no priority", "[Battling]")
|
||||
|
||||
TEST_CASE("Turn ordering: Higher priority goes before high priority", "[Battling]") {
|
||||
auto l = TestLibrary::Get()->GetAttackLibrary();
|
||||
auto a1 = new LearnedAttack(l->Get("highPriority"), AttackLearnMethod::Unknown);
|
||||
auto a2 = new LearnedAttack(l->Get("higherPriority"), AttackLearnMethod::Unknown);
|
||||
auto a1 = new LearnedAttack(l->Get("highPriority"_cnc), AttackLearnMethod::Unknown);
|
||||
auto a2 = new LearnedAttack(l->Get("higherPriority"_cnc), AttackLearnMethod::Unknown);
|
||||
auto choice1 = new AttackTurnChoice(nullptr, a1, CreatureIndex(0, 0));
|
||||
auto choice2 = new AttackTurnChoice(nullptr, a2, CreatureIndex(0, 0));
|
||||
auto vec = std::vector<BaseTurnChoice*>{choice1, choice2};
|
||||
@@ -72,8 +72,8 @@ TEST_CASE("Turn ordering: Higher priority goes before high priority", "[Battling
|
||||
|
||||
TEST_CASE("Turn ordering: High priority goes before low priority", "[Battling]") {
|
||||
auto l = TestLibrary::Get()->GetAttackLibrary();
|
||||
auto a1 = new LearnedAttack(l->Get("lowPriority"), AttackLearnMethod::Unknown);
|
||||
auto a2 = new LearnedAttack(l->Get("higherPriority"), AttackLearnMethod::Unknown);
|
||||
auto a1 = new LearnedAttack(l->Get("lowPriority"_cnc), AttackLearnMethod::Unknown);
|
||||
auto a2 = new LearnedAttack(l->Get("higherPriority"_cnc), AttackLearnMethod::Unknown);
|
||||
auto choice1 = new AttackTurnChoice(nullptr, a1, CreatureIndex(0, 0));
|
||||
auto choice2 = new AttackTurnChoice(nullptr, a2, CreatureIndex(0, 0));
|
||||
auto vec = std::vector<BaseTurnChoice*>{choice1, choice2};
|
||||
@@ -94,8 +94,8 @@ TEST_CASE("Turn ordering: High priority goes before low priority", "[Battling]")
|
||||
|
||||
TEST_CASE("Turn ordering: No priority goes before low priority", "[Battling]") {
|
||||
auto l = TestLibrary::Get()->GetAttackLibrary();
|
||||
auto a1 = new LearnedAttack(l->Get("lowPriority"), AttackLearnMethod::Unknown);
|
||||
auto a2 = new LearnedAttack(l->Get("standard"), AttackLearnMethod::Unknown);
|
||||
auto a1 = new LearnedAttack(l->Get("lowPriority"_cnc), AttackLearnMethod::Unknown);
|
||||
auto a2 = new LearnedAttack(l->Get("standard"_cnc), AttackLearnMethod::Unknown);
|
||||
auto choice1 = new AttackTurnChoice(nullptr, a1, CreatureIndex(0, 0));
|
||||
auto choice2 = new AttackTurnChoice(nullptr, a2, CreatureIndex(0, 0));
|
||||
auto vec = std::vector<BaseTurnChoice*>{choice1, choice2};
|
||||
|
||||
@@ -13,7 +13,8 @@ using namespace Battling;
|
||||
|
||||
TEST_CASE("Create Party", "[Integrations]") {
|
||||
auto library = TestLibrary::Get();
|
||||
auto c1 = CreateCreature(library, "testSpecies1", 50).WithAttack("standard", AttackLearnMethod::Unknown)->Create();
|
||||
auto c1 =
|
||||
CreateCreature(library, "testSpecies1", 50).WithAttack("standard"_cnc, AttackLearnMethod::Unknown)->Create();
|
||||
CreatureParty party1{c1};
|
||||
auto battleParty = BattleParty(&party1, {CreatureIndex(0, 0)});
|
||||
REQUIRE(battleParty.GetParty()->GetAtIndex(0) == c1);
|
||||
@@ -21,10 +22,12 @@ TEST_CASE("Create Party", "[Integrations]") {
|
||||
|
||||
TEST_CASE("Create Battle", "[Integrations]") {
|
||||
auto library = TestLibrary::Get();
|
||||
auto c1 = CreateCreature(library, "testSpecies1", 50).WithAttack("standard", AttackLearnMethod::Unknown)->Create();
|
||||
auto c1 =
|
||||
CreateCreature(library, "testSpecies1", 50).WithAttack("standard"_cnc, AttackLearnMethod::Unknown)->Create();
|
||||
CreatureParty party1{c1};
|
||||
auto battleParty1 = BattleParty(&party1, {CreatureIndex(0, 0)});
|
||||
auto c2 = CreateCreature(library, "testSpecies1", 50).WithAttack("standard", AttackLearnMethod::Unknown)->Create();
|
||||
auto c2 =
|
||||
CreateCreature(library, "testSpecies1", 50).WithAttack("standard"_cnc, AttackLearnMethod::Unknown)->Create();
|
||||
CreatureParty party2{c2};
|
||||
auto battleParty2 = BattleParty(&party2, {CreatureIndex(1, 0)});
|
||||
|
||||
@@ -33,10 +36,12 @@ TEST_CASE("Create Battle", "[Integrations]") {
|
||||
|
||||
TEST_CASE("Use damaging move", "[Integrations]") {
|
||||
auto library = TestLibrary::Get();
|
||||
auto c1 = CreateCreature(library, "testSpecies1", 50).WithAttack("standard", AttackLearnMethod::Unknown)->Create();
|
||||
auto c1 =
|
||||
CreateCreature(library, "testSpecies1", 50).WithAttack("standard"_cnc, AttackLearnMethod::Unknown)->Create();
|
||||
CreatureParty party1{c1};
|
||||
auto battleParty1 = BattleParty(&party1, {CreatureIndex(0, 0)});
|
||||
auto c2 = CreateCreature(library, "testSpecies1", 50).WithAttack("standard", AttackLearnMethod::Unknown)->Create();
|
||||
auto c2 =
|
||||
CreateCreature(library, "testSpecies1", 50).WithAttack("standard"_cnc, AttackLearnMethod::Unknown)->Create();
|
||||
CreatureParty party2{c2};
|
||||
auto battleParty2 = BattleParty(&party2, {CreatureIndex(1, 0)});
|
||||
|
||||
@@ -53,10 +58,12 @@ TEST_CASE("Use damaging move", "[Integrations]") {
|
||||
|
||||
TEST_CASE("Finish battle when all battle of one side have fainted", "[Integrations]") {
|
||||
auto library = TestLibrary::Get();
|
||||
auto c1 = CreateCreature(library, "testSpecies1", 50).WithAttack("standard", AttackLearnMethod::Unknown)->Create();
|
||||
auto c1 =
|
||||
CreateCreature(library, "testSpecies1", 50).WithAttack("standard"_cnc, AttackLearnMethod::Unknown)->Create();
|
||||
CreatureParty party1{c1};
|
||||
auto battleParty1 = BattleParty(&party1, {CreatureIndex(0, 0)});
|
||||
auto c2 = CreateCreature(library, "testSpecies1", 50).WithAttack("standard", AttackLearnMethod::Unknown)->Create();
|
||||
auto c2 =
|
||||
CreateCreature(library, "testSpecies1", 50).WithAttack("standard"_cnc, AttackLearnMethod::Unknown)->Create();
|
||||
CreatureParty party2{c2};
|
||||
auto battleParty2 = BattleParty(&party2, {CreatureIndex(1, 0)});
|
||||
|
||||
@@ -86,10 +93,12 @@ TEST_CASE("Finish battle when all battle of one side have fainted", "[Integratio
|
||||
|
||||
TEST_CASE("When creature is dealt enough damage, faint it and mark battle as ended", "[Integrations]") {
|
||||
auto library = TestLibrary::Get();
|
||||
auto c1 = CreateCreature(library, "testSpecies1", 100).WithAttack("standard", AttackLearnMethod::Unknown)->Create();
|
||||
auto c1 =
|
||||
CreateCreature(library, "testSpecies1", 100).WithAttack("standard"_cnc, AttackLearnMethod::Unknown)->Create();
|
||||
CreatureParty party1{c1};
|
||||
auto battleParty1 = BattleParty(&party1, {CreatureIndex(0, 0)});
|
||||
auto c2 = CreateCreature(library, "testSpecies1", 1).WithAttack("standard", AttackLearnMethod::Unknown)->Create();
|
||||
auto c2 =
|
||||
CreateCreature(library, "testSpecies1", 1).WithAttack("standard"_cnc, AttackLearnMethod::Unknown)->Create();
|
||||
CreatureParty party2{c2};
|
||||
auto battleParty2 = BattleParty(&party2, {CreatureIndex(1, 0)});
|
||||
|
||||
@@ -113,11 +122,14 @@ TEST_CASE("When creature is dealt enough damage, faint it and mark battle as end
|
||||
|
||||
TEST_CASE("When another creature is available on faint, make sure the battle hasn't ended", "[Integrations]") {
|
||||
auto library = TestLibrary::Get();
|
||||
auto c1 = CreateCreature(library, "testSpecies1", 100).WithAttack("standard", AttackLearnMethod::Unknown)->Create();
|
||||
auto c1 =
|
||||
CreateCreature(library, "testSpecies1", 100).WithAttack("standard"_cnc, AttackLearnMethod::Unknown)->Create();
|
||||
CreatureParty party1{c1};
|
||||
auto battleParty1 = BattleParty(&party1, {CreatureIndex(0, 0)});
|
||||
auto c2 = CreateCreature(library, "testSpecies1", 1).WithAttack("standard", AttackLearnMethod::Unknown)->Create();
|
||||
auto c3 = CreateCreature(library, "testSpecies1", 1).WithAttack("standard", AttackLearnMethod::Unknown)->Create();
|
||||
auto c2 =
|
||||
CreateCreature(library, "testSpecies1", 1).WithAttack("standard"_cnc, AttackLearnMethod::Unknown)->Create();
|
||||
auto c3 =
|
||||
CreateCreature(library, "testSpecies1", 1).WithAttack("standard"_cnc, AttackLearnMethod::Unknown)->Create();
|
||||
CreatureParty party2{c2, c3};
|
||||
auto battleParty2 = BattleParty(&party2, {CreatureIndex(1, 0)});
|
||||
|
||||
@@ -148,11 +160,14 @@ TEST_CASE("When another creature is available on faint, make sure the battle has
|
||||
|
||||
TEST_CASE("Switch Creature in", "[Integrations]") {
|
||||
auto library = TestLibrary::Get();
|
||||
auto c1 = CreateCreature(library, "testSpecies1", 100).WithAttack("standard", AttackLearnMethod::Unknown)->Create();
|
||||
auto c2 = CreateCreature(library, "testSpecies1", 1).WithAttack("standard", AttackLearnMethod::Unknown)->Create();
|
||||
auto c1 =
|
||||
CreateCreature(library, "testSpecies1", 100).WithAttack("standard"_cnc, AttackLearnMethod::Unknown)->Create();
|
||||
auto c2 =
|
||||
CreateCreature(library, "testSpecies1", 1).WithAttack("standard"_cnc, AttackLearnMethod::Unknown)->Create();
|
||||
CreatureParty party1{c1, c2};
|
||||
auto battleParty1 = BattleParty(&party1, {CreatureIndex(0, 0)});
|
||||
auto c3 = CreateCreature(library, "testSpecies1", 1).WithAttack("standard", AttackLearnMethod::Unknown)->Create();
|
||||
auto c3 =
|
||||
CreateCreature(library, "testSpecies1", 1).WithAttack("standard"_cnc, AttackLearnMethod::Unknown)->Create();
|
||||
CreatureParty party2{c3};
|
||||
auto battleParty2 = BattleParty(&party2, {CreatureIndex(1, 0)});
|
||||
|
||||
@@ -171,11 +186,14 @@ TEST_CASE("Switch Creature in", "[Integrations]") {
|
||||
|
||||
TEST_CASE("Switch Creature in, but have attack aimed at it. Attack should hit new creature", "[Integrations]") {
|
||||
auto library = TestLibrary::Get();
|
||||
auto c1 = CreateCreature(library, "testSpecies1", 50).WithAttack("standard", AttackLearnMethod::Unknown)->Create();
|
||||
auto c2 = CreateCreature(library, "testSpecies1", 50).WithAttack("standard", AttackLearnMethod::Unknown)->Create();
|
||||
auto c1 =
|
||||
CreateCreature(library, "testSpecies1", 50).WithAttack("standard"_cnc, AttackLearnMethod::Unknown)->Create();
|
||||
auto c2 =
|
||||
CreateCreature(library, "testSpecies1", 50).WithAttack("standard"_cnc, AttackLearnMethod::Unknown)->Create();
|
||||
CreatureParty party1{c1, c2};
|
||||
auto battleParty1 = BattleParty(&party1, {CreatureIndex(0, 0)});
|
||||
auto c3 = CreateCreature(library, "testSpecies1", 50).WithAttack("standard", AttackLearnMethod::Unknown)->Create();
|
||||
auto c3 =
|
||||
CreateCreature(library, "testSpecies1", 50).WithAttack("standard"_cnc, AttackLearnMethod::Unknown)->Create();
|
||||
CreatureParty party2{c3};
|
||||
auto battleParty2 = BattleParty(&party2, {CreatureIndex(1, 0)});
|
||||
|
||||
@@ -193,11 +211,14 @@ TEST_CASE("Switch Creature in, but have attack aimed at it. Attack should hit ne
|
||||
|
||||
TEST_CASE("Switch Creature in, mark as seen opponent for opponent", "[Integrations]") {
|
||||
auto library = TestLibrary::Get();
|
||||
auto c1 = CreateCreature(library, "testSpecies1", 100).WithAttack("standard", AttackLearnMethod::Unknown)->Create();
|
||||
auto c2 = CreateCreature(library, "testSpecies1", 1).WithAttack("standard", AttackLearnMethod::Unknown)->Create();
|
||||
auto c1 =
|
||||
CreateCreature(library, "testSpecies1", 100).WithAttack("standard"_cnc, AttackLearnMethod::Unknown)->Create();
|
||||
auto c2 =
|
||||
CreateCreature(library, "testSpecies1", 1).WithAttack("standard"_cnc, AttackLearnMethod::Unknown)->Create();
|
||||
CreatureParty party1{c1, c2};
|
||||
auto battleParty1 = BattleParty(&party1, {CreatureIndex(0, 0)});
|
||||
auto c3 = CreateCreature(library, "testSpecies1", 1).WithAttack("standard", AttackLearnMethod::Unknown)->Create();
|
||||
auto c3 =
|
||||
CreateCreature(library, "testSpecies1", 1).WithAttack("standard"_cnc, AttackLearnMethod::Unknown)->Create();
|
||||
CreatureParty party2{c3};
|
||||
auto battleParty2 = BattleParty(&party2, {CreatureIndex(1, 0)});
|
||||
|
||||
@@ -229,10 +250,12 @@ TEST_CASE("Switch Creature in, mark as seen opponent for opponent", "[Integratio
|
||||
|
||||
TEST_CASE("Flee Battle", "[Integrations]") {
|
||||
auto library = TestLibrary::Get();
|
||||
auto c1 = CreateCreature(library, "testSpecies1", 100).WithAttack("standard", AttackLearnMethod::Unknown)->Create();
|
||||
auto c1 =
|
||||
CreateCreature(library, "testSpecies1", 100).WithAttack("standard"_cnc, AttackLearnMethod::Unknown)->Create();
|
||||
CreatureParty party1{c1};
|
||||
auto battleParty1 = BattleParty(&party1, {CreatureIndex(0, 0)});
|
||||
auto c2 = CreateCreature(library, "testSpecies1", 1).WithAttack("standard", AttackLearnMethod::Unknown)->Create();
|
||||
auto c2 =
|
||||
CreateCreature(library, "testSpecies1", 1).WithAttack("standard"_cnc, AttackLearnMethod::Unknown)->Create();
|
||||
CreatureParty party2{c2};
|
||||
auto battleParty2 = BattleParty(&party2, {CreatureIndex(1, 0)});
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ TEST_CASE("Create basic creature", "[Library]") {
|
||||
TEST_CASE("Get creature species", "[Library]") {
|
||||
auto library = TestLibrary::Get();
|
||||
auto creature = CreateCreature(library, "testSpecies1", 1).Create();
|
||||
REQUIRE(creature->GetSpecies()->GetName() == "testSpecies1");
|
||||
REQUIRE(creature->GetSpecies()->GetName() == "testSpecies1"_cnc);
|
||||
delete creature;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,25 +22,25 @@ BattleLibrary* TestLibrary::Get() {
|
||||
|
||||
SpeciesLibrary* TestLibrary::BuildSpeciesLibrary() {
|
||||
auto l = new SpeciesLibrary();
|
||||
l->Insert("testSpecies1",
|
||||
new CreatureSpecies(0, "testSpecies1",
|
||||
l->Insert("testSpecies1"_cnc,
|
||||
new CreatureSpecies(0, "testSpecies1"_cnc,
|
||||
new SpeciesVariant("default", 1, 1, 10, {0, 1},
|
||||
StatisticSet<uint16_t>(10, 10, 10, 10, 10, 10), {"testTalent"},
|
||||
{"testSecretTalent"}, new LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate", 5));
|
||||
0.5f, "testGrowthRate"_cnc, 5));
|
||||
return l;
|
||||
}
|
||||
|
||||
AttackLibrary* TestLibrary::BuildAttackLibrary() {
|
||||
auto l = new AttackLibrary();
|
||||
l->Insert("standard", new AttackData("standard", 0, AttackCategory::Physical, 20, 100, 30,
|
||||
AttackTarget::AdjacentOpponent, 0, {}));
|
||||
l->Insert("highPriority", new AttackData("highPriority", 0, AttackCategory::Physical, 20, 100, 30,
|
||||
AttackTarget::AdjacentOpponent, 1, {}));
|
||||
l->Insert("higherPriority", new AttackData("higherPriority", 0, AttackCategory::Physical, 20, 100, 30,
|
||||
AttackTarget::AdjacentOpponent, 2, {}));
|
||||
l->Insert("lowPriority", new AttackData("lowPriority", 0, AttackCategory::Physical, 20, 100, 30,
|
||||
AttackTarget::AdjacentOpponent, -1, {}));
|
||||
l->Insert("standard"_cnc, new AttackData("standard", 0, AttackCategory::Physical, 20, 100, 30,
|
||||
AttackTarget::AdjacentOpponent, 0, {}));
|
||||
l->Insert("highPriority"_cnc, new AttackData("highPriority", 0, AttackCategory::Physical, 20, 100, 30,
|
||||
AttackTarget::AdjacentOpponent, 1, {}));
|
||||
l->Insert("higherPriority"_cnc, new AttackData("higherPriority", 0, AttackCategory::Physical, 20, 100, 30,
|
||||
AttackTarget::AdjacentOpponent, 2, {}));
|
||||
l->Insert("lowPriority"_cnc, new AttackData("lowPriority", 0, AttackCategory::Physical, 20, 100, 30,
|
||||
AttackTarget::AdjacentOpponent, -1, {}));
|
||||
return l;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ ItemLibrary* TestLibrary::BuildItemLibrary() {
|
||||
|
||||
GrowthRateLibrary* TestLibrary::BuildGrowthRateLibrary() {
|
||||
auto l = new GrowthRateLibrary();
|
||||
l->AddGrowthRate("testGrowthRate", new LookupGrowthRate());
|
||||
l->AddGrowthRate("testGrowthRate"_cnc, new LookupGrowthRate());
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user