Mercurial > libervia-backend
diff frontends/src/quick_frontend/quick_app.py @ 361:141eeb7cd9e6
Quizz game: first draft
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 12 Jun 2011 16:28:33 +0200 |
parents | ea3e1b82dd79 |
children | 208107419b17 |
line wrap: on
line diff
--- a/frontends/src/quick_frontend/quick_app.py Mon Jun 06 21:55:59 2011 +0200 +++ b/frontends/src/quick_frontend/quick_app.py Sun Jun 12 16:28:33 2011 +0200 @@ -63,6 +63,9 @@ self.bridge.register("tarotGameScore", self.tarotScore) self.bridge.register("tarotGameCardsPlayed", self.tarotCardsPlayed) self.bridge.register("tarotGameInvalidCards", self.tarotInvalidCards) + self.bridge.register("quizGameStarted", self.quizGameStarted) + self.bridge.register("quizGameNew", self.quizGameNew) + self.bridge.register("quizGameQuestion", self.quizGameQuestion) self.bridge.register("subscribe", self.subscribe) self.bridge.register("paramUpdate", self.paramUpdate) self.bridge.register("contactDeleted", self.contactDeleted) @@ -372,6 +375,30 @@ if self.chat_wins.has_key(room_jid): self.chat_wins[room_jid].getGame("Tarot").invalidCards(phase, played_cards, invalid_cards) + 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): + self.chat_wins[room_jid].startGame("Quiz", referee, players) + debug (_("new Quiz game started by [%(referee)s] in room [%(room_jid)s] with %(players)s") % {'referee':referee, 'room_jid':room_jid, 'players':[str(player) for player in players]}) + + def quizGameNew(self, room_jid, data, profile): + if not self.check_profile(profile): + return + debug (_("New Quiz Game")) + if self.chat_wins.has_key(room_jid): + self.chat_wins[room_jid].getGame("Quiz").quizGameNew(data) + + def quizGameQuestion(self, room_jid, question_id, question, timer, profile): + """Called when a new question is asked""" + if not self.check_profile(profile): + return + debug (_(u"Quiz: new question: %s") % question) + if self.chat_wins.has_key(room_jid): + self.chat_wins[room_jid].getGame("Quiz").quizGameQuestion(question_id, question, timer) + def _subscribe_cb(self, answer, data): entity, profile = data if answer: