def checkValid(self): if not isinstance(self.startRank, int) or self.startRank < -1: raise ConfigException('rank.start must be int >= -1') if not isinstance(self.endRank, int) or self.endRank < -1: raise ConfigException('rank.end must be int >= -1') if self.endRank != -1 and self.endRank < self.startRank: raise ConfigException('rank.end must greater than rewards.rank.start') return self
def checkValid(self): if not isinstance(self.infos, list): raise ConfigException('tips.infos must be array') for info in self.infos: if not isstring(info): raise ConfigException('tips.infos.item must be string') if not isinstance(self.interval, int) or self.interval <= 0: raise ConfigException('tips.interval must be int > 0') return self
def checkValid(self): if not GroupingType.isValid(self.type): raise ConfigException('matchs.grouping.type must in:' + str(GroupingType.VALID_TYPES)) if GroupingType.TYPE_GROUP_COUNT: if not isinstance(self.groupCount, int) or self.groupCount <= 0: raise ConfigException('matchs.grouping.group.count must in:' + str(GroupingType.VALID_TYPES)) else: if not isinstance(self.userCount, int) or self.userCount <= 0: raise ConfigException('matchs.grouping.user.count must be int > 0') return self
def parse(cls, gameId, roomId, matchId, name, conf): ret = MatchConfig() ret.conf = conf ret.gameId = gameId ret.roomId = roomId ret.matchId = matchId ret.name = name ret.desc = conf.get('desc', '') ret.descMultiLang = conf.get('descMultiLang', {}) ret.tableSeatCount = conf.get('table.seat.count', None) ret.recordId = conf.get('recordId', matchId) ret.outAssWait = conf.get('outAssWait', 0) ret.outAssKeepReferCount = conf.get('outAssKeepReferCount', 0) start = conf.get('start', None) if not isinstance(start, dict): raise ConfigException('start must be dict') ret.start = StartConfig.parse(start) fees = conf.get('fees', []) ret.fees = [] for fee in fees: matchFee = MatchFee.decodeFromDict(fee) if matchFee.count > 0: ret.fees.append(matchFee) ret.tips = cls.getTipsConfigClass().parse(conf.get('tips', {})) ret.stages = [] stages = conf.get('stages', None) if not isinstance(stages, list): raise ConfigException('stages must be list') for i, stage in enumerate(stages): stage = StageConfig.parse(stage) stage.index = i ret.stages.append(stage) for i in xrange(1, len(ret.stages)): if ret.stages[i].chipBase <= 0: ret.stages[i].chipBase = ret.stages[i - 1].chipBase if ret.stages[i].chipTimes <= 0: ret.stages[i].chipTimes = ret.stages[i - 1].chipTimes if ret.stages[i].chipGrow <= 0: ret.stages[i].chipGrow = ret.stages[i - 1].chipGrow ret.rankRewardsList = [] rankRewardsList = conf.get('rank.rewards') if rankRewardsList is not None: if not isinstance(rankRewardsList, list): raise ConfigException('rank.rewards must be list') for rankRewards in rankRewardsList: ret.rankRewardsList.append(cls.getRankRewardsClass().parse(rankRewards)) ret.rankRewardsDesc = cls.getRankRewardsClass().buildRewardDescList(ret.rankRewardsList) return ret.checkValid()
def parse(cls, conf): ret = MatchingConfig() ret.conf = conf grouping = conf.get('grouping', None) if not isinstance(grouping, dict): raise ConfigException('matchs item.grouping must be dict') ret.groupingConf = GroupingConfig.parse(grouping) ret.stages = cls._parseStages(conf) return ret.checkValid()
def parse(cls, conf): ret = cls() ret.conf = conf ret.startRank = conf['ranking']['start'] ret.endRank = conf['ranking']['end'] rewards = conf.get('rewards', []) ret.rewards = [] for reward in rewards: if not isinstance(reward, dict): raise ConfigException('reward item must dict') itemId = reward.get('itemId', None) if not isstring(itemId) or not itemId: raise ConfigException('reward item.name must be not empty string') count = reward.get('count', None) if not isinstance(count, int) or count < 0: raise ConfigException('reward item.count must be int >= 0') if count > 0: ret.rewards.append(reward) ret.desc = conf['desc'] ret.message = conf.get('message', None) ret.todotask = conf.get('todotask', None) return ret.checkValid()
def _parseStages(cls, conf): stageConfs = conf.get('stages', None) if not isinstance(stageConfs, list) or len(stageConfs) <= 0: raise ConfigException('matchs.stages must be not empty list') stages = [] for stageConf in stageConfs: stage = StageConfig.parse(stageConf) stage.index = len(stages) stages.append(stage) for i in xrange(1, len(stages)): if stages[i].chipBase <= 0: stages[i].chipBase = stages[i - 1].chipBase if stages[i].chipTimes <= 0: stages[i].chipTimes = stages[i - 1].chipTimes if stages[i].chipGrow <= 0: stages[i].chipGrow = stages[i - 1].chipGrow return stages
def checkValid(self): if not self.gameId in MatchConfig.VALID_GAMEIDS: raise ConfigException('gameId must in:' + str(MatchConfig.VALID_GAMEIDS)) if not isinstance(self.matchId, int): raise ConfigException('matchId must be int') if not isinstance(self.tableSeatCount, int) or self.tableSeatCount <= 0: raise ConfigException('table.seat.count must be int > 0') if not isinstance(self.recordId, int): raise ConfigException('recordId must be int') if not self.outAssWait in (0, 1): raise ConfigException('outAssWait must be int in (0,1)') if not self.outAssKeepReferCount in (0, 1): raise ConfigException('outAssKeepReferCount must be int in (0,1)') return self
def parse(cls, conf): ret = StageConfig() ret.conf = conf # 通用配置 ret.type = conf.get('type', None) ret.name = conf.get('name', None) ret.animationType = conf.get('animation.type', -1) ret.seatQueuing = conf.get('seat.principles', None) ret.cardCount = conf.get('card.count', None) ret.riseUserCount = conf.get('rise.user.count', None) ret.chipBase = conf.get('chip.base', None) ret.chipTimes = conf.get('chip.times', None) ret.chipGrow = conf.get('chip.grow', None) ret.chipUser = conf.get('chip.user', None) ret.chipUserRate = conf.get('chip.user.2.rate', None) ret.chipUserBase = conf.get('chip.user.3.base', None) # ASS赛制配置 ret.riseUserRefer = conf.get('rise.user.refer', None) ret.loseUserChip = conf.get('lose.user.chip', None) ret.chipGrowBase = conf.get('chip.grow.base', None) or 0 ret.chipGrowIncr = conf.get('chip.grow.incr', None) or 0 ret.groupingType = conf.get('grouping.type', GroupingType.TYPE_NO_GROUP) ret.groupingUserCount = conf.get('grouping.user.count', None) ret.groupingGroupCount = conf.get('grouping.group.count', None) ret.rankRewardsList = [] rankRewardsList = conf.get('rank.rewards') if rankRewardsList is not None: if not isinstance(rankRewardsList, list): raise ConfigException('rank.rewards must be list') for rankRewards in rankRewardsList: ret.rankRewardsList.append(RankRewards.parse(rankRewards)) ret.rankRewardsDesc = RankRewards.buildRewardDescList(ret.rankRewardsList) return ret.checkValid()
def checkValid(self): if not StageType.isValid(self.type): raise ConfigException('Stage.type must in:' + str(StageType.VALID_TYPES)) if not isstring(self.name): raise ConfigException('Stage.name must be string') if not AnimationType.isValid(self.animationType): raise ConfigException('Stage.animationType must in:' + str(AnimationType.VALID_TYPES)) if not SeatQueuingType.isValid(self.seatQueuing): raise ConfigException('Stage.seat.principles must in:' + str(SeatQueuingType.VALID_TYPES)) if (not isinstance(self.cardCount, int) or self.cardCount <= 0 or self.cardCount > MAX_CARD_COUNT): raise ConfigException('Stage.card.count must in:' + str((1, MAX_CARD_COUNT))) if (not isinstance(self.riseUserCount, int) or self.riseUserCount <= 0): raise ConfigException('Stage.raise.user.count must be integer >= 0') if not isinstance(self.chipBase, int): raise ConfigException('Stage.chip.base must be integer') if not isinstance(self.chipTimes, int): raise ConfigException('Stage.chip.times must be integer') if (not isinstance(self.chipGrow, (int, float)) or not self.chipGrow >= 0): raise ConfigException('Stage.chip.grow must be int or float >= 0.0') if not isinstance(self.chipUser, int): raise ConfigException('Stage.chip.user must be integer') if self.chipUser == ScoreCalcType.BAI_FEN_BI: if (not isinstance(self.chipUserRate, float) or not self.chipUserRate > 0): raise ConfigException('Stage.chip.user.2.rate must be float > 0.0') elif self.chipUser == ScoreCalcType.KAI_FANG_FANG_DA: if (not isinstance(self.chipUserBase, int) or not self.chipUserBase > 0): raise ConfigException('Stage.chip.user.3.base must be integer > 0.0') if self.type == StageType.ASS: if (not isinstance(self.riseUserRefer, int) or self.riseUserRefer < self.riseUserCount): raise ConfigException('Stage.raise.user.refer must be integer >= raise.user.count') if (not isinstance(self.loseUserChip, (int, float))): raise ConfigException('Stage.lose.user.chip must be integer or float') if (not isinstance(self.chipGrowBase, (int, float))): raise ConfigException('Stage.chip.grow.base must be integer or float') if (not isinstance(self.chipGrowIncr, (int, float))): raise ConfigException('Stage.chip.grow.incr must be integer or float') if not GroupingType.isValid(self.groupingType): raise ConfigException('Stage.grouping.type must in:' + str(GroupingType.VALID_TYPES)) if self.groupingType == GroupingType.TYPE_GROUP_COUNT: if not isinstance(self.groupingGroupCount, int) or self.groupingGroupCount <= 0: raise ConfigException('Stage.grouping.group.count must be integer > 0') elif self.groupingType == GroupingType.TYPE_USER_COUNT: if not isinstance(self.groupingUserCount, int) or self.groupingUserCount <= 0: raise ConfigException('Stage.grouping.user.count must be integer > 0') return self
def checkValid(self): if not MatchType.isValid(self.type): raise ConfigException('start.type must in:' + str(MatchType.VALID_TYPES)) if not FeesType.isValid(self.feeType): raise ConfigException('start.fee.type must in:' + str(FeesType.VALID_TYPES)) if not isinstance(self.maxPlayTime, int) or self.maxPlayTime <= 0: raise ConfigException('start.maxplaytime must be int > 0') if not isinstance(self.tableTimes, int) or self.tableTimes <= 0: raise ConfigException('start.tableTimes must be int > 0') if not isinstance(self.tableAvgTimes, int) or self.tableAvgTimes <= 0: raise ConfigException('start.tableAvgTimes must be int > 0') if not isinstance(self.startMatchSpeed, int) or self.startMatchSpeed <= 0: raise ConfigException('start.speed must be int > 0') if self.isUserCountType(): if not isinstance(self.userCount, int) or self.userCount <= 0: raise ConfigException('start.user.size must be int > 0') else: if not isinstance(self.userMaxCount, int) or self.userMaxCount <= 0: raise ConfigException('start.user.maxsize must be int > 0') if not isinstance(self.userMinCount, int) or self.userMinCount <= 0: raise ConfigException('start.user.minsize must be int > 0') if not isinstance(self.signinMaxCount, int) or self.signinMaxCount <= 0: raise ConfigException('start.signin.minsize must be int > 0') if self.signinMaxCount < self.userMinCount: raise ConfigException('start.signin.minsize must > start.user.maxsize') if self.userMaxCount < self.userMinCount: raise ConfigException('start.user.maxsize must greater than start.user.minsize') if not isinstance(self.signinTimes, int) or self.signinTimes < 0: raise ConfigException('start.signin.times must be int >= 0') if not isstring(self.signinTimesStr): raise ConfigException('start.signin.times.str must be string') if not isinstance(self.prepareTimes, int) or self.signinTimes < 0: raise ConfigException('start.prepare.times must be int >= 0') if not isinstance(self.times, dict): raise ConfigException('start.times must be dict') if not self._cron: raise ConfigException('start.times is invalid') if not isinstance(self.userNextGroup, (int, float)): raise ConfigException('start.user.next.group must be float') if self.selectFirstStage not in (0, 1): raise ConfigException('start.selectFirstStage must in (0, 1)') return self