def getScheduleBlock(modeCtrl, modeName, actualSeason, seasonIsStarted,
                     timeStringGetter):
    block = []
    if actualSeason.hasActiveCycle(
            time_utils.getCurrentLocalServerTimestamp()):
        currentCycle = actualSeason.getCycleInfo()
        block.append(getTimeTableBlock(modeCtrl, modeName))
        block.append(
            _getTimeBlock(seasonIsStarted, True,
                          time_utils.makeLocalServerTime(currentCycle.endDate),
                          modeName, timeStringGetter))
    elif actualSeason is not None:
        nextCycle = actualSeason.getNextByTimeCycle(
            time_utils.getCurrentLocalServerTimestamp())
        if nextCycle:
            block.append(
                _getTimeBlock(
                    seasonIsStarted, False,
                    time_utils.makeLocalServerTime(nextCycle.startDate),
                    modeName, timeStringGetter))
        else:
            wait = backport.text(
                R.strings.menu.headerButtons.battle.types.dyn(
                    modeName).extra.finished())
            block.append(
                formatters.packTitleDescBlock(title=text_styles.main(wait)))
    return block
 def __getStatusTitle(self):
     currServerName = self._connectionMgr.serverUserNameShort
     status, timeLeft, _ = self._getController().getPrimeTimeStatus()
     if not self._hasAvailableServers():
         return text_styles.grandTitle(
             backport.text(R.strings.mapbox.primeTimeView.status.
                           allServersDisabled()))
     if status == PrimeTimeStatus.NOT_AVAILABLE:
         if not timeLeft:
             currentSeason = self._getController().getCurrentSeason()
             return text_styles.grandTitle(
                 backport.text(
                     R.strings.mapbox.primeTimeView.status.seasonDisabled(),
                     season=currentSeason.getUserName(),
                     server=currServerName))
         if timeLeft < time_utils.ONE_DAY:
             startTime = time_formatters.formatDate(
                 '%H:%M',
                 time_utils.getCurrentLocalServerTimestamp() + timeLeft)
         else:
             startTime = time_formatters.formatDate(
                 '%d.%m.%Y',
                 time_utils.getCurrentLocalServerTimestamp() + timeLeft)
         return text_styles.grandTitle(
             backport.text(R.strings.mapbox.primeTimeView.status.untill(),
                           startTime=startTime,
                           server=currServerName))
     return text_styles.grandTitle(
         backport.text(
             R.strings.mapbox.primeTimeView.status.disableFirst(),
             server=currServerName)) if status in (
                 PrimeTimeStatus.FROZEN,
                 PrimeTimeStatus.NOT_SET) else text_styles.grandTitle(
                     backport.text(R.strings.mapbox.primeTimeView.status.
                                   allServersDisabled()))
 def __getScheduleStr(self):
     if self.__isFrozen:
         return backport.text(R.strings.menu.headerButtons.battle.types.
                              battleRoyale.extra.frozen())
     else:
         currentSeason = self.__battleRoyaleController.getCurrentSeason()
         if currentSeason is not None and currentSeason.hasActiveCycle(
                 time_utils.getCurrentLocalServerTimestamp()):
             seasonResID = R.strings.battle_royale.season.num(
                 currentSeason.getSeasonID())
             seasonName = backport.text(
                 seasonResID.name()) if seasonResID else None
             scheduleStr = backport.text(
                 R.strings.menu.headerButtons.battle.types.battleRoyale.
                 extra.currentCycle(),
                 season=seasonName,
                 cycle=int2roman(currentSeason.getCycleOrdinalNumber()))
             return text_styles.main(scheduleStr)
         currentOrNextSeason = currentSeason or self.__battleRoyaleController.getNextSeason(
         )
         if currentOrNextSeason is not None:
             nextCycle = currentOrNextSeason.getNextByTimeCycle(
                 time_utils.getCurrentLocalServerTimestamp())
             if nextCycle:
                 scheduleStr = backport.text(
                     R.strings.menu.headerButtons.battle.types.battleRoyale.
                     extra.startsAt(),
                     time=backport.getDateTimeFormat(nextCycle.startDate))
                 return text_styles.main(scheduleStr)
         scheduleStr = backport.text(R.strings.menu.headerButtons.battle.
                                     types.battleRoyale.extra.finished())
         return text_styles.main(scheduleStr)
 def __getScheduleStr(self):
     if self._isDisabled:
         return text_styles.error(
             backport.text(_R_BATTLE_TYPES.epic.extra.frozen()))
     else:
         currentSeason = self.__epicController.getCurrentSeason()
         if currentSeason:
             if currentSeason.hasActiveCycle(
                     time_utils.getCurrentLocalServerTimestamp()):
                 scheduleStr = None
             else:
                 nextCycle = currentSeason.getNextCycleInfo(
                     time_utils.getCurrentLocalServerTimestamp())
                 if nextCycle is None:
                     nextCycle = currentSeason.getNextByTimeCycle(
                         time_utils.getCurrentLocalServerTimestamp())
                 if nextCycle:
                     nextCycleStartTime = backport.getDateTimeFormat(
                         nextCycle.startDate)
                     scheduleStr = backport.text(
                         _R_BATTLE_TYPES.epic.extra.startsAt(),
                         time=nextCycleStartTime)
                 else:
                     scheduleStr = None
         else:
             nextSeason = self.__epicController.getNextSeason()
             nextCycle = nextSeason.getNextByTimeCycle(
                 time_utils.getCurrentLocalServerTimestamp())
             if nextCycle:
                 startTime = backport.getDateTimeFormat(nextCycle.startDate)
                 scheduleStr = backport.text(
                     _R_BATTLE_TYPES.epic.extra.startsAt(), time=startTime)
             else:
                 scheduleStr = None
         return text_styles.main(scheduleStr) if scheduleStr else None
