def encodePromote(cls, gameId, userId, clientId, promote):
     try:
         todotasks = TodoTaskHelper.makeTodoTasksByFactory(
             gameId, userId, clientId, promote.promotion.todotasks)
         tempRedPoint = False
         timestamp = pktimestamp.getCurrentTimestamp()
         ftlog.debug('promote.promotion.redPoint =',
                     promote.promotion.redPoint)
         for d in promote.promotion.redPoint:
             if d:
                 tempRedPoint = d.check(HALL_GAMEID, userId, clientId,
                                        timestamp)
         ret = {
             'id': promote.promotion.promotionId,
             'loc': promote.position.pos,
             'name': promote.promotion.displayName,
             'url': promote.promotion.url,
             'defaultRes': promote.promotion.defaultRes,
             'animate': promote.promotion.animate,
             'redPoint': tempRedPoint,
             'tasks': TodoTaskHelper.encodeTodoTasks(todotasks)
         }
         if promote.stopTime != -1:
             ret['endtime'] = datetime.fromtimestamp(
                 promote.stopTime).strftime('%Y-%m-%d %H:%M:%S')
         return ret
     except:
         ftlog.error('PromotionHelper.encodePromote gameId=', gameId,
                     'userId=', userId, 'clientId=', clientId,
                     'promotionId=', promote.promotion.promotionId)
         return None
示例#2
0
文件: game.py 项目: zhaozw/hall37
    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)
示例#3
0
def getClientCustomMenuSetting(gameId, userId, clientId, menus):
    ''' 获取自定义菜单设置
    '''
    settings = {}
    
    for menu in menus:
        if menu in _menuCustomMap:
            ms = {}
            # 图片
            ms['picUrl'] = _menuCustomMap[menu].get('picUrl', '')
            # 行为
            todotasks = []
            for todotaskDict in _menuCustomMap[menu].get('todotasks', []):
                todotask = TodoTaskRegister.decodeFromDict(todotaskDict)
                todotasks.append(todotask)
                
            todotasks = TodoTaskHelper.makeTodoTasksByFactory(gameId, userId, clientId, todotasks)
            ms['tasks'] = TodoTaskHelper.encodeTodoTasks(todotasks)
            
            settings[menu] = ms
            
    if ftlog.is_debug():
        ftlog.debug('hallmenulist.getClientCustomMenuSetting settings=', settings)
        
    return settings
    
示例#4
0
 def encodePromote(cls, gameId, userId, clientId, promote):
     try:
         todotasks = TodoTaskHelper.makeTodoTasksByFactory(gameId, userId, clientId, promote.promotion.todotasks)
         tempRedPoint = False
         timestamp = pktimestamp.getCurrentTimestamp()
         ftlog.debug('promote.promotion.redPoint =', promote.promotion.redPoint)
         for d in promote.promotion.redPoint:
             if d:
                 tempRedPoint = d.check(HALL_GAMEID, userId, clientId, timestamp)
         ret = {
             'id': promote.promotion.promotionId,
             'loc': promote.position.pos,
             'name': promote.promotion.displayName,
             'url': promote.promotion.url,
             'defaultRes': promote.promotion.defaultRes,
             'animate': promote.promotion.animate,
             'redPoint': tempRedPoint,
             'tasks': TodoTaskHelper.encodeTodoTasks(todotasks)
         }
         if promote.stopTime != -1:
             ret['endtime'] = datetime.fromtimestamp(promote.stopTime).strftime('%Y-%m-%d %H:%M:%S')
         return ret
     except:
         ftlog.error('PromotionHelper.encodePromote gameId=', gameId,
                     'userId=', userId,
                     'clientId=', clientId,
                     'promotionId=', promote.promotion.promotionId)
         return None
