PkmnLib/tests/BattleTests/DamageTests.cpp

46 lines
1.9 KiB
C++

#ifdef TESTS_BUILD
#include "../../extern/doctest.hpp"
#include "../../src/Battling/Library/DamageLibrary.hpp"
#include "../../src/Battling/Pokemon/CreatePokemon.hpp"
#include "../TestLibrary/TestLibrary.hpp"
using namespace PkmnLib::Battling;
TEST_CASE("Correct rounding for damage.") {
auto lib = TestLibrary::GetLibrary();
auto mon1 = CreatePokemon(lib, "testCharizard"_cnc, 100)
.WithIndividualValues(31, 31, 31, 31, 31, 31)
.WithEffortValues(0, 0, 0, 0, 0, 0)
.WithNature("neutralNature"_cnc)
.WithGender(CreatureLib::Library::Gender::Male)
.IsAllowedExperienceGain(false)
.Build();
auto mon2 = CreatePokemon(lib, "testVenusaur"_cnc, 100)
.WithIndividualValues(31, 31, 31, 31, 31, 31)
.WithEffortValues(0, 0, 0, 0, 0, 0)
.WithNature("neutralNature"_cnc)
.WithGender(CreatureLib::Library::Gender::Male)
.IsAllowedExperienceGain(false)
.Build();
auto move = PkmnLib::Library::MoveData("test", 0, PkmnLib::Library::MoveCategory::Physical, 55, 100, 10,
CreatureLib::Library::AttackTarget::All, 0, nullptr, {});
auto attack = PkmnLib::Battling::LearnedMove(&move, CreatureLib::Battling::AttackLearnMethod::Unknown);
auto executingAttack = CreatureLib::Battling::ExecutingAttack({mon2}, 1, mon1, &attack, &move, nullptr);
auto hit = executingAttack.GetHitData(mon2, 0);
hit.SetBasePower(55);
hit.SetEffectiveness(2.0f);
hit.SetCritical(0);
auto damage = lib->GetDamageLibrary()->GetDamage(&executingAttack, mon2, 0, hit);
REQUIRE_EQ(144, damage);
hit.SetBasePower(110);
damage = lib->GetDamageLibrary()->GetDamage(&executingAttack, mon2, 0, hit);
REQUIRE_EQ(284, damage);
}
#endif