Exemplo n.º 5
0
def packEpicBattleInfoBlock(epicController=None):
    descLvl = text_styles.stats(
        backport.text(
            R.strings.epic_battle.selectorTooltip.epicBattle.bodyVehicleLevel(
            ),
            level=toRomanRangeString(epicController.getValidVehicleLevels())))
    season = epicController.getCurrentSeason()
    cycle = None
    cycleNumber = None
    if season is not None and not season.isSingleCycleSeason():
        hasActiveCycle = season.hasActiveCycle(
            time_utils.getCurrentLocalServerTimestamp())
        if epicController.isEnabled() and hasActiveCycle:
            cycle = season.getCycleInfo()
        else:
            cycle = season.getNextByTimeCycle(
                time_utils.getCurrentLocalServerTimestamp())
    if cycle is not None:
        cycleNumber = cycle.getEpicCycleNumber()
    if cycleNumber:
        titleStr = R.strings.epic_battle.tooltips.common.titleWithCycle()
    else:
        titleStr = R.strings.epic_battle.tooltips.common.title()
    return formatters.packTitleDescBlock(
        title=text_styles.middleTitle(
            backport.text(titleStr, season=int2roman(cycleNumber))),
        desc=text_styles.main(
            backport.text(
                R.strings.epic_battle.selectorTooltip.epicBattle.body(),
                bodyVehicleLevel=descLvl)),
        padding=formatters.packPadding(top=20, left=20, right=20),
        descPadding=formatters.packPadding(right=30))
 def getSeasonEndTime(self):
     generalSettings = self.lobbyContext.getServerSettings().epicBattles
     if time_utils.getCurrentLocalServerTimestamp(
     ) < generalSettings.season['start']:
         return (generalSettings.season['start'], False)
     else:
         return (None, False) if time_utils.getCurrentLocalServerTimestamp(
         ) > generalSettings.season['end'] else (
             generalSettings.season['end'], True)
Exemplo n.º 7
0
 def _update(self):
     calendar = self.getCalendar()
     if calendar is not None:
         lowerTimeBound = time_utils.getCurrentLocalServerTimestamp() - self.TIME_LIMITS.LOW
         higherTimeBound = time_utils.getCurrentLocalServerTimestamp() + self.TIME_LIMITS.HIGH
         calendar.as_setMinAvailableDateS(lowerTimeBound)
         calendar.as_setMaxAvailableDateS(higherTimeBound)
         calendar.as_openMonthS(self.__selectedDate)
         calendar.as_selectDateS(self.__selectedDate)
     self._populateMonthEvents()
     self._populatePreviewBlock()
     self._populateCalendarMessage()
 def isDailyQuestsRefreshAvailable(self):
     if self.hasPrimeTimesLeftForCurrentCycle():
         return True
     primeTimePeriodsForDay = self.getPrimeTimesForDay(
         time_utils.getCurrentLocalServerTimestamp())
     if primeTimePeriodsForDay:
         _, periodTimeEnd = max(primeTimePeriodsForDay.values(),
                                key=itemgetter(1))
         periodTimeLeft = periodTimeEnd - time_utils.getCurrentLocalServerTimestamp(
         )
         return periodTimeLeft > time_utils.getDayTimeLeft()
     return False
