PkmnLib/tests/LibraryTests/StatCalculationTests.cpp

134 lines
7.3 KiB
C++
Raw Normal View History

2020-01-05 14:18:30 +00:00
#ifdef TESTS_BUILD
2022-02-11 11:17:27 +00:00
#include <doctest.h>
2020-01-05 14:18:30 +00:00
#include "../../src/Battling/Pokemon/CreatePokemon.hpp"
#include "../TestLibrary/TestLibrary.hpp"
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"_cnc).Build();
2020-01-05 14:18:30 +00:00
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::HealthPoints) == 40);
CHECK(pkmn->GetCurrentHealth() == 40);
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::PhysicalAttack) == 25);
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::PhysicalDefense) == 25);
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::SpecialAttack) == 25);
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::SpecialDefense) == 25);
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::Speed) == 25);
delete pkmn;
}
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"_cnc).Build();
2020-01-05 14:18:30 +00:00
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::HealthPoints) == 310);
CHECK(pkmn->GetCurrentHealth() == 310);
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::PhysicalAttack) == 205);
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::PhysicalDefense) == 205);
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::SpecialAttack) == 205);
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::SpecialDefense) == 205);
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::Speed) == 205);
delete pkmn;
}
TEST_CASE("Low level, max IVs, no EVs, neutral nature, no stat boosts stat test") {
auto pkmn = CreatePokemon(TestLibrary::GetLibrary(), "statTestSpecies1"_cnc, 10)
2020-04-17 16:20:48 +00:00
.WithNature("neutralNature"_cnc)
.WithIndividualValues(31, 31, 31, 31, 31, 31)
.Build();
2020-01-05 14:18:30 +00:00
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::HealthPoints) == 43);
CHECK(pkmn->GetCurrentHealth() == 43);
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::PhysicalAttack) == 28);
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::PhysicalDefense) == 28);
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::SpecialAttack) == 28);
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::SpecialDefense) == 28);
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::Speed) == 28);
delete pkmn;
}
TEST_CASE("High level, max IVs, no EVs, neutral nature, no stat boosts stat test") {
auto pkmn = CreatePokemon(TestLibrary::GetLibrary(), "statTestSpecies1"_cnc, 100)
2020-04-17 16:20:48 +00:00
.WithNature("neutralNature"_cnc)
.WithIndividualValues(31, 31, 31, 31, 31, 31)
.Build();
2020-01-05 14:18:30 +00:00
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::HealthPoints) == 341);
CHECK(pkmn->GetCurrentHealth() == 341);
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::PhysicalAttack) == 236);
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::PhysicalDefense) == 236);
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::SpecialAttack) == 236);
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::SpecialDefense) == 236);
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::Speed) == 236);
delete pkmn;
}
TEST_CASE("High level, max IVs, max EVs, neutral nature, no stat boosts stat test") {
auto pkmn = CreatePokemon(TestLibrary::GetLibrary(), "statTestSpecies1"_cnc, 100)
2020-04-17 16:20:48 +00:00
.WithNature("neutralNature"_cnc)
.WithIndividualValues(31, 31, 31, 31, 31, 31)
.WithEffortValues(255, 255, 255, 255, 255, 255)
.Build();
2020-01-05 14:18:30 +00:00
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::HealthPoints) == 404);
CHECK(pkmn->GetCurrentHealth() == 404);
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::PhysicalAttack) == 299);
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::PhysicalDefense) == 299);
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::SpecialAttack) == 299);
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::SpecialDefense) == 299);
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::Speed) == 299);
delete pkmn;
}
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)
2020-04-17 16:20:48 +00:00
.WithNature("buffsAttackNerfsSpeed"_cnc)
.WithIndividualValues(31, 31, 31, 31, 31, 31)
.WithEffortValues(255, 255, 255, 255, 255, 255)
.Build();
2020-01-05 14:18:30 +00:00
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::HealthPoints) == 404);
CHECK(pkmn->GetCurrentHealth() == 404);
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::PhysicalAttack) == 328);
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::PhysicalDefense) == 299);
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::SpecialAttack) == 299);
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::SpecialDefense) == 299);
CHECK(pkmn->GetFlatStat(PkmnLib::Library::Statistic::Speed) == 269);
delete pkmn;
}
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)
2020-04-17 16:20:48 +00:00
.WithNature("buffsAttackNerfsSpeed"_cnc)
.WithIndividualValues(31, 31, 31, 31, 31, 31)
.WithEffortValues(255, 255, 255, 255, 255, 255)
.Build();
2020-01-05 14:18:30 +00:00
pkmn->ChangeStatBoost(PkmnLib::Library::Statistic::PhysicalAttack, 6);
CHECK(pkmn->GetBoostedStat(PkmnLib::Library::Statistic::HealthPoints) == 404);
CHECK(pkmn->GetCurrentHealth() == 404);
CHECK(pkmn->GetBoostedStat(PkmnLib::Library::Statistic::PhysicalAttack) == 1312);
CHECK(pkmn->GetBoostedStat(PkmnLib::Library::Statistic::PhysicalDefense) == 299);
CHECK(pkmn->GetBoostedStat(PkmnLib::Library::Statistic::SpecialAttack) == 299);
CHECK(pkmn->GetBoostedStat(PkmnLib::Library::Statistic::SpecialDefense) == 299);
CHECK(pkmn->GetBoostedStat(PkmnLib::Library::Statistic::Speed) == 269);
delete pkmn;
}
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)
2020-04-17 16:20:48 +00:00
.WithNature("buffsAttackNerfsSpeed"_cnc)
.WithIndividualValues(31, 31, 31, 31, 31, 31)
.WithEffortValues(255, 255, 255, 255, 255, 255)
.Build();
2020-01-05 14:18:30 +00:00
pkmn->ChangeStatBoost(PkmnLib::Library::Statistic::PhysicalAttack, -6);
CHECK(pkmn->GetBoostedStat(PkmnLib::Library::Statistic::HealthPoints) == 404);
CHECK(pkmn->GetCurrentHealth() == 404);
CHECK(pkmn->GetBoostedStat(PkmnLib::Library::Statistic::PhysicalAttack) == 82);
CHECK(pkmn->GetBoostedStat(PkmnLib::Library::Statistic::PhysicalDefense) == 299);
CHECK(pkmn->GetBoostedStat(PkmnLib::Library::Statistic::SpecialAttack) == 299);
CHECK(pkmn->GetBoostedStat(PkmnLib::Library::Statistic::SpecialDefense) == 299);
CHECK(pkmn->GetBoostedStat(PkmnLib::Library::Statistic::Speed) == 269);
delete pkmn;
}
#endif