コード例 #1
0
 def decodeFromDict(self, d):
     super(HallTaskKindPoolWithCond, self).decodeFromDict(d)
     condition = d.get('acceptedCond')
     if condition:
         self._accepted_cond = UserConditionRegister.decodeFromDict(
             condition)
     condition = d.get('visibleCond')
     if condition:
         self._visible_cond = UserConditionRegister.decodeFromDict(
             condition)
     return self
コード例 #2
0
def _registerClasses():
    ftlog.debug('dizhu_segment_usercond._registerClasses')
    UserConditionRegister.registerClass(UserConditionSegmentRewardPool.TYPE_ID,
                                        UserConditionSegmentRewardPool)
    UserConditionRegister.registerClass(UserConditionSegmentWinDoubles.TYPE_ID,
                                        UserConditionSegmentWinDoubles)
    UserConditionRegister.registerClass(UserConditionSegmentChuntian.TYPE_ID,
                                        UserConditionSegmentChuntian)
    UserConditionRegister.registerClass(UserConditionCouponWithdraw.TYPE_ID,
                                        UserConditionCouponWithdraw)
    UserConditionRegister.registerClass(UserConditionSegment.TYPE_ID,
                                        UserConditionSegment)
コード例 #3
0
 def _decodeFromDictImpl(self, d):
     from hall.entity import hallpopwnd
     self._cycle = TimeCycleRegister.decodeFromDict(d.get('cycle'))
     self._condition = UserConditionRegister.decodeFromDict(
         d.get('condition'))
     playRounds = d.get('playRounds', [])
     if not playRounds or not isinstance(playRounds, list):
         raise TYBizConfException(
             d, 'PlayGameTodotask.playRounds must be not empty list')
     self._playRounds = []
     for item in playRounds:
         if not item or not isinstance(item, dict):
             raise TYBizConfException(
                 d,
                 'PlayGameTodotask.playRounds.item must be not empty dict')
         playRound = item.get('playRound')
         if not isinstance(playRound, int):
             raise TYBizConfException(
                 d,
                 'PlayGameTodotask.playRounds.item.playRound must be int')
         todotaskFac = hallpopwnd.decodeTodotaskFactoryByDict(
             item.get('todotask'))
         self._playRounds.append((playRound, todotaskFac))
     self._hallGameIds = d.get('hallGameIds', [])
     if not isinstance(self._hallGameIds, list):
         raise TYBizConfException(
             d, 'PlayGameTodotask.hallGameIds must be list')
     for hallGameId in self._hallGameIds:
         if not isinstance(hallGameId, int):
             raise TYBizConfException(
                 d, 'PlayGameTodotask.hallGameIds must be int list')
     return self
コード例 #4
0
ファイル: play_game_share.py プロジェクト: luningcowboy/tuyoo
 def _decodeFromDictImpl(self, d):
     self._cycle = TimeCycleRegister.decodeFromDict(d.get('cycle'))
     self._condition = UserConditionRegister.decodeFromDict(
         d.get('condition'))
     self._shareLoc = d.get('shareLoc', 'playGame')
     if not isstring(self._shareLoc):
         raise TYBizConfException(
             d, 'PlayGameShare.shareLoc must be not empty string')
     self._shares = d.get('shares', [])
     if not self._shares or not isinstance(self._shares, list):
         raise TYBizConfException(
             d, 'PlayGameShare.shares must be not empty list')
     for s in self._shares:
         if not s or not isinstance(s, dict):
             raise TYBizConfException(
                 d, 'PlayGameShare.shares.item must be not empty dict')
         playRound = s.get('playRound')
         if not isinstance(playRound, int):
             raise TYBizConfException(
                 d, 'PlayGameShare.shares.item.playRound must be int')
         shareId = s.get('shareId')
         if not isinstance(shareId, int):
             raise TYBizConfException(
                 d, 'PlayGameShare.shares.item.shareId must be int')
     self._hallGameIds = d.get('hallGameIds', [])
     if not isinstance(self._hallGameIds, list):
         raise TYBizConfException(d,
                                  'PlayGameShare.hallGameIds must be list')
     for hallGameId in self._hallGameIds:
         if not isinstance(hallGameId, int):
             raise TYBizConfException(
                 d, 'PlayGameShare.hallGameIds must be int list')
     return self
