1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-05 00:49:09 +02:00

proper logging of drained life and resurrected count

new struct for keeping track of healed HP (also drained life) and resurrected count
This commit is contained in:
MichalZr6
2024-06-09 23:54:20 +02:00
parent 2288acef69
commit 65d22f17ae
6 changed files with 94 additions and 37 deletions

View File

@ -228,7 +228,7 @@ void CHealth::damage(int64_t & amount)
addResurrected(getCount() - oldCount);
}
void CHealth::heal(int64_t & amount, EHealLevel level, EHealPower power)
HealInfo CHealth::heal(int64_t & amount, EHealLevel level, EHealPower power)
{
const int32_t unitHealth = owner->getMaxHealth();
const int32_t oldCount = getCount();
@ -252,7 +252,7 @@ void CHealth::heal(int64_t & amount, EHealLevel level, EHealPower power)
vstd::abetween(amount, int64_t(0), maxHeal);
if(amount == 0)
return;
return {};
int64_t availableHealth = available();
@ -263,6 +263,8 @@ void CHealth::heal(int64_t & amount, EHealLevel level, EHealPower power)
addResurrected(getCount() - oldCount);
else
assert(power == EHealPower::PERMANENT);
return HealInfo(amount, getCount() - oldCount);
}
void CHealth::setFromTotal(const int64_t totalHealth)
@ -834,14 +836,16 @@ void CUnitState::damage(int64_t & amount)
ghostPending = true;
}
void CUnitState::heal(int64_t & amount, EHealLevel level, EHealPower power)
HealInfo CUnitState::heal(int64_t & amount, EHealLevel level, EHealPower power)
{
if(level == EHealLevel::HEAL && power == EHealPower::ONE_BATTLE)
logGlobal->error("Heal for one battle does not make sense");
else if(cloned)
logGlobal->error("Attempt to heal clone");
else
health.heal(amount, level, power);
return health.heal(amount, level, power);
return {};
}
void CUnitState::afterAttack(bool ranged, bool counter)