#ifdef TESTS_BUILD
#include "../../extern/doctest.hpp"
#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();
    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();
    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)
                    .WithNature("neutralNature"_cnc)
                    .WithIndividualValues(31, 31, 31, 31, 31, 31)
                    .Build();
    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)
                    .WithNature("neutralNature"_cnc)
                    .WithIndividualValues(31, 31, 31, 31, 31, 31)
                    .Build();
    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)
                    .WithNature("neutralNature"_cnc)
                    .WithIndividualValues(31, 31, 31, 31, 31, 31)
                    .WithEffortValues(255, 255, 255, 255, 255, 255)
                    .Build();
    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)
                    .WithNature("buffsAttackNerfsSpeed"_cnc)
                    .WithIndividualValues(31, 31, 31, 31, 31, 31)
                    .WithEffortValues(255, 255, 255, 255, 255, 255)
                    .Build();
    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)
                    .WithNature("buffsAttackNerfsSpeed"_cnc)
                    .WithIndividualValues(31, 31, 31, 31, 31, 31)
                    .WithEffortValues(255, 255, 255, 255, 255, 255)
                    .Build();

    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)
                    .WithNature("buffsAttackNerfsSpeed"_cnc)
                    .WithIndividualValues(31, 31, 31, 31, 31, 31)
                    .WithEffortValues(255, 255, 255, 255, 255, 255)
                    .Build();

    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