|
@@ -49,10 +49,13 @@ void Heal::apply(ServerCallback * server, const Mechanics * m, const EffectTarge
|
|
|
|
|
|
void Heal::apply(int64_t value, ServerCallback * server, const Mechanics * m, const EffectTarget & target) const
|
|
|
{
|
|
|
+ BattleLogMessage logMessage;
|
|
|
BattleUnitsChanged pack;
|
|
|
- prepareHealEffect(value, pack, *server->getRNG(), m, target);
|
|
|
+ prepareHealEffect(value, pack, logMessage, *server->getRNG(), m, target);
|
|
|
if(!pack.changedStacks.empty())
|
|
|
server->apply(&pack);
|
|
|
+ if(!logMessage.lines.empty())
|
|
|
+ server->apply(&logMessage);
|
|
|
}
|
|
|
|
|
|
bool Heal::isValidTarget(const Mechanics * m, const battle::Unit * unit) const
|
|
@@ -112,7 +115,7 @@ void Heal::serializeJsonUnitEffect(JsonSerializeFormat & handler)
|
|
|
handler.serializeInt("minFullUnits", minFullUnits);
|
|
|
}
|
|
|
|
|
|
-void Heal::prepareHealEffect(int64_t value, BattleUnitsChanged & pack, RNG & rng, const Mechanics * m, const EffectTarget & target) const
|
|
|
+void Heal::prepareHealEffect(int64_t value, BattleUnitsChanged & pack, BattleLogMessage & logMessage, RNG & rng, const Mechanics * m, const EffectTarget & target) const
|
|
|
{
|
|
|
for(auto & oneTarget : target)
|
|
|
{
|
|
@@ -123,8 +126,20 @@ void Heal::prepareHealEffect(int64_t value, BattleUnitsChanged & pack, RNG & rng
|
|
|
auto unitHPgained = m->applySpellBonus(value, unit);
|
|
|
|
|
|
auto state = unit->acquire();
|
|
|
+ const auto countBeforeHeal = state->getCount();
|
|
|
state->heal(unitHPgained, healLevel, healPower);
|
|
|
|
|
|
+ if(const auto resurrectedCount = std::max(0, state->getCount() - countBeforeHeal))
|
|
|
+ {
|
|
|
+ // %d %s rise from the dead!
|
|
|
+ // in the table first comes plural string, then the singular one
|
|
|
+ MetaString resurrectText;
|
|
|
+ state->addText(resurrectText, MetaString::GENERAL_TXT, 116, resurrectedCount == 1);
|
|
|
+ state->addNameReplacement(resurrectText);
|
|
|
+ resurrectText.addReplacement(resurrectedCount);
|
|
|
+ logMessage.lines.push_back(std::move(resurrectText));
|
|
|
+ }
|
|
|
+
|
|
|
if(unitHPgained > 0)
|
|
|
{
|
|
|
UnitChanges info(state->unitId(), UnitChanges::EOperation::RESET_STATE);
|