コード例 #5
0
 def _validEnterRoomConditions(cls, gameId, userId, clientId, roomId, roomConfig):
     enterRoomCondList = roomConfig.get('enterRoomCond')
     if enterRoomCondList:
         try:
             for enterCond in enterRoomCondList:
                 cond = enterCond['cond']
                 msg = enterCond['msg']
                 result = UserConditionRegister.decodeFromDict(cond).check(gameId, userId, clientId, pktimestamp.getCurrentTimestamp())
                 if not result:
                     if ftlog.is_debug():
                         ftlog.debug('DizhuQuickStart._validEnterRoomConditions',
                                     'gameId=', gameId,
                                     'userId=', userId,
                                     'clientId=', clientId,
                                     'roomId=', roomId,
                                     'enterRoomCond=', enterRoomCondList,
                                     'ret=', msg)
                     return result, msg
             return True, 'ok'
         except:
             ftlog.error('DizhuQuickStart._validEnterRoomConditions',
                         'gameId=', gameId,
                         'userId=', userId,
                         'clientId=', clientId,
                         'roomId=', roomId,
                         'enterRoomCond=', enterRoomCondList)
             return False, 'error'
     return True, 0
コード例 #6
0
ファイル: hallads.py プロジェクト: luningcowboy/tuyoo
    def decodeFromDict(self, d):
        self.adsId = d.get('id')
        if not isinstance(self.adsId, int):
            raise TYBizConfException(d, 'TYAds.id must be int')
        self.clickable = d.get('clickable')
        # if self.clickable not in (0, 1):
        #     raise TYBizConfException(d, 'TYAds.clickable must be int int (0,1)')
        self.pic = d.get('pic', '')
        if not isstring(self.pic):
            raise TYBizConfException(d, 'TYAds.pic must be string')

        self.startDT = d.get('startTime')
        if self.startDT is not None:
            self.startDT = datetime.strptime(self.startDT, '%Y-%m-%d %H:%M:%S')
        self.endDT = d.get('endTime')
        if self.endDT is not None:
            self.endDT = datetime.strptime(self.endDT, '%Y-%m-%d %H:%M:%S')

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

        self.condition = d.get('condition')
        if self.condition is not None:
            self.condition = UserConditionRegister.decodeFromDict(
                self.condition)
        return self
コード例 #7
0
    def _checkRoomConditions(cls, userId, roomConfig):
        enterRoomCondList = roomConfig.get('enterRoomCond')
        clientId = sessiondata.getClientId(userId)
        if enterRoomCondList:
            try:
                for enterCond in enterRoomCondList:
                    cond = enterCond['cond']
                    msg = enterCond['msg']

                    result = UserConditionRegister.decodeFromDict(cond).check(DIZHU_GAMEID, userId, clientId, pktimestamp.getCurrentTimestamp())
                    if not result:
                        if ftlog.is_debug():
                            ftlog.debug('DizhuQuickStartWx._validEnterRoomConditions',
                                        'gameId=', DIZHU_GAMEID,
                                        'userId=', userId,
                                        'clientId=', clientId,
                                        'roomConfig=', roomConfig,
                                        'enterRoomCond=', enterRoomCondList,
                                        'ret=', msg)
                        return result, msg
                return True, 'ok'
            except Exception, e:
                ftlog.error('DizhuQuickStartWx._validEnterRoomConditions',
                            'gameId=', DIZHU_GAMEID,
                            'userId=', userId,
                            'clientId=', clientId,
                            'roomConfig=', roomConfig,
                            'enterRoomCond=', enterRoomCondList,
                            'err=', e.message)
                return False, e.message
コード例 #8
0
ファイル: hallgamelist2.py プロジェクト: zhaozw/hall37
    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', []))
コード例 #9
0
ファイル: hallshare.py プロジェクト: zhaozw/hall37
    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
コード例 #10
0
 def decodeFromDict(self, d):
     self.failure = d.get('failure', '')
     if not isstring(self.failure):
         raise TYBizConfException(d,
                                  'MatchCondition.failure must be string')
     self.condition = UserConditionRegister.decodeFromDict(
         d.get('condition'))
     return self
コード例 #11
0
ファイル: hallgamelist2.py プロジェクト: zhaozw/hall37
    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', []))
コード例 #12
0
ファイル: hall_login_reward.py プロジェクト: zhaozw/hall37
 def decodeFromDict(self, d):
     from hall.entity.hallusercond import UserConditionRegister
     self.conditions = UserConditionRegister.decodeList(
         d.get('conditions', []))
     rewardContent = d.get('rewardContent')
     if rewardContent:
         self.items = TYContentRegister.decodeFromDict(rewardContent)
     self.mail = d.get('mail', '')
     return self
コード例 #13
0
ファイル: hallgamelist2.py プロジェクト: zhaozw/hall37
    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', []))
