Reworks nature library to be simpler.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-04-17 18:20:48 +02:00
parent 94980ef7ab
commit 086438f547
9 changed files with 41 additions and 116 deletions

View File

@@ -12,15 +12,15 @@ TEST_CASE("Able to create and delete nature library", "library") {
TEST_CASE("Able to insert into nature library", "library") {
auto lib = new NatureLibrary();
lib->LoadNature("testNature", Nature(Statistic::PhysicalAttack, Statistic::Speed));
lib->LoadNature("testNature"_cnc, Nature(Statistic::PhysicalAttack, Statistic::Speed));
delete lib;
}
TEST_CASE("Able to retrieve nature by name", "library") {
auto lib = new NatureLibrary();
lib->LoadNature("testNature", Nature(Statistic::PhysicalAttack, Statistic::Speed));
lib->LoadNature("testNature"_cnc, Nature(Statistic::PhysicalAttack, Statistic::Speed));
auto nature = lib->GetNatureByName("testNature");
auto nature = lib->GetNatureByName("testNature"_cnc);
REQUIRE(nature.GetIncreasedStat() == Statistic::PhysicalAttack);
REQUIRE(nature.GetDecreasedStat() == Statistic::Speed);
REQUIRE(nature.GetIncreaseModifier() == 1.1f);
@@ -29,54 +29,4 @@ TEST_CASE("Able to retrieve nature by name", "library") {
delete lib;
}
TEST_CASE("Able to retrieve nature by id", "library") {
auto lib = new NatureLibrary();
auto id = lib->LoadNature("testNature", Nature(Statistic::PhysicalAttack, Statistic::Speed));
auto nature = lib->GetNature(id);
REQUIRE(nature.GetIncreasedStat() == Statistic::PhysicalAttack);
REQUIRE(nature.GetDecreasedStat() == Statistic::Speed);
REQUIRE(nature.GetIncreaseModifier() == 1.1f);
REQUIRE(nature.GetDecreaseModifier() == 0.9f);
delete lib;
}
TEST_CASE("Able to retrieve nature id by name", "library") {
auto lib = new NatureLibrary();
lib->LoadNature("testNature", Nature(Statistic::PhysicalAttack, Statistic::Speed));
auto id = lib->GetNatureIdByName("testNature");
REQUIRE(id == 0);
auto nature = lib->GetNature(id);
REQUIRE(nature.GetIncreasedStat() == Statistic::PhysicalAttack);
REQUIRE(nature.GetDecreasedStat() == Statistic::Speed);
REQUIRE(nature.GetIncreaseModifier() == 1.1f);
REQUIRE(nature.GetDecreaseModifier() == 0.9f);
delete lib;
}
TEST_CASE("Able to insert and retrieve multiple natures", "library") {
auto lib = new NatureLibrary();
auto id = lib->LoadNature("testNature", Nature(Statistic::PhysicalAttack, Statistic::Speed));
REQUIRE(id == 0);
auto id2 = lib->LoadNature("testNature2", Nature(Statistic::Speed, Statistic::PhysicalAttack));
REQUIRE(id2 == 1);
auto nature = lib->GetNature(id);
REQUIRE(nature.GetIncreasedStat() == Statistic::PhysicalAttack);
REQUIRE(nature.GetDecreasedStat() == Statistic::Speed);
REQUIRE(nature.GetIncreaseModifier() == 1.1f);
REQUIRE(nature.GetDecreaseModifier() == 0.9f);
nature = lib->GetNature(id2);
REQUIRE(nature.GetIncreasedStat() == Statistic::Speed);
REQUIRE(nature.GetDecreasedStat() == Statistic::PhysicalAttack);
REQUIRE(nature.GetIncreaseModifier() == 1.1f);
REQUIRE(nature.GetDecreaseModifier() == 0.9f);
delete lib;
}
#endif

View File

@@ -7,7 +7,7 @@ using namespace PkmnLib::Battling;
TEST_CASE("Low level, no IVs, no EVs, neutral nature, no stat boosts stat test") {
auto pkmn =
CreatePokemon(TestLibrary::GetLibrary(), "statTestSpecies1"_cnc, 10).WithNature("neutralNature")->Build();
CreatePokemon(TestLibrary::GetLibrary(), "statTestSpecies1"_cnc, 10).WithNature("neutralNature"_cnc)->Build();
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::HealthPoints) == 40);
CHECK(pkmn->GetCurrentHealth() == 40);
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::PhysicalAttack) == 25);
@@ -20,7 +20,7 @@ TEST_CASE("Low level, no IVs, no EVs, neutral nature, no stat boosts stat test")
TEST_CASE("High level, no IVs, no EVs, neutral nature, no stat boosts stat test") {
auto pkmn =
CreatePokemon(TestLibrary::GetLibrary(), "statTestSpecies1"_cnc, 100).WithNature("neutralNature")->Build();
CreatePokemon(TestLibrary::GetLibrary(), "statTestSpecies1"_cnc, 100).WithNature("neutralNature"_cnc)->Build();
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::HealthPoints) == 310);
CHECK(pkmn->GetCurrentHealth() == 310);
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::PhysicalAttack) == 205);
@@ -33,7 +33,7 @@ TEST_CASE("High level, no IVs, no EVs, neutral nature, no stat boosts stat test"
TEST_CASE("Low level, max IVs, no EVs, neutral nature, no stat boosts stat test") {
auto pkmn = CreatePokemon(TestLibrary::GetLibrary(), "statTestSpecies1"_cnc, 10)
.WithNature("neutralNature")
.WithNature("neutralNature"_cnc)
->WithIndividualValues(31, 31, 31, 31, 31, 31)
->Build();
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::HealthPoints) == 43);
@@ -48,7 +48,7 @@ TEST_CASE("Low level, max IVs, no EVs, neutral nature, no stat boosts stat test"
TEST_CASE("High level, max IVs, no EVs, neutral nature, no stat boosts stat test") {
auto pkmn = CreatePokemon(TestLibrary::GetLibrary(), "statTestSpecies1"_cnc, 100)
.WithNature("neutralNature")
.WithNature("neutralNature"_cnc)
->WithIndividualValues(31, 31, 31, 31, 31, 31)
->Build();
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::HealthPoints) == 341);
@@ -63,7 +63,7 @@ TEST_CASE("High level, max IVs, no EVs, neutral nature, no stat boosts stat test
TEST_CASE("High level, max IVs, max EVs, neutral nature, no stat boosts stat test") {
auto pkmn = CreatePokemon(TestLibrary::GetLibrary(), "statTestSpecies1"_cnc, 100)
.WithNature("neutralNature")
.WithNature("neutralNature"_cnc)
->WithIndividualValues(31, 31, 31, 31, 31, 31)
->WithEffortValues(255, 255, 255, 255, 255, 255)
->Build();
@@ -79,7 +79,7 @@ TEST_CASE("High level, max IVs, max EVs, neutral nature, no stat boosts stat tes
TEST_CASE("High level, max IVs, max EVs, nature buffs attack, nerfs speed, no stat boosts stat test") {
auto pkmn = CreatePokemon(TestLibrary::GetLibrary(), "statTestSpecies1"_cnc, 100)
.WithNature("buffsAttackNerfsSpeed")
.WithNature("buffsAttackNerfsSpeed"_cnc)
->WithIndividualValues(31, 31, 31, 31, 31, 31)
->WithEffortValues(255, 255, 255, 255, 255, 255)
->Build();
@@ -95,7 +95,7 @@ TEST_CASE("High level, max IVs, max EVs, nature buffs attack, nerfs speed, no st
TEST_CASE("High level, max IVs, max EVs, nature buffs attack, nerfs speed, Attack boosted +6 stat test") {
auto pkmn = CreatePokemon(TestLibrary::GetLibrary(), "statTestSpecies1"_cnc, 100)
.WithNature("buffsAttackNerfsSpeed")
.WithNature("buffsAttackNerfsSpeed"_cnc)
->WithIndividualValues(31, 31, 31, 31, 31, 31)
->WithEffortValues(255, 255, 255, 255, 255, 255)
->Build();
@@ -114,7 +114,7 @@ TEST_CASE("High level, max IVs, max EVs, nature buffs attack, nerfs speed, Attac
TEST_CASE("High level, max IVs, max EVs, nature buffs attack, nerfs speed, Attack boosted -6 stat test") {
auto pkmn = CreatePokemon(TestLibrary::GetLibrary(), "statTestSpecies1"_cnc, 100)
.WithNature("buffsAttackNerfsSpeed")
.WithNature("buffsAttackNerfsSpeed"_cnc)
->WithIndividualValues(31, 31, 31, 31, 31, 31)
->WithEffortValues(255, 255, 255, 255, 255, 255)
->Build();

View File

@@ -12,7 +12,7 @@ TEST_CASE("Create and delete Pokemon"){
TEST_CASE("Get Nature from Pokemon"){
auto lib = TestLibrary::GetLibrary();
auto mon = PkmnLib::Battling::CreatePokemon(lib, "testSpecies"_cnc, 1)
.WithNature("neutralNature")
.WithNature("neutralNature"_cnc)
->Build();
auto nature = mon->GetNature();
REQUIRE(nature.GetDecreaseModifier() == 1);

View File

@@ -64,9 +64,10 @@ public:
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",
lib->LoadNature("neutralNature"_cnc,
PkmnLib::Library::Nature(PkmnLib::Library::Statistic::PhysicalAttack,
PkmnLib::Library::Statistic::PhysicalDefense, 1, 1));
lib->LoadNature("buffsAttackNerfsSpeed"_cnc,
PkmnLib::Library::Nature(PkmnLib::Library::Statistic::PhysicalAttack,
PkmnLib::Library::Statistic::Speed, 1.1, 0.9));
return lib;