2021-08-28 10:04:18 +00:00
|
|
|
#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();
|
2021-08-29 14:28:21 +00:00
|
|
|
auto mon1 = ArbUt::ScopedPtr(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 = ArbUt::ScopedPtr(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());
|
2021-08-28 10:04:18 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2021-08-29 14:28:21 +00:00
|
|
|
auto executingAttack =
|
|
|
|
CreatureLib::Battling::ExecutingAttack({mon2.GetValue()}, 1, mon1.GetValue(), &attack, &move, nullptr);
|
2021-08-28 10:04:18 +00:00
|
|
|
|
2021-08-29 14:28:21 +00:00
|
|
|
auto hit = executingAttack.GetHitData(mon2.GetValue(), 0);
|
2021-08-28 10:04:18 +00:00
|
|
|
hit.SetBasePower(55);
|
|
|
|
hit.SetEffectiveness(2.0f);
|
|
|
|
hit.SetCritical(0);
|
|
|
|
|
|
|
|
auto damage = lib->GetDamageLibrary()->GetDamage(&executingAttack, mon2, 0, hit);
|
|
|
|
REQUIRE_EQ(144, damage);
|
2021-08-28 10:16:01 +00:00
|
|
|
|
|
|
|
hit.SetBasePower(110);
|
|
|
|
damage = lib->GetDamageLibrary()->GetDamage(&executingAttack, mon2, 0, hit);
|
|
|
|
REQUIRE_EQ(284, damage);
|
2021-08-28 10:04:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|