From e0e37877484dc297de21011fca796bae96a902b9 Mon Sep 17 00:00:00 2001 From: Andrii Danylchenko Date: Sat, 16 Apr 2022 13:18:41 +0300 Subject: [PATCH] When the battle is won with only summoned creatures - defeat --- client/battle/CBattleInterfaceClasses.cpp | 13 ++++++++++--- lib/battle/CBattleInfoCallback.cpp | 20 +++++++++++++------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/client/battle/CBattleInterfaceClasses.cpp b/client/battle/CBattleInterfaceClasses.cpp index fb32093fd..f9902989f 100644 --- a/client/battle/CBattleInterfaceClasses.cpp +++ b/client/battle/CBattleInterfaceClasses.cpp @@ -406,16 +406,23 @@ CBattleResultWindow::CBattleResultWindow(const BattleResult & br, CPlayerInterfa exit = std::make_shared(Point(384, 505), "iok6432.def", std::make_pair("", ""), [&](){ bExitf();}, SDLK_RETURN); exit->setBorderColor(Colors::METALLIC_GOLD); - if(br.winner==0) //attacker won + if(br.winner == 0) //attacker won { labels.push_back(std::make_shared(59, 124, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[410])); - labels.push_back(std::make_shared(408, 124, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[411])); } - else //if(br.winner==1) + else { labels.push_back(std::make_shared(59, 124, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[411])); + } + + if(br.winner == 1) + { labels.push_back(std::make_shared(412, 124, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[410])); } + else + { + labels.push_back(std::make_shared(408, 124, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[411])); + } labels.push_back(std::make_shared(232, 302, FONT_BIG, CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[407])); labels.push_back(std::make_shared(232, 332, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[408])); diff --git a/lib/battle/CBattleInfoCallback.cpp b/lib/battle/CBattleInfoCallback.cpp index 14789fbb1..4a283f3a0 100644 --- a/lib/battle/CBattleInfoCallback.cpp +++ b/lib/battle/CBattleInfoCallback.cpp @@ -1968,7 +1968,7 @@ boost::optional CBattleInfoCallback::battleIsFinished() const { auto units = battleGetUnitsIf([=](const battle::Unit * unit) { - return unit->alive() && !unit->isTurret() && unit->alive(); + return unit->alive() && !unit->isTurret() && !unit->hasBonusOfType(Bonus::SIEGE_WEAPON); }); std::array hasUnit = {false, false}; //index is BattleSide @@ -1976,20 +1976,26 @@ boost::optional CBattleInfoCallback::battleIsFinished() const for(auto & unit : units) { //todo: move SIEGE_WEAPON check to Unit state - if(!unit->hasBonusOfType(Bonus::SIEGE_WEAPON)) + hasUnit.at(unit->unitSide()) = true; + + if(hasUnit[0] && hasUnit[1]) + return boost::none; + } + + hasUnit = {false, false}; + + for(auto & unit : units) + { + if(!unit->isClone() && !unit->acquireState()->summoned && !dynamic_cast (unit)) { hasUnit.at(unit->unitSide()) = true; } - - if(hasUnit[0] && hasUnit[1]) - break; } if(!hasUnit[0] && !hasUnit[1]) return 2; if(!hasUnit[1]) return 0; - if(!hasUnit[0]) + else return 1; - return boost::none; }