1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-06 09:09:40 +02:00

add val; stat at end turn; events

This commit is contained in:
Laserlicht
2024-08-14 19:24:40 +02:00
parent e83a30ea11
commit ec2163b974
9 changed files with 62 additions and 6 deletions

View File

@@ -487,6 +487,16 @@ void BattleResultProcessor::endBattleConfirm(const CBattleInfoCallback & battle)
// Remove beaten hero
if(finishingBattle->loserHero)
{
if(!finishingBattle->isDraw())
{
ConstTransitivePtr<CGHeroInstance> strongestHero = nullptr;
for(auto & hero : gameHandler->gameState()->getPlayerState(finishingBattle->loser)->heroes)
if(!strongestHero || hero->exp > strongestHero->exp)
strongestHero = hero;
if(strongestHero->id == finishingBattle->loserHero->id)
gameHandler->gameState()->statistic.accumulatedValues[finishingBattle->victor].lastDefeatedStrongestHeroDay = gameHandler->gameState()->getDate(Date::DAY);
}
RemoveObject ro(finishingBattle->loserHero->id, finishingBattle->victor);
gameHandler->sendAndApply(&ro);
}