diff --git a/MultiClient.py b/MultiClient.py index 2768ed7e..96d0f3af 100644 --- a/MultiClient.py +++ b/MultiClient.py @@ -618,13 +618,13 @@ async def process_server_cmd(ctx : Context, cmd, args): if len(args['players']) < 1: print('No player connected') else: - args['players'].sort(key=lambda _, t, s: (t, s)) + args['players'].sort() current_team = 0 print('Connected players:') print(' Team #1') - for name, team, slot in args['players']: + for team, slot, name in args['players']: if team != current_team: - print(' Team #d' % team + 1) + print(f' Team #{team + 1}') current_team = team print(' %s (Player %d)' % (name, slot)) await server_auth(ctx, args['password']) diff --git a/MultiServer.py b/MultiServer.py index 5f8483d1..78e2fa79 100644 --- a/MultiServer.py +++ b/MultiServer.py @@ -39,12 +39,6 @@ class Context: self.clients = [] self.received_items = {} -def get_room_info(ctx : Context): - return { - 'password': ctx.password is not None, - 'players': [(client.name, client.team, client.slot) for client in ctx.clients if client.auth] - } - async def send_msgs(websocket, msgs): if not websocket or not websocket.open or websocket.closed: return @@ -100,7 +94,10 @@ async def server(websocket, path, ctx : Context): ctx.clients.remove(client) async def on_client_connected(ctx : Context, client : Client): - await send_msgs(client.socket, [['RoomInfo', get_room_info(ctx)]]) + await send_msgs(client.socket, [['RoomInfo', { + 'password': ctx.password is not None, + 'players': [(client.team, client.slot, client.name) for client in ctx.clients if client.auth] + }]]) async def on_client_disconnected(ctx : Context, client : Client): if client.auth: