Implements experience gain on opponent faint.
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2019-12-14 13:28:23 +01:00
parent 3baed93597
commit 649de39571
9 changed files with 119 additions and 21 deletions

View File

@@ -1,35 +1,37 @@
#ifdef TESTS_BUILD
#include "TestLibrary.hpp"
#include "../../src/Library/GrowthRates/LookupGrowthRate.hpp"
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(LibrarySettings(100, 4), BuildSpeciesLibrary(), BuildAttackLibrary(), BuildItemLibrary(),
BuildGrowthRateLibrary(), BuildTypeLibrary());
BattleLibrary* TestLibrary::Get() {
if (TestLibrary::_library == nullptr) {
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());
auto battleLib = new BattleLibrary(l, statCalc, new DamageLibrary(), new CriticalLibrary(),
new ExperienceLibrary(), new ScriptResolver());
TestLibrary::_library = battleLib;
}
return TestLibrary::_library;
}
SpeciesLibrary *TestLibrary::BuildSpeciesLibrary() {
SpeciesLibrary* TestLibrary::BuildSpeciesLibrary() {
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));
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));
return l;
}
AttackLibrary *TestLibrary::BuildAttackLibrary() {
AttackLibrary* TestLibrary::BuildAttackLibrary() {
auto l = new AttackLibrary();
l->LoadAttack("standard", new AttackData("standard", "normal", AttackCategory::Physical, 20, 100, 30,
AttackTarget::AdjacentOpponent, 0, {}));
@@ -42,17 +44,18 @@ AttackLibrary *TestLibrary::BuildAttackLibrary() {
return l;
}
ItemLibrary *TestLibrary::BuildItemLibrary() {
ItemLibrary* TestLibrary::BuildItemLibrary() {
auto l = new ItemLibrary();
return l;
}
GrowthRateLibrary *TestLibrary::BuildGrowthRateLibrary() {
GrowthRateLibrary* TestLibrary::BuildGrowthRateLibrary() {
auto l = new GrowthRateLibrary();
l->AddGrowthRate("testGrowthRate", new LookupGrowthRate());
return l;
}
TypeLibrary *TestLibrary::BuildTypeLibrary() {
TypeLibrary* TestLibrary::BuildTypeLibrary() {
auto l = new TypeLibrary();
l->RegisterType("testType1");
l->RegisterType("testType2");