示例#5
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)
示例#6
0
 def _sendTodoTaskJumpHighRoom(cls, userId, playMode, clientId):
     # todo fix the pop wnd to ddz's
     if not playMode in dizhuconf.PLAYMODE_ALLSET:
         playMode = dizhuconf.PLAYMODE_DEFAULT
     chosenRoomId, _ = cls._chooseRoom(userId, DIZHU_GAMEID, playMode)
     if chosenRoomId:
         quick_start_ = TodoTaskQuickStart(DIZHU_GAMEID, chosenRoomId)
         info_str_ = dizhuconf.getQuickStartErrorMsg(
             TYRoom.ENTER_ROOM_REASON_GREATER_MAX)
         show_info_ = TodoTaskShowInfo(info_str_, True)
         show_info_.setSubCmd(quick_start_)
         try:
             if cls._useSelfPopWnd(userId):
                 todoTaskObj = TodoTaskHelper.encodeTodoTasks(quick_start_)
                 Alert.sendNormalAlert2Button(DIZHU_GAMEID, userId, '提示',
                                              info_str_, todoTaskObj[0],
                                              '确定', None, '取消')
                 return
         except:
             ftlog.error('_sendTodoTaskJumpHighRoom error userId = ',
                         userId, ' clientId = ', clientId, 'playMode = ',
                         playMode)
         msg = TodoTaskHelper.makeTodoTaskMsg(DIZHU_GAMEID, userId,
                                              show_info_)
         router.sendToUser(msg, userId)
     else:
         cls._sendTodoTaskToUser(userId,
                                 TYRoom.ENTER_ROOM_REASON_GREATER_ALL)
示例#7
0
 def buildUpLevelTodoTasks(cls, gameId, userVip, clientId):
     deltaExp = userVip.deltaExpToNextLevel()
     if deltaExp > 0:
         payOrder = strutil.cloneData(hallvip.vipSystem.getLevelUpPayOrder())
         payOrder['priceDiamond'] = {'count': deltaExp, 'minCount': 0, 'maxCount': -1}
         product, _ = hallstore.findProductByPayOrder(gameId, userVip.userId, clientId, payOrder)
         if product:
             return TodoTaskHelper.encodeTodoTasks(TodoTaskPayOrder(product))
     return []
示例#8
0
 def encodeAds(cls, gameId, userId, clientId, ads):
     ret = {'id': ads.adsId, 'clickable': ads.clickable, 'pic': ads.pic}
     if ads.clickable and ads.todotasks:
         todotasks = []
         for todotaskFac in ads.todotasks:
             todotask = todotaskFac.newTodoTask(gameId, userId, clientId)
             if todotask:
                 todotasks.append(todotask)
         if todotasks:
             ret['tasks'] = TodoTaskHelper.encodeTodoTasks(todotasks)
     return ret
示例#9
0
    def getUserItemInfo(cls, userId, scoreActivity):
        additionConf = scoreActivity.itemAddition

        itemId = additionConf.get('itemId')
        assetKind = hallitem.itemSystem.findAssetKind(itemId)
        if not itemId or not assetKind:
            return

        remainTime = 0
        owned = False
        userBag = hallitem.itemSystem.loadUserAssets(userId).getUserBag()
        item = userBag.getItemByKindId(int(itemId.split(':')[-1]))
        if item:
            owned = True
            currentTimestamp = pktimestamp.getCurrentTimestamp()
            if item.expiresTime:
                remainTime = item.expiresTime - currentTimestamp
        todoTask = None
        todoTaskConf = additionConf.get('todoTask')
        if todoTaskConf:
            todoTask = TodoTaskDownloadApkPromote(todoTaskConf.get('url'))
            todoTask.setParam('action',
                              todoTaskConf.get('params', {}).get('action'))
            todoTask.setParam('func',
                              todoTaskConf.get('params', {}).get('func'))
        if ftlog.is_debug():
            ftlog.debug(
                'ActivityScoreRankingHandler.getUserItemInfo', 'userId=',
                userId, 'todoTask=', todoTask, 'todoTaskStr=',
                TodoTaskHelper.encodeTodoTasks(todoTask) if todoTask else None,
                'owned=', owned, 'remainTime=', remainTime, 'additionConf=',
                additionConf)

        return {
            'open': additionConf.get('open', 0),
            'owned': owned,
            'todoTask':
            TodoTaskHelper.encodeTodoTasks(todoTask) if todoTask else None,
            'rate': additionConf.get('rate', 0) + 1,
            'remainTime': remainTime
        }