Exemplo n.º 9
0
    def isDailyQuestsRefreshAvailable(self):
        if self.hasPrimeTimesLeftForCurrentCycle():
            return True
        serversPeriodsMapping = self.getPrimeTimesForDay(
            time_utils.getCurrentLocalServerTimestamp())
        periods = []
        for _, dayPeriods in serversPeriodsMapping.items():
            periods.append(max([periodEnd for _, periodEnd in dayPeriods]))

        if periods:
            periodTimeLeft = max(
                periods) - time_utils.getCurrentLocalServerTimestamp()
            return periodTimeLeft > time_utils.getDayTimeLeft()
        return False
 def getPrimeTimeStatus(self, peripheryID=None):
     if peripheryID is None:
         peripheryID = self.__connectionMgr.peripheryID
     primeTime = self.getPrimeTimes().get(peripheryID)
     if primeTime is None:
         return (PrimeTimeStatus.NOT_SET, 0, False)
     elif not primeTime.hasAnyPeriods():
         return (PrimeTimeStatus.FROZEN, 0, False)
     else:
         season = self.getCurrentSeason()
         currTime = time_utils.getCurrentLocalServerTimestamp()
         if season and season.hasActiveCycle(currTime):
             isNow, timeTillUpdate = primeTime.getAvailability(
                 currTime, season.getCycleEndDate())
         else:
             timeTillUpdate = 0
             if season:
                 nextCycle = season.getNextByTimeCycle(currTime)
                 if nextCycle:
                     primeTimeStart = primeTime.getNextPeriodStart(
                         nextCycle.startDate,
                         season.getEndDate(),
                         includeBeginning=True)
                     if primeTimeStart:
                         timeTillUpdate = max(
                             primeTimeStart, nextCycle.startDate) - currTime
             isNow = False
         return (PrimeTimeStatus.AVAILABLE, timeTillUpdate,
                 isNow) if isNow else (PrimeTimeStatus.NOT_AVAILABLE,
                                       timeTillUpdate, False)
Exemplo n.º 11
0
 def __getStatusTitle(self):
     currServerName = self._connectionMgr.serverUserNameShort
     status, timeLeft, _ = self.__rankedController.getPrimeTimeStatus()
     if status == PrimeTimeStatus.NOT_AVAILABLE:
         if not timeLeft:
             currentSeason = self.__rankedController.getCurrentSeason()
             return text_styles.grandTitle(
                 backport.text(R.strings.ranked_battles.primeTime.status.
                               seasonDisabled(),
                               season=currentSeason.getUserName(),
                               server=currServerName))
         if not self._hasAvailableServers():
             return text_styles.grandTitle(
                 backport.text(R.strings.ranked_battles.primeTime.status.
                               allServersDisabled()))
         startTime = formatDate(
             '%H:%M',
             time_utils.getCurrentLocalServerTimestamp() + timeLeft)
         return text_styles.grandTitle(
             backport.text(
                 R.strings.ranked_battles.primeTime.status.untill(),
                 startTime=startTime,
                 server=currServerName))
     return text_styles.grandTitle(
         backport.text(
             R.strings.ranked_battles.primeTime.status.disableFirst(),
             server=currServerName))
Exemplo n.º 12
0
    def __startRentTimeNotifyCallback(self):
        if not self.itemsCache.isSynced():
            return
        self.__vehiclesForUpdate = []
        rentedVehicles = self.itemsCache.items.getVehicles(REQ_CRITERIA.VEHICLE.RENT ^ REQ_CRITERIA.VEHICLE.RENT_PROMOTION).values()
        notificationList = []
        for vehicle in rentedVehicles:
            delta = vehicle.rentLeftTime
            if delta > 0:
                notificationList.append((vehicle.intCD, self.getDeltaPeriod(delta), vehicle.isRentPromotion))

        nextRentNotification = maxint
        if notificationList:
            _, nextRentNotification, forceUpdate = min(notificationList, key=itemgetter(1))
            for item in notificationList:
                if item[1] == nextRentNotification or forceUpdate:
                    self.__vehiclesForUpdate.append(item[0])

            nextRentNotification = max(nextRentNotification, 0)
        for seasonType in SEASON_NAME_BY_TYPE:
            currentSeason = self.seasonsController.getCurrentSeason(seasonType)
            if currentSeason:
                now = time_utils.getCurrentLocalServerTimestamp()
                if currentSeason.hasActiveCycle(now):
                    nextCycleChange = currentSeason.getCycleEndDate()
                else:
                    nextCycleChange = currentSeason.getCycleStartDate()
                delta = int(time_utils.getTimeDeltaFromNow(time_utils.makeLocalServerTime(nextCycleChange)))
                if delta > 0:
                    nextRentNotification = min(nextRentNotification, self.getDeltaPeriod(delta)) + 1

        if not notificationList and nextRentNotification == maxint:
            return
        self.__rentNotifyTimeCallback = BigWorld.callback(nextRentNotification, self.__notifyRentTime)
 def __updateViewModel(self):
     if not isMapboxEntryPointAvailable():
         return
     with self.viewModel.transaction() as model:
         currServerTime = time_utils.getCurrentLocalServerTimestamp()
         model.setEndDate(self.__mapboxCtrl.getEventEndTimestamp() +
                          time_utils.getCurrentTimestamp() - currServerTime)
