def _getConditions(self, svrEvents): subBlocks = [] bonus = self.event.bonusCond battlesLeft, battlesCount, inrow = None, None, False battles = bonus.getConditions().find('battles') if battles is not None: battlesCount = battles._getTotalValue() if not self.event.isCompleted() and bonus.getGroupByValue() is None: progress = battles.getProgressPerGroup() if None in progress: curProg, totalProg, _, _ = progress[None] battlesLeft = totalProg - curProg bonusFmtConds = bonus.format(svrEvents, event=self.event) if len(bonusFmtConds): subBlocks.extend(formatters.indexing(bonusFmtConds)) postBattleFmtConds = self.event.postBattleCond.format(svrEvents, event=self.event) if len(postBattleFmtConds): if len(bonusFmtConds): subBlocks.append(formatters.packSeparator(label=i18n.makeString('#quests:details/conditions/postBattle/separator'))) subBlocks.extend(formatters.indexing(postBattleFmtConds)) if bonus.isDaily(): resetHourOffset = (time_utils.ONE_DAY - self._getDailyProgressResetTimeOffset()) / 3600 if resetHourOffset >= 0: subBlocks.append(formatters.packTextBlock(label=formatters.formatYellow('#quests:details/conditions/postBattle/dailyReset') % {'time': time.strftime(i18n.makeString('#quests:details/conditions/postBattle/dailyReset/timeFmt'), time_utils.getTimeStructInLocal(time_utils.getTimeTodayForUTC(hour=resetHourOffset)))})) result = [] if len(subBlocks) or battlesCount: if not self.event.isGuiDisabled(): result.append(formatters.packConditionsBlock(battlesCount, battlesLeft, bonus.isInRow(), conditions=subBlocks)) else: result.append(formatters.packConditionsBlock(conditions=subBlocks)) if bonus.getGroupByValue() is not None and not self.event.isGuiDisabled(): progressesFmt = bonus.formatGroupByProgresses(svrEvents, self.event) if len(progressesFmt): result.append(formatters.packTopLevelContainer(i18n.makeString('#quests:details/conditions/groupBy/%s' % bonus.getGroupByValue()), subBlocks=progressesFmt, isResizable=len(progressesFmt) > 5)) return formatters.todict(result)
def _packConditions(self, svrEvents): subBlocks = [] bonus = self.event.bonusCond battlesLeft, battlesCount, inrow = None, None, False battles = bonus.getConditions().find('battles') if battles is not None: battlesCount = battles._getTotalValue() if not self.event.isCompleted() and bonus.getGroupByValue() is None: progress = battles.getProgressPerGroup() if None in progress: curProg, totalProg, _, _ = progress[None] battlesLeft = totalProg - curProg bonusFmtConds = bonus.format(svrEvents, event=self.event) if len(bonusFmtConds): subBlocks.extend(formatters.indexing(bonusFmtConds)) postBattleFmtConds = self.event.postBattleCond.format(svrEvents, event=self.event) if len(postBattleFmtConds): if len(bonusFmtConds): subBlocks.append(formatters.packSeparator(label=i18n.makeString('#quests:details/conditions/postBattle/separator'))) subBlocks.extend(formatters.indexing(postBattleFmtConds)) if bonus.isDaily(): resetHourOffset = (time_utils.ONE_DAY - self._getDailyProgressResetTimeOffset()) / 3600 if resetHourOffset >= 0: subBlocks.append(formatters.packTextBlock(label=formatters.formatYellow('#quests:details/conditions/postBattle/dailyReset') % {'time': time.strftime(i18n.makeString('#quests:details/conditions/postBattle/dailyReset/timeFmt'), time_utils.getTimeStructInLocal(time_utils.getTimeTodayForUTC(hour=resetHourOffset)))})) result = [] if len(subBlocks) or battlesCount: if not self.event.isGuiDisabled(): result.append(formatters.packConditionsBlock(battlesCount, battlesLeft, bonus.isInRow(), conditions=subBlocks)) else: result.append(formatters.packConditionsBlock(conditions=subBlocks)) if bonus.getGroupByValue() is not None and not self.event.isGuiDisabled(): progressesFmt = bonus.formatGroupByProgresses(svrEvents, self.event) if len(progressesFmt): result.append(formatters.packTopLevelContainer(i18n.makeString('#quests:details/conditions/groupBy/%s' % bonus.getGroupByValue()), subBlocks=progressesFmt, isResizable=len(progressesFmt) > 5)) return result
def _packConditions(self, svrEvents): subBlocks = [] bonus = self.event.bonusCond battlesLeft, battlesCount, inrow = None, None, False battles = bonus.getConditions().find('battles') if battles is not None: battlesCount = battles.getTotalValue() if not self.event.isCompleted( ) and bonus.getGroupByValue() is None: progress = battles.getProgressPerGroup() if None in progress: curProg, totalProg, _, _ = progress[None] battlesLeft = totalProg - curProg bonusFmtConds = bonusCondFormatter.format(bonus, self.event) if len(bonusFmtConds): subBlocks.extend(formatters.indexing(bonusFmtConds)) postBattleFmtConds = postBattleConditionFormatter.format( self.event.postBattleCond, self.event) if len(postBattleFmtConds): if len(bonusFmtConds): subBlocks.append( formatters.packSeparator(label=i18n.makeString( '#quests:details/conditions/postBattle/separator'))) subBlocks.extend(formatters.indexing(postBattleFmtConds)) resetLabel = self._getDailyResetStatus( '#quests:details/conditions/postBattle/dailyReset', formatters.formatYellow) if resetLabel: subBlocks.append(formatters.packTextBlock(label=resetLabel)) result = [] if len(subBlocks) or battlesCount: if not self.event.isGuiDisabled(): result.append( formatters.packConditionsBlock(battlesCount, battlesLeft, bonus.isInRow(), conditions=subBlocks)) else: result.append( formatters.packConditionsBlock(conditions=subBlocks)) if bonus.getGroupByValue( ) is not None and not self.event.isGuiDisabled(): progressesFmt = bonusCondFormatter.formatGroupByProgresses( bonus, self.event) if len(progressesFmt): result.append( formatters.packTopLevelContainer( i18n.makeString( '#quests:details/conditions/groupBy/%s' % bonus.getGroupByValue()), subBlocks=progressesFmt, isResizable=len(progressesFmt) > 5)) return result
def _format(self, condition, event): subBlocks = [] for cond in condition.getSortedItems(): formatter = self.getConditionFormatter(cond.getName()) if formatter: subBlocks.extend(formatter.format(cond, event)) result = [] for idx, block in enumerate(subBlocks): result.append(block) if idx < len(subBlocks) - 1: result.append( formatters.packSeparator(makeHtmlString( 'html_templates:lobby/quests', 'or'), needAlign=True)) return result