示例#10
0
 def encodeAds(cls, gameId, userId, clientId, ads):
     ret = {
         'id': ads.adsId,
         'clickable': ads.clickable,
         'pic': ads.pic
     }
     if ads.clickable and ads.todotasks:
         todotasks = []
         for todotaskFac in ads.todotasks:
             todotask = todotaskFac.newTodoTask(gameId, userId, clientId)
             if todotask:
                 todotasks.append(todotask)
         if todotasks:
             ret['tasks'] = TodoTaskHelper.encodeTodoTasks(todotasks)
     return ret
示例#11
0
 def buildUpLevelTodoTasks(cls, gameId, userVip, clientId):
     deltaExp = userVip.deltaExpToNextLevel()
     if deltaExp > 0:
         payOrder = strutil.cloneData(
             hallvip.vipSystem.getLevelUpPayOrder())
         payOrder['priceDiamond'] = {
             'count': deltaExp,
             'minCount': 0,
             'maxCount': -1
         }
         product, _ = hallstore.findProductByPayOrder(
             gameId, userVip.userId, clientId, payOrder)
         if product:
             return TodoTaskHelper.encodeTodoTasks(
                 TodoTaskPayOrder(product))
     return []
示例#12
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))
示例#13
0
def sendQuickStartRecommendMsg(userId, gameId, clientId, applyGame):
    '''
    发送快开配置的消息给客户端
    '''
    ftlog.debug('userId:', userId, ' gameId:', gameId, ' clientId:', clientId,
                ' applyGame:', applyGame)

    todotasksDict = applyGame.get('todotasks', [])
    todotasks = TodoTaskRegister.decodeList(todotasksDict)
    ftlog.debug('todotasks:', todotasks)

    todos = TodoTaskHelper.makeTodoTasksByFactory(gameId, userId, clientId,
                                                  todotasks)
    tasks = TodoTaskHelper.encodeTodoTasks(todos)
    ftlog.debug('build tasks ok: ', tasks)

    return sendTodoTaskToUser(userId, gameId, applyGame.get('name', ''), tasks)
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'
示例#15
0
def maekItem(ad, gameId, userId, clientId):
    item = {}
    item['todotasks'] = []

    for key in ad:
        if key != 'todotasks':
            item[key] = ad[key]

        # make the todotask
        todostasks = []
        for task in ad.get('todotasks', []):
            taskFactory = hallpopwnd.decodeTodotaskFactoryByDict(task)
            dstTask = taskFactory.newTodoTask(gameId, userId, clientId)
            todostasks.append(dstTask)

        item['todotasks'] = TodoTaskHelper.encodeTodoTasks(todostasks)

    return item
示例#16
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 sendQuickStartRecommendMsg(userId, gameId, clientId, quickList):
    '''
    发送快开配置的消息给客户端
    '''
    ftlog.debug('userId:', userId, ' gameId:', gameId, ' clientId:', clientId,
                ' quickList:', quickList)

    for quickConf in quickList:
        conds = UserConditionRegister.decodeList(
            quickConf.get('conditions', []))
        ftlog.debug('conds:', conds)

        bCondsOK = False
        if not conds:
            bCondsOK = True
        else:
            for cond in conds:
                if cond.check(gameId, userId, clientId,
                              pktimestamp.getCurrentTimestamp()):
                    bCondsOK = True
                    break

        if not bCondsOK:
            ftlog.debug(
                'bCondsOK if false, this user check cond error, return...')
            return

        todotasksDict = quickConf.get('todotasks', [])
        todotasks = TodoTaskRegister.decodeList(todotasksDict)
        ftlog.debug('todotasks:', todotasks)

        todos = TodoTaskHelper.makeTodoTasksByFactory(gameId, userId, clientId,
                                                      todotasks)
        tasks = TodoTaskHelper.encodeTodoTasks(todos)
        ftlog.debug('build tasks ok: ', tasks)

        return sendTodoTaskToUser(userId, gameId, quickConf.get('name', ''),
                                  tasks)
