diff src/plugins/plugin_misc_radiocol.py @ 828:8f335c03eebb

plugins room_games, radiocol, libervia: small changes like refactorization to ease the maintenance
author souliane <souliane@mailoo.org>
date Fri, 17 Jan 2014 15:02:46 +0100
parents 215a2cb15e2d
children c5a8f602662b
line wrap: on
line diff
--- a/src/plugins/plugin_misc_radiocol.py	Thu Jan 16 11:44:14 2014 +0100
+++ b/src/plugins/plugin_misc_radiocol.py	Fri Jan 17 15:02:46 2014 +0100
@@ -235,27 +235,19 @@
             else:
                 error(_('Unmanaged game element: %s') % elt.name)
 
-    def getSyncData(self, room_jid_s, force_nicks=[]):
-        data = {}
+    def getSyncDataForPlayer(self, room_jid_s, nick):
         game_data = self.games[room_jid_s]
-        status = game_data['status']
-        nicks = [nick for nick in status if status[nick] == 'desync']
-        for nick in force_nicks:
-            if nick not in nicks:
-                nicks.append(nick)
-        for nick in nicks:
-            elements = []
-            if game_data['playing']:
-                preload = copy.deepcopy(game_data['playing'])
-                preload['filename'] += '#t=%.2f' % (time.time() - game_data['playing_time'])
-                elements.append(preload)
-                play = domish.Element(('', 'play'))
-                play['filename'] = preload['filename']
-                elements.append(play)
-            if len(game_data['queue']) > 0:
-                elements.extend(copy.deepcopy(game_data['queue']))
-                if len(game_data['queue']) == QUEUE_LIMIT:
-                    elements.append(domish.Element(('', 'no_upload')))
-            if data:
-                data[nick] = elements
-        return data
+        elements = []
+        if game_data['playing']:
+            preload = copy.deepcopy(game_data['playing'])
+            current_time = game_data['playing_time'] + 1 if self.testing else time.time()
+            preload['filename'] += '#t=%.2f' % (current_time - game_data['playing_time'])
+            elements.append(preload)
+            play = domish.Element(('', 'play'))
+            play['filename'] = preload['filename']
+            elements.append(play)
+        if len(game_data['queue']) > 0:
+            elements.extend(copy.deepcopy(game_data['queue']))
+            if len(game_data['queue']) == QUEUE_LIMIT:
+                elements.append(domish.Element(('', 'no_upload')))
+        return elements