예제 #1
0
    def onLobbyStarted(self, ctx):
        """
        Starting new game session.
        @param ctx: lobby start context
        """
        sessionStartTime = ctx.get('sessionStartedAt', -1)
        LOG_DEBUG('GameSessionController::start', sessionStartTime)
        from gui.shared.utils.requesters import StatsRequester
        self.__stats = yield StatsRequester().request()
        self.__sessionStartedAt = sessionStartTime
        if constants.RESTRICTION_TYPE.BAN in self.__stats.restrictions:
            for ban in self.__stats.restrictions[constants.RESTRICTION_TYPE.BAN].itervalues():
                if ban.get('reason') == '#ban_reason:curfew_ban':
                    self.isAdult = False

        if self.__doNotifyInStart:
            self.__notifyClient()
        self.startNotification()
        if self.__banCallback is None:
            self.__midnightBlockTime = self.MIDNIGHT_BLOCK_TIME - time_utils.getServerRegionalTimeCurrentDay()
            playTimeLeft = min([self.getDailyPlayTimeLeft(), self.getWeeklyPlayTimeLeft()])
            self.__playTimeBlockTime = playTimeLeft - self.PLAY_TIME_LEFT_NOTIFY
            self.isPlayTimeBlock = self.__playTimeBlockTime < self.__midnightBlockTime
            self.__banCallback = BigWorld.callback(self.__getBlockTime(), self.__onBanNotifyHandler)
        g_clientUpdateManager.addCallbacks({'account': self.__onAccountChanged})
        return
예제 #2
0
 def __notifyClient(self):
     playTimeLeft = None
     if self.isParentControlEnabled:
         playTimeLeft = min([self.getDailyPlayTimeLeft(), self.getWeeklyPlayTimeLeft()])
         playTimeLeft = max(playTimeLeft, 0)
     self.onClientNotify(self.sessionDuration, time_utils.ONE_DAY - time_utils.getServerRegionalTimeCurrentDay(), playTimeLeft)
     return
 def __getDailyResetStatus():
     timeLeft = time_utils.ONE_DAY - time_utils.getServerRegionalTimeCurrentDay()
     if timeLeft >= 0:
         timeFmt = backport.text(R.strings.quests.details.conditions.postBattle.deltaDailyReset.timeFmt())
         try:
             return formatTime(timeFmt, getLanguageCode(), timeLeft)
         except ValueError as e:
             _logger.error("ValueError: formatTime error - '%s'", e)
 def __formatDescription(self, quests):
     season = self._eventProgression.getCurrentSeason(
     ) or self._eventProgression.getNextSeason()
     currentTime = time_utils.getCurrentLocalServerTimestamp()
     cycle = season.getCycleInfo()
     if not self._eventProgression.modeIsAvailable() or cycle is None:
         return ''
     elif self._eventProgression.isNeedAchieveMaxLevelForDailyQuest():
         maxLevel = self._eventProgression.getMaxPlayerLevel()
         description = backport.text(_R_EPIC_BATTLE.unavailable(),
                                     reason=backport.text(
                                         _R_EPIC_BATTLE.restrict.level(),
                                         level=maxLevel))
         return text_styles.concatStylesWithSpace(
             icons.markerBlocked(), text_styles.error(description))
     elif cycle.endDate - currentTime < time_utils.ONE_DAY:
         icon = icons.inProgress(vspace=-3)
         messageID = _R_EPIC_BATTLE.timeLeft
         valueStyle = text_styles.stats
         timeStr = valueStyle(
             backport.text(R.strings.epic_battle.questsTooltip.epicBattle.
                           lessThanDay()))
         textStyle = text_styles.main
         description = textStyle(
             backport.text(messageID(),
                           cycle=int2roman(cycle.ordinalNumber),
                           time=timeStr))
         return text_styles.concatStylesWithSpace(icon, description)
     elif all(
         (q.isCompleted() for q in quests
          )) and self._eventProgression.isDailyQuestsRefreshAvailable():
         data = time_utils.ONE_DAY - time_utils.getServerRegionalTimeCurrentDay(
         )
         valueStyle = text_styles.tutorial
         timeToStr = valueStyle(
             getTimeStr(data, R.strings.menu.Time.timeLeftShort))
         icon = icons.clockGold()
         textStyle = text_styles.tutorial
         description = textStyle(
             backport.text(_R_EPIC_BATTLE.startIn(), time=timeToStr))
         return text_styles.concatStylesWithSpace(icon, description)
     else:
         getDate = lambda c: c.endDate
         messageID = _R_EPIC_BATTLE.timeLeft
         icon = icons.inProgress(vspace=-3)
         textStyle = text_styles.main
         valueStyle = text_styles.stats
         timeToStr = valueStyle(
             getTimeStr(
                 getDate(cycle) - currentTime,
                 R.strings.menu.Time.timeLeftShort))
         description = textStyle(
             backport.text(messageID(),
                           cycle=int2roman(cycle.ordinalNumber),
                           time=timeToStr))
         return text_styles.concatStylesWithSpace(icon, description)
