From 32bc9e6d7eb52b844d2e4fcab9653eb5df1a9c5e Mon Sep 17 00:00:00 2001 From: Askaholic Date: Mon, 1 Jan 2024 16:56:02 -0500 Subject: [PATCH] Check for single player before uneven teams --- server/games/game.py | 10 ++++------ tests/unit_tests/test_game.py | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/server/games/game.py b/server/games/game.py index a16eece6c..c0b756ea0 100644 --- a/server/games/game.py +++ b/server/games/game.py @@ -645,16 +645,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) } diff --git a/tests/unit_tests/test_game.py b/tests/unit_tests/test_game.py index 7b3fb950d..d9f7ba661 100644 --- a/tests/unit_tests/test_game.py +++ b/tests/unit_tests/test_game.py @@ -274,7 +274,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):