Skip to content

Commit

Permalink
Ignore result reports for coop games
Browse files Browse the repository at this point in the history
  • Loading branch information
Askaholic committed Feb 20, 2021
1 parent 215fd91 commit c7410a4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
6 changes: 6 additions & 0 deletions server/games/coop.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,9 @@ async def validate_game_mode_settings(self):
"Expansion": ("true", ValidityState.EXPANSION_DISABLED),
}
await self._validate_game_options(valid_options)

async def process_game_results(self):
"""
When a coop game ends, we don't expect there to be any game results.
"""
pass
19 changes: 11 additions & 8 deletions server/games/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,14 +418,7 @@ async def on_game_end(self):
await self.mark_invalid(ValidityState.MUTUAL_DRAW)
return

if not self._results:
await self.mark_invalid(ValidityState.UNKNOWN_RESULT)
return

await self.persist_results()

game_results = await self.resolve_game_results()
await self.game_service.publish_game_results(game_results)
await self.process_game_results()

self._process_pending_army_stats()
except Exception: # pragma: no cover
Expand All @@ -438,6 +431,16 @@ async def on_game_end(self):
async def _run_pre_rate_validity_checks(self):
pass

async def process_game_results(self):
if not self._results:
await self.mark_invalid(ValidityState.UNKNOWN_RESULT)
return

await self.persist_results()

game_results = await self.resolve_game_results()
await self.game_service.publish_game_results(game_results)

async def resolve_game_results(self) -> EndedGameInfo:
if self.state not in (GameState.LIVE, GameState.ENDED):
raise GameError("Cannot rate game that has not been launched.")
Expand Down

0 comments on commit c7410a4

Please sign in to comment.