for room in self.server.rooms.itervalues(): for playerCode, client in room.clients.iteritems(): if client.playerCode == code: return client.username def getPlayerCode(self, name): for room in self.server.rooms.itervalues(): for playerCode, client in room.clients.iteritems(): if client.username == name: return client.playerCode def changeSyncroniserSpecific(self, username): for room in self.server.rooms.itervalues(): for playerCode, client in room.clients.iteritems(): if client.username == username: newSyncroniser = client break newSyncroniser.isSyncroniser = True self.currentSyncroniserCode = newSyncroniser.playerCode self.informAll(TransformiceClientHandler.sendSynchroniser, [newSyncroniser.playerCode]) def playMusic(self, path): self.informAll(TransformiceClientHandler.sendPlayMusic, [path]) def changeScore(self, playerCode, score): for playerCode, client in self.clients.iteritems(): if client.playerCode == playerCode: client.score = score def startSnowStorm(self): self.sendAllOthersAndSelf(self, "\x05" + "\x17", ["0"]) self.isSnowing=True self.endSnowStormTimer = threading.Timer(300, self.endSnowStorm) self.endSnowStormTimer.start() def endSnowStorm(self): self.sendAllOthersAndSelf(self, "\x05" + "\x17", []) self.isSnowing=False self.snowStormStartTimer = threading.Timer(random.randrange(900, 1500), self.startSnowStorm) self.snowStormStartTimer.start() def informAll(self, clientFunction, args): for playerCode, client in self.clients.iteritems(): lol = "%r"%(clientFunction) if "TransformiceClientHandler.sendPlayMusic" in lol: if client.musicOff: pass else: clientFunction(client, *args) else: clientFunction(client, *args) def informAllOthers(self, senderClient, clientFunction, args): for playerCode, client in self.clients.iteritems(): if playerCode != senderClient.playerCode: clientFunction(client, *args) def sendAll(self, eventTokens, data = None): for playerCode, client in self.clients.iteritems(): client.sendData(eventTokens, data) def sendAllOthers(self, senderClient, eventTokens, data): for playerCode, client in self.clients.iteritems(): if client.playerCode != senderClient.playerCode: client.sendData(eventTokens, data) def sendAllOthersAndSelf(self, senderClient, eventTokens, data): for playerCode, client in self.clients.iteritems(): client.sendData(eventTokens, data) def sendWholeServer(self, senderClient, eventTokens, data): for room in self.server.rooms.itervalues(): for playerCode, client in room.clients.iteritems(): client.sendData(eventTokens, data) def sendTribeMsg(self, sendClient, eventTokens, data): for room in self.server.rooms.itervalues(): for playerCode, client in room.clients.iteritems(): #self.room.sendTribeMsg(self, "\x10\x14", ['6', self.username, self.tribeName]) #print data if client.tribeName == data[0]: lol = data if lol[1] == "6": lol = data #[self.username, tribe, user]) data2 = [lol[1], lol[2], lol[3]] elif lol[1] == '12': #self.room.sendTribeMsg(self, "\x10\x04", ['12', name, rank]) lol = data data2 = [lol[1], lol[2], lol[3]] #print 'Sent: '+str(data2) elif lol[1] == '13': #[str(self.tribeName), '13', '1', name]) lol = data data2 = [lol[1], lol[2], lol[3]] elif lol[1] == '11': #[str(self.tribeName), '11', player]) lol = data data2 = [lol[1], lol[2]] if lol[2] == client.username: client.tribeName = "" else: lol = data data2 = [lol[1], lol[2]] client.sendData(eventTokens, data2) def sendTribeChat(self, senderClient, eventTokens, data): for room in self.server.rooms.itervalues(): for playerCode, client in room.clients.iteritems(): try: #[tmessage, self.username, self.tribeName) tribe = data[2] lol = [data[1], data[0]] if client.tribeName == tribe: if client.tribeMuted: pass else: client.sendData(eventTokens, lol) except: pass def sendRecruit(self, senderClient, eventTokens, data): for room in self.server.rooms.itervalues(): for playerCode, client in room.clients.iteritems(): #[self.username, tribe, user]) try: if client.username == data[2]: lol = data data = [2, lol[0], lol[1]] client.sendData(eventTokens, data) except: print '[ERROR] Recruit: %s'%(str(data)) def sendAdminChat(self, senderClient, eventTokens, data): for room in self.server.rooms.itervalues(): for playerCode, client in room.clients.iteritems(): if client.privilegeLevel>=3 and not client.isDrawer: client.sendData(eventTokens, data) def sendServeur(self, senderClient, eventTokens, data): for room in self.server.rooms.itervalues(): for playerCode, client in room.clients.iteritems(): if client.privilegeLevel>=5 and not client.isDrawer: client.sendData(eventTokens, data) def sendFriend(self, senderClient, eventTokens, data): for room in self.server.rooms.itervalues(): for playerCode, client in room.clients.iteritems(): friendList = self.server.getUserFriends(client.username).split(",") user = str(data).replace("['", "").replace("']", "") if user in friendList: client.sendData(eventTokens, data) def sendTribes(self, senderClient, eventTokens, data): for room in self.server.rooms.itervalues(): for playerCode, client in room.clients.iteritems(): users = self.server.getTribeUsers(data[1]).split(",") if client.username in users: data[5] = client.tribeRank #print 'Data: '+str(data) client.sendData(eventTokens, data) else: pass def sendModChat(self, senderClient, eventTokens, data): for room in self.server.rooms.itervalues(): for playerCode, client in room.clients.iteritems(): if client.privilegeLevel>=5 and not client.isDrawer: client.sendData(eventTokens,