def stopReactor(self): #Ctrl+c终止reactor from game.manager.PlayerManager import PlayerManager players = PlayerManager().players for key in players: _player = players[key] PlayerManager.updatePlayer(_player)
def startAllTasks(self): from game.manager.PlayerManager import PlayerManager GlobalManager.heartTask = task.LoopingCall(PlayerManager().heartCheck) GlobalManager.heartTask.start(60) from game.manager.PkSceneManager import PkSceneManager pkSearchTask = task.LoopingCall(PkSceneManager().searchPkPlayer) pkSearchTask.start(1)
def terminate(self): '''心跳包检测断开连接''' self.transport.loseConnection() PlayerManager().dropUserByConn(self)
def loadAllData(self): #加载所有的数据库数据 from game.manager.PlayerManager import PlayerManager PlayerManager().loadAllPlayers()
def connectionLost(self, reason): '''连接断开处理''' PlayerManager().dropUserByConn(self)
def chuPai_305_1(conn, data): proto = ChuPaiRequest() proto.ParseFromString(data) player = PlayerManager().getPlayerByConn(conn) PkSceneManager().chuPai(proto, player)
def decidePlayer_304_1(conn, data): proto = DecideRequest() proto.ParseFromString(data) player = PlayerManager().getPlayerByConn(conn) PkSceneManager().decide(proto.decide, player)
def readyPlayer_302_1(conn, data): proto = ReadyPkRequest() proto.ParseFromString(data) player = PlayerManager().getPlayerByConn(conn) PkSceneManager().setPlayerState(player)
def searchPlayer_301_1(conn, data): player = PlayerManager().getPlayerByConn(conn) PkSceneManager().addPkPlayer(player)