Exemplo n.º 14
0
 def __invalidatePrimeTimeStatus(self):
     currTime = int(time_utils.getCurrentLocalServerTimestamp())
     if self.__invalidationTime < currTime:
         primeTimeData = self._periodsController.getPrimeTimeStatus(
             peripheryID=self.__peripheryID)
         self.__primeTimeStatus, self.__timeLeft, self.__isAvailable = primeTimeData
         self.__invalidationTime = currTime
 def __getStatusText(self):
     if not self.__eventProgression.hasAvailablePrimeTimeServers():
         return EPIC_BATTLE.PRIMETIME_STATUS_NOPRIMETIMESONALLSERVERS
     else:
         currServerName = self._connectionMgr.serverUserName
         primeTime = self.__eventProgression.getPrimeTimes().get(
             self._connectionMgr.peripheryID)
         timestamp, status = self.__eventProgression.getCurrentCycleInfo()
         currTime = time_utils.getCurrentLocalServerTimestamp()
         if status and primeTime:
             startTime = primeTime.getNextPeriodStart(currTime, timestamp)
             if startTime:
                 if startTime - currTime > time_utils.ONE_DAY:
                     startTimeStr = backport.getShortDateFormat(startTime)
                 else:
                     startTimeStr = backport.getShortTimeFormat(startTime)
                 return _ms(
                     EPIC_BATTLE.PRIMETIME_STATUS_NOPRIMETIMEONTHISSERVER,
                     startTime=startTimeStr,
                     server=currServerName)
         season = self.__eventProgression.getCurrentSeason()
         if season is not None and primeTime is not None:
             lastCycle = season.getLastActiveCycleInfo(currTime)
             if lastCycle:
                 return _ms(
                     EPIC_BATTLE.PRIMETIME_STATUS_CYCLEFINISHEDONTHISSERVER,
                     cycleNo=lastCycle.ordinalNumber,
                     server=currServerName)
         return _ms(EPIC_BATTLE.PRIMETIME_STATUS_DISABLEDONTHISSERVER,
                    server=currServerName)
Exemplo n.º 16
0
    def getSeasonAchievements(self, _):
        achievements = self.__itemsCache.items.getAccountDossier(
        ).getDossierDescr().expand('epicSeasons')
        seasonsAchievements = []
        season = self.__epicController.getCurrentSeason(
        ) or self.__epicController.getPreviousSeason()
        if not season:
            return seasonsAchievements
        for seasonID, cycleID in achievements:
            if season.getSeasonID(
            ) == seasonID and cycleID in season.getAllCycles():
                key = (seasonID, cycleID)
                seasonsAchievements.append(
                    EpicSeasonAchievements(*(key +
                                             achievements[key]))._asdict())

        if season.hasActiveCycle(time_utils.getCurrentLocalServerTimestamp()):
            stats = self.__epicController.getStats()
            seasonsAchievements.append(
                EpicSeasonAchievements(
                    season_id=season.getSeasonID(),
                    episode_id=season.getCycleID(),
                    battle_count=stats.battleCount,
                    average_xp=stats.averageXP,
                    lvl=stats.playerLevelInfo[0],
                    battle_bp_points=stats.seasonData[2].get(
                        'battlePassPoints', 0),
                    season_bp_points=stats.seasonData[2].get(
                        'seasonBattlePassPoints', 0))._asdict())
        return seasonsAchievements
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 getPrimeTimeStatus(self, peripheryID=None):
        if not self.isEnabled():
            return (PRIME_TIME_STATUS.DISABLED, 0, False)
        else:
            if peripheryID is None:
                peripheryID = self.connectionMgr.peripheryID
            primeTimes = self.getPrimeTimes()
            hasAnyPeriods = False
            for pId in primeTimes:
                hasAnyPeriods = primeTimes[pId].hasAnyPeriods()
                if hasAnyPeriods:
                    break

            if not hasAnyPeriods:
                LOG_WARNING('RankedBattles enabled but primetimes did not have any period to play or they are frozen!')
            primeTime = primeTimes.get(peripheryID)
            if primeTime is None:
                if hasAnyPeriods:
                    return (PRIME_TIME_STATUS.NOT_SET, 0, False)
                LOG_WARNING('RankedBattles primetimes did not have playable period on pID:', peripheryID)
                return (PRIME_TIME_STATUS.DISABLED, 0, False)
            if not primeTime.hasAnyPeriods():
                return (PRIME_TIME_STATUS.FROZEN, 0, False)
            currentSeason = self.getCurrentSeason()
            if currentSeason is None:
                return (PRIME_TIME_STATUS.NO_SEASON, 0, False)
            isNow, timeLeft = primeTime.getAvailability(time_utils.getCurrentLocalServerTimestamp(), self.getCurrentSeason().getCycleEndDate())
            return (PRIME_TIME_STATUS.AVAILABLE, timeLeft, isNow) if isNow else (PRIME_TIME_STATUS.NOT_AVAILABLE, timeLeft, False)
    def _packBlocks(self, *_):
        items = super(PeriodicCalendarDayTooltip, self)._packBlocks()
        if not self._controller.isAvailable():
            return items
        now = time_utils.getCurrentLocalServerTimestamp()
        serversPeriodsMapping = self._controller.getPrimeTimesForDay(now)
        blocks = [self._packHeaderBlock()]
        timeFmt = backport.getShortTimeFormat
        for serverName in natsorted(serversPeriodsMapping.keys()):
            dayPeriods = serversPeriodsMapping[serverName]
            if dayPeriods:
                periodsStr = [
                    backport.text(self._RES_ROOT.time(),
                                  start=timeFmt(periodStart),
                                  end=timeFmt(periodEnd))
                    for periodStart, periodEnd in dayPeriods
                ]
            else:
                periodsStr = backport.text(R.strings.common.common.dash())
            blocks.append(
                self.__packServerTimeBlock(serverStr=text_styles.main(
                    backport.text(self._RES_ROOT.serverName(),
                                  server=serverName)),
                                           timeStr=text_styles.stats(
                                               '\n'.join(periodsStr))))

        items.append(formatters.packBuildUpBlockData(blocks, _TOOLTIP_MARGIN))
        return items
    def _getLastFutureCycleRentInfo(self):
        now = time_utils.getCurrentLocalServerTimestamp()
        for seasonType, rentTypes in self.seasonRent.iteritems():
            currentSeason = self.seasonsController.getCurrentSeason(seasonType)
            if currentSeason:
                currentCycleID = currentSeason.getCycleID(
                ) or currentSeason.getLastActiveCycleID(now)
                futureCycleRents = first(
                    sorted([
                        item[0] for item in rentTypes
                        if item[1] == SeasonRentDuration.SEASON_CYCLE
                        and item[0] > currentCycleID
                    ],
                           reverse=True))
                if futureCycleRents:
                    lastFutureCycleRentID = futureCycleRents
                    cycleInfo = currentSeason.getCycleInfo(
                        lastFutureCycleRentID)
                    if cycleInfo:
                        return SeasonRentInfo(seasonType,
                                              lastFutureCycleRentID,
                                              SeasonRentDuration.SEASON_CYCLE,
                                              cycleInfo.endDate)

        return None
 def _getTimeLeft(self, pID):
     primeTime = self.rankedController.getPrimeTimes().get(pID)
     currentSeason = self.rankedController.getCurrentSeason()
     _, timeLeft = primeTime.getAvailability(
         time_utils.getCurrentLocalServerTimestamp(),
         currentSeason.getCycleEndDate())
     return timeLeft
 def __getTimeText(self, serverInfo):
     if serverInfo:
         timeLeft = serverInfo.getTimeLeft()
         isAvailable = serverInfo.isAvailable()
         serverName = serverInfo.getName()
     else:
         _, timeLeft, isAvailable = self.__eventProgression.getPrimeTimeStatus(
         )
         serverName = ''
     currentSeason = self.__eventProgression.getCurrentSeason()
     if currentSeason and not timeLeft:
         return _ms(EPIC_BATTLE.PRIMETIME_ENDOFCYCLE, server=serverName)
     if not timeLeft and not isAvailable and not currentSeason:
         nextSeason = self.__eventProgression.getNextSeason()
         if nextSeason:
             currTime = time_utils.getCurrentLocalServerTimestamp()
             primeTime = self.__eventProgression.getPrimeTimes().get(
                 serverInfo.getPeripheryID())
             startTime = primeTime.getNextPeriodStart(
                 currTime, nextSeason.getEndDate())
             if startTime:
                 timeLeft = startTime - currTime
         else:
             self.destroy()
             return ''
     timeLeftStr = time_utils.getTillTimeString(timeLeft,
                                                MENU.TIME_TIMEVALUESHORT)
     i18nKey = EPIC_BATTLE.PRIMETIME_PRIMEISAVAILABLE if isAvailable else EPIC_BATTLE.PRIMETIME_PRIMEWILLBEAVAILABLE
     return _ms(i18nKey,
                server=serverName,
                time=text_styles.neutral(timeLeftStr))
