1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-29 23:07:48 +02:00

add BattleEnded pack which happens after BattleResultsApplied and losing heroes are removed

This commit is contained in:
Andrej Dudenhefner
2025-11-14 12:48:10 +01:00
parent 81db5c7cf4
commit 497995c11f
15 changed files with 65 additions and 0 deletions

View File

@@ -558,6 +558,7 @@ void BattleResultProcessor::battleFinalize(const BattleID & battleID, const Batt
resultsApplied.battleID = battleID;
resultsApplied.victor = finishingBattle->victor;
resultsApplied.loser = finishingBattle->loser;
//BattleResultsApplied does not end the battle, it only applies most of its consequences
gameHandler->sendAndApply(resultsApplied);
// Remove beaten hero
@@ -612,6 +613,13 @@ void BattleResultProcessor::battleFinalize(const BattleID & battleID, const Batt
gameHandler->heroPool->onHeroEscaped(finishingBattle->loser, loserHero);
}
//notify all players that battle has ended after all consequences are applied
BattleEnded ended;
ended.battleID = battleID;
ended.victor = finishingBattle->victor;
ended.loser = finishingBattle->loser;
gameHandler->sendAndApply(ended);
//handle victory/loss of engaged players
gameHandler->checkVictoryLossConditions({finishingBattle->loser, finishingBattle->victor});