def _bonusDecorator(self, bonus): if self.getType() == constants.EVENT_TYPE.TOKEN_QUEST and bonus.getName() == 'oneof': if ranked_helpers.isRankedQuestID(self.getID()): _, cohort, _ = ranked_helpers.getRankedDataFromTokenQuestID(self.getID()) bonus.setupIconHandler(BoxBonus.HANDLER_NAMES.RANKED, ('metal', cohort)) bonus.setTooltipType('rankedSeason') return bonus
def getLeagueAwards(self): isCurrent, seasonInfo = ranked_common.getRankedSeason( self.__getSettings().asDict()) result = [] percentTotal = 0 if isCurrent: _, _, seasonID, _ = seasonInfo seasonQuests = self.eventsCache.getHiddenQuests( lambda q: q.getType() == EVENT_TYPE.TOKEN_QUEST and ranked_helpers.isRankedQuestID(q.getID())) for qID in sorted(seasonQuests): season, cohort, percent = ranked_helpers.getRankedDataFromTokenQuestID( qID) percentTotal += percent if season == seasonID: quest = seasonQuests[qID] awards = [] for bonus in quest.getBonuses(): awards.extend(bonus.getRankedAwardVOs(iconSize='big')) result.append({ 'cohortNumber': cohort, 'playersPercent': percent, 'awards': awards }) result.append({ 'cohortNumber': 0, 'playersPercent': 100 - percentTotal, 'awards': [] }) return result
def __showSeasonAward(self, quest, data): seasonID, _, _ = ranked_helpers.getRankedDataFromTokenQuestID(quest.getID()) season = self.rankedController.getSeason(seasonID) if season is not None: g_eventBus.handleEvent(events.LoadViewEvent(RANKEDBATTLES_ALIASES.RANKED_BATTLES_SEASON_COMPLETE, ctx={'quest': quest, 'awards': data, 'closeClb': self.__unlock}), scope=EVENT_BUS_SCOPE.LOBBY) else: self.__unlock() return
def _bonusDecorator(self, bonus): """ allows to do some additional bonus configuration when they are created in getBonuses. Originally is used in RankedQuest to set BoxBonus icon configuration """ if self.getType( ) == constants.EVENT_TYPE.TOKEN_QUEST and bonus.getName() == 'oneof': if ranked_helpers.isRankedQuestID(self.getID()): _, cohort, _ = ranked_helpers.getRankedDataFromTokenQuestID( self.getID()) bonus.setupIconHandler(BoxBonus.HANDLER_NAMES.RANKED, ('metal', cohort)) bonus.setTooltipType('rankedSeason') return bonus
def __setData(self): seasonID, cohort, _ = ranked_helpers.getRankedDataFromTokenQuestID( self._quest.getID()) season = self.rankedController.getSeason(int(seasonID)) if season is not None: leagueData = yield self.rankedController.getLeagueData() if leagueData is not None: position = BigWorld.wg_getNiceNumberFormat( leagueData['position']) else: position = 'N/A' crystalsBonus = first(self._quest.getBonuses(Currency.CRYSTAL)) if crystalsBonus is not None: crystalsCount = crystalsBonus.getValue() else: crystalsCount = 0 self.as_setDataS({ 'boxImage': RES_ICONS.getRankedBoxIcon('450x400', 'metal', '_opened', cohort), 'scoresValue': BigWorld.wg_getNiceNumberFormat(season.getPoints()), 'scoresLabel': RANKED_BATTLES.SEASONCOMPLETE_TOTALSCORES, 'placeValue': position, 'placeHolderVisible': True, 'placeLabel': RANKED_BATTLES.SEASONCOMPLETE_PLACEINRATING, 'currencyLabel': RANKED_BATTLES.SEASONCOMPLETE_PROXYCURRENCYLABEL, 'currencyValue': str(crystalsCount), 'congratulationTitle': RANKED_BATTLES.SEASONCOMPLETE_SEASONRESULTS, 'nextButtonLabel': RANKED_BATTLES.AWARDS_YES, 'awards': self._packAwards(), 'bgSource': RES_ICONS.MAPS_ICONS_RANKEDBATTLES_BG_RANK_BLUR }) return
def __setData(self): seasonID, cohort, _ = ranked_helpers.getRankedDataFromTokenQuestID( self._quest.getID()) season = self.rankedController.getSeason(int(seasonID)) if season is not None: leagueData = yield self.rankedController.getLeagueData() if leagueData is not None: position = BigWorld.wg_getNiceNumberFormat( leagueData['position']) league = leagueData.get('league', 0) else: position = '0' league = 0 itemsCache = dependency.instance(IItemsCache) dossier = itemsCache.items.getAccountDossier( ).getPreviousSeasonRankedStats() seasonPoints = season.getPoints() efficiency = dossier.getStepsEfficiency() if efficiency is not None: efficiencyValue = efficiency * 100 else: efficiencyValue = 0 avgExp = dossier.getAvgXP() if avgExp is None: avgExp = 0 self.as_setDataS({ 'leagueImage': RES_ICONS.getRankedWebLeagueIcon('big', league), 'scoresValue': BigWorld.wg_getNiceNumberFormat(seasonPoints), 'scoresLabel': _ms(RANKED_BATTLES.SEASONCOMPLETE_TOTALSCORES), 'effectValue': BigWorld.wg_getIntegralFormat(efficiencyValue), 'effectLabel': _ms(RANKED_BATTLES.SEASONCOMPLETE_EFFECTLABEL), 'placeValue': position, 'placeLabel': _ms(RANKED_BATTLES.SEASONCOMPLETE_PLACEINRATING), 'expValue': BigWorld.wg_getIntegralFormat(avgExp), 'expLabel': _ms(RANKED_BATTLES.SEASONCOMPLETE_EXPLABEL), 'congratulationTitle': _ms(RANKED_BATTLES.SEASONCOMPLETE_BIGTITLE, season=str(season.getNumber())), 'typeTitle': _ms(RANKED_BATTLES.SEASONCOMPLETE_SMALLTITLE), 'typeIcon': RES_ICONS.MAPS_ICONS_BATTLETYPES_40X40_RANKED, 'nextButtonLabel': _ms(RANKED_BATTLES.SEASONCOMPLETE_LEADERSBUTTON), 'bgSource': RES_ICONS.MAPS_ICONS_RANKEDBATTLES_BG_RANK_BLUR, 'leagueLabel': _ms(RANKED_BATTLES.SEASONCOMPLETE_UNDERLABEL) }) self.as_setRewardsDataS({ 'ribbonType': 'ribbon2', 'rendererLinkage': COMPONENTS_ALIASES.RIBBON_AWARD_ANIM_RENDERER, 'gap': 20, 'rendererWidth': 80, 'rendererHeight': 80, 'awards': self._packAwards() }) else: LOG_WARNING( 'Try to show RankedBattlesSeasonCompleteView, but season is None. Params: ', seasonID, cohort) return
def _boxAnimationData(self): _, cohortNumber, _ = ranked_helpers.getRankedDataFromTokenQuestID( self._quest.getID()) return ('metal', cohortNumber)