コード例 #14
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', []))
コード例 #15
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
コード例 #16
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', []))
コード例 #17
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', []))
コード例 #18
0
ファイル: hallpromote.py プロジェクト: zhaozw/hall37
 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
コード例 #19
0
ファイル: hall_item_exchange.py プロジェクト: zhaozw/hall37
 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
コード例 #20
0
    def decodeFromDict(self, d):
        self.type = d.get('type')
        if not isstring(self.type):
            raise TYBizConfException(d, 'WxShareControlConf.ShareOrVideoConf.type must be str')

        condition = d.get('condition')
        if not isinstance(condition, dict):
            raise TYBizConfException(d, 'WxShareControlConf.ShareOrVideoConf.condition must be dict')
        try:
            self.condition = UserConditionRegister.decodeFromDict(condition)
        except Exception, e:
            raise TYBizConfException(d, 'WxShareControlConf.ShareOrVideoConf.condition err=%s' % e.message)
コード例 #21
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
コード例 #22
0
def _reloadConf():
    global _rouletteTemplateMap
    global _rouletteMap
    global _condition

    conf = hallconf.getRouletteConf()
    _rouletteMap = conf.get('items')
    _rouletteTemplateMap = conf.get('template')
    templateConf = _rouletteTemplateMap.get(getTemeplateName(), {})
    from hall.entity.hallusercond import UserConditionRegister
    condition = templateConf.get('conditions')
    if condition:
        _condition = UserConditionRegister.decodeFromDict(condition)
コード例 #23
0
    def _decodeFromDictImpl(self, d):
        self._gameId = d.get('gameId')
        if not isinstance(self._gameId, int):
            raise TYBizConfException(d, 'QuweiTaskActivity.gameId must be int')
        refreshFee = d.get('refreshFee')
        if refreshFee is not None:
            refreshFee = TYContentItem.decodeFromDict(refreshFee)
        taskKindMap = {}
        for taskKindConf in d.get('tasks', []):
            taskKind = QuweiTaskKindRegister.decodeFromDict(taskKindConf)
            if taskKind.kindId in taskKindMap:
                raise TYBizConfException(
                    taskKindConf, 'Duplicate taskKind: %s' % (taskKind.kindId))
            taskKindMap[taskKind.kindId] = taskKind

        taskCount = d.get('taskCount')
        if not isinstance(taskCount, int) or taskCount <= 0:
            raise TYBizConfException(
                taskCount, 'QuweiTaskActivity.taskCount must be int > 0')

        autoRefresh = d.get('autoRefresh', 0)
        initPools = []
        for poolConf in d.get('initPools', []):
            cond = poolConf.get('condition')
            if cond is not None:
                cond = UserConditionRegister.decodeFromDict(cond)
            taskKindList = []
            taskKindIds = poolConf.get('kindIds', [])
            for kindId in taskKindIds:
                taskKind = taskKindMap.get(kindId)
                if not taskKind:
                    raise TYBizConfException(poolConf,
                                             'Unknown kindId: %s' % (kindId))
                taskKindList.append(taskKind)
            initPools.append((cond, taskKindList))

        self._taskKindMap = taskKindMap
        self._refreshFee = refreshFee
        self._initPools = initPools
        self._taskCount = taskCount
        self._autoRefresh = autoRefresh
        self._allOpen = d.get('open', 0)

        ftlog.info('QuweiTaskActivity._decodeFromDictImpl', 'gameId=',
                   self.gameId, 'actId=', self.actId, 'taskCount=',
                   self._taskCount, 'autoRefresh=', self._autoRefresh,
                   'tasks=', self._taskKindMap.keys(), 'refreshFee=',
                   self._refreshFee.toDict() if self._refreshFee else None,
                   'allOpen=', self._allOpen, 'initPools=',
                   [(p[0], [tk.kindId for tk in p[1]])
                    for p in self._initPools])
コード例 #24
0
ファイル: hallfree.py プロジェクト: zhaozw/hall37
    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
コード例 #25
0
ファイル: store_handler.py プロジェクト: zhaozw/hall37
    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
