CreatureLib/tests/TestLibrary/TestLibrary.cpp

66 lines
2.8 KiB
C++
Raw Normal View History

2019-10-06 11:50:52 +00:00
#ifdef TESTS_BUILD
#include "TestLibrary.hpp"
#include "../../src/Library/GrowthRates/LookupGrowthRate.hpp"
2019-10-06 11:50:52 +00:00
using namespace CreatureLib::Core;
using namespace CreatureLib::Library;
using namespace CreatureLib::Battling;
BattleLibrary* TestLibrary::_library = nullptr;
BattleLibrary* TestLibrary::Get() {
if (TestLibrary::_library == nullptr) {
auto l = new DataLibrary(new LibrarySettings(100, 4), BuildSpeciesLibrary(), BuildAttackLibrary(),
BuildItemLibrary(), BuildGrowthRateLibrary(), BuildTypeLibrary());
auto statCalc = new BattleStatCalculator();
2019-12-15 10:52:10 +00:00
auto battleLib = new BattleLibrary(l, statCalc, new DamageLibrary(), new ExperienceLibrary(),
new ScriptResolver(), new MiscLibrary());
TestLibrary::_library = battleLib;
}
return TestLibrary::_library;
}
2019-10-06 11:50:52 +00:00
SpeciesLibrary* TestLibrary::BuildSpeciesLibrary() {
2019-10-06 11:50:52 +00:00
auto l = new SpeciesLibrary();
l->Insert("testSpecies1"_cnc,
new CreatureSpecies(0, "testSpecies1"_cnc,
new SpeciesVariant("default"_cnc, 1, 1, 10, {0, 1},
StatisticSet<uint16_t>(10, 10, 10, 10, 10, 10), {"testTalent"_cnc},
{"testSecretTalent"_cnc}, new LearnableAttacks(100)),
0.5f, "testGrowthRate"_cnc, 5));
2019-10-06 11:50:52 +00:00
return l;
}
AttackLibrary* TestLibrary::BuildAttackLibrary() {
2019-10-06 11:50:52 +00:00
auto l = new AttackLibrary();
2020-03-02 14:29:42 +00:00
l->Insert("standard"_cnc, new AttackData("standard"_cnc, 0, AttackCategory::Physical, 20, 100, 30,
AttackTarget::AdjacentOpponent, 0, {}));
2020-03-02 14:29:42 +00:00
l->Insert("highPriority"_cnc, new AttackData("highPriority"_cnc, 0, AttackCategory::Physical, 20, 100, 30,
AttackTarget::AdjacentOpponent, 1, {}));
2020-03-02 14:29:42 +00:00
l->Insert("higherPriority"_cnc, new AttackData("higherPriority"_cnc, 0, AttackCategory::Physical, 20, 100, 30,
AttackTarget::AdjacentOpponent, 2, {}));
2020-03-02 14:29:42 +00:00
l->Insert("lowPriority"_cnc, new AttackData("lowPriority"_cnc, 0, AttackCategory::Physical, 20, 100, 30,
AttackTarget::AdjacentOpponent, -1, {}));
2019-10-06 11:50:52 +00:00
return l;
}
ItemLibrary* TestLibrary::BuildItemLibrary() {
2019-10-06 11:50:52 +00:00
auto l = new ItemLibrary();
return l;
}
GrowthRateLibrary* TestLibrary::BuildGrowthRateLibrary() {
2019-10-06 11:50:52 +00:00
auto l = new GrowthRateLibrary();
l->AddGrowthRate("testGrowthRate"_cnc, new LookupGrowthRate());
2019-10-06 11:50:52 +00:00
return l;
}
TypeLibrary* TestLibrary::BuildTypeLibrary() {
2019-11-04 16:58:26 +00:00
auto l = new TypeLibrary();
2020-02-29 14:41:43 +00:00
l->RegisterType("testType1"_cnc);
l->RegisterType("testType2"_cnc);
l->RegisterType("testType3"_cnc);
2019-11-04 16:58:26 +00:00
return l;
}
2019-10-06 11:50:52 +00:00
#endif