playerCode, client in self.clients.iteritems(): client.isAfk=True if self.clients.has_key(self.currentShamanCode): currentShaman = self.clients[self.currentShamanCode] for playerCode, client in self.clients.iteritems(): try: if self.isCatchTheCheeseMap==True: self.isCatchTheCheeseMap=False else: client.sendShamanPerformance(currentShaman.username, self.numCompleted) except: pass currentShaman.micesaves = self.numCompleted + currentShaman.micesaves self.currentShamanCode = None for playerCode, client in self.clients.iteritems(): client.resetPlay() self.currentWorld = mapnumber for playerCode, client in self.clients.iteritems(): client.startPlay() if self.currentWorld==888: self.worldChangeTimer = threading.Timer(60, self.worldChange) elif self.racing: self.worldChangeTimer = threading.Timer(60, self.worldChange) self.Timerz = threading.Timer(58, self.changingMap1) self.Timerz2 = threading.Timer(59, self.changingMap1) self.Timerz.start() self.Timerz2.start() else: self.worldChangeTimer = threading.Timer(120, self.worldChange) self.worldChangeTimer.start() self.killAfkTimer = threading.Timer(30, self.killAfk) self.killAfkTimer.start() if self.isSandbox: self.worldChangeTimer.cancel() self.killAfkTimer.cancel() self.gameStartTime = time.time() self.numCompleted = 0 self.numGotCheese = 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):