mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
fixed wrong battle result
This commit is contained in:
parent
2fb531b6d0
commit
df13851176
@ -264,12 +264,15 @@ void CHealth::toInfo(CHealthInfo & info) const
|
||||
|
||||
void CHealth::takeResurrected()
|
||||
{
|
||||
int64_t totalHealth = total();
|
||||
if(resurrected != 0)
|
||||
{
|
||||
int64_t totalHealth = available();
|
||||
|
||||
totalHealth -= resurrected * owner->unitMaxHealth();
|
||||
vstd::amax(totalHealth, 0);
|
||||
setFromTotal(totalHealth);
|
||||
resurrected = 0;
|
||||
totalHealth -= resurrected * owner->unitMaxHealth();
|
||||
vstd::amax(totalHealth, 0);
|
||||
setFromTotal(totalHealth);
|
||||
resurrected = 0;
|
||||
}
|
||||
}
|
||||
|
||||
///CStack
|
||||
|
@ -6429,6 +6429,7 @@ CasualtiesAfterBattle::CasualtiesAfterBattle(const CArmedInstance * _army, Battl
|
||||
}
|
||||
else if(st->base && !army->slotEmpty(st->slot))
|
||||
{
|
||||
logGlobal->debug("Count: %d; base count: %d", st->getCount(), army->getStackCount(st->slot));
|
||||
if(st->getCount() == 0 || !st->alive())
|
||||
{
|
||||
logGlobal->debug("Stack has been destroyed.");
|
||||
|
@ -166,6 +166,18 @@ BOOST_FIXTURE_TEST_CASE(resurrectOneBattle, CUnitHealthInfoMock)
|
||||
|
||||
health.init();
|
||||
|
||||
checkNormalDamage(health, UNIT_HEALTH);
|
||||
BOOST_CHECK_EQUAL(health.getCount(), UNIT_AMOUNT - 1);
|
||||
BOOST_CHECK_EQUAL(health.getFirstHPleft(), UNIT_HEALTH);
|
||||
BOOST_CHECK_EQUAL(health.getResurrected(), 0);
|
||||
|
||||
health.takeResurrected();
|
||||
BOOST_CHECK_EQUAL(health.getCount(), UNIT_AMOUNT - 1);
|
||||
BOOST_CHECK_EQUAL(health.getFirstHPleft(), UNIT_HEALTH);
|
||||
BOOST_CHECK_EQUAL(health.getResurrected(), 0);
|
||||
|
||||
health.init();
|
||||
|
||||
checkNormalDamage(health, UNIT_HEALTH * UNIT_AMOUNT);
|
||||
checkEmptyHealth(health, *this);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user