Пример #1
0
    def enterFriendTable(self, userId, gameId, clientId, ftId):
        """进入自建桌,插件实现具体功能"""
        if ftlog.is_debug():
            ftlog.debug('MAJIANG enterFriendTable userId:', userId, ' gameId:',
                        gameId, ' clientId:', clientId, ' ftId:', ftId)

        tableId0, roomId0 = CreateTableData.getTableIdByCreateTableNo(ftId)
        if ftlog.is_debug():
            ftlog.debug('MAJIANG enterFriendTable ftId:', ftId, ' roomId:',
                        roomId0, ' tableId:', tableId0)

        if not tableId0 or not roomId0:
            from difang.majiang2.entity.util import sendPopTipMsg
            sendPopTipMsg(userId, '您要进入的朋友场房间不存在,请核对房间号')
            return

        config = {
            "type": "game",
            "pluginParams": {
                "gameType": 11,
                "ftId": ftId
            }
        }

        todotask = TodoTaskEnterGameNew(GAMEID, config)
        mo = MsgPack()
        mo.setCmd('todo_tasks')
        mo.setResult('gameId', gameId)
        mo.setResult('pluginId', GAMEID)
        mo.setResult('userId', userId)
        mo.setResult('tasks', TodoTaskHelper.encodeTodoTasks(todotask))
        router.sendToUser(mo, userId)
Пример #2
0
 def enterFriendTable(self, userId, gameId, clientId, ftId):
     todotask = TodoTaskEnterGameNew(DIZHU_GAMEID, {
                                                     'type':'game',
                                                     'pluginParams':{
                                                         'gameType':9, 'ftId':ftId, 'action':'enter'
                                                     }
                                     })
     TodoTaskHelper.sendTodoTask(DIZHU_GAMEID, userId, todotask)
Пример #3
0
    def doJoinCreateTable(self, userId, gameId, clientId, roomId0, tableId0,
                          playMode):
        """用户加入自建牌桌
        """
        loc = onlinedata.checkUserLoc(userId, clientId, gameId)
        lgameId, lroomId, ltableId, lseatId = loc.split('.')
        lgameId, lroomId, ltableId, lseatId = strutil.parseInts(
            lgameId, lroomId, ltableId, lseatId)
        if lgameId > 0 and lroomId > 0 and ltableId > 0 and lseatId >= 0:
            ftlog.warn('create_table error, user in table')
            sendPopTipMsg(userId, "请稍候,正在进桌...")
            config = {
                "type": "quickstart",
                "pluginParams": {
                    "roomId": lroomId,
                    "tableId": ltableId,
                    "seatId": lseatId
                }
            }
            todotask = TodoTaskEnterGameNew(lgameId, config)
            mo = MsgPack()
            mo.setCmd('todo_tasks')
            mo.setResult('gameId', gameId)
            mo.setResult('pluginId', lgameId)
            mo.setResult('userId', userId)
            mo.setResult('tasks', TodoTaskHelper.encodeTodoTasks(todotask))
            router.sendToUser(mo, userId)
        else:
            msg = runcmd.getMsgPack()
            createTableNo = msg.getParam('createTableNo', 0)
            if not createTableNo:
                return
            tableId0, roomId0 = CreateTableData.getTableIdByCreateTableNo(
                createTableNo)
            if not tableId0 or not roomId0:
                sendPopTipMsg(userId, "找不到您输入的房间号")
                return
            msg = runcmd.getMsgPack()
            msg.setParam("shadowRoomId", roomId0)
            msg.setParam("roomId", roomId0)
            msg.setParam("tableId", tableId0)
            msg.setCmdAction("room", "join_create_table")
            router.sendRoomServer(msg, roomId0)

            if router.isQuery():
                mo = runcmd.newOkMsgPack(1)
                router.responseQurery(mo, '', str(userId))
def queryQuickStartRecommend(userId, gameId, clientId):
    '''
    获取推荐的快开配置
    '''
    # 首先检查改玩家有米有上次快开的信息,如果有的话,继续引导玩家进入
    qsrGameStr = gamedata.getGameAttr(userId, HALL_GAMEID,
                                      KEY_QUICK_START_RECOMMEND_GAME)
    qsrGame = 0
    if qsrGameStr:
        qsrGame = int(qsrGameStr)
    ftlog.debug('quickStartRecommendGame:', qsrGame)

    if qsrGame > 0:
        qsrParamStr = gamedata.getGameAttr(userId, qsrGame,
                                           KEY_QUICK_START_RECOMMEND_PARAMS)
        ftlog.debug('quickStartRecommendParams:', qsrParamStr)
        qsrName = gamedata.getGameAttr(userId, qsrGame,
                                       KEY_QUICK_START_RECOMMEND_NAME)
        ftlog.debug('quickStartRecommendName:', qsrName)

        if qsrParamStr:
            qsrParams = json.loads(qsrParamStr)
            todo = TodoTaskEnterGameNew(qsrGame, qsrParams)
            todos = TodoTaskHelper.encodeTodoTasks(todo)
            return sendTodoTaskToUser(userId, gameId, qsrName, todos)

    global _ordersMap
    templateName = hallconf.getQuickStartRecommendTemplateName(clientId)
    ftlog.debug('templateName:', templateName)

    templates = _ordersMap.get('templates', [])
    for template in templates:
        ftlog.debug('template:', template)

        if template.get('name', '') == templateName:
            # 找到当前的模板了
            applyGames = template.get('applyGames', [])
            for applyGame in applyGames:
                ftlog.debug('applyGame:', applyGame)

                if applyGame.get('pushToNewUser', 0):
                    quickList = applyGame.get('list', [])
                    return sendQuickStartRecommendMsg(userId, gameId, clientId,
                                                      quickList)

    return '1'
Пример #5
0
def sendFriendInviteEnterGameTodotask(userId, gameId, play_mode, roomId, tableId, info_str):
    """ 构造从大厅主界面进桌子的todotask
    """
    enter_param = {
        'type': 'quickstart',
        'pluginParams': {
            'play_mode': play_mode,
            'roomId': roomId,
            'tableId': tableId,
            'gameType': 9  # TODO: 写死了9,因为目前只有贵宾桌使用到了这个功能
        }
    }
    todotask = TodoTaskEnterGameNew(gameId, enter_param)
    show_info_ = TodoTaskShowInfo(info_str, True)
    show_info_.setSubCmd(todotask)
    msg = TodoTaskHelper.makeTodoTaskMsg(gameId, userId, show_info_)
    router.sendToUser(msg, userId)
Пример #6
0
    def enterFriendTable(self, userId, gameId, clientId, ftId):
        """进入自建桌,插件实现具体功能"""
        if ftlog.is_debug():
            ftlog.debug('|userId, gameId, clientId, ftId:', userId, gameId, clientId, ftId, caller=self)

        tableId = DiFangCustomRoomPlugin.getTableIdOfFtId(self.GAME_ID, ftId)

        if not tableId:
            ftlog.error("enterFriendTable not tableId |userId, gameId, clientId, ftId:", userId, gameId, clientId, ftId)
            return

        enterParams = {
            "type": "game",  # 需要前端统一
            "pluginParams": {
                "gameType": 11,  # 需要前端统一
                "ftId": ftId,
                "tableId": tableId,
                "roomId": tableId / 10000
            }
        }

        todotask = TodoTaskEnterGameNew(self.GAME_ID, enterParams)
        TodoTaskHelper.sendTodoTask(gameId, userId, todotask)
Пример #7
0
    def doCreateTable(self,
                      userId,
                      gameId,
                      clientId,
                      roomId0,
                      tableId0,
                      playMode,
                      hasRobot=0):

        #临时硬编码,解决91晃晃提审问题
        if gameId == 791 and playMode == "queshou-lianjiang" and clientId == "IOS_3.901_weixin.appStore,weixinPay.0-hall791.queshou.iostsljmj":
            hasRobot = 1
        if gameId == 790 and playMode == 'luosihu-luosihuts' and clientId == "IOS_3.901_weixin.appStore,weixinPay.0-hall790.laodao.iostsxjmj":
            hasRobot = 1
        """房主创建牌桌"""
        if not playMode:
            ftlog.error(
                'game_handler, cat not create table without playMode...')

        loc = onlinedata.checkUserLoc(userId, clientId, gameId)
        lgameId, lroomId, ltableId, lseatId = loc.split('.')
        lgameId, lroomId, ltableId, lseatId = strutil.parseInts(
            lgameId, lroomId, ltableId, lseatId)
        if lgameId > 0 and lroomId > 0 and ltableId > 0 and lseatId >= 0:
            ftlog.warn('create_table error, user in table', lgameId, lroomId,
                       ltableId, lseatId)
            sendPopTipMsg(userId, "请稍候,正在进桌...")
            config = {
                "type": "quickstart",
                "pluginParams": {
                    "roomId": lroomId,
                    "tableId": ltableId,
                    "seatId": lseatId
                }
            }
            todotask = TodoTaskEnterGameNew(lgameId, config)
            mo = MsgPack()
            mo.setCmd('todo_tasks')
            mo.setResult('gameId', gameId)
            mo.setResult('pluginId', lgameId)
            mo.setResult('userId', userId)
            mo.setResult('tasks', TodoTaskHelper.encodeTodoTasks(todotask))
            router.sendToUser(mo, userId)
        elif self._canEnterGame(userId, gameId):
            # 保存建桌时间戳
            gamedata.setGameAttr(userId, gameId, 'createTableTime',
                                 pktimestamp.getCurrentTimestamp())

            msg = runcmd.getMsgPack()
            itemParams = msg.getParam("itemParams")

            playerCount = 4
            playerTypeId = itemParams.get(MFTDefine.PLAYER_TYPE, 1)
            playerTypeConfig = majiang_conf.getCreateTableConfig(
                gameId, playMode, MFTDefine.PLAYER_TYPE, playerTypeId)
            if not playerTypeConfig:
                sendPopTipMsg(userId, '人数配置有误,请稍后重试')
                return

            playerCount = playerTypeConfig.get('count', 4)
            ftlog.debug('MajiangCreateTable.create_table playerCount:',
                        playerCount)
            cardCountKey = playerTypeConfig.get(MFTDefine.CARD_COUNT,
                                                MFTDefine.CARD_COUNT)

            cardCountId = itemParams.get(cardCountKey, 0)
            cardCountConfig = majiang_conf.getCreateTableConfig(
                gameId, playMode, cardCountKey, cardCountId)
            if not cardCountConfig:
                sendPopTipMsg(userId, '房卡配置有误,请稍后重试')
                return

            if hasRobot == 1 and 'hasRobot' in cardCountConfig:
                cardCountConfig = cardCountConfig.get('hasRobot', {})
                ftlog.debug('MajiangCreateTable.create_table hasRobot == 1:')
            fangka_count = cardCountConfig.get('fangka_count', 1)
            ftlog.debug('MajiangCreateTable.create_table fangka_count:',
                        fangka_count, ' cardCountConfig:', cardCountConfig)

            msg.setParam('isCreateTable', 1)  #标记创建的桌子是 自建桌
            from poker.entity.game.rooms.room import TYRoom
            '''
            根据五个因素筛选合适的房间
            1)gameId         游戏ID
            2)playMode       游戏玩法
            3)playerCount    玩家个数
            4)hasRobot       是否有机器人
            5)itemId         房卡道具
            '''
            itemId = hall_fangka.queryFangKaItem(gameId, userId, clientId)
            if itemId:
                ftlog.debug(
                    'MajiangCreateTable._chooseCreateRoom fangKa itemId:',
                    itemId)
            roomId, checkResult = MajiangCreateTable._chooseCreateRoom(
                userId, gameId, playMode, playerCount, hasRobot, itemId)
            ftlog.debug('MajiangCreateTable._chooseCreateRoom roomId:', roomId,
                        ' checkResult:', checkResult)

            if checkResult == TYRoom.ENTER_ROOM_REASON_OK:
                msg = runcmd.getMsgPack()
                msg.setCmdAction("room", "create_table")
                msg.setParam("roomId", roomId)
                msg.setParam("itemParams", itemParams)
                msg.setParam('needFangka', fangka_count)
                ftlog.debug(
                    'MajiangCreateTable._chooseCreateRoom send message to room:',
                    msg)

                router.sendRoomServer(msg, roomId)
            else:
                sendPopTipMsg(userId, "暂时无法创建请稍后重试")

            if router.isQuery():
                mo = runcmd.newOkMsgPack(1)
                router.responseQurery(mo, '', str(userId))
        else:
            ftlog.info('majiang2 game_handler, ignore enter game request...')
