def getDefencePeriod(self): if self.getStartDefHour() != NOT_ACTIVATED: return (time_utils.getTimeTodayForUTC(hour=self.getStartDefHour()), time_utils.getTimeTodayForUTC( hour=self.getFinishDefHour())) else: return (None, None)
def __setup(self, defHour): defHourUTC = adjustDefenceHourToUTC(defHour) result = yield self.fortProvider.sendRequest(DefenceHourCtx(defHourUTC, waitingID='fort/settings')) if result: start = time_utils.getTimeTodayForUTC(defHourUTC) finish = time_utils.getTimeTodayForUTC(defHourUTC + 1) defenceHourStr = '%s - %s' % (BigWorld.wg_getShortTimeFormat(start), BigWorld.wg_getShortTimeFormat(finish)) SystemMessages.g_instance.pushI18nMessage(SYSTEM_MESSAGES.FORTIFICATION_DEFENCEHOURSET, defenceHour=defenceHourStr, type=SystemMessages.SM_TYPE.Warning)
def getDefencePeriod(self): if self.getStartDefHour() != NOT_ACTIVATED: return ( time_utils.getTimeTodayForUTC(hour=self.getStartDefHour()), time_utils.getTimeTodayForUTC(hour=self.getFinishDefHour()), ) else: return (None, None)
def __setup(self, defHour): defHourUTC = adjustDefenceHourToUTC(defHour) result = yield self.fortProvider.sendRequest( DefenceHourCtx(defHourUTC, waitingID='fort/settings')) if result: start = time_utils.getTimeTodayForUTC(defHourUTC) finish = time_utils.getTimeTodayForUTC(defHourUTC + 1) defenceHourStr = '%s - %s' % (BigWorld.wg_getShortTimeFormat( start), BigWorld.wg_getShortTimeFormat(finish)) SystemMessages.g_instance.pushI18nMessage( SYSTEM_MESSAGES.FORTIFICATION_DEFENCEHOURSET, defenceHour=defenceHourStr, type=SystemMessages.SM_TYPE.Warning)
def __makeDefencePeriodData(self): alertMessage = '' blockBtnEnabled = True fort = self.fortCtrl.getFort() inProcess, inCooldown = fort.getDefenceHourProcessing() conditionPostfix = self.app.utilsManager.textManager.getText(TextType.NEUTRAL_TEXT, fort.getDefencePeriodStr()) blockBtnToolTip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_DEFENCEBTNENABLED descriptionTooltip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_DEFENCEPERIODDESCRIPTION if inProcess: defenceHourChangeDay, nextDefenceHour, _ = fort.events[FORT_EVENT_TYPE.DEFENCE_HOUR_CHANGE] timestampStart = time_utils.getTimeTodayForUTC(nextDefenceHour) value = '%s - %s' % (BigWorld.wg_getShortTimeFormat(timestampStart), BigWorld.wg_getShortTimeFormat(timestampStart + time_utils.ONE_HOUR)) msgString = i18n.makeString(FORTIFICATIONS.SETTINGSWINDOW_BLOCKCONDITION_INPROGRESS, value=value, date=BigWorld.wg_getShortDateFormat(defenceHourChangeDay)) alertMessage = self.app.utilsManager.textManager.getText(TextType.ALERT_TEXT, msgString) blockBtnEnabled = False blockBtnToolTip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_DEFENCEBTNDISABLED elif inCooldown: msgString = i18n.makeString(FORTIFICATIONS.SETTINGSWINDOW_BLOCKCONDITION_RECENTLYSCHEDULED) alertMessage = self.app.utilsManager.textManager.getText(TextType.ALERT_TEXT, msgString) blockBtnEnabled = False blockBtnToolTip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_DEFENCEBTNDISABLED conditionPrefix = self.app.utilsManager.textManager.getText(TextType.MAIN_TEXT, i18n.makeString(FORTIFICATIONS.settingswindow_blockcondition('defencePeriodTime'))) blockDescr = self.app.utilsManager.textManager.getText(TextType.STANDARD_TEXT, i18n.makeString(FORTIFICATIONS.settingswindow_blockdescr('defencePeriodTime'))) if alertMessage: alertMessage = self.app.utilsManager.textManager.getIcon(TextIcons.ALERT_ICON) + ' ' + alertMessage return {'blockBtnEnabled': blockBtnEnabled, 'blockDescr': blockDescr, 'blockCondition': conditionPrefix + ' ' + conditionPostfix, 'alertMessage': alertMessage, 'blockBtnToolTip': blockBtnToolTip, 'descriptionTooltip': descriptionTooltip}
def requestFort(self, clanDossier, callback): sInfo = yield clanDossier.requestStrongholdInfo() if sInfo.hasFort(): sStats = yield clanDossier.requestStrongholdStatistics() buildingsList = sInfo.getBuildings() buildings = self._makeBuildingsList(buildingsList, sStats) dossierDescriptor = _UserDossierAdapter(sInfo) defModeParams = None if sInfo.isDefenceModeActivated(): defence_hour = sInfo.getDefenceHour() dHours = None if defence_hour is not None: hour = time_utils.getTimeTodayForUTC(defence_hour.hour) dHours = (hour, hour + time_utils.ONE_HOUR) defModeParams = (sStats.getOffDay(), dHours, sStats.getVacationInfo()) data = _getFortBuildingsVO( FortSortiesStatisticsVO( FortRegionSortiesStats(dossierDescriptor), sStats.getFsBattlesCount28d(), sStats.getFsWinsCount28d()), FortBattlesStatisticsVO( FortRegionBattlesStats(dossierDescriptor), sInfo.getFbBattlesCount8(), sInfo.getFbBattlesCount10()), buildings, _getFortSortiesSchemaTexts(defModeParams, sStats.getPeripheryID(), len(buildingsList), sStats.getDirectionsCount())) else: data = _getNoFortBuildingsVO() callback(data) return
def __makeDefencePeriodData(self): alertMessage = '' blockBtnEnabled = True fort = self.fortCtrl.getFort() inProcess, inCooldown = fort.getDefenceHourProcessing() if self._isFortFrozen(): conditionPostfix = text_styles.standard(fort.getDefencePeriodStr()) else: conditionPostfix = text_styles.neutral(fort.getDefencePeriodStr()) blockBtnToolTip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_DEFENCEBTNENABLED descriptionTooltip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_DEFENCEPERIODDESCRIPTION if inProcess: defenceHourChangeDay, nextDefenceHour, _ = fort.events[FORT_EVENT_TYPE.DEFENCE_HOUR_CHANGE] timestampStart = time_utils.getTimeTodayForUTC(nextDefenceHour) value = '%s - %s' % (BigWorld.wg_getShortTimeFormat(timestampStart), BigWorld.wg_getShortTimeFormat(timestampStart + time_utils.ONE_HOUR)) msgString = i18n.makeString(FORTIFICATIONS.SETTINGSWINDOW_BLOCKCONDITION_INPROGRESS, value=value, date=BigWorld.wg_getShortDateFormat(defenceHourChangeDay)) alertMessage = text_styles.alert(msgString) blockBtnEnabled = False blockBtnToolTip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_DEFENCEBTNDISABLED elif inCooldown: msgString = i18n.makeString(FORTIFICATIONS.SETTINGSWINDOW_BLOCKCONDITION_RECENTLYSCHEDULED) alertMessage = text_styles.alert(msgString) blockBtnEnabled = False blockBtnToolTip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_DEFENCEBTNDISABLED conditionPrefix = text_styles.main(i18n.makeString(FORTIFICATIONS.settingswindow_blockcondition('defencePeriodTime'))) blockDescr = text_styles.standard(i18n.makeString(FORTIFICATIONS.settingswindow_blockdescr('defencePeriodTime'))) if alertMessage: alertMessage = icons.alert() + ' ' + alertMessage return {'blockBtnEnabled': blockBtnEnabled, 'blockDescr': blockDescr, 'blockCondition': conditionPrefix + ' ' + conditionPostfix, 'alertMessage': alertMessage, 'blockBtnToolTip': blockBtnToolTip, 'descriptionTooltip': descriptionTooltip}
def getClosestDefencePeriod(self): if not self.isDefenceHourEnabled(): return (None, None) timestampStart = time_utils.getTimeTodayForUTC(self.defenceHour) if time_utils.getTimeDeltaFromNow(timestampStart) < time_utils.ONE_HOUR: timestampStart += time_utils.ONE_DAY timestampFinish = timestampStart + time_utils.ONE_HOUR return (timestampStart, timestampFinish)
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 _getDailyResetStatus(self, resetLabelKey, labeFormatter): if self.event.bonusCond.isDaily(): resetHourUTC = self._getDailyProgressResetTimeUTC( ) / time_utils.ONE_HOUR if resetHourUTC >= 0: return labeFormatter(resetLabelKey) % { 'time': time.strftime( i18n.makeString( '#quests:details/conditions/postBattle/dailyReset/timeFmt' ), time_utils.getTimeStructInLocal( time_utils.getTimeTodayForUTC(hour=resetHourUTC))) }
def _getWeeklyResetStatus(self, resetLabelKey, labeFormatter): if self.event.bonusCond.isWeekly(): day, resetSeconds = self._getWeeklyProgressResetTimeUTC() resetHourUTC = resetSeconds / time_utils.ONE_HOUR dayStr = i18n.makeString('#menu:dateTime/weekDays/full/' + str(day + 1)) + ', ' if resetHourUTC >= 0: resetTime = time_utils.getTimeStructInLocal( time_utils.getTimeTodayForUTC(hour=resetHourUTC)) resetTime = time.struct_time(resetTime[:6] + (day, ) + resetTime[7:]) return labeFormatter(resetLabelKey) % { 'time': dayStr + time.strftime( i18n.makeString( '#quests:details/conditions/postBattle/weeklyReset/timeFmt' ), resetTime) }
def requestFort(self, clanDossier, callback): sInfo = yield clanDossier.requestStrongholdInfo() if sInfo.hasFort(): sStats = yield clanDossier.requestStrongholdStatistics() buildings = self._makeBuildingsList(sInfo.getBuildings(), sStats) dossierDescriptor = _UserDossierAdapter(sInfo) defModeParams = None if sInfo.isDefenceModeActivated(): defence_hour = sInfo.getDefenceHour() dHours = None if defence_hour is not None: hour = time_utils.getTimeTodayForUTC(defence_hour.hour) dHours = (hour, hour + time_utils.ONE_HOUR) defModeParams = (sStats.getOffDay(), dHours, sStats.getVacationInfo()) data = _getFortBuildingsVO(FortSortiesStatisticsVO(FortRegionSortiesStats(dossierDescriptor), sStats.getFsBattlesCount28d(), sStats.getFsWinsCount28d()), FortBattlesStatisticsVO(FortRegionBattlesStats(dossierDescriptor), sInfo.getFbBattlesCount8(), sInfo.getFbBattlesCount10()), buildings, _getFortSortiesSchemaTexts(defModeParams, sStats.getPeripheryID(), len(buildings), sStats.getDirectionsCount())) else: data = _getNoFortBuildingsVO() callback(data) return
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 getDefencePeriod(self): if self.isDefenceHourEnabled(): timestampStart = time_utils.getTimeTodayForUTC(self.defenceHour) return (timestampStart, timestampStart + time_utils.ONE_HOUR) else: return (None, None)