1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

When the battle is won with only summoned creatures - defeat

This commit is contained in:
Andrii Danylchenko 2022-04-16 13:18:41 +03:00 committed by Andrii Danylchenko
parent 05b5ab62aa
commit e0e3787748
2 changed files with 23 additions and 10 deletions

View File

@ -409,13 +409,20 @@ CBattleResultWindow::CBattleResultWindow(const BattleResult & br, CPlayerInterfa
if(br.winner == 0) //attacker won
{
labels.push_back(std::make_shared<CLabel>(59, 124, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[410]));
labels.push_back(std::make_shared<CLabel>(408, 124, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[411]));
}
else //if(br.winner==1)
else
{
labels.push_back(std::make_shared<CLabel>(59, 124, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[411]));
}
if(br.winner == 1)
{
labels.push_back(std::make_shared<CLabel>(412, 124, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[410]));
}
else
{
labels.push_back(std::make_shared<CLabel>(408, 124, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[411]));
}
labels.push_back(std::make_shared<CLabel>(232, 302, FONT_BIG, CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[407]));
labels.push_back(std::make_shared<CLabel>(232, 332, FONT_SMALL, CENTER, Colors::WHITE, CGI->generaltexth->allTexts[408]));

View File

@ -1968,7 +1968,7 @@ boost::optional<int> 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<bool, 2> hasUnit = {false, false}; //index is BattleSide
@ -1976,20 +1976,26 @@ boost::optional<int> 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 <const CCommanderInstance *>(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;
}