MultiServer: add /status and allow status command to dynamically filter for Tags
This commit is contained in:
parent
76f6eb1434
commit
aa954b776d
|
@ -720,16 +720,16 @@ def get_players_string(ctx: Context):
|
||||||
return f'{len(auth_clients)} players of {total} connected ' + text[:-1]
|
return f'{len(auth_clients)} players of {total} connected ' + text[:-1]
|
||||||
|
|
||||||
|
|
||||||
def get_status_string(ctx: Context, team: int):
|
def get_status_string(ctx: Context, team: int, tag: str):
|
||||||
text = "Player Status on your team:"
|
text = f"Player Status on team {team}:"
|
||||||
for slot in ctx.locations:
|
for slot in ctx.locations:
|
||||||
connected = len(ctx.clients[team][slot])
|
connected = len(ctx.clients[team][slot])
|
||||||
death_link = len([client for client in ctx.clients[team][slot] if "DeathLink" in client.tags])
|
tagged = len([client for client in ctx.clients[team][slot] if tag in client.tags])
|
||||||
completion_text = f"({len(ctx.location_checks[team, slot])}/{len(ctx.locations[slot])})"
|
completion_text = f"({len(ctx.location_checks[team, slot])}/{len(ctx.locations[slot])})"
|
||||||
death_text = f" {death_link} of which are death link" if connected else ""
|
tag_text = f" {tagged} of which are tagged {tag}" if connected and tag else ""
|
||||||
goal_text = " and has finished." if ctx.client_game_state[team, slot] == ClientStatus.CLIENT_GOAL else "."
|
goal_text = " and has finished." if ctx.client_game_state[team, slot] == ClientStatus.CLIENT_GOAL else "."
|
||||||
text += f"\n{ctx.get_aliased_name(team, slot)} has {connected} connection{'' if connected == 1 else 's'}" \
|
text += f"\n{ctx.get_aliased_name(team, slot)} has {connected} connection{'' if connected == 1 else 's'}" \
|
||||||
f"{death_text}{goal_text} {completion_text}"
|
f"{tag_text}{goal_text} {completion_text}"
|
||||||
return text
|
return text
|
||||||
|
|
||||||
|
|
||||||
|
@ -1113,9 +1113,11 @@ class ClientMessageProcessor(CommonCommandProcessor):
|
||||||
self.output(get_players_string(self.ctx))
|
self.output(get_players_string(self.ctx))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _cmd_status(self) -> bool:
|
def _cmd_status(self, tag:str="") -> bool:
|
||||||
"""Get status information about your team."""
|
"""Get status information about your team.
|
||||||
self.output(get_status_string(self.ctx, self.client.team))
|
Optionally mention a Tag name and get information on who has that Tag.
|
||||||
|
For example: DeathLink or EnergyLink."""
|
||||||
|
self.output(get_status_string(self.ctx, self.client.team, tag))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _cmd_release(self) -> bool:
|
def _cmd_release(self) -> bool:
|
||||||
|
@ -1657,6 +1659,14 @@ class ServerCommandProcessor(CommonCommandProcessor):
|
||||||
self.output(get_players_string(self.ctx))
|
self.output(get_players_string(self.ctx))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def _cmd_status(self, tag: str = "") -> bool:
|
||||||
|
"""Get status information about teams.
|
||||||
|
Optionally mention a Tag name and get information on who has that Tag.
|
||||||
|
For example: DeathLink or EnergyLink."""
|
||||||
|
for team in self.ctx.clients:
|
||||||
|
self.output(get_status_string(self.ctx, team, tag))
|
||||||
|
return True
|
||||||
|
|
||||||
def _cmd_exit(self) -> bool:
|
def _cmd_exit(self) -> bool:
|
||||||
"""Shutdown the server"""
|
"""Shutdown the server"""
|
||||||
asyncio.create_task(self.ctx.server.ws_server._close())
|
asyncio.create_task(self.ctx.server.ws_server._close())
|
||||||
|
|
Loading…
Reference in New Issue