def fromDict(self, d): self.switch = d.get('switch') if not isinstance(self.switch, int): raise TYBizConfException( d, 'TreasureChestTotalConf.switch must be int') self.totalCount = d.get('totalCount') if not isinstance(self.totalCount, int): raise TYBizConfException( d, 'TreasureChestTotalConf.totalCount must be int') self.clientIds = d.get('clientIds') if not isinstance(self.clientIds, list): raise TYBizConfException( d, 'TreasureChestTotalConf.clientIds must be list') treasureChest = d.get('treasureChest') if not isinstance(treasureChest, dict): raise TYBizConfException( d, 'TreasureChestTotalConf.treasureChest must be dict') self.treasureChest = TreasureChestConf().fromDict(treasureChest) if d.get('winStreak'): winStreak = d.get('winStreak') if not isinstance(winStreak, dict): raise TYBizConfException( d, 'TreasureChestTotalConf.winStreak must be int') self.winStreakChest = WinStreakChestConf().fromDict(winStreak) return self
def decodeFromDict(self, d): self.inspector = TYTaskInspectorRegister.decodeFromDict(d['inspector']) self.segment_id = d["segmentId"] reward_content = d.get('rewardContent') reward_multi_rate = d.get("multiReward", {}).get("rewardMultiRate", 0) if not isinstance(reward_multi_rate, (int, float)): raise TYBizConfException(d, 'task.rewardMultiRate must be number') self.totalLimit = d.get('total', 0) if not isinstance(self.totalLimit, int): raise TYBizConfException(d, 'task.totalLimit must be int') if reward_content: multi_reward_content = copy.deepcopy(reward_content) if reward_multi_rate > 0: for item in multi_reward_content.get("items", []): if "count" not in item: continue item["count"] += int(item["count"] * reward_multi_rate) self.reward_content = TYContentRegister.decodeFromDict( reward_content) self.multi_reward_content = TYContentRegister.decodeFromDict( multi_reward_content) self.reward_mail = d.get('rewardMail', '') if not isstring(self.reward_mail): raise TYBizConfException(d, 'task.rewardMail must be string') return self
def reloadConf(self): taskKindMap = {} taskKindList = [] acts = [] conf = configure.getGameJson(HALL_GAMEID, 'red_packet_task', {}) closed = conf.get('closed', 0) if not isinstance(closed, int) or closed not in (0, 1): raise TYBizConfException(conf, 'closed must be int in (0, 1)') for actD in conf.get('acts', []): act = RPAct().fromDict(actD) acts.append(act) for taskKindConf in conf.get('tasks', []): taskKind = RPTaskKind().decodeFromDict(taskKindConf) if taskKind.kindId in taskKindMap: raise TYBizConfException( conf, 'Duplicate taskKind %s' % (taskKind.kindId)) taskKindMap[taskKindConf['kindId']] = taskKind taskKindList.append(taskKind) self._unregisterEvents(self._taskKindList) self._registerEvents(taskKindList) self._taskKindList = taskKindList self._taskKindMap = taskKindMap self._acts = acts self._closed = closed ftlog.info('RPTaskSystem.reloadConf ok', 'closed=', self._closed, 'taskList=', [taskKind.kindId for taskKind in self._taskKindList], 'acts=', [act.todotaskFac for act in self._acts])
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
def _reloadConf(): global _freeItemMap global _templateMap freeItemMap = {} templateMap = {} conf = hallconf.getFreeConf() for freeDict in conf.get('freeItems', []): freeItem = HallFree().decodeFromDict(freeDict) if freeItem.freeItemId in freeItemMap: raise TYBizConfException( freeDict, 'Duplicate freeId %s' % (freeItem.freeItemId)) freeItemMap[freeItem.freeItemId] = freeItem if ftlog.is_debug(): ftlog.debug('hallfree._reloadConf freeIds=', freeItemMap.keys()) for templateDict in conf.get('templates', []): template = HallFreeTemplate().decodeFromDict(templateDict, freeItemMap) if template.name in templateMap: raise TYBizConfException( templateDict, 'Duplicate templateName %s' % (template.name)) templateMap[template.name] = template _freeItemMap = freeItemMap _templateMap = templateMap ftlog.debug('hallfree._reloadConf successed freeIds=', _freeItemMap.keys(), 'templateNames=', _templateMap.keys())
def decodeFromDict(self, d): startTimeStr = d.get('startTime') endTimeStr = d.get('endTime') if startTimeStr: self.startDT = datetime.strptime(startTimeStr, '%Y-%m-%d %H:%M:%S').timetuple() if endTimeStr: self.endDT = datetime.strptime(endTimeStr, '%Y-%m-%d %H:%M:%S').timetuple() if self.endDT and self.startDT and self.endDT < self.startDT: raise TYBizConfException(d, 'BuyCountLimit.endTime must >= BuyCountLimit.startTime') periods = d.get('periods', []) if not periods: raise TYBizConfException(d, 'BuyCountLimit.periods must not empty list') for period in periods: limit = TimePeriodLimit().decodeFromDict(period) if limit.periodId in self.periodLimitMap: raise TYBizConfException(d, 'Duplicate BuyCountLimit period %s' % (limit.periodId)) self.periodLimitList.append(limit) self.periodLimitMap[limit.periodId] = limit self.outTimeFailure = d.get('outTimeFailure', '') if not isstring(self.outTimeFailure) or not self.outTimeFailure: raise TYBizConfException(d, 'BuyCountLimit.outTimeFailure must be not empty string') return self
def decodeFromDict(self, d): self.couponId = d.get('id') if not self.couponId: raise TYBizConfException(d, 'couponItem.id must be set') self.couponCount = d.get('couponCount') if not isinstance(self.couponCount, int) or self.couponCount <= 0: raise TYBizConfException(d, 'couponItem.couponCount must be int > 0') self.itemCount = d.get('itemCount') if not isinstance(self.itemCount, int) or self.itemCount <= 0: raise TYBizConfException(d, 'couponItem.itemCount must be int > 0') self.itemUnits = d.get('itemUnits', '') if not isstring(self.itemUnits): raise TYBizConfException(d, 'couponItem.itemUnits must be string') self.itemName = d.get('itemName') if not isstring(self.itemName) or not self.itemName: raise TYBizConfException(d, 'couponItem.itemCount must be not empty string') self.itemType = d.get('itemType') if self.itemType not in self.VALID_TYPES: raise TYBizConfException(d, 'couponItem.itemType must in %s' % (self.VALID_TYPES)) self.pic = d.get('pic', '') if not isstring(self.pic): raise TYBizConfException(d, 'couponItem.pic must be string') self.tag = d.get('tag', '') if not isstring(self.tag): raise TYBizConfException(d, 'couponItem.tag must be string') self.mailOk = d.get('mailOk', '') if not isstring(self.mailOk): raise TYBizConfException(d, 'couponItem.mailOk must be string') self.mailFail = d.get('mailFail', '') if not isstring(self.mailFail): raise TYBizConfException(d, 'couponItem.mailFail must be string') return self
def decodeFromDict(self, d): self.messageNumber = d.get('messageNumber') if not isinstance(self.messageNumber, int) or self.messageNumber < 0: raise TYBizConfException(d, 'WorshipConf.messageNumber must be int and >0') self.rankLimit = d.get('rankLimit') if not isinstance(self.rankLimit, int) or self.rankLimit < 0: raise TYBizConfException(d, 'WorshipConf.rankLimit must be int and >0') self.messages = d.get('messages') if not isinstance(self.messages, list): raise TYBizConfException(d, 'WorshipConf.messages must be list') self.foods = d.get('foods') if not isinstance(self.foods, list): raise TYBizConfException(d, 'WorshipConf.foods must be list') tempFoods = [] for foodDict in self.foods: tempFoods.append(Food().decodeFromDict(foodDict)) self.foods = tempFoods self.userFoods = d.get('userFoods') if not isinstance(self.userFoods, list): raise TYBizConfException(d, 'WorshipConf.userFoods must be list') return self
def _decodeFromDictImpl(self, d): self._prizes = [] self._limitCount = d.get('limitCount', -1) if not isinstance(self._limitCount, int) or self._limitCount < -1: raise TYBizConfException(d, 'limitCount must be int >= -1') self._mail = d.get('mail', '') if not isstring(self._mail): raise TYBizConfException(d, 'mail must be string') self._timeCycle = TimeCycleRegister.decodeFromDict( d.get('limitTimeCycle')) for prize in d.get('prizes', []): payOrder = prize.get('payOrder') if not payOrder or not isinstance(payOrder, dict): raise TYBizConfException(prize, 'prize.payOrder must dict') content = TYContentRegister.decodeFromDict(prize.get('content')) self._prizes.append((payOrder, content)) self._hallGameIds = d.get('hallGameIds', []) if not isinstance(self._hallGameIds, list): raise TYBizConfException(d, 'BuySendPrize.hallGameIds must be list') for hallGameId in self._hallGameIds: if not isinstance(hallGameId, int): raise TYBizConfException( d, 'BuySendPrize.hallGameIds must be int list') return self
def decodeFromDict(self, d): startTimeStr = d.get('startTime') endTimeStr = d.get('endTime') self.periods = [] s = datetime.strptime(d.get('startTime'), '%H:%M').time() e = datetime.strptime(d.get('endTime'), '%H:%M').time() self.periodId = '%s-%s' % (startTimeStr, endTimeStr) s = s if s != self.timeZero else None e = e if e != self.timeZero else None if s != e: if (s is None or e is None) or (s < e): self.periods.append((s, e)) elif s > e: self.periods.append((s, None)) self.periods.append((None, e)) self.count = d.get('count') if not isinstance(self.count, int) or self.count < -1: raise TYBizConfException( d, 'TimePeriodLimit.count must be int >= -1') self.failure = d.get('failure', '') if not isstring(self.failure) or not self.failure: raise TYBizConfException( d, 'TimePeriodLimit.failure must be not empty string') return self
def _reloadConf(): global _promotionMap global _templateMap promotionMap = {} templateMap = {} conf = hallconf.getPromoteConf() for promotionDict in conf.get('promotions', []): promotion = HallPromotion().decodeFromDict(promotionDict) if promotion.promotionId in promotionMap: raise TYBizConfException( promotionDict, 'Duplicate promotionId %s' % (promotion.promotionId)) promotionMap[promotion.promotionId] = promotion if ftlog.is_debug(): ftlog.debug('hallpromote._reloadConf promotionIds=', promotionMap.keys()) for templateDict in conf.get('templates', []): template = HallPromoteTemplate().decodeFromDict( templateDict, promotionMap) if template.name in templateMap: raise TYBizConfException( templateDict, 'Duplicate templateName %s' % (template.name)) templateMap[template.name] = template _promotionMap = promotionMap _templateMap = templateMap ftlog.debug('hallpromote._reloadConf successed promotionIds=', _promotionMap.keys(), 'templateNames=', _templateMap.keys())
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
def _loadGameConf(gameId): conf = configure.getGameJson(gameId, 'share3', {}, 0) if not conf: return None, None sharePointMap = {} sharePointGroupMap = {} for gp in conf.get('groups', []): sharePointGroup = SharePointGroup3().decodeFromDict(gp) if sharePointGroup.groupId in sharePointGroupMap: raise TYBizConfException(gp, 'Duplicate sharePointGroupId %s' % (sharePointGroup.groupId)) sharePointGroupMap[sharePointGroup.groupId] = sharePointGroup if ftlog.is_debug(): ftlog.debug('hall_share3._loadGameConf', 'gameId=', gameId, 'groupIds=', sharePointGroupMap.keys()) for sp in conf.get('points', []): sharePoint = SharePoint3().decodeFromDict(sp) if sharePoint.pointId in sharePointMap: raise TYBizConfException(sp, 'Duplicate sharePointId %s' % (sharePoint.pointId)) if sharePoint.groupId: group = sharePointGroupMap.get(sharePoint.groupId) if not group: raise TYBizConfException(sp, 'Not found groupId %s for sharePoint %s' % (sharePoint.groupId, sharePoint.pointId)) sharePoint.group = group sharePointMap[sharePoint.pointId] = sharePoint return sharePointMap, sharePointGroupMap
def decodeFromDict(self, d): startTime = d.get('startTime') if startTime: try: self.startDT = datetime.strptime(startTime, '%Y-%m-%d %H:%M:%S') except: raise TYBizConfException( d, 'GiftConf.startTime must be datetime string with format %Y-%m-%d %H:%M:%S' ) endTime = d.get('endTime') if endTime: try: self.endDT = datetime.strptime(endTime, '%Y-%m-%d %H:%M:%S') except: raise TYBizConfException( d, 'GiftConf.endTime must be datetime string with format %Y-%m-%d %H:%M:%S' ) if self.startDT and self.endDT and self.endDT < self.startDT: raise TYBizConfException( d, 'GiftConf.endTime must ge than startTime') for giftD in d.get('gifts', []): productIds = giftD.get('productIds') if not productIds or not isinstance(productIds, list): raise TYBizConfException(d, 'GiftConf.productIds must be list') gift = GiftConf().decodeFromDict(giftD) for productId in productIds: self.giftMap[productId] = gift return self
def _decodeFromDictImpl(self, d): self.maxRankNum = d.get('maxRankNum') if not isinstance(self.maxRankNum, int): raise TYBizConfException( d, 'ActivityWxShareCharm.maxRankNum must be int') rankRewards = d.get('rankRewards') if not isinstance(rankRewards, list): raise TYBizConfException( d, 'ActivityWxShareCharm.rankRewards must be list') self.rankRewards = [ RankRewardItem().decodeFromDict(r) for r in rankRewards ] settleDayOrWeek = d.get('settleDayOrWeek', 'week') if not isstring(settleDayOrWeek) or (settleDayOrWeek not in ['day', 'week']): raise TYBizConfException( d, 'ActivityWxShareCharm.settleDayOrWeek must be str and in ["day", "week"]' ) self.settleDayOrWeek = settleDayOrWeek if ftlog.is_debug(): ftlog.debug('ActivityWxShareCharm._decodeFromDictImpl maxRankNum=', self.maxRankNum, 'rankRewards=', rankRewards, 'settleDayOrWeek=', self.settleDayOrWeek) return self
def reloadConf(self, conf): qqGroup = conf.get('qqGroup', '') if not isstring(qqGroup): raise TYBizConfException(conf, 'qqGroup must be string') instruction = conf.get('instruction', '') if not isstring(instruction): raise TYBizConfException(conf, 'instruction must be string') mailWhenCanExchange = conf.get('mailWhenCanExchange', '') if not isstring(mailWhenCanExchange): raise TYBizConfException(conf, 'mailWhenCanExchange must be string') items = conf.get('items', []) if not isinstance(items, list): raise TYBizConfException(conf, 'items must be list') couponItemList = [] couponItemMap = {} for item in items: couponItem = CouponItem().decodeFromDict(item) if couponItem.couponId in couponItemMap: raise TYBizConfException(item, 'Duplicate couponId %s' % (couponItem.couponId)) couponItemList.append(couponItem) couponItemMap[couponItem.couponId] = couponItem self._couponItemList = couponItemList self._couponItemMap = couponItemMap self._qqGroup = qqGroup self._instruction = instruction self._mailWhenCanExchange = mailWhenCanExchange ftlog.debug('CouponService.reloadConf successed gameId=', self.gameId, 'couponItems=', self._couponItemMap.keys(), 'qqGroup=', self._qqGroup, 'instruction=', self._instruction, 'mailWhenCanExchange=', self._mailWhenCanExchange)
def _reloadConf(): global _gameMap global _templateMap gameMap = {} templateMap = {} conf = hallconf.getGameList2Conf() for gameDict in conf.get('games', []): hallGame = HallGame().decodeFromDict(gameDict) if hallGame.gameId in gameMap: raise TYBizConfException(gameDict, 'Duplicate game %s' % (hallGame.gameId)) gameMap[hallGame.gameId] = hallGame for templateDict in conf.get('templates', []): template = HallUITemplate().decodeFromDict(templateDict) if template.name in templateMap: raise TYBizConfException( templateDict, 'Duplicate template name %s' % (template.name)) templateMap[template.name] = template for template in templateMap.values(): template.initWhenLoaded(gameMap) _gameMap = gameMap _templateMap = templateMap ftlog.debug('hallgamelist2._reloadConf successed gameIds=', gameMap.keys(), 'templateNames=', _templateMap.keys())
def fromDict(self, d): self.nRound = d.get('nRound') if not isinstance(self.nRound, int) or self.nRound <= 0: raise TYBizConfException(d, 'RoundConf.nRound must be int > 0') self.fee = d.get('fee') if not isinstance(self.fee, int) or self.fee < 0: raise TYBizConfException(d, 'RoundConf.fee must be int >= 0') return self
def fromDict(self, d): self.name = d.get('type') if not self.name or not isstring(self.name): raise TYBizConfException(d, 'PlayModeConfMin.name must be not empty string') self.displayName = d.get('name') if not self.displayName or not isstring(self.displayName): raise TYBizConfException(d, 'PlayModeConfMin.displayName must be not empty string') return self
def _reloadConf(self): conf = configure.getGameJson(self.gameId, 'skill.score', {}, configure.DEFAULT_CLIENT_ID) gameName = conf.get('game_name') if not isstring(gameName): raise TYBizConfException( conf, '%s.skill.score.game_name must be string: %s' % (self.gameId, gameName)) desc = conf.get('des', '') if not isstring(desc): raise TYBizConfException( conf, '%s.skill.score.des must be string: %s' % (self.gameId, desc)) titlePic = conf.get('title_pic', '') if not isstring(titlePic): raise TYBizConfException( conf, '%s.skill.score.title_pic must be string: %s' % (self.gameId, titlePic)) levels = [] levelMap = {} levelScores = conf.get('score', []) levelPics = conf.get('level_pic', []) levelBigPics = conf.get('big_level_pic', []) rewardMap = conf.get('reward', {}) if not levelScores: raise TYBizConfException( conf, '%s.skill.score.scores must be not empty list' % (self.gameId)) for i, score in enumerate(levelScores): level = i + 1 scoreRange = (score, -1) if level >= len(levelScores) else ( score, levelScores[level]) pic = levelPics[-1] if level >= len(levelPics) else levelPics[i] bigPic = levelBigPics[-1] if level >= len( levelBigPics) else levelBigPics[i] rewards = rewardMap.get(str(level), {}).get('rewards') rewardContent = None if rewards: rewardContent = TYContentRegister.decodeFromDict(rewards) skillScoreLevel = SkillScoreLevel(self, level, scoreRange, pic, bigPic, rewardContent) levelMap[level] = skillScoreLevel levels.append(skillScoreLevel) self.gameName = gameName self.desc = desc self.titlePic = titlePic self.levels = levels self.levelMap = levelMap self.levelScores = levelScores[:] ftlog.info('GameSkillScore._reloadConf', 'gameId=', self.gameId, 'gameName=', self.gameName, 'titlePic=', self.titlePic, 'levelKeys=', self.levelMap.keys()) return self
def decodeFromDict(self, d): self.unlockSeconds = d.get('unlockSeconds') if not isinstance(self.unlockSeconds, int) or self.unlockSeconds < 0: raise TYBizConfException(d, 'RewardControlFixedPerson.unlockSeconds must be int') self.count = d.get('count') if not isinstance(self.count, int) or self.count < 0: raise TYBizConfException(d, 'RewardControlFixedPerson.count must be int') return self
def decodeFromDict(self, d): self.desc = d.get('desc', '') if not isstring(self.desc): raise TYBizConfException(d, 'FlipableCard.desc must be string') self.tips = d.get('tips', '') if not isstring(self.tips): raise TYBizConfException(d, 'FlipableCard.tips must be string') self._decodeFromDictImpl(d) return self
def decodeFromDict(self, d): self.burialId = d.get('burialId') if not isstring(self.burialId): raise TYBizConfException(d, 'WxShareControlConf.BurialIdConf.burialId must be str') shareOrVideo = d.get('shareOrVideo') if not isinstance(shareOrVideo, list): raise TYBizConfException(d, 'WxShareControlConf.BurialIdConf.shareOrVideo must be list') self.shareOrVideo = [ShareOrVideoConf().decodeFromDict(d) for d in shareOrVideo] return self
def decodeFromDict(self, d): self.sharePointId = d.get('sharePointId') if not isinstance(self.sharePointId, int): raise TYBizConfException( d, 'TodoTaskNewShareRulePopFactory.sharePointId must be int') self.urlParams = d.get('urlParams', {}) if not isinstance(self.urlParams, dict): raise TYBizConfException( d, 'TodoTaskNewShareRulePopFactory.urlParams must be dict') return self
def decodeFromDict(cls, d): assetKindId = d.get('itemId') count = d.get('count') if not isstring(assetKindId): raise TYBizConfException( d, 'TYContentItem.itemId must be valid string') if not isinstance(count, (int, float)) or count < 0: raise TYBizConfException( d, 'TYContentItem.count must be int or float >= 0') return TYContentItem(assetKindId, count)
def decodeFromDict(self, d): self.cycleSeconds = d.get('cycleSeconds') if not isinstance(self.cycleSeconds, int): raise TYBizConfException(d, 'WXFollowConf.cycleSeconds must be int') rewardList = d.get('rewardList') if not isinstance(rewardList, list): raise TYBizConfException(d, 'WXFollowConf.rewardList must be list') self.rewardList = [RewardItem().decodeFromDict(d) for d in rewardList] return self
def decodeFromDict(self, d): self.open = d.get('open') if not isinstance(self.open, int) or self.open not in (0, 1): raise TYBizConfException(d, 'MatchLottery.open must in 0, 1') self.matchList = d.get('matchList', {}) if self.matchList and not isinstance(self.matchList, dict): raise TYBizConfException(d, 'MatchLottery.matchList must be dict') return self.matchList
def decodeFromDict(self, d): self.skinId = d.get('id') if not isstring(self.skinId): raise TYBizConfException(d, 'TableSkin.skinId must be string') self.name = d.get('name') if not isstring(self.name): raise TYBizConfException(d, 'TableSkin.name must be string') self.type = d.get('type', '2d') if not isstring(self.type): raise TYBizConfException(d, 'TableSkin.type must be string') self.displayName = d.get('display') if not isstring(self.displayName): raise TYBizConfException(d, 'TableSkin.display must be string') self.updateVersion = d.get('update') if not isinstance(self.updateVersion, int): raise TYBizConfException(d, 'TableSkin.display must be int') self.icon = d.get('icon') if not isstring(self.icon): raise TYBizConfException(d, 'TableSkin.icon must be string') self.preview = d.get('preview') if not isstring(self.preview): raise TYBizConfException(d, 'TableSkin.preview must be string') feeItem = d.get('fee') if feeItem: self.feeItem = FeeItem().decodeFromDict(feeItem) self.url = d.get('url') if not isstring(self.url): raise TYBizConfException(d, 'TableSkin.url must be string') self.md5 = d.get('md5') if not isstring(self.md5): raise TYBizConfException(d, 'TableSkin.md5 must be string') return self
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 string") params = d.get("params", {}) if not isinstance(params, dict): raise TYBizConfException(d, "MatchFee.params must be dict") return MatchFee(assetKindId, count, params)
def decodeFromDict(self, d): self.name = d.get('name', '') if not isstring(self.name): raise TYBizConfException(d, 'DizhuMatchStageConf.name must string') self.animationType = d.get('animationType', 0) if not isinstance(self.animationType, int): raise TYBizConfException( d, 'DizhuMatchStageConf.animationType must int') self.cardCount = d.get('cardCount') if not isinstance(self.cardCount, int) or self.cardCount <= 0: raise TYBizConfException( d, 'DizhuMatchStageConf.cardCount must be int > 0') self.totalUserCount = d.get('totalUserCount') if not isinstance(self.totalUserCount, int) or self.totalUserCount <= 0: raise TYBizConfException( d, 'DizhuMatchStageConf.totalUserCount must be int > 0') self.riseUserCount = d.get('riseUserCount') if not isinstance(self.riseUserCount, int) or self.riseUserCount <= 0: raise TYBizConfException( d, 'DizhuMatchStageConf.riseUserCount must be int > 0') self.scoreInit = d.get('scoreInit') if not isinstance(self.scoreInit, int) or self.scoreInit < 0: raise TYBizConfException( d, 'DizhuMatchStageConf.scoreInit must be int >= 0') self.scoreIntoRate = d.get('scoreIntoRate') if not isinstance( self.scoreInit, (int, float)) or self.scoreIntoRate <= 0 or self.scoreIntoRate > 1: raise TYBizConfException( d, 'DizhuMatchStageConf.scoreInit must in (0,1]') self.scoreIntoRateHigh = d.get('scoreIntoRateHigh', None) if self.scoreIntoRateHigh: if not isinstance( self.scoreInit, (int, float)) or self.scoreIntoRate <= 0 or self.scoreIntoRate > 1: raise TYBizConfException( d, 'DizhuMatchStageConf.scoreIntoRateHigh must in (0,1]') rankLine = d.get('rankLine') if ftlog.is_debug(): ftlog.debug('DizhuMatchStageConf.rankLine =', rankLine, 'rankList=', d.get('rankLineList')) if rankLine: self.rankLine = MatchRankLine().decodeFromDict(rankLine) else: rankLineList = d.get('rankLineList') try: self.rankLineList = [{ 'mixId': rankLine['mixId'], 'rankLine': MatchRankLine().decodeFromDict(rankLine['rankLine']) } for rankLine in rankLineList] except Exception, e: raise TYBizConfException( d, 'DizhuMatchStageConf.rankLineList err=' % e.message)