Пример #8
0
    def doCreateTable(self, userId, gameId, clientId, roomId0, tableId0, playMode):
        """
        房主创建牌桌
        """
        if not playMode:
            ftlog.error('game_handler, cat not create table without playMode...')

        loc = onlinedata.checkUserLoc(userId, clientId, gameId)
        lgameId, lroomId, ltableId, lseatId = loc.split('.')
        lgameId, lroomId, ltableId, lseatId = strutil.parseInts(lgameId, lroomId, ltableId, lseatId)
        if lgameId > 0 and lroomId > 0 and ltableId > 0 and lseatId >= 0:
            ftlog.warn('create_table error, user in table', lgameId, lroomId, ltableId, lseatId)
            sendPopTipMsg(userId, "请稍候,正在进桌...")
            config = {
                "type": "quickstart",
                "pluginParams": {
                    "roomId": lroomId,
                    "tableId": ltableId,
                    "seatId": lseatId
                }
            }
            todotask = TodoTaskEnterGameNew(lgameId, config)
            mo = MsgPack()
            mo.setCmd('todo_tasks')
            mo.setResult('gameId', gameId)
            mo.setResult('pluginId', lgameId)
            mo.setResult('userId', userId)
            mo.setResult('tasks', TodoTaskHelper.encodeTodoTasks(todotask))
            router.sendToUser(mo, userId)
        elif self._canEnterGame(userId, gameId):
            # 保存建桌时间戳
            gamedata.setGameAttr(userId, gameId, 'createTableTime', pktimestamp.getCurrentTimestamp())

            msg = runcmd.getMsgPack()
            itemParams = msg.getParam("itemParams")
            # cardCount为总局数
            if "cardCount" in itemParams:
                cardCountId = itemParams.get('cardCount', 0)
                cardCountConfig = majiang_conf.getCreateTableConfig(gameId, playMode, 'cardCount', cardCountId)
                fangka_count = cardCountConfig.get('fangka_count', 1)
                ftlog.debug('MajiangCreateTable.create_table fangka_count:', fangka_count)

                playerCount = 4
                playerTypeId = itemParams.get('playerType', 1)
                if playerTypeId:
                    playerTypeConfig = majiang_conf.getCreateTableConfig(gameId, playMode, 'playerType', playerTypeId)
                    playerCount = playerTypeConfig.get('count', 4)
                    ftlog.debug('MajiangCreateTable.create_table playerCount:', playerCount)

                msg.setParam('isCreateTable', 1)  # 标记创建的桌子是 自建桌
                from poker.entity.game.rooms.room import TYRoom
                roomId, checkResult = MajiangCreateTable._chooseCreateRoom(userId, gameId, playMode, playerCount)
                ftlog.debug('MajiangCreateTable._chooseCreateRoom roomId:', roomId, ' checkResult:', checkResult)

                if checkResult == TYRoom.ENTER_ROOM_REASON_OK:
                    msg = runcmd.getMsgPack()
                    msg.setCmdAction("room", "create_table")
                    msg.setParam("roomId", roomId)
                    msg.setParam("itemParams", itemParams)
                    msg.setParam('needFangka', fangka_count)
                    ftlog.debug('MajiangCreateTable._chooseCreateRoom send message to room:', msg)

                    router.sendRoomServer(msg, roomId)
                else:
                    sendPopTipMsg(userId, "暂时无法创建请稍后重试")
            else:
                sendPopTipMsg(userId, "暂时无法创建请稍后重试")

            if router.isQuery():
                mo = runcmd.newOkMsgPack(1)
                router.responseQurery(mo, '', str(userId))
        else:
            ftlog.info('majiang2 game_handler, ignore enter game request...')