comparison 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
comparison
equal deleted inserted replaced
360:6b5626c37909 361:141eeb7cd9e6
61 self.bridge.register("tarotGameShowCards", self.tarotShowCards) 61 self.bridge.register("tarotGameShowCards", self.tarotShowCards)
62 self.bridge.register("tarotGameYourTurn", self.tarotMyTurn) 62 self.bridge.register("tarotGameYourTurn", self.tarotMyTurn)
63 self.bridge.register("tarotGameScore", self.tarotScore) 63 self.bridge.register("tarotGameScore", self.tarotScore)
64 self.bridge.register("tarotGameCardsPlayed", self.tarotCardsPlayed) 64 self.bridge.register("tarotGameCardsPlayed", self.tarotCardsPlayed)
65 self.bridge.register("tarotGameInvalidCards", self.tarotInvalidCards) 65 self.bridge.register("tarotGameInvalidCards", self.tarotInvalidCards)
66 self.bridge.register("quizGameStarted", self.quizGameStarted)
67 self.bridge.register("quizGameNew", self.quizGameNew)
68 self.bridge.register("quizGameQuestion", self.quizGameQuestion)
66 self.bridge.register("subscribe", self.subscribe) 69 self.bridge.register("subscribe", self.subscribe)
67 self.bridge.register("paramUpdate", self.paramUpdate) 70 self.bridge.register("paramUpdate", self.paramUpdate)
68 self.bridge.register("contactDeleted", self.contactDeleted) 71 self.bridge.register("contactDeleted", self.contactDeleted)
69 self.bridge.register("updatedValue", self.updatedValue, "request") 72 self.bridge.register("updatedValue", self.updatedValue, "request")
70 self.bridge.register("askConfirmation", self.askConfirmation, "request") 73 self.bridge.register("askConfirmation", self.askConfirmation, "request")
370 return 373 return
371 debug (_("Cards played are not valid: %s") % invalid_cards) 374 debug (_("Cards played are not valid: %s") % invalid_cards)
372 if self.chat_wins.has_key(room_jid): 375 if self.chat_wins.has_key(room_jid):
373 self.chat_wins[room_jid].getGame("Tarot").invalidCards(phase, played_cards, invalid_cards) 376 self.chat_wins[room_jid].getGame("Tarot").invalidCards(phase, played_cards, invalid_cards)
374 377
378 def quizGameStarted(self, room_jid, referee, players, profile):
379 if not self.check_profile(profile):
380 print "gof: NOT CHECK PROFILE", profile
381 return
382 debug (_("Quiz Game Started \o/"))
383 if self.chat_wins.has_key(room_jid):
384 self.chat_wins[room_jid].startGame("Quiz", referee, players)
385 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]})
386
387 def quizGameNew(self, room_jid, data, profile):
388 if not self.check_profile(profile):
389 return
390 debug (_("New Quiz Game"))
391 if self.chat_wins.has_key(room_jid):
392 self.chat_wins[room_jid].getGame("Quiz").quizGameNew(data)
393
394 def quizGameQuestion(self, room_jid, question_id, question, timer, profile):
395 """Called when a new question is asked"""
396 if not self.check_profile(profile):
397 return
398 debug (_(u"Quiz: new question: %s") % question)
399 if self.chat_wins.has_key(room_jid):
400 self.chat_wins[room_jid].getGame("Quiz").quizGameQuestion(question_id, question, timer)
401
375 def _subscribe_cb(self, answer, data): 402 def _subscribe_cb(self, answer, data):
376 entity, profile = data 403 entity, profile = data
377 if answer: 404 if answer:
378 self.bridge.subscription("subscribed", entity.short, profile_key = profile) 405 self.bridge.subscription("subscribed", entity.short, profile_key = profile)
379 else: 406 else: