Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue where players added or removed from friend or foe lists did not have games updated #1026

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
49 changes: 49 additions & 0 deletions server/lobbyconnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,31 @@
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"
Expand All @@ -358,7 +383,31 @@
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'

Check warning on line 394 in server/lobbyconnection.py

View workflow job for this annotation

GitHub Actions / flake8

Single quotes found but double quotes preferred

Check warning on line 394 in server/lobbyconnection.py

View workflow job for this annotation

GitHub Actions / flake8

Single quotes found but double quotes preferred
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({
Expand Down
Loading