예제 #5
0
 def __getDailyResetStatus():
     timeLeft = time_utils.ONE_DAY - time_utils.getServerRegionalTimeCurrentDay()
     if timeLeft >= 0:
         timeFmt = backport.text(R.strings.quests.details.conditions.postBattle.deltaDailyReset.timeFmt())
         parts = time_utils.getTimeStructInUTC(timeLeft)
         try:
             return time.strftime(timeFmt, parts)
         except ValueError:
             _logger.error('Current time locale: %r', locale.getlocale(locale.LC_TIME))
             _logger.error('Selected language: %r', getLanguageCode())
             _logger.exception('Invalid formatting string %r to delta of time %r', timeFmt, parts)
예제 #6
0
 def isParentControlActive(self):
     """
     Is parent control active now: current time between
     MIDNIGHT_BLOCK_TIME and midnight or playing time is less
     than PLAY_TIME_LEFT_NOTIFY.
     
     @return: <bool> is parent control active now
     """
     playTimeLeft = min([self.getDailyPlayTimeLeft(), self.getWeeklyPlayTimeLeft()])
     parentControl = self.isParentControlEnabled and playTimeLeft <= self.PLAY_TIME_LEFT_NOTIFY
     curfewControl = not self.isAdult and (time_utils.getServerRegionalTimeCurrentDay() >= self.MIDNIGHT_BLOCK_TIME or time_utils.getServerRegionalTimeCurrentDay() <= time_utils.QUARTER_HOUR)
     return parentControl or curfewControl
예제 #7
0
 def _getStatus(self, pCur=None):
     if self.event.isCompleted(progress=pCur):
         if self.event.bonusCond.isDaily():
             msg = i18n.makeString(
                 '#quests:details/status/completed/daily',
                 time=self._getTillTimeString(
                     time_utils.ONE_DAY -
                     time_utils.getServerRegionalTimeCurrentDay()))
         else:
             msg = i18n.makeString('#quests:details/status/completed')
         return (EVENT_STATUS.COMPLETED, msg)
     else:
         isAvailable, errorMsg = self.event.isAvailable()
         if not isAvailable:
             timeLeftInfo = self.event.getNearestActivityTimeLeft()
             if errorMsg in (
                     'in_future', 'invalid_weekday',
                     'invalid_time_interval') and timeLeftInfo is not None:
                 startTimeLeft = timeLeftInfo[0]
                 if startTimeLeft > START_TIME_LIMIT:
                     fmt = self._getDateTimeString(
                         self.event.getStartTime())
                 else:
                     fmt = self._getTillTimeString(startTimeLeft)
                 msg = i18n.makeString(
                     '#quests:details/status/notAvailable/%s' % errorMsg,
                     time=fmt)
             else:
                 msg = i18n.makeString(
                     '#quests:details/status/notAvailable/%s' % errorMsg)
             return (EVENT_STATUS.NOT_AVAILABLE, msg)
         bonus = self.event.bonusCond
         bonusLimit = bonus.getBonusLimit()
         if bonusLimit is None or bonusLimit >= MAX_BONUS_LIMIT:
             msg = i18n.makeString(
                 QUESTS.DETAILS_HEADER_COMPLETION_UNLIMITED)
         else:
             groupBy = bonus.getGroupByValue()
             if bonus.isDaily():
                 key = QUESTS.DETAILS_HEADER_COMPLETION_DAILY
                 if groupBy is not None:
                     key = '#quests:details/header/completion/daily/groupBy%s' % groupBy.capitalize(
                     )
             else:
                 key = QUESTS.DETAILS_HEADER_COMPLETION_SINGLE
                 if groupBy is not None:
                     key = '#quests:details/header/completion/single/groupBy%s' % groupBy.capitalize(
                     )
             msg = i18n.makeString(key, count=bonusLimit)
         return (EVENT_STATUS.NONE, msg)
