1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

Merge pull request #1011 from kambala-decapitator/fix-multiple-heals

allow healing ability only before first turn of each round
This commit is contained in:
Andrii Danylchenko 2022-10-03 21:43:08 +03:00 committed by GitHub
commit 5c44c8f4da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5200,19 +5200,6 @@ void CGameHandler::stackTurnTrigger(const CStack *st)
sendAndApply(&ssp); sendAndApply(&ssp);
} }
} }
//regeneration
if (st->hasBonusOfType(Bonus::HP_REGENERATION))
{
bte.effect = Bonus::HP_REGENERATION;
bte.val = std::min((int)(st->MaxHealth() - st->getFirstHPleft()), st->valOfBonuses(Bonus::HP_REGENERATION));
}
if (st->hasBonusOfType(Bonus::FULL_HP_REGENERATION))
{
bte.effect = Bonus::HP_REGENERATION;
bte.val = st->MaxHealth() - st->getFirstHPleft();
}
if (bte.val) //anything to heal
sendAndApply(&bte);
if (st->hasBonusOfType(Bonus::POISON)) if (st->hasBonusOfType(Bonus::POISON))
{ {
@ -6549,8 +6536,28 @@ void CGameHandler::runBattle()
if(!q.front().empty()) if(!q.front().empty())
{ {
auto next = q.front().front(); auto next = q.front().front();
const auto stack = dynamic_cast<const CStack *>(next);
// regeneration takes place before everything else but only during first turn attempt in each round
// also works under blind and similar effects
if(stack && stack->alive() && !stack->waiting)
{
BattleTriggerEffect bte;
bte.stackID = stack->ID;
bte.effect = Bonus::HP_REGENERATION;
const int32_t lostHealth = stack->MaxHealth() - stack->getFirstHPleft();
if(stack->hasBonusOfType(Bonus::FULL_HP_REGENERATION))
bte.val = lostHealth;
else if(stack->hasBonusOfType(Bonus::HP_REGENERATION))
bte.val = std::min(lostHealth, stack->valOfBonuses(Bonus::HP_REGENERATION));
if(bte.val) // anything to heal
sendAndApply(&bte);
}
if(next->willMove()) if(next->willMove())
return dynamic_cast<const CStack *>(next); return stack;
} }
} }