Rework several libraries to use new StringViewDictionary
This commit is contained in:
@@ -12,8 +12,7 @@ using namespace CreatureLib::Battling;
|
||||
|
||||
TEST_CASE("Turn ordering: Attack before pass") {
|
||||
auto lib = TestLibrary::Get();
|
||||
auto learnedAttack =
|
||||
LearnedAttack(lib->GetAttackLibrary()->Get("standard"_cnc.GetHash()), AttackLearnMethod::Unknown);
|
||||
auto learnedAttack = LearnedAttack(lib->GetAttackLibrary()->Get("standard"_cnc), AttackLearnMethod::Unknown);
|
||||
auto creature = CreateCreature(lib, "testSpecies1"_cnc, 1).Create();
|
||||
|
||||
auto choice1 = std::make_shared<PassTurnChoice>(creature);
|
||||
@@ -32,8 +31,8 @@ TEST_CASE("Turn ordering: Attack before pass") {
|
||||
TEST_CASE("Turn ordering: High priority goes before no priority") {
|
||||
auto lib = TestLibrary::Get();
|
||||
const auto& l = lib->GetAttackLibrary();
|
||||
auto a1 = new LearnedAttack(l->Get("standard"_cnc.GetHash()), AttackLearnMethod::Unknown);
|
||||
auto a2 = new LearnedAttack(l->Get("highPriority"_cnc.GetHash()), AttackLearnMethod::Unknown);
|
||||
auto a1 = new LearnedAttack(l->GetByHash("standard"_cnc.GetHash()), AttackLearnMethod::Unknown);
|
||||
auto a2 = new LearnedAttack(l->GetByHash("highPriority"_cnc.GetHash()), AttackLearnMethod::Unknown);
|
||||
auto creature = CreateCreature(lib, "testSpecies1"_cnc, 1).Create();
|
||||
|
||||
auto choice1 = std::make_shared<AttackTurnChoice>(creature, a1, CreatureIndex(0, 0));
|
||||
@@ -55,8 +54,8 @@ TEST_CASE("Turn ordering: High priority goes before no priority") {
|
||||
TEST_CASE("Turn ordering: Higher priority goes before high priority") {
|
||||
auto lib = TestLibrary::Get();
|
||||
const auto& l = lib->GetAttackLibrary();
|
||||
auto a1 = new LearnedAttack(l->Get("highPriority"_cnc.GetHash()), AttackLearnMethod::Unknown);
|
||||
auto a2 = new LearnedAttack(l->Get("higherPriority"_cnc.GetHash()), AttackLearnMethod::Unknown);
|
||||
auto a1 = new LearnedAttack(l->GetByHash("highPriority"_cnc.GetHash()), AttackLearnMethod::Unknown);
|
||||
auto a2 = new LearnedAttack(l->GetByHash("higherPriority"_cnc.GetHash()), AttackLearnMethod::Unknown);
|
||||
auto creature = CreateCreature(lib, "testSpecies1"_cnc, 1).Create();
|
||||
auto choice1 = std::make_shared<AttackTurnChoice>(creature, a1, CreatureIndex(0, 0));
|
||||
auto choice2 = std::make_shared<AttackTurnChoice>(creature, a2, CreatureIndex(0, 0));
|
||||
@@ -76,8 +75,8 @@ TEST_CASE("Turn ordering: Higher priority goes before high priority") {
|
||||
TEST_CASE("Turn ordering: High priority goes before low priority") {
|
||||
auto lib = TestLibrary::Get();
|
||||
const auto& l = lib->GetAttackLibrary();
|
||||
auto a1 = new LearnedAttack(l->Get("lowPriority"_cnc.GetHash()), AttackLearnMethod::Unknown);
|
||||
auto a2 = new LearnedAttack(l->Get("higherPriority"_cnc.GetHash()), AttackLearnMethod::Unknown);
|
||||
auto a1 = new LearnedAttack(l->GetByHash("lowPriority"_cnc.GetHash()), AttackLearnMethod::Unknown);
|
||||
auto a2 = new LearnedAttack(l->GetByHash("higherPriority"_cnc.GetHash()), AttackLearnMethod::Unknown);
|
||||
auto creature = CreateCreature(lib, "testSpecies1"_cnc, 1).Create();
|
||||
|
||||
auto choice1 = std::make_shared<AttackTurnChoice>(creature, a1, CreatureIndex(0, 0));
|
||||
@@ -99,8 +98,8 @@ TEST_CASE("Turn ordering: High priority goes before low priority") {
|
||||
TEST_CASE("Turn ordering: No priority goes before low priority") {
|
||||
auto lib = TestLibrary::Get();
|
||||
const auto& l = lib->GetAttackLibrary();
|
||||
auto a1 = new LearnedAttack(l->Get("lowPriority"_cnc.GetHash()), AttackLearnMethod::Unknown);
|
||||
auto a2 = new LearnedAttack(l->Get("standard"_cnc.GetHash()), AttackLearnMethod::Unknown);
|
||||
auto a1 = new LearnedAttack(l->GetByHash("lowPriority"_cnc.GetHash()), AttackLearnMethod::Unknown);
|
||||
auto a2 = new LearnedAttack(l->GetByHash("standard"_cnc.GetHash()), AttackLearnMethod::Unknown);
|
||||
auto creature = CreateCreature(lib, "testSpecies1"_cnc, 1).Create();
|
||||
auto choice1 = std::make_shared<AttackTurnChoice>(creature, a1, CreatureIndex(0, 0));
|
||||
auto choice2 = std::make_shared<AttackTurnChoice>(creature, a2, CreatureIndex(0, 0));
|
||||
|
||||
@@ -7,7 +7,7 @@ using namespace CreatureLib::Library;
|
||||
TEST_CASE("Iterate over library") {
|
||||
auto& lib = TestLibrary::Get()->GetSpeciesLibrary();
|
||||
auto i = 0;
|
||||
for (auto b : *lib) {
|
||||
for (auto& b : *lib) {
|
||||
if (i == 0) {
|
||||
CHECK(b.second->GetName() == "testSpecies1"_cnc);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ BattleLibrary* TestLibrary::Get() {
|
||||
|
||||
SpeciesLibrary* TestLibrary::BuildSpeciesLibrary(const TalentLibrary* talentLibrary) {
|
||||
auto l = new SpeciesLibrary();
|
||||
l->Insert("testSpecies1"_cnc.GetHash(),
|
||||
l->Insert("testSpecies1"_cnc,
|
||||
new CreatureSpecies(
|
||||
0, "testSpecies1"_cnc,
|
||||
new SpeciesVariant("default"_cnc, 1, 1, 10, {0, 1}, StatisticSet<u16>(10, 10, 10, 10, 10, 10),
|
||||
@@ -34,17 +34,14 @@ SpeciesLibrary* TestLibrary::BuildSpeciesLibrary(const TalentLibrary* talentLibr
|
||||
|
||||
AttackLibrary* TestLibrary::BuildAttackLibrary() {
|
||||
auto l = new AttackLibrary();
|
||||
l->Insert("standard"_cnc.GetHash(), new AttackData("standard"_cnc, 0, AttackCategory::Physical, 20, 100, 30,
|
||||
AttackTarget::AdjacentOpponent, 0, new SecondaryEffect(), {}));
|
||||
l->Insert("highPriority"_cnc.GetHash(),
|
||||
new AttackData("highPriority"_cnc, 0, AttackCategory::Physical, 20, 100, 30,
|
||||
AttackTarget::AdjacentOpponent, 1, new SecondaryEffect(), {}));
|
||||
l->Insert("higherPriority"_cnc.GetHash(),
|
||||
new AttackData("higherPriority"_cnc, 0, AttackCategory::Physical, 20, 100, 30,
|
||||
AttackTarget::AdjacentOpponent, 2, new SecondaryEffect(), {}));
|
||||
l->Insert("lowPriority"_cnc.GetHash(),
|
||||
new AttackData("lowPriority"_cnc, 0, AttackCategory::Physical, 20, 100, 30,
|
||||
AttackTarget::AdjacentOpponent, -1, new SecondaryEffect(), {}));
|
||||
l->Insert("standard"_cnc, new AttackData("standard"_cnc, 0, AttackCategory::Physical, 20, 100, 30,
|
||||
AttackTarget::AdjacentOpponent, 0, new SecondaryEffect(), {}));
|
||||
l->Insert("highPriority"_cnc, new AttackData("highPriority"_cnc, 0, AttackCategory::Physical, 20, 100, 30,
|
||||
AttackTarget::AdjacentOpponent, 1, new SecondaryEffect(), {}));
|
||||
l->Insert("higherPriority"_cnc, new AttackData("higherPriority"_cnc, 0, AttackCategory::Physical, 20, 100, 30,
|
||||
AttackTarget::AdjacentOpponent, 2, new SecondaryEffect(), {}));
|
||||
l->Insert("lowPriority"_cnc, new AttackData("lowPriority"_cnc, 0, AttackCategory::Physical, 20, 100, 30,
|
||||
AttackTarget::AdjacentOpponent, -1, new SecondaryEffect(), {}));
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user