Damage calculation can only return 0 if effectiveness is 0.
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Deukhoofd 2021-08-28 12:20:22 +02:00
parent aee0f04d9c
commit e323b62250
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
1 changed files with 7 additions and 3 deletions

View File

@ -34,7 +34,7 @@ uint32_t PkmnLib::Battling::DamageLibrary::GetDamage(CreatureLib::Battling::Exec
if (_hasRandomness) {
Ensure(attack->GetUser()->GetBattle().GetValue());
float randPercentage = 85 + attack->GetUser()->GetBattle().GetValue()->GetRandom()->Get(0, 16);
floatDamage = fl(floatDamage * (randPercentage / 100.0));
floatDamage = fl(floatDamage * (randPercentage / 100.0f));
}
if (attack->GetUser()->HasType(hitData.GetType())) {
@ -46,8 +46,12 @@ uint32_t PkmnLib::Battling::DamageLibrary::GetDamage(CreatureLib::Battling::Exec
floatDamage = fl(floatDamage * hitData.GetEffectiveness());
uint32_t damage = 0;
if (floatDamage < 0) {
damage = 0;
if (floatDamage <= 0) {
if (hitData.GetEffectiveness() == 0) {
damage = 0;
} else {
damage = 1;
}
} else if (floatDamage >= (float)UINT32_MAX) {
damage = UINT32_MAX;
} else {