Exemplo n.º 1
0
    def decodeFromDict(self, d):
        self.base = d.get('base')
        if not isinstance(self.base, int):
            raise TYBizConfException('MatchScoreGrowRate.base must be int > 0')

        self.incr = d.get('incr')
        if not isinstance(self.incr, int):
            raise TYBizConfException('MatchScoreGrowRate.incr must be int > 0')

        return self
Exemplo n.º 2
0
 def decodeFromDict(cls, d):
     assetKindId = d.get('itemId')
     if not isstring(assetKindId):
         raise TYBizConfException(d, 'MatchFee.itemId must be string')
     count = d.get('count')
     if not isinstance(count, int):
         raise TYBizConfException(d, 'MatchFee.count must be int')
     params = d.get('params', {})
     if not isinstance(params, dict):
         raise TYBizConfException(d, 'MatchFee.params must be dict')
     desc = d.get('desc', {})
     if not isstring(desc):
         raise TYBizConfException(d, 'MatchFee.desc must be string')
     return MatchFee(TYContentItem(assetKindId, count), params, desc)
Exemplo n.º 3
0
    def decodeFromDict(self, d):
        self.conf = d
        self.rankRange = d.get('rankRange')
        if not isinstance(self.rankRange, list) or len(self.rankRange) != 2:
            raise TYBizConfException(d, 'MatchRankRewards.rankRange must be [rankStart, rankStop]')

        if not isinstance(self.rankRange[0], int) or not isinstance(self.rankRange[1], int):
            raise TYBizConfException(d, 'MatchRankRewards.rankRange must be [int, int]')

        if self.rankRange[0] != -1 and self.rankRange[1] < self.rankRange[0]:
            raise TYBizConfException(d, 'MatchRankRewards.rankRange.rankStop must >= rankStart')

        self.desc = d.get('desc', '')
        if not isstring(self.desc):
            raise TYBizConfException(d, 'MatchRankRewards.desc must dict')

        self.message = d.get('message', '')
        if not isstring(self.message):
            raise TYBizConfException(d, 'MatchRankRewards.message must be string')

        self.rewards = []
        for reward in d.get('rewards'):
            if not isinstance(reward, dict):
                raise TYBizConfException(reward, 'reward item must dict')
            itemId = reward.get('itemId', None)
            if not isstring(itemId) or not itemId:
                raise TYBizConfException(reward, 'reward item.name must be not empty string')
            count = reward.get('count', None)
            if not isinstance(count, (int, float)) or count < 0:
                raise TYBizConfException('reward item.count must be int or float >= 0')
            if count > 0:
                self.rewards.append(reward)

        return self
Exemplo n.º 4
0
 def decodeFromDict(self, d):
     super(TYItemActionConditionCanOpenFlag, self).decodeFromDict(d)
     self.gameId = self.params.get('gameId', tyglobal.gameId())
     if not isinstance(self.gameId, int) or self.gameId <= 0:
         raise TYBizConfException(
             self.params,
             'TYItemActionConditionCanOpenFlag.params.gameId must = 0')
     return self
Exemplo n.º 5
0
    def decodeFromDict(self, d):
        self.rate = d.get('rate')
        if (not isinstance(self.rate, (int, float))
            or self.rate < 0
            or self.rate > 1):
            raise TYBizConfException(d, 'MatchPlayerScoreCalcFactoryPercent.rate must be int or float in [0, 1]')

        return self
Exemplo n.º 6
0
    def decodeFromDict(self, d):
        self.riseUserRefer = d.get('rise.user.refer')

        if not isinstance(self.riseUserRefer, int) or self.riseUserRefer <= 0:
            raise TYBizConfException(
                d, 'StageMatchRulesConfASS.rise.user.refer must be int > 0')

        self.baseScoreGrowTimes = d.get('score.base.grow.times')

        if not isinstance(self.baseScoreGrowTimes, int):
            raise TYBizConfException(
                d,
                'StageMatchRulesConfASS.score.base.grow.times must be int >= 0'
            )

        self.baseScoreGrowFactory = MatchBaseScoreGrowFactoryRegister(
        ).decodeFromDict(d.get('score.base.grow'))
        self.loseScoreCalc = MatchLoseScoreRegister().decodeFromDict(
            d.get('score.lose'))
