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

MultiServer: add all worlds goal completion message #2956

Merged
merged 5 commits into from
Apr 14, 2024
Merged
Changes from 2 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
9 changes: 9 additions & 0 deletions MultiServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1839,6 +1839,15 @@ def update_client_status(ctx: Context, client: Client, new_status: ClientStatus)
if current != ClientStatus.CLIENT_GOAL: # can't undo goal completion
if new_status == ClientStatus.CLIENT_GOAL:
ctx.on_goal_achieved(client)
relevant_players = [player for player in ctx.player_names
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe rest_of_team or other_players_in_team would be even clearer?

if player[0] == client.team and player[1] != client.slot]
for player in relevant_players:
if player not in ctx.client_game_state:
break # player has yet to ever connect to the server
if ctx.client_game_state[player] != ClientStatus.CLIENT_GOAL:
break
else:
ctx.broadcast_text_all(f"Team #{client.team + 1} has completed all of their games! Congratulations!")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
relevant_players = [player for player in ctx.player_names
if player[0] == client.team and player[1] != client.slot]
for player in relevant_players:
if player not in ctx.client_game_state:
break # player has yet to ever connect to the server
if ctx.client_game_state[player] != ClientStatus.CLIENT_GOAL:
break
else:
ctx.broadcast_text_all(f"Team #{client.team + 1} has completed all of their games! Congratulations!")
if all(player in ctx.client_game_state and ctx.client_game_state[player] == ClientStatus.CLIENT_GOAL for player in ctx.player_names if player[0] in client.team):
ctx.broadcast_text_all(f"Team #{client.team + 1} has completed all of their games! Congratulations!")

didn't test, just wrote it up in github.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'd need to ignore the current player (since ctx.client_game_state is not changed yet), but this probably works. I'll test it soon.


ctx.client_game_state[client.team, client.slot] = new_status
ctx.on_client_status_change(client.team, client.slot)
Expand Down
Loading