diff frontends/src/quick_frontend/quick_app.py @ 362:208107419b17

Quiz game: buzzer, timer, answer management
author Goffi <goffi@goffi.org>
date Sun, 12 Jun 2011 22:34:15 +0200
parents 141eeb7cd9e6
children 0806a65a5fa9
line wrap: on
line diff
--- a/frontends/src/quick_frontend/quick_app.py	Sun Jun 12 16:28:33 2011 +0200
+++ b/frontends/src/quick_frontend/quick_app.py	Sun Jun 12 22:34:15 2011 +0200
@@ -66,6 +66,11 @@
         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 @@
   
     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 @@
         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: