CreatureLib/tests/TestLibrary/TestLibrary.cpp

66 lines
2.6 KiB
C++
Raw Normal View History

2019-10-06 11:50:52 +00:00
#ifdef TESTS_BUILD
#include "../../extern/catch.hpp"
#include "../../src/Battling/Library/BattleLibrary.hpp"
2019-10-06 11:50:52 +00:00
using namespace CreatureLib::Core;
using namespace CreatureLib::Library;
using namespace CreatureLib::Battling;
static BattleLibrary* __library = nullptr;
2019-10-06 11:50:52 +00:00
static SpeciesLibrary* BuildSpeciesLibrary() {
2019-10-06 11:50:52 +00:00
auto l = new SpeciesLibrary();
l->LoadSpecies("testSpecies1",
new CreatureSpecies(
0, "testSpecies1",
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, 100));
2019-10-06 11:50:52 +00:00
return l;
}
static AttackLibrary* BuildAttackLibrary() {
2019-10-06 11:50:52 +00:00
auto l = new AttackLibrary();
l->LoadAttack("standard", new AttackData("standard", "normal", AttackCategory::Physical, 20, 100, 30,
AttackTarget::AdjacentOpponent, 0, {}));
l->LoadAttack("highPriority", new AttackData("highPriority", "normal", AttackCategory::Physical, 20, 100, 30,
AttackTarget::AdjacentOpponent, 1, {}));
l->LoadAttack("higherPriority", new AttackData("higherPriority", "normal", AttackCategory::Physical, 20, 100, 30,
AttackTarget::AdjacentOpponent, 2, {}));
l->LoadAttack("lowPriority", new AttackData("lowPriority", "normal", AttackCategory::Physical, 20, 100, 30,
AttackTarget::AdjacentOpponent, -1, {}));
2019-10-06 11:50:52 +00:00
return l;
}
static ItemLibrary* BuildItemLibrary() {
2019-10-06 11:50:52 +00:00
auto l = new ItemLibrary();
return l;
}
static GrowthRateLibrary* BuildGrowthRateLibrary() {
2019-10-06 11:50:52 +00:00
auto l = new GrowthRateLibrary();
return l;
}
static TypeLibrary* BuildTypeLibrary() {
2019-11-04 16:58:26 +00:00
auto l = new TypeLibrary();
l->RegisterType("testType1");
l->RegisterType("testType2");
l->RegisterType("testType3");
return l;
}
2019-10-06 11:50:52 +00:00
static BattleLibrary* BuildLibrary() {
auto l = new DataLibrary(LibrarySettings(100, 4), BuildSpeciesLibrary(), BuildAttackLibrary(), BuildItemLibrary(),
BuildGrowthRateLibrary(), BuildTypeLibrary());
auto statCalc = new BattleStatCalculator();
auto battleLib = new BattleLibrary(l, statCalc, new DamageLibrary(), new CriticalLibrary(), new ScriptResolver());
return battleLib;
2019-10-06 11:50:52 +00:00
}
[[maybe_unused]] static BattleLibrary* GetLibrary() {
if (__library == nullptr) {
2019-10-06 11:50:52 +00:00
__library = BuildLibrary();
}
return __library;
}
#endif