示例#18
0
 def _sendTodoTaskJumpHighRoom(cls, userId, playMode, clientId, **kwargs):
     if not playMode in dizhuconf.PLAYMODE_ALLSET:
         playMode = dizhuconf.PLAYMODE_DEFAULT
     ctrlRoomIds, _ = cls._getQuickStartRoomList(userId, playMode, rankId=kwargs.get('rankId', '-1'))  # 快开列表
     chosenRoomId, reason, mixId = cls._chooseRoom(userId, ctrlRoomIds, rankId=kwargs.get('rankId', '-1'))
     if chosenRoomId and reason == ENTER_ROOM_REASON_OK:
         quick_start_ = TodoTaskQuickStart(DIZHU_GAMEID, chosenRoomId)
         quick_start_.setParam('mixId', mixId)
         info_str_ = dizhuconf.getQuickStartErrorMsg(ENTER_ROOM_REASON_GREATER_MAX)
         show_info_ = TodoTaskShowInfo(info_str_, True)
         show_info_.setSubCmd(quick_start_)
         try:
             if cls._useSelfPopWnd(userId):
                 todoTaskObj = TodoTaskHelper.encodeTodoTasks(quick_start_)
                 Alert.sendNormalAlert2Button(DIZHU_GAMEID, userId, '提示', info_str_, todoTaskObj[0], '确定', None, '取消')
                 return
         except:
             ftlog.error('DizhuQuickStart _sendTodoTaskJumpHighRoom error userId = ', userId,
                         ' clientId = ', clientId,
                         'playMode = ', playMode)
         msg = TodoTaskHelper.makeTodoTaskMsg(DIZHU_GAMEID, userId, show_info_)
         router.sendToUser(msg, userId)
     else:
         cls._sendTodoTaskToUser(userId, ENTER_ROOM_REASON_GREATER_ALL)
示例#19
0
def queryExitRemind(gameId, userId, clientId):
    global _ordersMap

    exitSDK = queryExitSDK(gameId, userId, clientId)
    if ftlog.is_debug():
        ftlog.debug('queryExitRemind exitSDK:', exitSDK)

    gameIdInClientId = strutil.getGameIdFromHallClientId(clientId)
    if ftlog.is_debug():
        ftlog.debug('hall_exit_remind.queryExitRemind gameIdInClientId',
                    gameIdInClientId)

    strGameId = str(gameIdInClientId)
    if strGameId not in _ordersMap:
        if ftlog.is_debug():
            ftlog.debug(
                'hall_exit_remind.queryExitRemind no this game exit remind config....'
            )
        return

    orders = _ordersMap[strGameId]
    if ftlog.is_debug():
        ftlog.debug('hall_exit_remind.queryExitRemind orders:', orders)

    for order in orders:
        if ftlog.is_debug():
            ftlog.debug('hall_exit_remind.queryExitRemind order:', order)
        if order.get('name', '') == 'checkin':
            # 是否是v4.56
            from hall.entity.localservice.localservice import checkClientVer
            if checkClientVer(userId, gameId, clientId):
                ftlog.hinfo("queryExitRemind|checkClientVer|clientVer|gt|",
                            userId, gameId, clientId)
                continue

        conds = UserConditionRegister.decodeList(order.get('conditions', []))
        if ftlog.is_debug():
            ftlog.debug('hall_exit_remind.queryExitRemind conds:', conds)

        bCondsOK = False
        if len(conds) == 0:
            bCondsOK = True

        for cond in conds:
            if cond.check(HALL_GAMEID, userId, clientId,
                          pktimestamp.getCurrentTimestamp()):
                if ftlog.is_debug():
                    ftlog.debug('hall_exit_remind.queryExitRemind cond ok: ',
                                cond)
                bCondsOK = True
                break

        if bCondsOK:
            todotasksDict = order.get('todotasks', [])
            todotasks = TodoTaskRegister.decodeList(todotasksDict)
            if ftlog.is_debug():
                ftlog.debug('hall_exit_remind.queryExitRemind todotasks:',
                            todotasks)

            todos = TodoTaskHelper.makeTodoTasksByFactory(
                HALL_GAMEID, userId, clientId, todotasks)
            tasks = TodoTaskHelper.encodeTodoTasks(todos)
            if ftlog.is_debug():
                ftlog.debug(
                    'hall_exit_remind.queryExitRemind build tasks ok: ', tasks)

            mo = MsgPack()
            mo.setCmd('game')
            mo.setResult('action', 'get_exit_remind')
            mo.setResult('gameId', gameId)
            mo.setResult('userId', userId)
            mo.setResult('button', order.get('button', ''))
            mo.setResult('tips', order.get('tips', ''))
            mo.setResult('tasks', tasks)
            mo.setResult('exitSDK', exitSDK)
            router.sendToUser(mo, userId)

            if ftlog.is_debug():
                ftlog.debug('hall_exit_remind.queryExitRemind userId:', userId,
                            ' clientId:', clientId, ' msg:', mo)

            return
