comparison 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
comparison
equal deleted inserted replaced
827:215a2cb15e2d 828:8f335c03eebb
233 # songs in queue. We can now start the party :) 233 # songs in queue. We can now start the party :)
234 self.playNext(room_jid, profile) 234 self.playNext(room_jid, profile)
235 else: 235 else:
236 error(_('Unmanaged game element: %s') % elt.name) 236 error(_('Unmanaged game element: %s') % elt.name)
237 237
238 def getSyncData(self, room_jid_s, force_nicks=[]): 238 def getSyncDataForPlayer(self, room_jid_s, nick):
239 data = {}
240 game_data = self.games[room_jid_s] 239 game_data = self.games[room_jid_s]
241 status = game_data['status'] 240 elements = []
242 nicks = [nick for nick in status if status[nick] == 'desync'] 241 if game_data['playing']:
243 for nick in force_nicks: 242 preload = copy.deepcopy(game_data['playing'])
244 if nick not in nicks: 243 current_time = game_data['playing_time'] + 1 if self.testing else time.time()
245 nicks.append(nick) 244 preload['filename'] += '#t=%.2f' % (current_time - game_data['playing_time'])
246 for nick in nicks: 245 elements.append(preload)
247 elements = [] 246 play = domish.Element(('', 'play'))
248 if game_data['playing']: 247 play['filename'] = preload['filename']
249 preload = copy.deepcopy(game_data['playing']) 248 elements.append(play)
250 preload['filename'] += '#t=%.2f' % (time.time() - game_data['playing_time']) 249 if len(game_data['queue']) > 0:
251 elements.append(preload) 250 elements.extend(copy.deepcopy(game_data['queue']))
252 play = domish.Element(('', 'play')) 251 if len(game_data['queue']) == QUEUE_LIMIT:
253 play['filename'] = preload['filename'] 252 elements.append(domish.Element(('', 'no_upload')))
254 elements.append(play) 253 return elements
255 if len(game_data['queue']) > 0:
256 elements.extend(copy.deepcopy(game_data['queue']))
257 if len(game_data['queue']) == QUEUE_LIMIT:
258 elements.append(domish.Element(('', 'no_upload')))
259 if data:
260 data[nick] = elements
261 return data