Exemple #1
0
    def initGameAfter(self):
        serverType = gdata.serverType()
        if ftlog.is_debug():
            ftlog.debug("<< |gameId, serverType:", self.gameId(), serverType)

        if serverType in (gdata.SRV_TYPE_HTTP,
                          gdata.SRV_TYPE_UTIL,
                          gdata.SRV_TYPE_ROOM,
                          gdata.SRV_TYPE_TABLE,
                          gdata.SRV_TYPE_CENTER):
            TYPluginCenter.reload(self.GAME_ID)

        if serverType == gdata.SRV_TYPE_TABLE:
            for room in gdata.rooms().values():
                if room.gameId != self.gameId():
                    continue

                if ftlog.is_debug():
                    ftlog.debug("init tables"
                                "|gameId, serverType, roomId:",
                                self.gameId(), serverType, room.roomId)

                for table in room.maptable.values():
                    TYPluginCenter.evmsg(table.gameId,
                                         PluginEvent.EV_AFTER_TABLE_CHILD_INIT,
                                         {'table': table,
                                          'tableType': table.tableType})
Exemple #2
0
    def _doLeave(self, msg, userId, clientId):
        '''
        玩家操作, 尝试离开当前的桌子
        实例桌子可以覆盖 _doLeave 方法来进行自己的业务逻辑处理
        '''
        ftlog.hinfo(self._baseLogStr("_doLeave <<", userId), "|msg, observers:", msg, self.observers, caller=self)

        gameId = msg.getParam("gameId", 0)
        if gameId and gameId != self.gameId:
            ftlog.warn("_doLeave gameId != self.gameId", userId, gameId, clientId)
            return {"isOK": False, "reason": TYRoom.LEAVE_ROOM_REASON_SYSTEM}

        reason = msg.getParam("reason", TYRoom.LEAVE_ROOM_REASON_ACTIVE)

        # if reason == TYRoom.LEAVE_ROOM_REASON_LOST_CONNECTION:
        #     self.sendPlayerDataToAll(userId, managed=True)
        #     return {"isOK": False, "reason": reason}

        if ftlog.is_debug():
            ftlog.debug(self._baseLogStr("<<", userId), "|locList:", onlinedata.getOnlineLocList(userId), caller=self)

        result = {"isOK": True, "userId": userId, "gameId": self.gameId, "roomId": self.roomId, "tableId": self.tableId}

        player = self.getPlayer(userId)
        if player:
            self._doStandUp(msg, userId, player.seatId, reason, clientId)

        if userId in self.observers:
            del self.observers[userId]
            onlinedata.removeOnlineLoc(userId, self.roomId, self.tableId)
        if ftlog.is_debug():
            ftlog.debug(self._baseLogStr(">>", userId), "|locList:", onlinedata.getOnlineLocList(userId),
                        "|observers:", self.observers, caller=self)

        mpRes = self.createMsgPackRes("table_leave")
        mpRes.setResult("reason", reason)
        mpRes.setResult("userId", userId)
        router.sendToUser(mpRes, userId)

        if ftlog.is_debug():
            ftlog.info(self._baseLogStr("_doLeave >>", userId), "|reason, observers:", reason, self.observers,
                       caller=self)

        TYPluginCenter.evmsg(self.gameId, PluginEvents.EV_LEAVE_TABLE, {
            'table': self, 'userId': userId, 'reason': reason
        })

        return result
Exemple #3
0
    def checkSitCondition(self, userId):
        '''队列房间的准入条件靠quick_start模块和queue_table模块分别判断, 按产品需求两者标准不同'''
        msg = TYPluginCenter.evmsg(self.gameId, 'EV_CHECK_ENTER_ROOM_CONDITION',
                                   params={'userId': userId, 'room': self})

        reason = msg.getResult("reason")
        if reason and reason != TYRoom.ENTER_ROOM_REASON_OK:
            return False, reason

        return True, TYRoom.ENTER_ROOM_REASON_OK