If no side is still alive, mark battle as inconclusive ended.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-06-12 16:25:21 +02:00
parent 32bb641f75
commit fd1c6e9a0a
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
1 changed files with 6 additions and 1 deletions

View File

@ -102,7 +102,7 @@ bool Battle::CanSlotBeFilled(uint8_t side, uint8_t index) const {
void Battle::ValidateBattleState() {
bool survivingSideExists = false;
uint8_t winningSide = 0;
uint8_t winningSide = 255;
for (uint8_t i = 0; i < _sides.Count(); i++) {
auto side = _sides[i];
if (side->HasFled()) {
@ -118,6 +118,11 @@ void Battle::ValidateBattleState() {
winningSide = i;
}
}
if (!survivingSideExists) {
this->_battleResult = BattleResult::Inconclusive();
this->_hasEnded = true;
return;
}
this->_battleResult = BattleResult::Conclusive(winningSide);
this->_hasEnded = true;
}