Quiz game: buzzer, timer, answer management
This commit is contained in:
parent
fb41ecbbf5
commit
bb255b7a3d
1 changed files with 322 additions and 37 deletions
|
|
@ -66,6 +66,11 @@ class QuickApp():
|
|||
self.bridge.register("quizGameStarted", self.quizGameStarted)
|
||||
self.bridge.register("quizGameNew", self.quizGameNew)
|
||||
self.bridge.register("quizGameQuestion", self.quizGameQuestion)
|
||||
self.bridge.register("quizGamePlayerBuzzed", self.quizGamePlayerBuzzed)
|
||||
self.bridge.register("quizGamePlayerSays", self.quizGamePlayerSays)
|
||||
self.bridge.register("quizGameAnswerResult", self.quizGameAnswerResult)
|
||||
self.bridge.register("quizGameTimerExpired", self.quizGameTimerExpired)
|
||||
self.bridge.register("quizGameTimerRestarted", self.quizGameTimerRestarted)
|
||||
self.bridge.register("subscribe", self.subscribe)
|
||||
self.bridge.register("paramUpdate", self.paramUpdate)
|
||||
self.bridge.register("contactDeleted", self.contactDeleted)
|
||||
|
|
@ -377,7 +382,6 @@ class QuickApp():
|
|||
|
||||
def quizGameStarted(self, room_jid, referee, players, profile):
|
||||
if not self.check_profile(profile):
|
||||
print "gof: NOT CHECK PROFILE", profile
|
||||
return
|
||||
debug (_("Quiz Game Started \o/"))
|
||||
if self.chat_wins.has_key(room_jid):
|
||||
|
|
@ -399,6 +403,41 @@ class QuickApp():
|
|||
if self.chat_wins.has_key(room_jid):
|
||||
self.chat_wins[room_jid].getGame("Quiz").quizGameQuestion(question_id, question, timer)
|
||||
|
||||
def quizGamePlayerBuzzed(self, room_jid, player, pause, profile):
|
||||
"""Called when a player pushed the buzzer"""
|
||||
if not self.check_profile(profile):
|
||||
return
|
||||
if self.chat_wins.has_key(room_jid):
|
||||
self.chat_wins[room_jid].getGame("Quiz").quizGamePlayerBuzzed(player, pause)
|
||||
|
||||
def quizGamePlayerSays(self, room_jid, player, text, delay, profile):
|
||||
"""Called when a player say something"""
|
||||
if not self.check_profile(profile):
|
||||
return
|
||||
if self.chat_wins.has_key(room_jid):
|
||||
self.chat_wins[room_jid].getGame("Quiz").quizGamePlayerSays(player, text, delay)
|
||||
|
||||
def quizGameAnswerResult(self, room_jid, player, good_answer, score, profile):
|
||||
"""Called when a player say something"""
|
||||
if not self.check_profile(profile):
|
||||
return
|
||||
if self.chat_wins.has_key(room_jid):
|
||||
self.chat_wins[room_jid].getGame("Quiz").quizGameAnswerResult(player, good_answer, score)
|
||||
|
||||
def quizGameTimerExpired(self, room_jid, profile):
|
||||
"""Called when nobody answered the question in time"""
|
||||
if not self.check_profile(profile):
|
||||
return
|
||||
if self.chat_wins.has_key(room_jid):
|
||||
self.chat_wins[room_jid].getGame("Quiz").quizGameTimerExpired()
|
||||
|
||||
def quizGameTimerRestarted(self, room_jid, time_left, profile):
|
||||
"""Called when the question is not answered, and we still have time"""
|
||||
if not self.check_profile(profile):
|
||||
return
|
||||
if self.chat_wins.has_key(room_jid):
|
||||
self.chat_wins[room_jid].getGame("Quiz").quizGameTimerRestarted(time_left)
|
||||
|
||||
def _subscribe_cb(self, answer, data):
|
||||
entity, profile = data
|
||||
if answer:
|
||||
|
|
|
|||
Loading…
Reference in a new issue