Active clues
This commit is contained in:
parent
0a96d571bd
commit
a310b74e9f
@ -50,6 +50,21 @@ def on_host_start():
|
|||||||
emit('categories', session.game.categories, to=session.game.display)
|
emit('categories', session.game.categories, to=session.game.display)
|
||||||
|
|
||||||
|
|
||||||
|
@socketio.on('activate-clue')
|
||||||
|
def on_activate_clue(data):
|
||||||
|
name = data['name']
|
||||||
|
value = data['value']
|
||||||
|
clues = session.game.categories.get(name)
|
||||||
|
if clues:
|
||||||
|
match = None
|
||||||
|
for clue in clues:
|
||||||
|
if clue['value'] == value:
|
||||||
|
match = clue
|
||||||
|
break
|
||||||
|
if match:
|
||||||
|
emit('active-clue', match, 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)
|
||||||
|
|
||||||
|
@ -40,19 +40,16 @@ class Category:
|
|||||||
self.questions = []
|
self.questions = []
|
||||||
|
|
||||||
|
|
||||||
Clue = namedtuple('Class', ['value', 'question', 'answer'])
|
|
||||||
|
|
||||||
|
|
||||||
def check_and_build_category(j):
|
def check_and_build_category(j):
|
||||||
if not j or not j['title'] or not j['clues_count'] or j['clues_count'] < 5:
|
if not j or not j['title'] or not j['clues_count'] or j['clues_count'] < 5:
|
||||||
return None
|
return None
|
||||||
name = j['title']
|
name = j['title']
|
||||||
all_clues = [Clue(c['value'], c['question'], c['answer'])
|
all_clues = [{key: c[key] for key in ['value', 'question', 'answer']}
|
||||||
for c in j['clues']]
|
for c in j['clues']]
|
||||||
clues = []
|
clues = []
|
||||||
for value in [200, 400, 600, 800, 1000]:
|
for value in [200, 400, 600, 800, 1000]:
|
||||||
for clue in all_clues:
|
for clue in all_clues:
|
||||||
if clue.value == value:
|
if clue['value'] == value:
|
||||||
clues.append(clue)
|
clues.append(clue)
|
||||||
break
|
break
|
||||||
if len(clues) == 5:
|
if len(clues) == 5:
|
||||||
|
Loading…
Reference in New Issue
Block a user