def _getAlertStatusText(timeLeft, hasAvailableServers, connectionMgr=None, epicController=None): rAlertMsgBlock = R.strings.epic_battle.widgetAlertMessageBlock alertStr = '' if hasAvailableServers: alertStr = backport.text(rAlertMsgBlock.somePeripheriesHalt(), serverName=connectionMgr.serverUserNameShort) else: currSeason = epicController.getCurrentSeason() currTime = time_utils.getCurrentLocalServerTimestamp() primeTime = epicController.getPrimeTimes().get(connectionMgr.peripheryID) isCycleNow = currSeason and currSeason.hasActiveCycle(currTime) and primeTime and primeTime.getPeriodsBetween(currTime, currSeason.getCycleEndDate()) if isCycleNow: if connectionMgr.isStandalone(): key = rAlertMsgBlock.singleModeHalt else: key = rAlertMsgBlock.allPeripheriesHalt timeLeftStr = time_formatters.getTillTimeByResource(timeLeft, R.strings.epic_battle.status.timeLeft, removeLeadingZeros=True) alertStr = backport.text(key(), time=timeLeftStr) else: nextSeason = currSeason or epicController.getNextSeason() if nextSeason is not None: nextCycle = nextSeason.getNextByTimeCycle(currTime) if nextCycle is not None: if nextCycle.announceOnly: alertStr = backport.text(rAlertMsgBlock.announcement()) else: timeLeftStr = time_formatters.getTillTimeByResource(nextCycle.startDate - currTime, R.strings.epic_battle.status.timeLeft, removeLeadingZeros=True) alertStr = backport.text(rAlertMsgBlock.startIn(), time=timeLeftStr) if not alertStr: prevSeason = currSeason or epicController.getPreviousSeason() if prevSeason is not None: prevCycle = prevSeason.getLastActiveCycleInfo(currTime) if prevCycle is not None: alertStr = backport.text(rAlertMsgBlock.noCycleMessage()) return text_styles.vehicleStatusCriticalText(alertStr)
def _getTimeText(self, serverInfo): if serverInfo: timeLeft = serverInfo.getTimeLeft() isAvailable = serverInfo.isAvailable() serverName = serverInfo.getName() else: _, timeLeft, isAvailable = self._getController().getPrimeTimeStatus() serverName = '' currentSeason = self._getController().getCurrentSeason() if currentSeason and not timeLeft: return '' if not timeLeft and not isAvailable and not currentSeason: nextSeason = self._getController().getNextSeason() if nextSeason: currTime = time_utils.getCurrentLocalServerTimestamp() primeTime = self._getController().getPrimeTimes().get(serverInfo.getPeripheryID()) startTime = primeTime.getNextPeriodStart(currTime, nextSeason.getEndDate()) if startTime: timeLeft = startTime - currTime else: self.destroy() return '' timeLeftStr = time_formatters.getTillTimeByResource(timeLeft, R.strings.menu.Time.timeValueShort) if isAvailable: stringR = R.strings.epic_battle.primeTime.primeIsAvailable() else: stringR = R.strings.epic_battle.primeTime.primeWillBeAvailable() return backport.text(stringR, server=serverName, time=text_styles.neutral(timeLeftStr))
def __onPiggyBankCreditsChanged(self, credits_=None): config = self.__lobbyContext.getServerSettings().getPiggyBankConfig() maxAmount = config.get('threshold', PiggyBankConstants.MAX_AMOUNT) data = self.__itemsCache.items.stats.piggyBank if credits_ >= maxAmount: timeLeft = time_formatters.getTillTimeByResource(getDeltaTimeHelper(config, data), R.strings.premacc.piggyBankCard.timeLeft) SystemMessages.pushMessage(priority=NotificationPriorityLevel.MEDIUM, text=backport.text(R.strings.system_messages.piggyBank.piggyBankFull(), timeValue=timeLeft))
def _buildTooltip(self, peripheryID): if not self.getTimeLeft(): tooltipStr = text_styles.expText( backport.text(R.strings.epic_battle.primeTime.endOfCycle(), server=self.getName())) else: timeStr = text_styles.neutral( time_formatters.getTillTimeByResource( self.getTimeLeft(), R.strings.menu.Time.timeValueShort)) if self._getIsAvailable(): tooltipStr = text_styles.expText( backport.text( R.strings.epic_battle.primeTime.serverTooltip(), server=self.getName(), time=timeStr)) else: tooltipStr = text_styles.expText( backport.text(R.strings.epic_battle.primeTime. serverUnavailableTooltip(), time=timeStr)) return { 'tooltip': tooltipStr, 'specialArgs': [], 'specialAlias': None, 'isSpecial': None }
def __fillViewModel(self): with self.viewModel.transaction() as vm: self.__resetViewModel(vm) currentSeason = self.__epicController.getCurrentSeason() nextSeason = self.__epicController.getNextSeason() season = currentSeason or nextSeason currentTime = time_utils.getCurrentLocalServerTimestamp() vm.setConditions( backport.text( R.strings.mode_selector.mode.epicBattle.condition(), levels=toRomanRangeString( self.__epicController.getValidVehicleLevels()))) vm.setDescription( backport.text( R.strings.mode_selector.mode.epicBattle.description())) if season is None: return if season.hasActiveCycle(currentTime): vm.setStatusActive( backport.text( R.strings.mode_selector.mode.epicBattle.seasonActive(), cycle=int2roman(currentSeason.getCycleInfo(). getEpicCycleNumber()))) self._addReward(ModeSelectorRewardID.CREDITS) self._addReward(ModeSelectorRewardID.EXPERIENCE) timeLeftStr = '' cycleInfo = season.getCycleInfo() if cycleInfo is not None: timeLeftStr = time_formatters.getTillTimeByResource( cycleInfo.endDate - currentTime, R.strings.menu.Time.timeLeftShort, removeLeadingZeros=True) vm.setTimeLeft(timeLeftStr) else: cycleInfo = season.getNextByTimeCycle(currentTime) if cycleInfo is not None: if cycleInfo.announceOnly: vm.setStatusNotActive( backport.text(R.strings.mode_selector.mode. epicBattle.cycleSoon(), cycle=int2roman( cycleInfo.getEpicCycleNumber()))) else: vm.setStatusNotActive( backport.text(R.strings.mode_selector.mode. epicBattle.cycleNext(), cycle=int2roman( cycleInfo.getEpicCycleNumber()), date=backport.getShortDateFormat( cycleInfo.startDate))) self.viewModel.setBattlePassState(BattlePassState.NONE) else: vm.setStatusNotActive( backport.text(R.strings.mode_selector.mode.epicBattle. seasonEnd())) setBattlePassState(self.viewModel) return
def getFormattedTimeLeft(seconds): return time_formatters.getTillTimeByResource( seconds, R.strings.battle_pass_2020.status.timeLeft, removeLeadingZeros=True)
def _getTimeLeftStr(timeStamp): timeLeft = time_formatters.getTillTimeByResource( timeStamp, R.strings.menu.Time.timeLeftShort, removeLeadingZeros=True) return text_styles.stats(timeLeft)
def getTimeTo(timeStamp, textId): timeLeft = time_formatters.getTillTimeByResource( timeStamp, R.strings.menu.headerButtons.battle.types.ranked.availability, removeLeadingZeros=True) return backport.text(textId, value=text_styles.stats(timeLeft))