diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 793f83142..7bd9dff9f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,19 +1,19 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.0.1 + rev: v4.6.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer - id: check-docstring-first - repo: https://github.com/PyCQA/flake8 - rev: 3.9.2 + rev: 7.1.1 hooks: - id: flake8 - repo: https://github.com/pre-commit/mirrors-autopep8 - rev: v1.5.7 + rev: v2.0.4 hooks: - id: autopep8 - repo: https://github.com/PyCQA/isort - rev: 5.9.3 + rev: 5.13.2 hooks: - id: isort diff --git a/server/lobbyconnection.py b/server/lobbyconnection.py index c50c10964..bf85eff14 100644 --- a/server/lobbyconnection.py +++ b/server/lobbyconnection.py @@ -336,6 +336,31 @@ async def command_social_remove(self, message): with contextlib.suppress(KeyError): player_attr.remove(subject_id) + if self.player.game is None: + return + + subject_player = self.player_service.get_player(int(subject_id)) + game_info = self.player.game.to_dict() + + if "foe" in message: + with contextlib.suppress(DisconnectedError): + await subject_player.send_message({ + "command": "game_info", + "games": [ + game_info + ] + }) + + if "friend" in message and self.player.game.visibility == VisibilityState.FRIENDS: + with contextlib.suppress(DisconnectedError): + game_info["state"] = "closed" + await subject_player.send_message({ + "command": "game_info", + "games": [ + game_info + ] + }) + async def command_social_add(self, message): if "friend" in message: status = "FRIEND" @@ -358,7 +383,31 @@ async def command_social_add(self, message): subject_id=subject_id, )) + if self.player.game is None: + return + player_attr.add(subject_id) + subject_player = self.player_service.get_player(int(subject_id)) + + game_info = self.player.game.to_dict() + if "foe" in message: + game_info['state'] = 'closed' + with contextlib.suppress(DisconnectedError): + await subject_player.send_message({ + "command": "game_info", + "games": [ + game_info + ] + }) + + if "friend" in message and self.player.game.visibility == VisibilityState.FRIENDS: + with contextlib.suppress(DisconnectedError): + await subject_player.send_message({ + "command": "game_info", + "games": [ + game_info + ] + }) async def kick(self): await self.send({