Ejemplo n.º 1
0
    def decodeFromDict(self, d):
        from hall.entity.hallusercond import UserConditionRegister
        self.value = d.get('value', '')
        if not isstring(self.value):
            raise TYBizConfException(d, 'hallshare.HallShareConfigItem.value must be string')

        self.conditions = UserConditionRegister.decodeList(d.get('conditions', []))
        return self
Ejemplo n.º 2
0
    def _decodeFromDictImpl(self, d):
        self.type = d.get('type')
        if not isstring(self.type):
            raise TYBizConfException(d, 'HallGameNode.type must be string')

        self.params = d.get('params', {})

        self.conditions = UserConditionRegister.decodeList(d.get('conditions', []))
Ejemplo n.º 3
0
    def _decodeFromDictImpl(self, d):
        self.todotasks = []
        # 给TodoTask类型添加params参数
        self.params = d.get('params', {})
        for todotaskDict in d.get('todotasks', []):
            todotask = TodoTaskRegister.decodeFromDict(todotaskDict)
            self.todotasks.append(todotask)

        self.conditions = UserConditionRegister.decodeList(d.get('conditions', []))
Ejemplo n.º 4
0
    def _decodeFromDictImpl(self, d):
        self.params = d.get('params', {})

        self.nodes = []
        for nodeDict in d.get('nodes', []):
            node = HallGameNodeRegister.decodeFromDict(nodeDict)
            self.nodes.append(node)

        self.conditions = UserConditionRegister.decodeList(d.get('conditions', []))
Ejemplo n.º 5
0
 def decodeFromDict(self, d):
     self.promotionId = d.get('promotionId')
     self.displayName = d.get('displayName')
     self.url = d.get('url')
     self.defaultRes = d.get('defaultRes', None)
     self.animate = d.get('animate')
     self.todotasks = []
     for todotaskDict in d.get('todotasks', []):
         self.todotasks.append(hallpopwnd.decodeTodotaskFactoryByDict(todotaskDict))
     self.redPoint = UserConditionRegister.decodeList(d.get('redPoint', []))
     return self
Ejemplo n.º 6
0
 def decodeFromDict(self, d):
     from hall.entity.hallusercond import UserConditionRegister
     self.conditions = UserConditionRegister.decodeList(d.get('conditions', []))
     self.itemSrc = d.get('itemIdSrc', None)
     self.itemDst = d.get('itemIdDst', None)
     self.ratio = d.get('ratio', 0)
     if (not self.itemSrc) or (not self.itemDst) or (not self.ratio) or (self.ratio <= 1) or (
             not isinstance(self.ratio, int)):
         ftlog.error('HallItemAutoExchange.exchange config error. src:', self.itemSrc, ' dst:', self.itemDst,
                     ' ratio:', self.ratio)
         return None
     return self
Ejemplo n.º 7
0
    def isProductShow(cls, product, userId):
        ftlog.debug('StoreHelper.isProductShow product=', product,
                    'userId=', userId)

        if product.showConditions:
            ftlog.debug('StoreHelper.isProductShow product conditions:', product.showConditions)
            conditions = UserConditionRegister.decodeList(product.showConditions)

            for cond in conditions:
                clientId = sessiondata.getClientId(userId)
                if not cond.check(HALL_GAMEID, userId, clientId, pktimestamp.getCurrentTimestamp()):
                    ftlog.debug('StoreHelper.isProductShow not suitable for condition:', cond)
                    return False
        return True
Ejemplo n.º 8
0
    def decodeFromDict(self, d):
        self.desc = d.get('desc', '')
        self.btnText = d.get('btnText', '')
        self.hasMark = d.get('hasMark', False)
        self.enable = d.get('enable', True)
        self.visible = d.get('visible', True)

        self.conditionList = UserConditionRegister.decodeList(d.get('conditions', []))

        self.todotaskList = []
        for todotaskDict in d.get('todotasks', []):
            self.todotaskList.append(hallpopwnd.decodeTodotaskFactoryByDict(todotaskDict))

        return self
Ejemplo n.º 9
0
 def decodeFromDict(self, d, promotionMap):
     self.weight = d.get('weight', 0)
     if not isinstance(self.weight, int):
         raise TYBizConfException(d, 'HallPromotePosition.weight must int')
     self.startTime = self.stopTime = -1
     startTime = d.get('startTime')
     if startTime:
         startTime = datetime.strptime(startTime, '%Y-%m-%d %H:%M:%S')
         self.startTime = int(time.mktime(startTime.timetuple()))
     stopTime = d.get('stopTime')
     if stopTime:
         stopTime = datetime.strptime(stopTime, '%Y-%m-%d %H:%M:%S')
         self.stopTime = int(time.mktime(stopTime.timetuple()))
     promotionId = d.get('promotionId')
     promotion = promotionMap.get(promotionId)
     if not promotion:
         raise TYBizConfException(d, 'Not found promotion for %s' % (promotionId))
     self.promotion = promotion
     self.conditionList = UserConditionRegister.decodeList(d.get('conditions', []))
     return self
Ejemplo n.º 10
0
 def decodeFromDict(self, d):
     from hall.entity.hallusercond import UserConditionRegister
     self.conditions = UserConditionRegister.decodeList(
         d.get('conditions', []))
     self.itemSrc = d.get('itemIdSrc', None)
     self.itemDst = d.get('itemIdDst', None)
     self.ratio = d.get('ratio', 0)
     self.message = d.get('message', None)
     if (not self.itemSrc) or (not self.message) or (not self.itemDst) or (
             not self.ratio) or (self.ratio < 1) or (not isinstance(
                 self.ratio, int)):
         ftlog.error('HallItemAutoExchange.exchange config error. src:',
                     self.itemSrc, ' dst:', self.itemDst, ' ratio:',
                     self.ratio)
         return None
     if self.itemDst == self.itemSrc:
         ftlog.error('HallItemAutoExchange.exchange config error. src:',
                     self.itemSrc, ' dst:', self.itemDst, ' ratio:',
                     self.ratio)
         return None
     return self
Ejemplo n.º 11
0
 def decodeFromDict(self, d, promotionMap):
     self.weight = d.get('weight', 0)
     if not isinstance(self.weight, int):
         raise TYBizConfException(d, 'HallPromotePosition.weight must int')
     self.startTime = self.stopTime = -1
     startTime = d.get('startTime')
     if startTime:
         startTime = datetime.strptime(startTime, '%Y-%m-%d %H:%M:%S')
         self.startTime = int(time.mktime(startTime.timetuple()))
     stopTime = d.get('stopTime')
     if stopTime:
         stopTime = datetime.strptime(stopTime, '%Y-%m-%d %H:%M:%S')
         self.stopTime = int(time.mktime(stopTime.timetuple()))
     promotionId = d.get('promotionId')
     promotion = promotionMap.get(promotionId)
     if not promotion:
         raise TYBizConfException(
             d, 'Not found promotion for %s' % (promotionId))
     self.promotion = promotion
     self.conditionList = UserConditionRegister.decodeList(
         d.get('conditions', []))
     return self
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)
Ejemplo n.º 13
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
Ejemplo n.º 14
0
 def _decodeFromDictImpl(self, d):
     self.params = d.get('params', {})
     self.conditions = UserConditionRegister.decodeList(
         d.get('conditions', []))
Ejemplo n.º 15
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
Ejemplo n.º 16
0
 def _decodeFromDictImpl(self, d):
     self.params = d.get('params', {})
     self.conditions = UserConditionRegister.decodeList(d.get('conditions', []))