Skip to content

Commit

Permalink
Fix issue where players added or removed from friend or foe lists did…
Browse files Browse the repository at this point in the history
… not have games updated
  • Loading branch information
benjamin-lawson committed Sep 6, 2024
1 parent 645d001 commit 6fa0ee7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions server/lobbyconnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,15 @@ async def send_game_list(self):
]
})

async def send_game_list_to_player(self, player: Player):
await player.send_message({
"command": "game_info",
"games": [
game.to_dict() for game in self.game_service.open_games
if game.is_visible_to_player(player)
]
})

async def command_social_remove(self, message):
if "friend" in message:
subject_id = message["friend"]
Expand All @@ -336,6 +345,10 @@ async def command_social_remove(self, message):
with contextlib.suppress(KeyError):
player_attr.remove(subject_id)

subject_player = self.player_service.get_player(int(subject_id))
with contextlib.suppress(DisconnectedError):
self.send_game_list_to_player(subject_player)

async def command_social_add(self, message):
if "friend" in message:
status = "FRIEND"
Expand All @@ -360,6 +373,10 @@ async def command_social_add(self, message):

player_attr.add(subject_id)

subject_player = self.player_service.get_player(int(subject_id))
with contextlib.suppress(DisconnectedError):
self.send_game_list_to_player(subject_player)

async def kick(self):
await self.send({
"command": "notice",
Expand Down

0 comments on commit 6fa0ee7

Please sign in to comment.