0 def checkShouldChangeWorld(self): if not self.isSandbox: if not self.isBootcamp: if all(client.isDead for client in self.clients.itervalues()): self.worldChangeTimer.cancel() self.killAfkTimer.cancel() self.worldChange() def checkIfShamanCanGoIn(self): allgone=1 #if all(client.isDead for client in self.clients.itervalues()): for playerCode, client in self.clients.iteritems(): if client.playerCode != self.currentShamanCode: if client.isDead: pass else: allgone=0 if allgone==1: return 1 else: return 0 def setTimer(self): print 'setTimer() called(alreadySet: %s)'%(str(self.alreadySet)) if self.alreadySet: pass else: print 'changing Timer...' try: self.worldChangeTimer.cancel() except: pass try: self.worldChangeTimerz.cancel() except: pass self.worldChangeTimerz = threading.Timer(20, self.worldChange) self.worldChangeTimerz.start() print ':20 Set' self.alreadySet = True def resetSandbox(self): if self.isSandbox: for playerCode, client in self.clients.iteritems(): resetpscore=0 self.informAll(TransformiceClientHandler.sendPlayerDied, [playerCode, resetpscore]) client.isDead=True if all(client.isDead for client in self.clients.itervalues()): #self.worldChangeTimer.cancel() #self.worldChange() for playerCode, client in self.clients.iteritems(): client.resetPlay() self.currentWorld = self.currentWorld for playerCode, client in self.clients.iteritems(): client.startPlay() else: pass def addClient(self, newClient): self.clients[newClient.playerCode] = newClient self.informAllOthers(newClient, TransformiceClientHandler.sendNewPlayer, [newClient.getPlayerData()]) newClient.room = self newClient.startPlay() #self.stateRecorder.sendToClient(newClient) def updatesqlserver(self): for playerCode, client in self.clients.iteritems(): if client.username.startswith("*"): pass else: dbcur.execute('UPDATE users SET rounds = ? WHERE name = ?', [client.roundCount, client.username]) dbcur.execute('UPDATE users SET saves = ? WHERE name = ?', [client.micesaves, client.username]) dbcur.execute('UPDATE users SET shamcheese = ? WHERE name = ?', [client.shamancheese, client.username]) dbcur.execute('UPDATE users SET first = ? WHERE name = ?', [client.firstcount, client.username]) dbcur.execute('UPDATE users SET cheese = ? WHERE name = ?', [client.cheesecount, client.username]) dbcur.execute('UPDATE users SET shopcheese = ? WHERE name = ?', [client.shopcheese, client.username]) dbcur.execute('UPDATE users SET shop = ? WHERE name = ?', [client.shopitems, client.username]) dbcur.execute('UPDATE users SET look = ? WHERE name = ?', [client.look, client.username]) dbcur.execute('UPDATE users SET lastroom = ? WHERE name = ?', [client.room, client.username]) def removeClient(self, removeClient): if self.clients.has_key(removeClient.playerCode): for playerCode, client in self.clients.iteritems(): if playerCode == removeClient.playerCode: if client.username.startswith("*"): pass else: dbcur.execute('UPDATE users SET rounds = ? WHERE name = ?', [client.roundCount, client.username]) dbcur.execute('UPDATE users SET lastroom = ? WHERE name = ?', ["Offline", client.username]) dbcur.execute('UPDATE users SET saves = ? WHERE name = ?', [client.micesaves, client.username]) dbcur.execute('UPDATE users SET shamcheese = ? WHERE name = ?', [client.shamancheese, client.username]) dbcur.execute('UPDATE users SET first = ? WHERE name = ?', [client.firstcount, client.username]) dbcur.execute('UPDATE users SET cheese = ? WHERE name = ?', [client.cheesecount, client.username]) dbcur.execute('UPDATE users SET shopcheese = ? WHERE name = ?', [client.shopcheese, client.username]) dbcur.execute('UPDATE users SET shop = ? WHERE name = ?', [client.shopitems, client.username]) dbcur.execute('UPDATE users SET look = ? WHERE name = ?', [client.look, client.username]) del self.clients[removeClient.playerCode] if self.getPlayerCount() == 0: self.server.closeRoom(self) return self.informAll(TransformiceClientHandler.sendPlayerDisconnect, [removeClient.playerCode]) if self.currentSyncroniserCode == removeClient.playerCode: newSyncroniser = random.choice(self.clients.values()) newSyncroniser.isSyncroniser = True self.currentSyncroniserCode = newSyncroniser.playerCode self.informAll(TransformiceClientHandler.sendSynchroniser, [newSyncroniser.playerCode]) self.checkShouldChangeWorld() def changeSyncroniserRandom(self): newSyncroniser = random.choice(self.clients.values()) newSyncroniser.isSyncroniser = True self.currentSyncroniserCode = newSyncroniser.playerCode self.informAll(TransformiceClientHandler.sendSynchroniser, [newSyncroniser.playerCode]) def getPlayerName(self, code): 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 =