コード例 #26
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
コード例 #27
0
 def processUserTableRewards(cls, userId, winlose):
     ''' 处理牌局结束用户的奖励 '''
     gameWinRewardConf = getSegmentConf().gameWinReward
     # 判断condition
     condList = gameWinRewardConf.get('conditions')
     if condList and winlose.isWin:
         for condD in condList:
             cond = UserConditionRegister.decodeFromDict(condD)
             clientId = sessiondata.getClientId(userId)
             retCheck = cond.check(DIZHU_GAMEID,
                                   userId,
                                   clientId,
                                   pktimestamp.getCurrentTimestamp(),
                                   winlose=winlose)
             if retCheck:
                 reward = gameWinRewardConf.get('reward')
                 if reward:
                     try:
                         contentItems = TYContentItem.decodeList([reward])
                         from dizhu.entity import dizhu_util
                         dizhu_util.sendRewardItems(
                             userId, contentItems, None,
                             'DIZHU_SEGMENT_TABLE_WIN', 0)
                         ret = SegmentMatchHelper.addUserSegmentTableWinRewardCount(
                             userId, reward['count'])
                         if ret:
                             retMsg = ''
                             if cond.TYPE_ID == UserConditionSegmentWinDoubles.TYPE_ID:
                                 retMsg = '满贯'
                             elif cond.TYPE_ID == UserConditionSegmentChuntian.TYPE_ID:
                                 retMsg = '春天'
                             retReward = {
                                 'itemId': reward['itemId'],
                                 'count': reward['count'],
                                 'des': retMsg
                             }
                             ftlog.info(
                                 'DizhuSegmentRewardsHelper.processUserTableRewards',
                                 'userId=', userId, 'typeId=', cond.TYPE_ID,
                                 'reward=', retReward)
                             return retReward
                         else:
                             return None
                     except Exception, e:
                         ftlog.error(
                             'DizhuSegmentRewardsHelper.processUserTableRewards',
                             'userId=', userId, 'gameWinRewardConf=',
                             gameWinRewardConf, 'errmsg=', e.message)
コード例 #28
0
ファイル: hallfree.py プロジェクト: zhaozw/hall37
    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
コード例 #29
0
    def decodeFromDict(self, d):
        from hall.entity.hallusercond import UserConditionRegister
        self.conditions = UserConditionRegister.decodeList(
            d.get('conditions', []))

        rewardContent = d.get('rewardContent')
        if rewardContent:
            self.items = TYContentRegister.decodeFromDict(rewardContent)
        self.mail = d.get('mail', '')

        from hall.entity.halluseraction import UserActionRegister
        self.actions = UserActionRegister.decodeList(d.get('actions', []))

        from hall.entity.todotask import TodoTaskRegister
        self.todotasks = TodoTaskRegister.decodeList(d.get('todotasks', []))

        return self
コード例 #30
0
    def decodeFromDict(self, d):
        self.desc = d.get('desc')
        if not isstring(self.desc):
            raise TYBizConfException(d, 'ChargeBoxConf.desc must be str')

        self.type = d.get('type')
        if not isstring(self.type):
            raise TYBizConfException(d, 'ChargeBoxConf.type must be str')

        conditions = d.get('conditions', [])
        if not isinstance(conditions, list):
            raise TYBizConfException(d,
                                     'ChargeBoxConf.conditions must be list')
        try:
            self.conditions = UserConditionRegister.decodeList(conditions)
        except Exception, e:
            raise TYBizConfException(
                d, 'ChargeBoxConf.conditions err= %s' % e.message)
コード例 #31
0
ファイル: store_handler.py プロジェクト: zhaozw/hall37
    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
コード例 #32
0
def canDisplaySessionRoom(gameId, userId, clientId, roomId, displayCondDict):
    if displayCondDict:
        try:
            displayCond = UserConditionRegister.decodeFromDict(displayCondDict)
            ret = displayCond.check(gameId, userId, clientId,
                                    pktimestamp.getCurrentTimestamp())
            if not ret:
                if ftlog.is_debug():
                    ftlog.debug('dizhuhallinfo.canDisplaySessionRoom',
                                'gameId=', gameId, 'userId=', userId,
                                'clientId=', clientId, 'roomId=', roomId,
                                'displayCond=', displayCondDict, 'ret=', ret)
            return ret
        except:
            ftlog.error('dizhuhallinfo.canDisplaySessionRoom', 'gameId=',
                        gameId, 'userId=', userId, 'clientId=', clientId,
                        'roomId=', roomId, 'displayCond=', displayCondDict)
            return False
    return True
コード例 #33
0
ファイル: hallpromote.py プロジェクト: zhaozw/hall37
 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
コード例 #34
0
ファイル: dizhu_invite.py プロジェクト: luningcowboy/tuyoo
def getSimpleInviteBigReward(userId):
    '''
    获取大奖
    '''
    conf = getSimpleInviteConf()

    if conf.get('switch'):
        conditon = conf.get('condition')
        cond = UserConditionRegister.decodeFromDict(conditon)
        retCheck = cond.check(DIZHU_GAMEID, userId, None, None)
        ftlog.debug('dizhu_invite.getSimpleInviteBigReward userId=', userId,
                    'retCheck=', retCheck,
                    'isInterventionUser='******'firstBigRewards')
            if not firstBigRewards:
                return conf.get('firstBigRewards') if conf.get('firstBigRewards') else {}
        if isInterventionUser(userId):
            return conf.get('interventionBigRewards') if conf.get('interventionBigRewards') else {}

    return dizhu_util.getItemByWeight(conf.get('bigRewards')) if conf.get('bigRewards') else {}
