Esempio n. 1
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
    
 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
Esempio n. 3
0
 def doCheckout(self, gameId, userId, clientId, freeItemId):
     """
     {
         "cmd": "game",
         "params": {
             "action": "free_checkout",
             "userId": 10856,
             "gameId": 9999,
             "freeItemId": 1
         }
     }
     """
     if freeItemId == FREEITEMID_NEWCHECKIN:
         from hall.entity.newcheckin import clientReqCheckin
         clientReqCheckin(userId,clientId,gameId)
         return
     timestamp = pktimestamp.getCurrentTimestamp()
     freeList = hallfree.getFree(gameId, userId, clientId, timestamp)
     free = FreeHelper.getFreeById(freeList, freeItemId)
     if free:
         curState = FreeHelper.getCurStateOfFreeItem(gameId, userId, clientId, free, timestamp)
         if curState:
             todotasks = TodoTaskHelper.makeTodoTasksByFactory(gameId, userId, clientId, curState.todotaskList)
             if todotasks:
                 TodoTaskHelper.sendTodoTask(gameId, userId, todotasks)
Esempio n. 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
Esempio n. 5
0
def queryFangKaBuyInfo(gameId, userId, clientId):
    templateName = hallconf.getFangKaBuyInfoCliengConf(clientId)
    if templateName:
        ret = _fbTemplateMap.get(templateName, None)
        if not ret:
            return

        # 执行todotask
        ftlog.debug('hall_fangka_buy_info.queryFangKaBuyInfo gameId=', gameId,
                    'userId=', userId, 'clientId=', clientId, 'templateName=',
                    templateName, 'tasks=', ret.todotasks)
        todotasks = TodoTaskRegister.decodeList(ret.todotasks)
        tasks = TodoTaskHelper.makeTodoTasksByFactory(gameId, userId, clientId,
                                                      todotasks)
        TodoTaskHelper.sendTodoTask(gameId, userId, tasks)
Esempio n. 6
0
def queryFangKaBuyInfo(gameId, userId, clientId):
    templateName = hallconf.getFangKaBuyInfoCliengConf(clientId)
    if templateName:
        ret = _fbTemplateMap.get(templateName, None)
        if not ret:
            return

        # 执行todotask
        ftlog.debug('hall_fangka_buy_info.queryFangKaBuyInfo gameId=', gameId,
                    'userId=', userId,
                    'clientId=', clientId,
                    'templateName=', templateName,
                    'tasks=', ret.todotasks)
        todotasks = TodoTaskRegister.decodeList(ret.todotasks)
        tasks = TodoTaskHelper.makeTodoTasksByFactory(gameId, userId, clientId, todotasks)
        TodoTaskHelper.sendTodoTask(gameId, userId, tasks)
Esempio n. 7
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)
Esempio n. 8
0
 def doCheckout(self, gameId, userId, clientId, freeItemId):
     """
     {
         "cmd": "game",
         "params": {
             "action": "free_checkout",
             "userId": 10856,
             "gameId": 9999,
             "freeItemId": 1
         }
     }
     """
     timestamp = pktimestamp.getCurrentTimestamp()
     freeList = hallfree.getFree(gameId, userId, clientId, timestamp)
     free = FreeHelper.getFreeById(freeList, freeItemId)
     if free:
         curState = FreeHelper.getCurStateOfFreeItem(gameId, userId, clientId, free, timestamp)
         if curState:
             todotasks = TodoTaskHelper.makeTodoTasksByFactory(gameId, userId, clientId, curState.todotaskList)
             if todotasks:
                 TodoTaskHelper.sendTodoTask(gameId, userId, todotasks)
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)
Esempio n. 10
0
 def doCheckout(self, gameId, userId, clientId, freeItemId):
     """
     {
         "cmd": "game",
         "params": {
             "action": "free_checkout",
             "userId": 10856,
             "gameId": 9999,
             "freeItemId": 1
         }
     }
     """
     timestamp = pktimestamp.getCurrentTimestamp()
     freeList = hallfree.getFree(gameId, userId, clientId, timestamp)
     free = FreeHelper.getFreeById(freeList, freeItemId)
     if free:
         curState = FreeHelper.getCurStateOfFreeItem(
             gameId, userId, clientId, free, timestamp)
         if curState:
             todotasks = TodoTaskHelper.makeTodoTasksByFactory(
                 gameId, userId, clientId, curState.todotaskList)
             if todotasks:
                 TodoTaskHelper.sendTodoTask(gameId, userId, todotasks)
Esempio n. 11
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
Esempio n. 12
0
    def sendRewards(self, userId, gameId, clientId):
        bSend = True

        for cond in self.conditions:
            if not cond.check(gameId, userId, clientId,
                              pktimestamp.getCurrentTimestamp()):
                bSend = False

        if not bSend:
            return

        # 第一步 发奖励
        if self.items:
            from hall.entity import hallitem
            userAssets = hallitem.itemSystem.loadUserAssets(userId)
            assetList = userAssets.sendContent(
                gameId, self.items, 1, True, pktimestamp.getCurrentTimestamp(),
                'LOGIN_REWARD', 0)

            if assetList:
                if ftlog.is_debug():
                    ftlog.debug('hall_login_reward.sendReward gameId=', gameId,
                                'userId=', userId, 'rewards=',
                                [(atup[0].kindId, atup[1])
                                 for atup in assetList])
                # 记录登录奖励获取时间
                gamedata.setGameAttr(userId, HALL_GAMEID, 'login_reward',
                                     pktimestamp.getCurrentTimestamp())
                # 通知更新
                changedDataNames = TYAssetUtils.getChangeDataNames(assetList)
                datachangenotify.sendDataChangeNotify(gameId, userId,
                                                      changedDataNames)
                from poker.util import strutil
                _, cVer, _ = strutil.parseClientId(clientId)
                if cVer < 3.90:
                    TodoTaskHelper.sendTodoTask(
                        gameId, userId, TodoTaskShowInfo(self.mail, True))
                else:
                    rewardsList = []
                    for assetItemTuple in assetList:
                        '''
                        0 - assetItem
                        1 - count
                        2 - final
                        '''
                        assetItem = assetItemTuple[0]
                        reward = {}
                        reward['itemId'] = assetItem.kindId
                        reward['name'] = assetItem.displayName
                        reward['pic'] = assetItem.pic
                        reward['count'] = assetItemTuple[1]
                        rewardsList.append(reward)

                    if ftlog.is_debug():
                        ftlog.debug(
                            'hall_login_reward.TodoTaskShowRewards rewardsList: ',
                            rewardsList)

                    TodoTaskHelper.sendTodoTask(
                        gameId, userId, TodoTaskShowRewards(rewardsList))

        # 第二步,执行actions
        for action in self.actions:
            action.doAction(gameId, userId, clientId,
                            pktimestamp.getCurrentTimestamp())

        # 第三步,发送todotasks
        tasks = TodoTaskHelper.makeTodoTasksByFactory(gameId, userId, clientId,
                                                      self.todotasks)
        TodoTaskHelper.sendTodoTask(gameId, userId, tasks)

        # 第四步,发送消息
        pkmessage.send(gameId, pkmessage.MESSAGE_TYPE_SYSTEM, userId,
                       self.mail)
Esempio n. 13
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
Esempio n. 14
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
Esempio n. 15
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