Buzzer related events
This commit is contained in:
parent
793d155c78
commit
6fde22965c
@ -36,8 +36,10 @@ def on_join_contestant(data):
|
|||||||
@socketio.on('buzz')
|
@socketio.on('buzz')
|
||||||
def on_buzz():
|
def on_buzz():
|
||||||
contestant = session.game.contestants[request.sid]
|
contestant = session.game.contestants[request.sid]
|
||||||
if contestant.locked:
|
if contestant.locked or not session.game.buzzers_armed:
|
||||||
return
|
return
|
||||||
|
session.game.buzzing_contestant = contestant
|
||||||
|
session.game.buzzers_armed = False
|
||||||
emit('contestant-buzzed', {'sid': request.sid}, to=session.room)
|
emit('contestant-buzzed', {'sid': request.sid}, to=session.room)
|
||||||
|
|
||||||
|
|
||||||
@ -63,6 +65,8 @@ def on_activate_clue(data):
|
|||||||
name = data['name']
|
name = data['name']
|
||||||
value = data['value']
|
value = data['value']
|
||||||
clues = session.game.categories.get(name)
|
clues = session.game.categories.get(name)
|
||||||
|
for contestant in session.game.contestants.values():
|
||||||
|
contestant.locked = False
|
||||||
if clues:
|
if clues:
|
||||||
match = None
|
match = None
|
||||||
for clue in clues:
|
for clue in clues:
|
||||||
@ -75,9 +79,28 @@ def on_activate_clue(data):
|
|||||||
|
|
||||||
@socketio.on('start-clue-clock')
|
@socketio.on('start-clue-clock')
|
||||||
def on_start_clue_clock():
|
def on_start_clue_clock():
|
||||||
|
session.game.buzzers_armed = True
|
||||||
emit('clue-clock-on', to=session.room)
|
emit('clue-clock-on', to=session.room)
|
||||||
|
|
||||||
|
|
||||||
|
@socketio.on('clue-clock-timeout')
|
||||||
|
def on_clue_clock_timeout():
|
||||||
|
if session.game.buzzers_armed:
|
||||||
|
session.game.buzzers_armed = False
|
||||||
|
emit('clue-clock-off', to=session.room)
|
||||||
|
|
||||||
|
|
||||||
|
@socketio.on('contestant-correct')
|
||||||
|
def on_contestant_correct():
|
||||||
|
emit('contestant-scores', to=session.room)
|
||||||
|
|
||||||
|
|
||||||
|
@socketio.on('contestant-incorrect')
|
||||||
|
def on_contestant_incorrect():
|
||||||
|
session.game.buzzing_contestant.locked = True
|
||||||
|
emit('contestant-penalized', to=session.room)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
socketio.run(app, host='0.0.0.0', debug=True)
|
socketio.run(app, host='0.0.0.0', debug=True)
|
||||||
|
|
||||||
|
@ -9,11 +9,12 @@ class Game:
|
|||||||
def __init__(self, code):
|
def __init__(self, code):
|
||||||
self.code = code
|
self.code = code
|
||||||
self.locked = False
|
self.locked = False
|
||||||
self.players = {}
|
self.contestants = {}
|
||||||
self.categories = {}
|
self.categories = {}
|
||||||
|
self.buzzers_armed = False
|
||||||
|
|
||||||
def add_contestant(self, sid, signature):
|
def add_contestant(self, sid, signature):
|
||||||
self.players[sid] = Contestant(signature)
|
self.contestants[sid] = Contestant(signature)
|
||||||
|
|
||||||
def load_clues(self):
|
def load_clues(self):
|
||||||
while len(self.categories) < 6:
|
while len(self.categories) < 6:
|
||||||
@ -30,7 +31,7 @@ class Game:
|
|||||||
class Contestant:
|
class Contestant:
|
||||||
def __init__(self, signature):
|
def __init__(self, signature):
|
||||||
self.signature = signature
|
self.signature = signature
|
||||||
self.points = 0
|
self.locked = False
|
||||||
|
|
||||||
|
|
||||||
class Category:
|
class Category:
|
||||||
|
Loading…
Reference in New Issue
Block a user