コード例 #35
0
ファイル: activity.py プロジェクト: luningcowboy/tuyoo
    def _getConfigForClient(self, actName, gameId, userId, clientId,
                            activities, curstate):
        if ftlog.is_debug():
            ftlog.debug('TYActivitySystemImpl._getConfigForClient actName:',
                        actName, ' gameId:', gameId, ' userId:', userId,
                        ' clientId:', clientId, ' curstate:', curstate)

        actObj = self.getActivityObj(actName)
        if not actObj or not actObj.checkOperative():
            return

        condition = actObj._serverConf.get('condition')
        if condition is not None:
            condition = UserConditionRegister.decodeFromDict(condition)
            if not condition.check(HALL_GAMEID, userId, clientId,
                                   pktimestamp.getCurrentTimestamp()):
                return

        configForClient = actObj.getConfigForClient(gameId, userId, clientId)
        if configForClient:
            configForClient['state'] = curstate
            activities.append(configForClient)
コード例 #36
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
コード例 #37
0
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)
コード例 #38
0
 def _withdrawConf(cls, userId, gameId, clientId):
     from hall.entity.hallusercond import UserConditionRegister
     withdrawAmount = 5
     condList = getWithdrawConf().get('withdrawAmount')
     for conditon in condList:
         conD = conditon.get('conditions')
         cond = UserConditionRegister.decodeFromDict(conD)
         retCheck = cond.check(DIZHU_GAMEID, userId, clientId, pktimestamp.getCurrentTimestamp())
         if retCheck:
             withdrawAmount = conditon.get('amount')
             break
     openTimeList = getWithdrawConf().get('openTimeList', [])
     openTimeDesc = getWithdrawConf().get('openTimeDesc', '')
     msg = MsgPack()
     msg.setCmd('dizhu')
     msg.setResult('openTimeList', openTimeList)
     msg.setResult('openTimeDesc', openTimeDesc)
     msg.setResult('action', 'coupon_withdraw')
     msg.setResult('withdrawAmount', withdrawAmount)
     if ftlog.is_debug():
         ftlog.debug('SegmentMatchHandler._withdrawConf',
                    'userId=', userId,
                    'withdrawAmount=', withdrawAmount)
     return msg
コード例 #39
0
def _reloadConf():
    global _conf
    newConf = RPMainConf()
    
    conf = configure.getGameJson(HALL_GAMEID, 'red_packet_main', {})
    startDT = conf.get('startTime')
    if startDT is not None:
        newConf.startDT = datetime.strptime(startDT, '%Y-%m-%d %H:%M:%S')
    stopDT = conf.get('stopTime')
    if stopDT is not None:
        newConf.stopDT = datetime.strptime(stopDT, '%Y-%m-%d %H:%M:%S')
    inviteTodotaskD = conf.get('inviteTodotask')
    if inviteTodotaskD is not None:
        newConf.inviteTodotaskFac = TodoTaskRegister.decodeFromDict(inviteTodotaskD)

    oldInviteTodotaskD = conf.get('oldInviteTodotask')
    if oldInviteTodotaskD:
        newConf.oldInviteTodotaskFac = TodoTaskRegister.decodeFromDict(oldInviteTodotaskD)

    newConf.rewards = []
    for reward in conf.get('rewards', []):
        cond = None
        content = None
        condD = reward.get('condition')
        if condD:
            cond = UserConditionRegister.decodeFromDict(condD)
        content = TYContentRegister.decodeFromDict(reward.get('content'))
        newConf.rewards.append((cond, content))
    
    _conf = newConf    
    
    ftlog.info('hall_red_packet_main._reloadConf ok',
               'startDT=', newConf.startDT,
               'stopDT=', newConf.stopDT,
               'inviteTodotaskFac=', newConf.inviteTodotaskFac,
               'oldInviteTodotaskFac=', newConf.oldInviteTodotaskFac)
コード例 #40
0
ファイル: hallgamelist2.py プロジェクト: zhaozw/hall37
 def _decodeFromDictImpl(self, d):
     self.params = d.get('params', {})
     self.conditions = UserConditionRegister.decodeList(d.get('conditions', []))
コード例 #41
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