Skip to content

Commit

Permalink
Check for single player before uneven teams (#994)
Browse files Browse the repository at this point in the history
  • Loading branch information
Askaholic authored Jan 1, 2024
1 parent 6d9ffe8 commit cbf1ce1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 4 additions & 6 deletions server/games/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -675,16 +675,14 @@ async def validate_game_mode_settings(self):
"""
A subset of checks that need to be overridden in coop games.
"""
if None in self.teams or not self.is_even:
await self.mark_invalid(ValidityState.UNEVEN_TEAMS_NOT_RANKED)
return

# TODO: This validity state seems to be impossible to get because it is
# already covered by UNEVEN_TEAMS_NOT_RANKED above.
if len(self.players) < 2:
await self.mark_invalid(ValidityState.SINGLE_PLAYER)
return

if None in self.teams or not self.is_even:
await self.mark_invalid(ValidityState.UNEVEN_TEAMS_NOT_RANKED)
return

valid_options = {
"Victory": (Victory.DEMORALIZATION, ValidityState.WRONG_VICTORY_CONDITION)
}
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/test_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ async def test_single_player_not_rated(game, game_add_players):
game.launched_at = time.time() - 60 * 20
await game.add_result(0, 0, "victory", 5)
await game.on_game_finish()
assert game.validity is ValidityState.UNEVEN_TEAMS_NOT_RANKED
assert game.validity is ValidityState.SINGLE_PLAYER


async def test_game_visible_to_host(game: Game, players):
Expand Down

0 comments on commit cbf1ce1

Please sign in to comment.