PkmnLib/tests/TestLibrary/TestLibrary.hpp

67 lines
2.8 KiB
C++

#ifndef PKMNLIB_TESTLIBRARY_HPP
#define PKMNLIB_TESTLIBRARY_HPP
#include <Library/GrowthRates/LookupGrowthRate.hpp>
#include "../../src/Battling/Library/BattleLibrary.hpp"
#include "../../src/Library/Moves/MoveLibrary.hpp"
#include "../../src/Library/PokemonLibrary.hpp"
#include "../../src/Library/Statistic.hpp"
class TestLibrary {
private:
static PkmnLib::Battling::BattleLibrary* _library;
public:
static PkmnLib::Battling::BattleLibrary* GetLibrary() {
if (_library == nullptr) {
_library = BuildLibrary();
}
return _library;
}
static PkmnLib::Battling::BattleLibrary* BuildLibrary() {
auto statCalc = new PkmnLib::Battling::StatCalculator();
auto scriptResolver = PkmnLib::Battling::BattleLibrary::CreateScriptResolver();
auto lib = new PkmnLib::Battling::BattleLibrary(
BuildStaticLibrary(), statCalc, new CreatureLib::Battling::DamageLibrary(),
new CreatureLib::Battling::ExperienceLibrary(), scriptResolver,
new CreatureLib::Battling::MiscLibrary());
scriptResolver->Initialize(lib);
return lib;
}
static PkmnLib::Library::PokemonLibrary* BuildStaticLibrary() {
return new PkmnLib::Library::PokemonLibrary(CreatureLib::Library::LibrarySettings(100, 4),
BuildSpeciesLibrary(), BuildMoveLibrary(), BuildItemLibrary(),
BuildGrowthRateLibrary(), BuildTypeLibrary(), BuildNatureLibrary());
}
static PkmnLib::Library::SpeciesLibrary* BuildSpeciesLibrary();
static PkmnLib::Library::MoveLibrary* BuildMoveLibrary();
static PkmnLib::Library::ItemLibrary* BuildItemLibrary();
static CreatureLib::Library::GrowthRateLibrary* BuildGrowthRateLibrary() {
auto lib = new CreatureLib::Library::GrowthRateLibrary();
lib->AddGrowthRate("testGrowthRate", new CreatureLib::Library::LookupGrowthRate());
return lib;
}
static CreatureLib::Library::TypeLibrary* BuildTypeLibrary() {
auto lib = new CreatureLib::Library::TypeLibrary();
return lib;
}
static PkmnLib::Library::NatureLibrary* BuildNatureLibrary() {
auto lib = new PkmnLib::Library::NatureLibrary();
lib->LoadNature("neutralNature", PkmnLib::Library::Nature(PkmnLib::Library::Statistic::PhysicalAttack,
PkmnLib::Library::Statistic::PhysicalDefense, 1, 1));
lib->LoadNature("buffsAttackNerfsSpeed", PkmnLib::Library::Nature(PkmnLib::Library::Statistic::PhysicalAttack,
PkmnLib::Library::Statistic::Speed, 1.1, 0.9));
return lib;
}
};
#endif // PKMNLIB_TESTLIBRARY_HPP