Revert "Use smart pointers for basic libraries."
All checks were successful
continuous-integration/drone/push Build is passing

This reverts commit 214ff819
This commit is contained in:
2020-04-04 13:37:06 +02:00
parent 91bea44113
commit 1e0d00d3b7
9 changed files with 121 additions and 96 deletions

View File

@@ -29,7 +29,7 @@ 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 l = TestLibrary::Get()->GetAttackLibrary();
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));
@@ -51,7 +51,7 @@ 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 l = TestLibrary::Get()->GetAttackLibrary();
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));
@@ -73,7 +73,7 @@ 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 l = TestLibrary::Get()->GetAttackLibrary();
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));
@@ -95,7 +95,7 @@ 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 l = TestLibrary::Get()->GetAttackLibrary();
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));

View File

@@ -9,14 +9,11 @@ BattleLibrary* TestLibrary::_library = nullptr;
BattleLibrary* TestLibrary::Get() {
if (TestLibrary::_library == nullptr) {
auto l = new DataLibrary(
std::make_unique<LibrarySettings>(100, 4), std::unique_ptr<SpeciesLibrary>(BuildSpeciesLibrary()),
std::unique_ptr<AttackLibrary>(BuildAttackLibrary()), std::unique_ptr<ItemLibrary>(BuildItemLibrary()),
std::unique_ptr<GrowthRateLibrary>(BuildGrowthRateLibrary()),
std::unique_ptr<TypeLibrary>(BuildTypeLibrary()));
auto battleLib = new BattleLibrary(l, std::make_unique<BattleStatCalculator>(),
std::make_unique<DamageLibrary>(), std::make_unique<ExperienceLibrary>(),
std::make_unique<ScriptResolver>(), std::make_unique<MiscLibrary>());
auto l = new DataLibrary(new LibrarySettings(100, 4), BuildSpeciesLibrary(), BuildAttackLibrary(),
BuildItemLibrary(), BuildGrowthRateLibrary(), BuildTypeLibrary());
auto statCalc = new BattleStatCalculator();
auto battleLib = new BattleLibrary(l, statCalc, new DamageLibrary(), new ExperienceLibrary(),
new ScriptResolver(), new MiscLibrary());
TestLibrary::_library = battleLib;
}
return TestLibrary::_library;