Exemplo n.º 7
0
    def decodeFromDict(self, d):
        self.name = d.get('name')
        if not isstring(self.name):
            raise TYBizConfException(
                d, 'StageMatchConf.name must be not empty string')
        self.desc = d.get('desc')
        # TODO 德州9人桌不满
        self.tableSeatCount = d.get('table.seat.count')
        if not isinstance(self.tableSeatCount,
                          int) or self.tableSeatCount <= 0:
            raise TYBizConfException(
                d, 'StageMatchConf.table.seat.count must be int > 0')

        self.startConf = MatchStartConf().decodeFromDict(d.get('start'))

        self.stages = []
        for i, stageConfD in enumerate(d.get('stages')):
            stageConf = StageConf().decodeFromDict(stageConfD)
            stageConf.stageIndex = i
            self.stages.append(stageConf)

        self.fees = []
        fees = d.get('fees', [])
        for fee in fees:
            matchFee = MatchFee().decodeFromDict(fee)
            if matchFee.fee and matchFee.fee.count > 0:
                self.fees.append(matchFee)

        self.rankRewardsList = []
        rankRewardsList = d.get('rank.rewards', [])
        if not isinstance(rankRewardsList, list):
            raise TYBizConfException(
                d, 'StageMatchConf.rank.rewards must be list')
        for rankRewards in rankRewardsList:
            self.rankRewardsList.append(
                MatchRankRewards().decodeFromDict(rankRewards))

        self.tipsConf = d.get('tips', {})
        if not isinstance(self.tipsConf, dict):
            raise TYBizConfException(d, 'StageMatchConf.tips must be dict')

        self.recordId = self.matchId
        return self
Exemplo n.º 8
0
    def decodeFromDict(self, d):
        self.name = d.get('name')
        if not isstring(self.name):
            raise TYBizConfException(
                d, 'StageConf.name must be not empty string')

        self.cardCount = d.get('card.count')
        if not isinstance(self.cardCount, int) or self.cardCount <= 0:
            raise TYBizConfException(d, 'StageConf.card.count must be int > 0')

        self.riseUserCount = d.get('rise.user.count')
        if not isinstance(self.riseUserCount, int) or self.riseUserCount <= 0:
            raise TYBizConfException(
                d, 'StageConf.rise.user.count must be int > 0')

        self.baseScore = d.get('score.base')
        if not isinstance(self.baseScore, int):
            raise TYBizConfException(d, 'StageConf.chip.base must be int > 0')

        # decodeFromDict 不是类方法了
        self.scoreCalcFac = MatchPlayerScoreCalcFactoryRegister(
        ).decodeFromDict(d.get('score.calc'))

        self.userCountPerGroup = d.get('grouping.user.count', 0)
        if not isinstance(self.userCountPerGroup,
                          int) or self.userCountPerGroup < 0:
            raise TYBizConfException(
                d, 'StageConf.grouping.user.count must be int >= 0')

        self.rankRewardsList = []
        rankRewardsList = d.get('rank.rewards', [])
        if not isinstance(rankRewardsList, list):
            raise TYBizConfException(d, 'StageConf.rank.rewards must be list')
        for rankRewards in rankRewardsList:
            self.rankRewardsList.append(
                MatchRankRewards().decodeFromDict(rankRewards))

        self.delayEntryTimes = d.get('delayEntryTimes', 0)
        if not isinstance(self.delayEntryTimes,
                          (int, float)) or self.delayEntryTimes < 0:
            raise TYBizConfException(
                d, 'StageConf.delayEntryTimes must be (int, float) >= 0')

        self.params = d.get('params', {})
        if not isinstance(self.params, dict):
            raise TYBizConfException(d, 'StageConf.params must be dict')

        # 赛制配置
        self.rulesConf = StageMatchRulesConfRegister().decodeFromDict(
            d.get('rules'))

        return self
Exemplo n.º 9
0
 def decodeFromDict(self, d):
     super(TYItemActionConditionTimeRange, self).decodeFromDict(d)
     startTime = self.params.get('startTime')
     if startTime is not None:
         try:
             self.startTime = fttime.timestrToTimestamp(
                 startTime, '%Y-%m-%d %H:%M:%S')
         except:
             raise TYBizConfException(
                 startTime,
                 'TYItemActionConditionTimeRange.params.startTime must be timestr'
             )
     stopTime = self.params.get('stopTime')
     if stopTime is not None:
         try:
             self.stopTime = fttime.timestrToTimestamp(
                 stopTime, '%Y-%m-%d %H:%M:%S')
         except:
             raise TYBizConfException(
                 stopTime,
                 'TYItemActionConditionTimeRange.params.stopTime must be timestr'
             )
     return self
Exemplo n.º 10
0
    def decodeFromDict(self, d):
        self.type = d.get('type')
        if not MatchStartType.isValid(self.type):
            raise TYBizConfException(
                d, 'MatchStartConf.type must in %s' %
                (MatchStartType.VALID_TYPES))

        self.feeType = d.get('fee.type')
        if not MatchFeeType.isValid(self.feeType):
            raise TYBizConfException(
                d, 'MatchStartConf.fee.type must in %s' %
                (MatchFeeType.VALID_TYPES))

        self.maxPlayTime = d.get('maxplaytime')
        if not isinstance(self.maxPlayTime, int) or self.maxPlayTime <= 0:
            raise TYBizConfException(
                d, 'MatchStartConf.maxplaytime must int > 0')

        self.tableTimes = d.get('table.times', 400)
        if not isinstance(self.tableTimes, int) or self.tableTimes <= 0:
            raise TYBizConfException(
                d, 'MatchStartConf.table.times must int > 0')

        self.tableAvgTimes = d.get('table.avg.times', 400)
        if not isinstance(self.tableAvgTimes, int) or self.tableAvgTimes <= 0:
            raise TYBizConfException(
                d, 'MatchStartConf.table.avg.times must int > 0')

        if self.isUserCountType():
            # 人满开赛的配置
            self.userCount = d.get('user.size', None)
            if not isinstance(self.userCount, int) or self.userCount <= 0:
                raise TYBizConfException(
                    d, 'MatchStartConf.user.size must int > 0')
        else:
            self.userMinCount = d.get('user.minsize')
            if not isinstance(self.userMinCount,
                              int) or self.userMinCount <= 0:
                raise TYBizConfException(
                    'MatchStartConf.user.minsize must be int > 0')

            self.userMaxCount = d.get('user.maxsize')
            if not isinstance(self.userMaxCount,
                              int) or self.userMaxCount <= 0:
                raise TYBizConfException(
                    'MatchStartConf.user.maxsize must be int > 0')

            self.signinMaxCount = d.get('signin.maxsize', self.userMaxCount)
            if not isinstance(self.signinMaxCount,
                              int) or self.signinMaxCount <= 0:
                raise TYBizConfException(
                    'MatchStartConf.signin.maxsize must be int > 0')

            self.userMaxCountPerMatch = self.userMaxCount
            self.signinMaxCountPerMatch = self.signinMaxCount

            self.signinTimes = d.get('signin.times')
            if not isinstance(self.signinTimes, int) or self.signinTimes < 0:
                raise TYBizConfException(
                    'MatchStartConf.signin.times must be int >= 0')

            self.signinTimesStr = d.get('signinTimesStr', '')
            if not isstring(self.signinTimesStr):
                raise TYBizConfException(
                    'MatchStartConf.signinTimesStr must be string')

            self.prepareTimes = d.get('prepare.times', 5)
            if not isinstance(self.prepareTimes, int) or self.prepareTimes < 0:
                raise TYBizConfException(
                    'MatchStartConf.prepare.times must be int >= 0')

            self.userNextGroup = d.get('user.next.group')
            if not isinstance(self.userNextGroup, (int, float)):
                raise TYBizConfException(
                    'MatchStartConf.user.next.group must be float')

            self.selectFirstStage = d.get('selectFirstStage', 0)
            if self.selectFirstStage not in (0, 1):
                raise TYBizConfException(
                    'MatchStartConf.selectFirstStage must in (0, 1)')

            self._cron = FTCron(d.get('times'))
        return self
Exemplo n.º 11
0
    def decodeFromDict(self, d):
        self.loseScore = d.get('loseScore')
        if not isinstance(self.loseScore, int):
            raise TYBizConfException(d, 'MatchLoseScoreCalcFixed.loseScore must be int')

        return self
Exemplo n.º 12
0
    def decodeFromDict(self, d):
        self.rate = d.get('rate')
        if not isinstance(self.rate, (int, float)) or self.rate < 0 or self.rate > 1:
            raise TYBizConfException(d, 'MatchLoseScoreRate.rate must be int in [0, 1]')

        return self
Exemplo n.º 13
0
    def decodeFromDict(self, d):
        self.rate = d.get('rate')
        if not isinstance(self.rate, (int, float)) or self.rate <= 0:
            raise TYBizConfException(d, 'MatchBaseScoreGrowRate.rate must be int or float > 0')

        return self
Exemplo n.º 14
0
    def decodeFromDict(self, d):
        self.base = d.get('base')
        if not isinstance(self.base, (int, float)):
            raise TYBizConfException(d, 'MatchPlayerScoreCalcFactorySqrt.base must be int or float')

        return self
Exemplo n.º 15
0
    def decodeFromDict(self, d):
        self.score = d.get('score')
        if not isinstance(self.score, int):
            raise TYBizConfException(d, 'MatchPlayerScoreCalcSet.score must be int')

        return self