Exemplo n.º 23
0
 def getSeasonAchievements(self, _):
     dossierDescr = self.__itemsCache.items.getAccountDossier(
     ).getDossierDescr()
     seasonsAchievements = self.__getSeasonAchievements(
         dossierDescr.expand('battleRoyaleSeasons'),
         BattleRoyaleSeasonAchievements)
     currentSeason = self.__battleRoyale.getCurrentSeason()
     if currentSeason and currentSeason.getCycleID():
         now = time_utils.getCurrentLocalServerTimestamp()
         stats = self.__battleRoyale.getStats()
         seasonsAchievements[currentSeason.getSeasonID(),
                             currentSeason.getCycleID()] = {
                                 'battle_count':
                                 stats.battleCount,
                                 'kill_count':
                                 stats.killCount,
                                 'top1':
                                 stats.topCount,
                                 'season_id':
                                 currentSeason.getSeasonID(),
                                 'episode_id':
                                 currentSeason.getCycleID()
                                 or currentSeason.getLastActiveCycleID(now)
                             }
     return seasonsAchievements.values()
 def getRentalPeriodInCycles(self):
     activeSeasonRentInfo = self.getActiveSeasonRent()
     if not activeSeasonRentInfo:
         return
     else:
         seasonType, rentID, duration, _ = activeSeasonRentInfo
         currentSeason = self.seasonsController.getCurrentSeason(seasonType)
         if currentSeason:
             if duration == SeasonRentDuration.ENTIRE_SEASON:
                 if self.seasonsController.isWithinSeasonTime(
                         rentID, seasonType):
                     curCycle = currentSeason.getCycleInfo()
                     lastCycle = currentSeason.getLastCycleInfo()
                     if curCycle is None or lastCycle is None:
                         return
                     if curCycle == lastCycle:
                         return (curCycle, )
                     return (curCycle, lastCycle)
             elif duration == SeasonRentDuration.SEASON_CYCLE:
                 now = time_utils.getCurrentLocalServerTimestamp()
                 curCycle = currentSeason.getCycleInfo(
                 ) or currentSeason.getNextByTimeCycle(now)
                 if curCycle:
                     lastFutureCycleInfo = self._getLastFutureCycleRentInfo(
                     )
                     if lastFutureCycleInfo and lastFutureCycleInfo.seasonID != curCycle.ID:
                         lastCycle = currentSeason.getCycleInfo(
                             lastFutureCycleInfo.seasonID)
                         return (curCycle, lastCycle)
                     return (curCycle, )
         return
def packEpicBattleSeasonBlock(epicController=None):
    if not epicController.isEnabled():
        return
    else:
        season = epicController.getCurrentSeason(
        ) or epicController.getNextSeason()
        currentTime = time_utils.getCurrentLocalServerTimestamp()
        if epicController.isCurrentCycleActive():
            cycle = season.getCycleInfo()
            getDate = lambda c: c.endDate
            getTimeToStr = getTimeToEndStr
        else:
            cycle = season.getNextByTimeCycle(currentTime) if season else None
            if cycle and cycle.announceOnly:
                return
            getDate = lambda c: c.startDate
            getTimeToStr = getTimeToStartStr
        if cycle is not None:
            description = getTimeToStr(getDate(cycle) - currentTime)
        else:
            description = backport.text(
                R.strings.epic_battle.tooltips.widget.finished())
        return formatters.packBuildUpBlockData([
            formatters.packImageTextBlockData(
                desc=text_styles.main(description),
                padding=formatters.packPadding(left=20, right=20))
        ])