示例#20
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...')
示例#21
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...')
示例#22
0
 def _buildToDictImpl(self, gameId, userId, clientId, d):
     todotasks = TodoTaskHelper.makeTodoTasksByFactory(gameId, userId, clientId, self.todotasks)
     d['tasks'] = TodoTaskHelper.encodeTodoTasks(todotasks)
     d['params'] = self.params
示例#23
0
def queryExitRemind(gameId, userId, clientId):
    exitSDK = queryExitSDK(gameId, userId, clientId)
    if ftlog.is_debug():
        ftlog.debug('queryExitRemind exitSDK:', exitSDK)

    gameIdInClientId = strutil.getGameIdFromHallClientId(clientId)
    if ftlog.is_debug():
        ftlog.debug('hall_exit_remind.queryExitRemind gameIdInClientId', gameIdInClientId)

    strGameId = str(gameIdInClientId)
    if strGameId not in hall_exit_remind._ordersMap:
        if ftlog.is_debug():
            ftlog.debug('hall_exit_remind.queryExitRemind no this game exit remind config....')
        return

    orders = hall_exit_remind._ordersMap[strGameId]
    if ftlog.is_debug():
        ftlog.debug('hall_exit_remind.queryExitRemind orders:', orders)

    for order in orders:
        if ftlog.is_debug():
            ftlog.debug('hall_exit_remind.queryExitRemind order:', order)

        conds = UserConditionRegister.decodeList(order.get('conditions', []))
        if ftlog.is_debug():
            ftlog.debug('hall_exit_remind.queryExitRemind conds:', conds)

        bCondsOK = False
        if len(conds) == 0:
            bCondsOK = True

        for cond in conds:
            if cond.check(HALL_GAMEID, userId, clientId, pktimestamp.getCurrentTimestamp()):
                if ftlog.is_debug():
                    ftlog.debug('hall_exit_remind.queryExitRemind cond ok: ', cond)
                bCondsOK = True
                break

        if bCondsOK:
            todotasksDict = order.get('todotasks', [])
            todotasks = TodoTaskRegister.decodeList(todotasksDict)
            if ftlog.is_debug():
                ftlog.debug('hall_exit_remind.queryExitRemind todotasks:', todotasks)

            todos = TodoTaskHelper.makeTodoTasksByFactory(HALL_GAMEID, userId, clientId, todotasks)
            tasks = TodoTaskHelper.encodeTodoTasks(todos)
            if ftlog.is_debug():
                ftlog.debug('hall_exit_remind.queryExitRemind build tasks ok: ', tasks)

            mo = MsgPack()
            mo.setCmd('game')
            mo.setResult('action', 'get_exit_remind')
            mo.setResult('gameId', gameId)
            mo.setResult('userId', userId)
            mo.setResult('button', order.get('button', ''))
            mo.setResult('tips', order.get('tips', ''))
            mo.setResult('tasks', tasks)
            mo.setResult('exitSDK', exitSDK)
            router.sendToUser(mo, userId)

            if ftlog.is_debug():
                ftlog.debug('hall_exit_remind.queryExitRemind userId:', userId, ' clientId:', clientId, ' msg:', mo)

            return
示例#24
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...')
示例#25
0
 def _buildToDictImpl(self, gameId, userId, clientId, d):
     todotasks = TodoTaskHelper.makeTodoTasksByFactory(
         gameId, userId, clientId, self.todotasks)
     d['tasks'] = TodoTaskHelper.encodeTodoTasks(todotasks)
     d['params'] = self.params