Support Pokemon style experience gain.
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@@ -17,7 +17,7 @@ TEST_CASE("Able to build, destroy and insert library", "library") {
|
||||
"default"_cnc, 1.0f, 1.0f, 100, {0},
|
||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
|
||||
{"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100));
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100, 100));
|
||||
delete lib;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ TEST_CASE("Able to insert and retrieve from library", "library") {
|
||||
"default"_cnc, 1.0f, 1.0f, 100, {0},
|
||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
|
||||
{"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100));
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100, 100));
|
||||
auto val = lib->Get("foo"_cnc);
|
||||
REQUIRE(val->GetName() == "foo");
|
||||
delete lib;
|
||||
|
||||
@@ -9,7 +9,7 @@ TEST_CASE("Able to create and destroy species", "library") {
|
||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||
new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100, 100);
|
||||
delete species;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ TEST_CASE("Able to get default forme", "library") {
|
||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||
new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100, 100);
|
||||
|
||||
auto forme = species->GetDefaultForme();
|
||||
REQUIRE(forme != nullptr);
|
||||
@@ -35,7 +35,7 @@ TEST_CASE("Able to get default forme name", "library") {
|
||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||
new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100, 100);
|
||||
|
||||
auto forme = species->GetDefaultForme();
|
||||
REQUIRE(forme != nullptr);
|
||||
@@ -51,7 +51,7 @@ TEST_CASE("Able to get species name", "library") {
|
||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||
new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100, 100);
|
||||
|
||||
REQUIRE(species->GetName() == "foo");
|
||||
|
||||
@@ -65,7 +65,7 @@ TEST_CASE("Able to get species id", "library") {
|
||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||
new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100, 100);
|
||||
|
||||
REQUIRE(species->GetId() == 1);
|
||||
|
||||
@@ -79,7 +79,7 @@ TEST_CASE("Able to get species gender ratio", "library") {
|
||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||
new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100, 100);
|
||||
|
||||
REQUIRE(species->GetGenderRate() == 0.5f);
|
||||
|
||||
@@ -93,7 +93,7 @@ TEST_CASE("Able to get species growth rate", "library") {
|
||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||
new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100, 100);
|
||||
|
||||
REQUIRE(species->GetGrowthRate() == "testGrowthRate");
|
||||
|
||||
@@ -107,7 +107,7 @@ TEST_CASE("Able to get species capture rate", "library") {
|
||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||
new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100, 100);
|
||||
|
||||
REQUIRE(species->GetCaptureRate() == 100);
|
||||
|
||||
@@ -121,7 +121,7 @@ TEST_CASE("Able to get species base happiness", "library") {
|
||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||
new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100, 100);
|
||||
|
||||
REQUIRE(species->GetBaseHappiness() == 100);
|
||||
|
||||
@@ -135,14 +135,14 @@ TEST_CASE("Able to set and get evolution", "library") {
|
||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||
new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100, 100);
|
||||
auto species2 = new PkmnLib::Library::PokemonSpecies(
|
||||
2, "bar"_cnc,
|
||||
new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0},
|
||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
||||
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
|
||||
new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100);
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100, 100);
|
||||
|
||||
species->AddEvolution(PkmnLib::Library::EvolutionData::CreateLevelEvolution(16, species2));
|
||||
auto evolutions = species->GetEvolutions();
|
||||
|
||||
17
tests/PokemonTests/ExperienceGainTests.cpp
Normal file
17
tests/PokemonTests/ExperienceGainTests.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifdef TESTS_BUILD
|
||||
#include "../../extern/catch.hpp"
|
||||
#include "../../src/Battling/Library/ExperienceLibrary.hpp"
|
||||
#include "../../src/Battling/Pokemon/CreatePokemon.hpp"
|
||||
#include "../TestLibrary/TestLibrary.hpp"
|
||||
using namespace PkmnLib::Battling;
|
||||
|
||||
TEST_CASE("Basic Experience gain test", "battling") {
|
||||
auto lib = TestLibrary::GetLibrary();
|
||||
auto mon1 = CreatePokemon(lib, "testSpecies"_cnc, 55).Build();
|
||||
auto initialExp = mon1->GetExperience();
|
||||
auto mon2 = CreatePokemon(lib, "testSpecies2"_cnc, 62).Build();
|
||||
auto expLib = lib->GetExperienceLibrary();
|
||||
expLib->HandleExperienceGain(mon2, {mon1});
|
||||
REQUIRE(mon1->GetExperience() - initialExp == 4339);
|
||||
}
|
||||
#endif
|
||||
@@ -11,7 +11,7 @@ PkmnLib::Library::SpeciesLibrary* TestLibrary::BuildSpeciesLibrary() {
|
||||
"default"_cnc, 1.0f, 1.0f, 100, {0},
|
||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
|
||||
{"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100));
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100, 236));
|
||||
lib->Insert("testSpecies2"_cnc,
|
||||
new PkmnLib::Library::PokemonSpecies(
|
||||
2, "testSpecies2"_cnc,
|
||||
@@ -19,7 +19,7 @@ PkmnLib::Library::SpeciesLibrary* TestLibrary::BuildSpeciesLibrary() {
|
||||
"default"_cnc, 1.0f, 1.0f, 100, {0},
|
||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
|
||||
{"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100));
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100, 306));
|
||||
lib->Insert("statTestSpecies1"_cnc,
|
||||
new PkmnLib::Library::PokemonSpecies(
|
||||
3, "statTestSpecies1"_cnc,
|
||||
@@ -27,7 +27,7 @@ PkmnLib::Library::SpeciesLibrary* TestLibrary::BuildSpeciesLibrary() {
|
||||
"default"_cnc, 1.0f, 1.0f, 100, {0},
|
||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
|
||||
{"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100));
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100, 236));
|
||||
lib->Insert("testSpecies3"_cnc,
|
||||
new PkmnLib::Library::PokemonSpecies(
|
||||
2, "testSpecies3"_cnc,
|
||||
@@ -35,7 +35,7 @@ PkmnLib::Library::SpeciesLibrary* TestLibrary::BuildSpeciesLibrary() {
|
||||
"default"_cnc, 1.0f, 1.0f, 100, {0, 4},
|
||||
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
|
||||
{"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)),
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100));
|
||||
0.5f, "testGrowthRate"_cnc, 100, 100, 236));
|
||||
|
||||
return lib;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
auto scriptResolver = PkmnLib::Battling::BattleLibrary::CreateScriptResolver();
|
||||
auto lib = new PkmnLib::Battling::BattleLibrary(
|
||||
BuildStaticLibrary(), statCalc, new PkmnLib::Battling::DamageLibrary(),
|
||||
new CreatureLib::Battling::ExperienceLibrary(), scriptResolver, new PkmnLib::Battling::MiscLibrary());
|
||||
new PkmnLib::Battling::ExperienceLibrary(), scriptResolver, new PkmnLib::Battling::MiscLibrary());
|
||||
scriptResolver->Initialize(lib);
|
||||
return lib;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user