Exemplo n.º 26
0
 def _getStatusText(self):
     if not self._getController().hasAvailablePrimeTimeServers():
         return backport.text(R.strings.epic_battle.primeTime.status.
                              noPrimeTimesOnAllServers())
     else:
         currServerName = self._connectionMgr.serverUserName
         primeTime = self._getController().getPrimeTimes().get(
             self._connectionMgr.peripheryID)
         timestamp, status = self._getController().getCurrentCycleInfo()
         currTime = time_utils.getCurrentLocalServerTimestamp()
         if status and primeTime:
             startTime = primeTime.getNextPeriodStart(currTime, timestamp)
             if startTime:
                 if startTime - currTime > time_utils.ONE_DAY:
                     startTimeStr = backport.getShortDateFormat(startTime)
                 else:
                     startTimeStr = backport.getShortTimeFormat(startTime)
                 return backport.text(R.strings.epic_battle.primeTime.
                                      status.noPrimeTimeOnThisServer(),
                                      startTime=startTimeStr,
                                      server=currServerName)
         season = self._getController().getCurrentSeason()
         if season is not None and primeTime is not None:
             lastCycle = season.getLastActiveCycleInfo(currTime)
             if lastCycle:
                 return self._getCycleFinishedOnThisServerText(
                     cycleNumber=lastCycle.ordinalNumber,
                     serverName=currServerName)
         return backport.text(
             R.strings.epic_battle.primeTime.status.disabledOnThisServer(),
             server=currServerName)
Exemplo n.º 27
0
    def _packBlocks(self, selectedTime):
        if selectedTime is None:
            selectedTime = time_utils.getCurrentLocalServerTimestamp()
        items = super(RankedCalendarDayTooltip, self)._packBlocks()
        seasonEnd = None
        if self.rankedController.getCurrentSeason():
            seasonEnd = self.rankedController.getCurrentSeason().getEndDate()
            seasonEnd = datetime.fromtimestamp(seasonEnd).date()
        if datetime.fromtimestamp(selectedTime).date() > seasonEnd:
            return items
        else:
            blocks = [self.__packHeaderBlock()]
            serversPeriodsMapping = self.rankedController.getPrimeTimesForDay(selectedTime)
            frmt = backport.getShortTimeFormat
            for serverName in sorted(serversPeriodsMapping.keys()):
                periodsStr = []
                dayPeriods = serversPeriodsMapping[serverName]
                if dayPeriods:
                    for periodStart, periodEnd in dayPeriods:
                        periodsStr.append(backport.text(R.strings.ranked_battles.calendarDay.time(), start=frmt(periodStart), end=frmt(periodEnd)))

                else:
                    periodsStr = backport.text(R.strings.common.common.dash())
                blocks.append(self.__packServerTimeBlock(serverStr=text_styles.main(backport.text(R.strings.ranked_battles.calendarDay.serverName(), server=serverName)), timeStr=text_styles.stats('\n'.join(periodsStr))))

            items.append(formatters.packBuildUpBlockData(blocks, 13))
            return items
    def _onLoading(self, engravingId):
        viewModel = self.getViewModel()
        dtHelper = BigWorld.player().dogTags
        with viewModel.transaction() as model:
            engravingComponent = dtHelper.getDogTagComponentForAccount(
                engravingId)
            engravingId = engravingComponent.compId
            skillRecords = sorted(dtHelper.getSkillData(engravingId),
                                  key=lambda e: e.date)
            indexMax = -1
            if skillRecords:
                maxValue = max(skillRecords[::-1], key=attrgetter('value'))
                if maxValue.value >= engravingComponent.componentDefinition.grades[
                        0]:
                    indexMax = skillRecords.index(maxValue)
            model.setHighlightedIndex(indexMax)
            monthNames = model.getMonthNames()
            monthlyValues = model.getMonthlyValues()
            for date, value in skillRecords:
                monthRes = self._getMonthRes(date[1])
                monthNames.addResource(monthRes)
                if value is not None:
                    monthlyValues.addReal(value)

            currentMonth = getTimeStructInLocal(
                getCurrentLocalServerTimestamp()).tm_mon
            model.setCurrentMonth(self._getMonthRes(currentMonth))
            model.setProgressNumberType(
                engravingComponent.componentDefinition.numberType.value)
        return
 def __getAlertStatusText(self, timeLeft, unsuitablePeriphery,
                          hasAvailableServers):
     rAlertMsgBlock = R.strings.battle_royale.widgetAlertMessageBlock
     alertStr = ''
     if hasAvailableServers:
         if unsuitablePeriphery:
             alertStr = backport.text(
                 R.strings.battle_royale.alertMessage.unsuitablePeriphery())
         else:
             alertStr = backport.text(
                 rAlertMsgBlock.somePeripheriesHalt(),
                 serverName=self.__connectionMgr.serverUserNameShort)
     else:
         currSeason = self.__battleRoyaleController.getCurrentSeason()
         currTime = time_utils.getCurrentLocalServerTimestamp()
         primeTime = self.__battleRoyaleController.getPrimeTimes().get(
             self.__connectionMgr.peripheryID)
         isCycleNow = currSeason and currSeason.hasActiveCycle(
             currTime) and primeTime and primeTime.getPeriodsBetween(
                 currTime, currSeason.getCycleEndDate())
         if isCycleNow:
             if self.__connectionMgr.isStandalone():
                 key = rAlertMsgBlock.singleModeHalt
             else:
                 key = rAlertMsgBlock.allPeripheriesHalt
             timeLeftStr = time_utils.getTillTimeString(
                 timeLeft,
                 EPIC_BATTLE.STATUS_TIMELEFT,
                 removeLeadingZeros=True)
             alertStr = backport.text(key(), time=timeLeftStr)
         else:
             nextSeason = currSeason or self.__battleRoyaleController.getNextSeason(
             )
             if nextSeason is not None:
                 nextCycle = nextSeason.getNextByTimeCycle(currTime)
                 if nextCycle is not None:
                     cycleNumber = nextCycle.getEpicCycleNumber()
                     timeLeftStr = time_utils.getTillTimeString(
                         nextCycle.startDate - currTime,
                         EPIC_BATTLE.STATUS_TIMELEFT,
                         removeLeadingZeros=True)
                     alertStr = backport.text(
                         rAlertMsgBlock.startIn.single()
                         if nextSeason.isSingleCycleSeason() else
                         rAlertMsgBlock.startIn.multi(),
                         cycle=int2roman(cycleNumber),
                         time=timeLeftStr)
             if not alertStr:
                 prevSeason = currSeason or self.__battleRoyaleController.getPreviousSeason(
                 )
                 if prevSeason is not None:
                     prevCycle = prevSeason.getLastActiveCycleInfo(currTime)
                     if prevCycle is not None:
                         cycleNumber = prevCycle.getEpicCycleNumber()
                         alertStr = backport.text(
                             rAlertMsgBlock.noCycleMessage.single()
                             if prevSeason.isSingleCycleSeason() else
                             rAlertMsgBlock.noCycleMessage.multi(),
                             cycle=int2roman(cycleNumber))
     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))
