From 1ac37f90390fe12a2b2186b2ba1ce935fb21f07a Mon Sep 17 00:00:00 2001 From: Alberto Xamin Date: Sat, 19 Jun 2021 14:00:42 +0200 Subject: [PATCH] hide bad rooms --- backend/__init__.py | 7 ++++++- backend/bang/game.py | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/backend/__init__.py b/backend/__init__.py index 2472603..b23c725 100644 --- a/backend/__init__.py +++ b/backend/__init__.py @@ -31,7 +31,7 @@ games: List[Game] = [] online_players = 0 def advertise_lobbies(): - sio.emit('lobbies', room='lobby', data=[{'name': g.name, 'players': len(g.players), 'locked': g.password != ''} for g in games if not g.started and len(g.players) < 10]) + sio.emit('lobbies', room='lobby', data=[{'name': g.name, 'players': len(g.players), 'locked': g.password != ''} for g in games if not g.started and len(g.players) < 10 and not g.is_hidden]) sio.emit('spectate_lobbies', room='lobby', data=[{'name': g.name, 'players': len(g.players), 'locked': g.password != ''} for g in games if g.started]) @sio.event @@ -253,6 +253,11 @@ def chat_message(sid, msg): eventlet.sleep(0.3) else: sio.emit('chat_message', room=sid, data={'color': f'','text':f'{msg} bad format'}) + elif '/hide' in msg: + cmd = msg.split() + ses.game.is_hidden = not ses.game.is_hidden + advertise_lobbies() + sio.emit('chat_message', room=sid, data={'color': f'','text':f'{msg} room hidden: {ses.game.is_hidden}'}) elif '/ddc' in msg and ses.game.started: # debug destroy cards usage: [/ddc *] [/ddc username] cmd = msg.split() if len(cmd) == 2: diff --git a/backend/bang/game.py b/backend/bang/game.py index 1880893..d0138b0 100644 --- a/backend/bang/game.py +++ b/backend/bang/game.py @@ -44,6 +44,7 @@ class Game: self.characters_to_distribute = 2 # personaggi da dare a inizio partita self.debug = self.name == 'debug' self.is_changing_pwd = False + self.is_hidden = False def reset(self): print('resetting lobby')