Set winner when player leaves elimination mid-game

Some players immediately leave the game mid-way in elimination maps
when they have the final turn in the team and they are about to
die/fall off a cliff, which causes the game to draw when the opponent
team should have been declared the winner.

The game will now check if the player to leave the elimination game was
the last player in the team and in case they were so, mark their team
score so the opponent team is declared as the winner.
This commit is contained in:
Ritiek Malhotra 2021-05-10 03:00:40 +05:30
parent f5fe5ba95f
commit 47584e2941
2 changed files with 9 additions and 0 deletions

View File

@ -1,3 +1,5 @@
- Declare opponent team as the winner if a player with their final turn leaves an elimination game.
### 1.6.0 (20357)
- Revamped netcode significantly. We still don't have client-prediction, but things should (hopefully) feel much lower latency now.
- Added network debug graphs accessible by hitting F8.

View File

@ -483,6 +483,13 @@ class EliminationGame(ba.TeamGameActivity[Player, Team]):
# list then.
ba.timer(0, self._update_icons)
# If the player to leave was the last in spawn order and had
# their final turn currently in-progress, mark the survival time
# for their team.
if self._get_total_team_lives(player.team) == 0:
assert self._start_time is not None
player.team.survival_seconds = int(ba.time() - self._start_time)
def _get_total_team_lives(self, team: Team) -> int:
return sum(player.lives for player in team.players)