Exemplo n.º 31
0
 def __setAttacksAndDefenses(self):
     clanID = self.itemData.clanDBID
     currentUserTime = time_utils.getCurrentLocalServerTimestamp()
     self.__upcomingAttacks = self.__fort.getAttacks(clanID, lambda item: item.isPlanned())
     self.__attacksInCooldown = self.__fort.getAttacks(
         clanID,
         lambda item: currentUserTime < item.getStartTime() + fortified_regions.g_cache.attackCooldownTime
         and item.isEnded(),
     )
     self.__defencesInCooldown = self.__fort.getDefences(
         clanID, lambda item: currentUserTime > item.getStartTime() and item.isEnded()
     )
Exemplo n.º 32
0
 def getDisplayableData(self):
     return {'name': i18n.makeString(TOOLTIPS.FORTWRONGTIME_HEADER),
      'descr': i18n.makeString(TOOLTIPS.FORTWRONGTIME_BODY, local=BigWorld.wg_getShortTimeFormat(time_utils.getCurrentTimestamp()), server=BigWorld.wg_getShortTimeFormat(time_utils.getCurrentLocalServerTimestamp()))}
Exemplo n.º 33
0
 def __init__(self, ctx):
     super(FortDatePickerPopover, self).__init__()
     self.__selectedDate = ctx['data'].timestamp
     self.__lowerTimeBound = time_utils.getCurrentLocalServerTimestamp() + fortified_regions.g_cache.attackPreorderTime
     self.__higherTimeBound = self.__lowerTimeBound + (FORTIFICATION_ALIASES.ACTIVE_EVENTS_FUTURE_LIMIT - 1) * time_utils.ONE_DAY
 def _getTimeStamp(self):
     return time_utils.getCurrentLocalServerTimestamp()