diff src/plugins/plugin_misc_quiz.py @ 587:952322b1d490

Remove trailing whitespaces.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 18 Jan 2013 17:55:34 +0100
parents ca13633d3b6b
children beaf6bec2fcd
line wrap: on
line diff
--- a/src/plugins/plugin_misc_quiz.py	Fri Jan 18 17:55:27 2013 +0100
+++ b/src/plugins/plugin_misc_quiz.py	Fri Jan 18 17:55:34 2013 +0100
@@ -2,7 +2,7 @@
 # -*- coding: utf-8 -*-
 
 """
-SAT plugin for managing Quiz game 
+SAT plugin for managing Quiz game
 Copyright (C) 2009, 2010, 2011, 2012, 2013 Jérôme Poisson (goffi@goffi.org)
 
 This program is free software: you can redistribute it and/or modify
@@ -133,7 +133,7 @@
         for data in game_data:
             data_elt = domish.Element((None,data))
             data_elt.addContent(game_data[data])
-            game_data_elt.addChild(data_elt) 
+            game_data_elt.addChild(data_elt)
         return game_data_elt
 
     def __xml_to_game_data(self, game_data_elt):
@@ -161,17 +161,17 @@
         score = {}
         for player in game_data['players']:
             score[player] = players_data[player]['score']
-        
+
         answer_result_elt = domish.Element((None,'answer_result'))
         answer_result_elt['player'] = player_answering
         answer_result_elt['good_answer'] = str(good_answer)
-        
+
         for player in score:
             score_elt = domish.Element((None,"score"))
             score_elt['player'] = player
             score_elt['score'] = str(score[player])
-            answer_result_elt.addChild(score_elt) 
-        
+            answer_result_elt.addChild(score_elt)
+
         return answer_result_elt
 
     def __create_started_elt(self, players):
@@ -193,7 +193,7 @@
         question_elt['timer'] = str(timer)
         question_elt.addContent(question)
         return question_elt
-    
+
     def __start_play(self, room_jid, game_data, profile):
         """Start the game (tell to the first player after dealer to play"""
         game_data['stage'] = "play"
@@ -231,14 +231,14 @@
             for player in players:
                 self.host.plugins["XEP-0249"].invite(jid.JID(player), room.occupantJID.userhostJID(), {"game":"Quiz"}, profile)
             self.waiting_inv[_room] = (time(), players) #TODO: remove invitation waiting for too long, using the time data
-        
+
         def after_init(ignore):
             room_name = "sat_quiz_%s" % self.host.plugins["XEP-0045"].getUniqueName(profile_key)
             print "\n\n===> room_name:", room_name
             muc_service = None
             for service in self.host.memory.getServerServiceEntities("conference", "text", profile):
                 if not ".irc." in service.userhost():
-                    #FIXME: 
+                    #FIXME:
                     #This awfull ugly hack is here to avoid an issue with openfire: the irc gateway
                     #use "conference/text" identity (instead of "conference/irc"), there is certainly a better way
                     #to manage this, but this hack fill do it for test purpose
@@ -247,7 +247,7 @@
             if not muc_service:
                 error(_("Can't find a MUC service"))
                 return
-            
+
             _jid, xmlstream = self.host.getJidNStream(profile)
             d = self.host.plugins["XEP-0045"].join(jid.JID("%s@%s" % (room_name, muc_service.userhost())), _jid.user, {}, profile).addCallback(quizRoomJoined)
 
@@ -355,18 +355,18 @@
         game_data["timer"] = reactor.callLater(timer, self.timerExpired, room_jid, profile)
         game_data["time_left"] = None
 
-    def checkAnswer(self, room_jid, player, answer, profile): 
+    def checkAnswer(self, room_jid, player, answer, profile):
         """Check if the answer given is right"""
         game_data = self.games[room_jid.userhost()]
         players_data = game_data['players_data']
         good_answer =  game_data['question_id'] == "1" and answer=="42"
         players_data[player]['score'] += 1 if good_answer else -1
         players_data[player]['score'] = min(9, max(0, players_data[player]['score']))
-        
+
         mess = self.createGameElt(room_jid)
         mess.firstChildElement().addChild(self.__answer_result(player, good_answer, game_data))
         self.host.profiles[profile].xmlstream.send(mess)
-        
+
         if good_answer:
             reactor.callLater(4, self.askQuestion, room_jid, profile)
         else:
@@ -382,7 +382,7 @@
 
         for player in players:
             players_data[player]['game_score'] = 0
-        
+
         new_game_data = {"instructions": _(u"""Bienvenue dans cette partie rapide de quizz, le premier à atteindre le score de 9 remporte le jeu
 
 Attention, tu es prêt ?""")}
@@ -393,20 +393,20 @@
         reactor.callLater(10, self.askQuestion, room_jid, profile)
 
     def quiz_game_cmd(self, mess_elt, profile):
-        from_jid = jid.JID(mess_elt['from']) 
+        from_jid = jid.JID(mess_elt['from'])
         room_jid = jid.JID(from_jid.userhost())
         game_elt = mess_elt.firstChildElement()
         game_data = self.games[room_jid.userhost()]
         players_data = game_data['players_data']
-        
+
         for elt in game_elt.elements():
-            
+
             if elt.name == 'started': #new game created
                 players = []
                 for player in elt.elements():
                     players.append(unicode(player))
                 self.host.bridge.quizGameStarted(room_jid.userhost(), from_jid.full(), players, profile)
-            
+
             elif elt.name == 'player_ready': #ready to play
                 player = elt['player']
                 status = self.games[room_jid.userhost()]['status']
@@ -418,10 +418,10 @@
 
             elif elt.name == 'game_data':
                 self.host.bridge.quizGameNew(room_jid.userhost(), self.__xml_to_game_data(elt), profile)
-            
+
             elif elt.name == 'question': #A question is asked
                 self.host.bridge.quizGameQuestion(room_jid.userhost(), elt["id"], unicode(elt), int(elt["timer"]), profile )
-            
+
             elif elt.name == 'player_answer':
                 player = elt['player']
                 pause = game_data['stage'] == 'question' #we pause the game only if we are have a question at the moment
@@ -429,7 +429,7 @@
                 mess = self.createGameElt(room_jid)
                 buzzer_elt = mess.firstChildElement().addElement('player_buzzed')
                 buzzer_elt['player'] = player
-                buzzer_elt['pause'] = str(pause) 
+                buzzer_elt['pause'] = str(pause)
                 self.host.profiles[profile].xmlstream.send(mess)
                 if pause:
                     self.pauseTimer(room_jid)
@@ -442,17 +442,17 @@
                     say_elt['delay'] = "3"
                     reactor.callLater(2, self.host.profiles[profile].xmlstream.send, mess)
                     reactor.callLater(6, self.checkAnswer, room_jid, player, _answer, profile=profile)
-                
+
             elif elt.name == 'player_buzzed':
                 self.host.bridge.quizGamePlayerBuzzed(room_jid.userhost(), elt["player"], elt['pause'] == str(True), profile)
-            
+
             elif elt.name == 'player_says':
                 self.host.bridge.quizGamePlayerSays(room_jid.userhost(), elt["player"], unicode(elt), int(elt["delay"]), profile)
-           
+
             elif elt.name == 'answer_result':
                 player, good_answer, score = self.__answer_result_to_signal_args(elt)
                 self.host.bridge.quizGameAnswerResult(room_jid.userhost(), player, good_answer, score, profile)
-            
+
             elif elt.name == 'timer_expired':
                 self.host.bridge.quizGameTimerExpired(room_jid.userhost(), profile)
 
@@ -461,13 +461,13 @@
 
             else:
                 error (_('Unmanaged game element: %s') % elt.name)
-                
+
     def getHandler(self, profile):
             return QuizGameHandler(self)
 
 class QuizGameHandler (XMPPHandler):
     implements(iwokkel.IDisco)
-   
+
     def __init__(self, plugin_parent):
         self.plugin_parent = plugin_parent
         self.host = plugin_parent.host