def getQuestsDescriptionForHangarFlag(battleRoyaleController=None):
    quests = battleRoyaleController.getQuests()
    season = battleRoyaleController.getCurrentSeason(
    ) or battleRoyaleController.getNextSeason()
    currentTime = time_utils.getCurrentLocalServerTimestamp()
    cycle = season.getCycleInfo()
    if not battleRoyaleController.isActive() or cycle is None:
        return ''
    elif cycle.endDate - currentTime < time_utils.ONE_DAY:
        icon = icons.inProgress(vspace=-3)
        messageID = _R_BATTLE_ROYALE.timeLeft
        valueStyle = text_styles.stats
        timeStr = valueStyle(
            backport.text(R.strings.battle_royale.questsTooltip.lessThanDay()))
        textStyle = text_styles.main
        description = textStyle(
            backport.text(messageID(),
                          cycle=int2roman(cycle.ordinalNumber),
                          time=timeStr))
        return text_styles.concatStylesWithSpace(icon, description)
    elif all((q.isCompleted() for _, q in quests.items())):
        data = time_utils.ONE_DAY - time_utils.getServerRegionalTimeCurrentDay(
        )
        valueStyle = text_styles.tutorial
        timeToStr = valueStyle(
            getTimeStr(data, R.strings.menu.Time.timeLeftShort))
        icon = icons.clockGold()
        textStyle = text_styles.tutorial
        description = textStyle(
            backport.text(_R_BATTLE_ROYALE.startIn(), time=timeToStr))
        return text_styles.concatStylesWithSpace(icon, description)
    else:
        getDate = lambda c: c.endDate
        messageID = _R_BATTLE_ROYALE.timeLeft
        icon = icons.inProgress(vspace=-3)
        textStyle = text_styles.main
        valueStyle = text_styles.stats
        timeToStr = valueStyle(
            getTimeStr(
                getDate(cycle) - currentTime,
                R.strings.menu.Time.timeLeftShort))
        description = textStyle(
            backport.text(messageID(),
                          cycle=int2roman(cycle.ordinalNumber),
                          time=timeToStr))
        return text_styles.concatStylesWithSpace(icon, description)
예제 #9
0
 def _getStatus(self, pCur=None):
     if self.event.isCompleted(progress=pCur):
         if self.event.bonusCond.isDaily():
             msg = i18n.makeString(
                 "#quests:details/status/completed/daily",
                 time=self._getTillTimeString(time_utils.ONE_DAY - time_utils.getServerRegionalTimeCurrentDay()),
             )
         else:
             msg = i18n.makeString("#quests:details/status/completed")
         return (EVENT_STATUS.COMPLETED, msg)
     isAvailable, errorMsg = self.event.isAvailable()
     if not isAvailable:
         timeLeftInfo = self.event.getNearestActivityTimeLeft()
         if errorMsg in ("in_future", "invalid_weekday", "invalid_time_interval") and timeLeftInfo is not None:
             startTimeLeft = timeLeftInfo[0]
             if startTimeLeft > START_TIME_LIMIT:
                 fmt = self._getDateTimeString(self.event.getStartTime())
             else:
                 fmt = self._getTillTimeString(startTimeLeft)
             msg = i18n.makeString("#quests:details/status/notAvailable/%s" % errorMsg, time=fmt)
         else:
             msg = i18n.makeString("#quests:details/status/notAvailable/%s" % errorMsg)
         return (EVENT_STATUS.NOT_AVAILABLE, msg)
     bonus = self.event.bonusCond
     bonusLimit = bonus.getBonusLimit()
     if bonusLimit is None or bonusLimit >= MAX_BONUS_LIMIT:
         msg = i18n.makeString(QUESTS.DETAILS_HEADER_COMPLETION_UNLIMITED)
     else:
         groupBy = bonus.getGroupByValue()
         if bonus.isDaily():
             key = QUESTS.DETAILS_HEADER_COMPLETION_DAILY
             if groupBy is not None:
                 key = "#quests:details/header/completion/daily/groupBy%s" % groupBy.capitalize()
         else:
             key = QUESTS.DETAILS_HEADER_COMPLETION_SINGLE
             if groupBy is not None:
                 key = "#quests:details/header/completion/single/groupBy%s" % groupBy.capitalize()
         msg = i18n.makeString(key, count=bonusLimit)
     return (EVENT_STATUS.NONE, msg)
예제 #10
0
 def _getCompleteDailyStatus(self, completeKey):
     return i18n.makeString(
         completeKey,
         time=self._getTillTimeString(
             time_utils.ONE_DAY -
             time_utils.getServerRegionalTimeCurrentDay()))
예제 #11
0
 def __notifyNewDay(self):
     nextNotification = time_utils.ONE_DAY - time_utils.getServerRegionalTimeCurrentDay()
     self.onNewDayNotify(nextNotification)
예제 #12
0
 def __getClosestNewDayNotification(self):
     return time_utils.ONE_DAY - time_utils.getServerRegionalTimeCurrentDay()
예제 #13
0
def _getSvrLocalToday():
    return time_utils.getServerRegionalTimeCurrentDay()
def _getSvrLocalToday():
    return time_utils.getServerRegionalTimeCurrentDay()
예제 #15
0
 def __startNewDayNotifyCallback(self):
     self.__clearNewDayNotifyCallback()
     nextNotification = time_utils.ONE_DAY - time_utils.getServerRegionalTimeCurrentDay()
     self.__notifyNewDayCallback = BigWorld.callback(nextNotification, self.__notifyNewDay)