def __onMatchmakingTimerChanged(self, event):
     data = event.ctx
     if data['dtime'] > 0 and data['textid'] in (
             TOOLTIPS.STRONGHOLDS_TIMER_SQUADINQUEUE, FORTIFICATIONS.
             ROSTERINTROWINDOW_INTROVIEW_FORTBATTLES_NEXTTIMEOFBATTLESOON):
         timerLabel = i18n.makeString(FORTIFICATIONS.BATTLEQUEUE_WAITBATTLE)
         currentTime = data['dtime']
     else:
         _, unit = self.prbEntity.getUnit()
         currentTime = 0
         if unit:
             timestamp = unit.getModalTimestamp()
             if timestamp:
                 currentTime = max(
                     0, int(time_utils.getServerUTCTime() - timestamp))
         if data['isSortie'] or data['isFirstBattle']:
             timerLabel = i18n.makeString(
                 FORTIFICATIONS.BATTLEQUEUE_SEARCHENEMY)
         else:
             timerLabel = i18n.makeString(
                 FORTIFICATIONS.BATTLEQUEUE_WAITBATTLE)
     timeLabel = '%d:%02d' % divmod(currentTime, 60)
     self.as_setTimerS(timerLabel, timeLabel)
     n = len(self.__groups)
     if n != 0:
         self.as_hideWaitingS()
         if self.__startAnimationTime is None:
             self.__startAnimationTime = time_utils.getCurrentTimestamp()
         i, r = divmod(
             int(time_utils.getCurrentTimestamp() -
                 self.__startAnimationTime), self.__animationDuration)
         if r == 0:
             self.as_setLeaguesS(self.__groups[i % n])
     return
 def _onMatchmakingTimerChanged(self, event):
     if self.currentState and self.prbEntity.hasLockedState():
         data = event.ctx
         timerState = data['textid']
         if data['dtime'] > 0 and timerState == TOOLTIPS.STRONGHOLDS_TIMER_SQUADINQUEUE:
             self.as_changeAutoSearchMainLabelS(
                 i18n.makeString(
                     CYBERSPORT.WINDOW_AUTOSEARCH_SEARCHENEMY_MAINTEXT))
             self.as_changeAutoSearchCountDownSecondsS(data['dtime'])
         else:
             self.as_changeAutoSearchTimeDirectionS(1)
             _, unit = self.prbEntity.getUnit()
             startTimer = 0
             if unit:
                 timestamp = unit.getModalTimestamp()
                 if timestamp:
                     startTimer = max(
                         0,
                         int(time_utils.getCurrentTimestamp() -
                             time_utils.makeLocalServerTime(timestamp)))
                     LOG_DEBUG('time direction change, timers: ',
                               time_utils.getCurrentTimestamp(),
                               time_utils.makeLocalServerTime(timestamp))
             self.as_changeAutoSearchCountDownSecondsS(startTimer)
             LOG_DEBUG('changeAutoSearchCountDownSeconds', startTimer)
             if data['isSortie'] or data['isFirstBattle']:
                 self.as_changeAutoSearchMainLabelS(
                     i18n.makeString(
                         TOOLTIPS.STRONGHOLDS_TIMER_SEARCHENEMY))
             else:
                 self.as_changeAutoSearchMainLabelS(
                     i18n.makeString(
                         CYBERSPORT.WINDOW_AUTOSEARCH_SEARCHENEMY_MAINTEXT))
Ejemplo n.º 3
0
 def __setData(self):
     _getText = self.app.utilsManager.textManager.getText
     _ms = i18n.makeString
     place, league, division, ladderPts = self.__makeLadderData()
     league = _getText(TextType.STATUS_WARNING_TEXT, str(league))
     division = _getText(TextType.STATUS_WARNING_TEXT, division)
     ladderPts = _getText(TextType.STATUS_WARNING_TEXT, ladderPts)
     placeText = _getText(TextType.PROMO_SUB_TITLE, _ms(CYBERSPORT.STATICFORMATIONSUMMARYVIEW_LADDER_PLACE, place=place))
     leagueDivisionText = _getText(TextType.MIDDLE_TITLE, _ms(CYBERSPORT.STATICFORMATIONSUMMARYVIEW_LADDER_LEAGUEDIVISION, league=league, division=division))
     ladderPtsText = _getText(TextType.MAIN_TEXT, _ms(CYBERSPORT.STATICFORMATIONSUMMARYVIEW_LADDER_LADDERPTS, points=ladderPts))
     bestTanksText = _getText(TextType.STATS_TEXT, _ms(CYBERSPORT.STATICFORMATIONSUMMARYVIEW_BESTTANKS))
     bestMapsText = _getText(TextType.STATS_TEXT, _ms(CYBERSPORT.STATICFORMATIONSUMMARYVIEW_BESTMAPS))
     notEnoughTanksText = notEnoughMapsText = _getText(TextType.STANDARD_TEXT, _ms(CYBERSPORT.STATICFORMATIONSUMMARYVIEW_NOTENOUGHTANKSMAPS))
     registeredDate = time_utils.getCurrentTimestamp() - random.randint(0, 20) * time_utils.ONE_DAY
     lastBattleDate = time_utils.getCurrentTimestamp() - random.randint(0, 20) * time_utils.ONE_DAY
     registeredDate = _getText(TextType.MAIN_TEXT, BigWorld.wg_getShortDateFormat(registeredDate))
     lastBattleDate = _getText(TextType.MAIN_TEXT, BigWorld.wg_getShortDateFormat(lastBattleDate))
     registeredText = _getText(TextType.STANDARD_TEXT, _ms(CYBERSPORT.STATICFORMATIONSUMMARYVIEW_REGISTERED, date=registeredDate))
     lastBattleText = _getText(TextType.STANDARD_TEXT, _ms(CYBERSPORT.STATICFORMATIONSUMMARYVIEW_LASTBATTLE, date=lastBattleDate))
     ladderIconSource = RES_ICONS.MAPS_ICONS_LIBRARY_CYBERSPORT_LADDER_256_1A
     noAwardsText = _getText(TextType.STATS_TEXT, _ms(CYBERSPORT.STATICFORMATIONSUMMARYVIEW_NOAWARDS))
     ribbonSource = RES_ICONS.MAPS_ICONS_LIBRARY_CYBERSPORT_RIBBON
     battlesNumData, winsPercentData, winsByCaptureData, techDefeatsData = self.__makeStats()
     bestTanks, bestMaps = self.__makeBestTanksMaps()
     bestTanksGroupWidth = 152
     bestMapsGroupWidth = 211
     notEnoughTanksTFVisible = False if len(bestTanks) else True
     notEnoughMapsTFVisible = False if len(bestMaps) else True
     result = {'placeText': placeText,
      'leagueDivisionText': leagueDivisionText,
      'ladderPtsText': ladderPtsText,
      'bestTanksText': bestTanksText,
      'bestMapsText': bestMapsText,
      'notEnoughTanksText': notEnoughTanksText,
      'notEnoughMapsText': notEnoughMapsText,
      'registeredText': registeredText,
      'lastBattleText': lastBattleText,
      'ladderIconSource': ladderIconSource,
      'noAwardsText': noAwardsText,
      'ribbonSource': ribbonSource,
      'battlesNumData': battlesNumData,
      'winsPercentData': winsPercentData,
      'winsByCaptureData': winsByCaptureData,
      'techDefeatsData': techDefeatsData,
      'bestTanks': bestTanks,
      'bestMaps': bestMaps,
      'achievements': self.__makeAchievements(),
      'bestTanksGroupWidth': bestTanksGroupWidth,
      'bestMapsGroupWidth': bestMapsGroupWidth,
      'notEnoughTanksTFVisible': notEnoughTanksTFVisible,
      'notEnoughMapsTFVisible': notEnoughMapsTFVisible}
     self.as_setDataS(result)
 def _populate(self):
     super(FortIntelligenceClanFilterPopover, self)._populate()
     headerText = text_styles.highTitle(_ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANFILTERPOPOVER_HEADER))
     clanLevelText = text_styles.standard(_ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANFILTERPOPOVER_CLANLEVEL))
     startHourRangeText = text_styles.standard(_ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANFILTERPOPOVER_STARTHOURRANGE))
     self.as_setDescriptionsTextS(headerText, clanLevelText, startHourRangeText)
     defaultButtonText = _ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANFILTERPOPOVER_DEFAULTBUTTONTEXT)
     applyButtonText = _ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANFILTERPOPOVER_APPLYBUTTONTEXT)
     cancelButtonText = _ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANFILTERPOPOVER_CANCELBUTTONTEXT)
     self.as_setButtonsTextS(defaultButtonText, applyButtonText, cancelButtonText)
     defaultButtonTooltip = TOOLTIPS.FORTIFICATION_FORTINTELLIGENCECLANFILTERPOPOVER_DEFAULT
     applyButtonTooltip = TOOLTIPS.FORTIFICATION_FORTINTELLIGENCECLANFILTERPOPOVER_APPLY
     self.as_setButtonsTooltipsS(defaultButtonTooltip, applyButtonTooltip)
     minClanLevel = FORTIFICATION_ALIASES.CLAN_FILTER_MIN_LEVEL
     maxClanLevel = FORTIFICATION_ALIASES.CLAN_FILTER_MAX_LEVEL
     startDefenseHour = FORTIFICATION_ALIASES.CLAN_FILTER_MIN_HOUR
     startDefenseMin = 0
     cache = self.fortCtrl.getPublicInfoCache()
     if cache:
         minClanLevel, maxClanLevel, startDefenseHour, availability = cache.getDefaultFilterData()
         selectedDate = time.localtime(time_utils.getTimeForLocal(time_utils.getCurrentTimestamp(), max(0, startDefenseHour)))
         startDefenseMin = selectedDate.tm_min
     data = {'minClanLevel': minClanLevel,
      'maxClanLevel': maxClanLevel,
      'startDefenseHour': startDefenseHour,
      'startDefenseMinutes': startDefenseMin,
      'isTwelveHoursFormat': self.app.utilsManager.isTwelveHoursFormat(),
      'isWrongLocalTime': self._isWrongLocalTime(),
      'skipValues': adjustDefenceHoursListToLocal(g_lobbyContext.getServerSettings().getForbiddenFortDefenseHours())}
     defenceStart, _ = self.fortCtrl.getFort().getLocalDefenceHour()
     if defenceStart != NOT_ACTIVATED:
         data['yourOwnClanStartDefenseHour'] = defenceStart
     self.as_setDataS(data)
 def _populate(self):
     super(FortIntelligenceClanFilterPopover, self)._populate()
     headerText = self.app.utilsManager.textManager.getText(TextType.HIGH_TITLE, _ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANFILTERPOPOVER_HEADER))
     clanLevelText = self.app.utilsManager.textManager.getText(TextType.STANDARD_TEXT, _ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANFILTERPOPOVER_CLANLEVEL))
     startHourRangeText = self.app.utilsManager.textManager.getText(TextType.STANDARD_TEXT, _ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANFILTERPOPOVER_STARTHOURRANGE))
     availabilityText = self.app.utilsManager.textManager.getText(TextType.STANDARD_TEXT, _ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANFILTERPOPOVER_AVAILABILITY))
     self.as_setDescriptionsTextS(headerText, clanLevelText, startHourRangeText, availabilityText)
     defaultButtonText = _ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANFILTERPOPOVER_DEFAULTBUTTONTEXT)
     applyButtonText = _ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANFILTERPOPOVER_APPLYBUTTONTEXT)
     cancelButtonText = _ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANFILTERPOPOVER_CANCELBUTTONTEXT)
     self.as_setButtonsTextS(defaultButtonText, applyButtonText, cancelButtonText)
     defaultButtonTooltip = TOOLTIPS.FORTIFICATION_FORTINTELLIGENCECLANFILTERPOPOVER_DEFAULT
     applyButtonTooltip = TOOLTIPS.FORTIFICATION_FORTINTELLIGENCECLANFILTERPOPOVER_APPLY
     self.as_setButtonsTooltipsS(defaultButtonTooltip, applyButtonTooltip)
     minClanLevel = FORTIFICATION_ALIASES.CLAN_FILTER_MIN_LEVEL
     maxClanLevel = FORTIFICATION_ALIASES.CLAN_FILTER_MAX_LEVEL
     startDefenseHour = FORTIFICATION_ALIASES.CLAN_FILTER_MIN_HOUR
     startDefenseMin = 0
     availability = FORTIFICATION_ALIASES.CLAN_FILTER_DAY_ANY
     cache = self.fortCtrl.getPublicInfoCache()
     if cache:
         minClanLevel, maxClanLevel, startDefenseHour, availability = cache.getDefaultFilterData()
         selectedDate = time.localtime(time_utils.getTimeForUTC(time_utils.getCurrentTimestamp(), startDefenseHour))
         startDefenseHour, startDefenseMin = selectedDate.tm_hour, selectedDate.tm_min
     data = {'minClanLevel': minClanLevel,
      'maxClanLevel': maxClanLevel,
      'startDefenseHour': startDefenseHour,
      'startDefenseMinutes': startDefenseMin,
      'isTwelveHoursFormat': self.app.utilsManager.isTwelveHoursFormat(),
      'isWrongLocalTime': self._isWrongLocalTime()}
     defenceStart, _ = self.fortCtrl.getFort().getLocalDefenceHour()
     if defenceStart != NOT_ACTIVATED:
         data['yourOwnClanStartDefenseHour'] = defenceStart
     self.as_setDataS(data)
Ejemplo n.º 6
0
 def _makeLockBlock(self):
     clanLockTime = self.vehicle.clanLock
     if clanLockTime and clanLockTime <= time_utils.getCurrentTimestamp():
         LOG_DEBUG("clan lock time is less than current time: %s" % clanLockTime)
         clanLockTime = None
     isDisabledInRoaming = self.vehicle.isDisabledInRoaming
     if clanLockTime or isDisabledInRoaming:
         headerLock = text_styles.concatStylesToMultiLine(text_styles.warning(_ms(TOOLTIPS.TANKCARUSEL_LOCK_HEADER)))
         if isDisabledInRoaming:
             textLock = text_styles.main(_ms(TOOLTIPS.TANKCARUSEL_LOCK_ROAMING))
         else:
             time = time_utils.getDateTimeFormat(clanLockTime)
             timeStr = text_styles.main(text_styles.concatStylesWithSpace(_ms(TOOLTIPS.TANKCARUSEL_LOCK_TO), time))
             textLock = text_styles.concatStylesToMultiLine(
                 timeStr, text_styles.main(_ms(TOOLTIPS.TANKCARUSEL_LOCK_CLAN))
             )
         lockHeaderBlock = formatters.packTextBlockData(
             headerLock, padding=formatters.packPadding(left=77 + self.leftPadding, top=5)
         )
         lockTextBlock = formatters.packTextBlockData(
             textLock, padding=formatters.packPadding(left=77 + self.leftPadding)
         )
         return formatters.packBuildUpBlockData(
             [lockHeaderBlock, lockTextBlock],
             stretchBg=False,
             linkage=BLOCKS_TOOLTIP_TYPES.TOOLTIP_BUILDUP_BLOCK_LOCK_BG_LINKAGE,
             padding=formatters.packPadding(left=-17, top=20, bottom=0),
         )
     else:
         return
         return
 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)
Ejemplo n.º 8
0
 def _loadExpiryCallback(self):
     self._clearExpiryCallback()
     if self.__invitations:
         invite = min(self.__invitations.values(), key=operator.itemgetter('expiresAt'))
         expTime = max(invite['expiresAt'] - getCurrentTimestamp(), 0.0)
         self.__expCbID = BigWorld.callback(expTime, partial(self.__onInviteExpired, invite))
         LOG_DEBUG('Invite expiration callback has been loaded', _getUniqueId(invite), expTime)
 def _populate(self):
     super(RankedBattlesCalendarPopover, self)._populate()
     self.as_setDataS({
         'rawDate':
         self.__selectedDate,
         'arrowDirection':
         self.arrowDirection,
         'statusText':
         self.__getCurrnetCycleString(),
         'statusTooltip':
         TOOLTIPS_CONSTANTS.RANKED_CALENDAR_STEPS_INFO
     })
     self.onDaySelect(time_utils.getCurrentTimestamp())
     calendar = self.__getCalendar()
     if calendar is not None:
         calendar.as_setMinAvailableDateS(self.__seasonInfo.getStartDate())
         calendar.as_setMaxAvailableDateS(self.__seasonInfo.getEndDate())
         calendar.as_openMonthS(self.__selectedDate)
         calendar.as_selectDateS(self.__selectedDate)
         calendar.as_setHighlightedDaysS([
             self.__seasonInfo.getCycleStartDate(),
             self.__seasonInfo.getCycleEndDate()
         ])
         calendar.as_setDayTooltipTypeS(
             TOOLTIPS_CONSTANTS.RANKED_CALENDAR_DAY_INFO)
     return
Ejemplo n.º 10
0
    def start(self, model):
        result = super(_ClanNotificationsCommonListener, self).start(model)
        self.startClanListening()
        g_wgncEvents.onProxyDataItemShowByDefault += self._onProxyDataItemShow
        self.__startTime = time_utils.getCurrentTimestamp()
        if not self._canBeShown():
            return
        else:
            newReceivedItemType = self._getNewReceivediItemType()
            itemsByType = []
            for notification in g_wgncProvider.getNotMarkedNots():
                proxyDataItem = notification.getProxyItemByType(
                    newReceivedItemType)
                if proxyDataItem is None:
                    continue
                itemsByType.append(proxyDataItem)

            itemsByTypeCount = len(itemsByType)
            LOG_DEBUG('Clan WGNC new notifications count with type = %d: %d' %
                      (newReceivedItemType, itemsByTypeCount))
            if itemsByTypeCount:
                if itemsByTypeCount > 1:
                    self._addMultiNotification(itemsByType)
                else:
                    self._addSingleNotification(itemsByType[0])
            return result
Ejemplo n.º 11
0
    def __onMsgReceived(self, clientID, eventData):
        eType, battleID = eventData
        if eType == MsgCustomEvents.FORT_BATTLE_INVITE:
            self.__fortInvitesData[battleID] = clientID
        elif eType == MsgCustomEvents.FORT_BATTLE_FINISHED:
            model = self._model()
            if model:
                storedClientID = self.__fortInvitesData.get(battleID, None)
                if storedClientID:
                    _, formatted, settings = self.proto.serviceChannel.getMessage(
                        storedClientID)
                    if formatted and settings:
                        if formatted['savedData'][
                                'battleFinishTime'] - time_utils.getCurrentTimestamp(
                                ) < 0:
                            buttonsStates = {}
                            buttonsLayout = formatted.get('buttonsLayout', [])
                            for layout in buttonsLayout:
                                buttonsStates[layout[
                                    'type']] = NOTIFICATION_BUTTON_STATE.VISIBLE

                            formatted['buttonsStates'] = buttonsStates
                            model.updateNotification(NOTIFICATION_TYPE.MESSAGE,
                                                     storedClientID, formatted,
                                                     False)
                            del self.__fortInvitesData[battleID]
        return
Ejemplo n.º 12
0
 def __setData(self):
     dayStartUTC, _ = time_utils.getDayTimeBoundsForUTC(time_utils.getCurrentTimestamp())
     vacationStart = dayStartUTC + time_utils.ONE_DAY + fortified_regions.g_cache.minVacationPreorderTime
     self.as_setDataS({'startVacation': vacationStart,
      'vacationDuration': -1,
      'isAmericanStyle': False,
      'showMonth': SHOW_MAX_MONTH})
Ejemplo n.º 13
0
 def getLocalDefenceDate(self):
     if not self.isDefenceHourEnabled():
         return None
     else:
         return time.localtime(
             time_utils.getTimeForUTC(time_utils.getCurrentTimestamp(),
                                      self.defenceHour))
 def getRentLeftStr(self,
                    localization=None,
                    timeStyle=None,
                    ctx=None,
                    formatter=None,
                    strForSpecialTimeFormat=''):
     activeSeasonRent = self.__rentInfo.getActiveSeasonRent()
     if activeSeasonRent is not None:
         resultStr = self.getRentSeasonLeftStr(activeSeasonRent,
                                               localization, formatter,
                                               timeStyle, ctx)
     elif self.__rentInfo.getTimeLeft() > 0:
         if strForSpecialTimeFormat:
             finishTime = self.__rentInfo.getTimeLeft(
             ) + time_utils.getCurrentTimestamp()
             resultStr = self.getUntilTimeLeftStr(finishTime,
                                                  strForSpecialTimeFormat)
         else:
             resultStr = self.getRentTimeLeftStr(localization, timeStyle,
                                                 ctx, formatter)
     elif self.__rentInfo.battlesLeft:
         resultStr = self.getRentBattlesLeftStr(localization, formatter)
     elif self.__rentInfo.winsLeft > 0:
         resultStr = self.getRentWinsLeftStr(localization, formatter)
     else:
         resultStr = ''
     return resultStr
    def _format(self, bonus):
        result = []
        for vehicle, vehInfo in bonus.getVehicles():
            compensation = bonus.compensation(vehicle)
            if compensation:
                formatter = SimpleBonusFormatter()
                for bonusComp in compensation:
                    result.extend(formatter.format(bonusComp))

            tmanRoleLevel = bonus.getTmanRoleLevel(vehInfo)
            rentDays = bonus.getRentDays(vehInfo)
            rentBattles = bonus.getRentBattles(vehInfo)
            rentWins = bonus.getRentWins(vehInfo)
            if rentDays:
                rentExpiryTime = time_utils.getCurrentTimestamp()
                rentExpiryTime += rentDays * time_utils.ONE_DAY
            else:
                rentExpiryTime = 0
            isRent = rentDays or rentBattles or rentWins
            result.append(
                PreformattedBonus(
                    bonusName=bonus.getName(),
                    label=self._getLabel(vehicle),
                    userName=self._getUserName(vehicle),
                    images=self._getImages(vehicle, isRent),
                    isSpecial=True,
                    specialAlias=TOOLTIPS_CONSTANTS.AWARD_VEHICLE,
                    specialArgs=[
                        vehicle.intCD, tmanRoleLevel, rentExpiryTime,
                        rentBattles, rentWins
                    ],
                    isCompensation=self._isCompensation(bonus)))

        return result
Ejemplo n.º 16
0
 def _getRentExpiryTime(rentDays):
     if rentDays:
         rentExpiryTime = time_utils.getCurrentTimestamp()
         rentExpiryTime += rentDays * time_utils.ONE_DAY
     else:
         rentExpiryTime = 0.0
     return rentExpiryTime
Ejemplo n.º 17
0
 def _loadExpiryCallback(self):
     self._clearExpiryCallback()
     if self.__invitations:
         invite = min(self.__invitations.values(), key=operator.itemgetter('expiresAt'))
         expTime = max(invite['expiresAt'] - getCurrentTimestamp(), 0.0)
         self.__expCbID = BigWorld.callback(expTime, partial(self.__onInviteExpired, invite))
         LOG_DEBUG('Invite expiration callback has been loaded', _getUniqueId(invite), expTime)
 def _populate(self):
     super(FortIntelligenceClanFilterPopover, self)._populate()
     headerText = text_styles.highTitle(_ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANFILTERPOPOVER_HEADER))
     clanLevelText = text_styles.standard(_ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANFILTERPOPOVER_CLANLEVEL))
     startHourRangeText = text_styles.standard(_ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANFILTERPOPOVER_STARTHOURRANGE))
     self.as_setDescriptionsTextS(headerText, clanLevelText, startHourRangeText)
     defaultButtonText = _ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANFILTERPOPOVER_DEFAULTBUTTONTEXT)
     applyButtonText = _ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANFILTERPOPOVER_APPLYBUTTONTEXT)
     cancelButtonText = _ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANFILTERPOPOVER_CANCELBUTTONTEXT)
     self.as_setButtonsTextS(defaultButtonText, applyButtonText, cancelButtonText)
     defaultButtonTooltip = TOOLTIPS.FORTIFICATION_FORTINTELLIGENCECLANFILTERPOPOVER_DEFAULT
     applyButtonTooltip = TOOLTIPS.FORTIFICATION_FORTINTELLIGENCECLANFILTERPOPOVER_APPLY
     self.as_setButtonsTooltipsS(defaultButtonTooltip, applyButtonTooltip)
     minClanLevel = FORTIFICATION_ALIASES.CLAN_FILTER_MIN_LEVEL
     maxClanLevel = FORTIFICATION_ALIASES.CLAN_FILTER_MAX_LEVEL
     startDefenseHour = FORTIFICATION_ALIASES.CLAN_FILTER_MIN_HOUR
     startDefenseMin = 0
     cache = self.fortCtrl.getPublicInfoCache()
     if cache:
         minClanLevel, maxClanLevel, startDefenseHour, availability = cache.getDefaultFilterData()
         selectedDate = time.localtime(time_utils.getTimeForLocal(time_utils.getCurrentTimestamp(), max(0, startDefenseHour)))
         startDefenseMin = selectedDate.tm_min
     data = {'minClanLevel': minClanLevel,
      'maxClanLevel': maxClanLevel,
      'startDefenseHour': startDefenseHour,
      'startDefenseMinutes': startDefenseMin,
      'isTwelveHoursFormat': self.app.utilsManager.isTwelveHoursFormat(),
      'isWrongLocalTime': self._isWrongLocalTime(),
      'skipValues': adjustDefenceHoursListToLocal(g_lobbyContext.getServerSettings().getForbiddenFortDefenseHours())}
     defenceStart, _ = self.fortCtrl.getFort().getLocalDefenceHour()
     if defenceStart != NOT_ACTIVATED:
         data['yourOwnClanStartDefenseHour'] = defenceStart
     self.as_setDataS(data)
 def __onBanNotifyHandler(self):
     LOG_DEBUG('GameSessionController:__onBanNotifyHandler')
     playTimeLeft = min([self.getDailyPlayTimeLeft(), self.getWeeklyPlayTimeLeft()])
     playTimeLeft = max(playTimeLeft, 0)
     banTime = time.strftime('%H:%M', time.localtime(time_utils.getCurrentTimestamp() + playTimeLeft))
     self.__lastBanMsg = (self.isPlayTimeBlock, banTime)
     self.onTimeTillBan(*self.__lastBanMsg)
     self.__loadBanCallback()
Ejemplo n.º 20
0
 def __getClosestSessionTimeNotification(self):
     delay = self.NOTIFY_PERIOD
     if self.__lastNotifyTime is not None:
         timeSinceLastNotify = time_utils.getCurrentTimestamp() - self.__lastNotifyTime
         delay -= timeSinceLastNotify
         if delay <= 0:
             delay = 1
     return delay
Ejemplo n.º 21
0
    def canPlanAttackOn(self, dayTimestamp, clanFortInfo):
        if self.isFrozen():
            return ATTACK_PLAN_RESULT.MY_FROZEN
        currentDefHourTimestamp = time_utils.getTimeForLocal(dayTimestamp, clanFortInfo.getStartDefHour())
        enemyDefHour = clanFortInfo.getDefHourFor(currentDefHourTimestamp)
        enemyDefHourTimestamp = time_utils.getTimeForLocal(dayTimestamp, enemyDefHour)
        if enemyDefHourTimestamp - time_utils.getCurrentTimestamp() <= fortified_regions.g_cache.attackPreorderTime:
            return ATTACK_PLAN_RESULT.PREORDER_TIME
        if self.isOnVacationAt(enemyDefHourTimestamp):
            return ATTACK_PLAN_RESULT.MY_VACATION
        (vacationStart, vacationEnd,) = clanFortInfo.getVacationPeriod()
        if vacationStart <= enemyDefHourTimestamp <= vacationEnd:
            return ATTACK_PLAN_RESULT.OPP_VACATION
        dayDate = time_utils.getDateTimeInLocal(dayTimestamp)
        localOffDay = clanFortInfo.getLocalOffDayFor(currentDefHourTimestamp)
        if dayDate.weekday() == localOffDay:
            return ATTACK_PLAN_RESULT.OPP_OFF_DAY
        if self.defenceHour == clanFortInfo.getStartDefHour():
            return ATTACK_PLAN_RESULT.DEFENCE_HOUR_SAME

        def filterInFight(item):
            if enemyDefHourTimestamp <= item.getStartTime() < enemyDefHourTimestamp + time_utils.ONE_HOUR:
                return True
            return False


        attacksInFight = self.getAttacks(clanFortInfo.getClanDBID(), filterInFight)
        if attacksInFight:
            return ATTACK_PLAN_RESULT.WAR_DECLARED
        if clanFortInfo.closestAttackInCooldown is not None and dayTimestamp < clanFortInfo.closestAttackInCooldown.getStartTime() + time_utils.ONE_DAY * 7 and not clanFortInfo.counterAttacked:
            return ATTACK_PLAN_RESULT.IN_COOLDOWN
        (hasAvailableDirections, hasFreeDirections,) = (False, False)
        for direction in self.getOpenedDirections():
            eventTypeID = FORT_EVENT_TYPE.DIR_OPEN_ATTACKS_BASE + direction
            (availableTime, _, _,) = self.events.get(eventTypeID, (None, None, None))
            if availableTime <= enemyDefHourTimestamp:
                hasAvailableDirections = True

                def filterAttacks(item):
                    if enemyDefHourTimestamp <= item.getStartTime() <= enemyDefHourTimestamp + time_utils.ONE_HOUR and direction == item.getDirection() and not item.isEnded():
                        return True
                    return False


                if not self.getAttacks(filterFunc=filterAttacks):
                    hasFreeDirections = True
                    break

        if not hasAvailableDirections:
            return ATTACK_PLAN_RESULT.MY_NO_DIR
        if not hasFreeDirections:
            return ATTACK_PLAN_RESULT.MY_BUSY
        (isBusy, isAvailable,) = clanFortInfo.isAvailableForAttack(enemyDefHourTimestamp)
        if not isAvailable:
            return ATTACK_PLAN_RESULT.OPP_NO_DIR
        if isBusy:
            return ATTACK_PLAN_RESULT.OPP_BUSY
        return ATTACK_PLAN_RESULT.OK
Ejemplo n.º 22
0
 def __notifyClient(self):
     self.__lastNotifyTime = time_utils.getCurrentTimestamp()
     if self.isParentControlEnabled:
         playTimeLeft = min([self.getDailyPlayTimeLeft(), self.getWeeklyPlayTimeLeft()])
         playTimeLeft = max(playTimeLeft, 0)
     else:
         playTimeLeft = None
     self.onClientNotify(self.sessionDuration, time_utils.ONE_DAY - _getSvrLocalToday(), playTimeLeft)
     return
Ejemplo n.º 23
0
def onShopResync():
    yield g_itemsCache.update(CACHE_SYNC_REASON.SHOP_RESYNC)
    if not g_itemsCache.isSynced():
        Waiting.hide('sinhronize')
        return
    yield g_eventsCache.update()
    Waiting.hide('sinhronize')
    now = time_utils.getCurrentTimestamp()
    SystemMessages.g_instance.pushI18nMessage(SYSTEM_MESSAGES.SHOP_RESYNC, date=BigWorld.wg_getLongDateFormat(now), time=BigWorld.wg_getShortTimeFormat(now), type=SystemMessages.SM_TYPE.Information)
Ejemplo n.º 24
0
def onShopResync():
    yield ServicesLocator.itemsCache.update(CACHE_SYNC_REASON.SHOP_RESYNC)
    if not ServicesLocator.itemsCache.isSynced():
        Waiting.hide('sinhronize')
        return
    yield ServicesLocator.eventsCache.update()
    Waiting.hide('sinhronize')
    now = time_utils.getCurrentTimestamp()
    SystemMessages.pushI18nMessage(SYSTEM_MESSAGES.SHOP_RESYNC, date=BigWorld.wg_getLongDateFormat(now), time=BigWorld.wg_getShortTimeFormat(now), type=SystemMessages.SM_TYPE.Information)
Ejemplo n.º 25
0
 def onWindowClose(self):
     if isGoldFishActionActive():
         AccountSettings.setFilter(GOLD_FISH_LAST_SHOW_TIME,
                                   getCurrentTimestamp())
         self.fireEvent(
             events.CloseWindowEvent(
                 events.CloseWindowEvent.GOLD_FISH_CLOSED),
             EVENT_BUS_SCOPE.LOBBY)
     self.destroy()
Ejemplo n.º 26
0
 def _isValidTime(cls, timestampToCheck, rootTimestamp = None):
     rootTimestamp = rootTimestamp or time_utils.getCurrentTimestamp()
     minLimit = rootTimestamp - cls.TIME_LIMITS.LOW
     dayStart, _ = time_utils.getDayTimeBoundsForLocal(minLimit)
     minLimit = dayStart
     maxLimit = rootTimestamp + cls.TIME_LIMITS.HIGH
     _, dayEnd = time_utils.getDayTimeBoundsForLocal(maxLimit)
     maxLimit = dayEnd
     return minLimit < timestampToCheck < maxLimit
Ejemplo n.º 27
0
 def _isValidTime(cls, timestampToCheck, rootTimestamp=None):
     rootTimestamp = rootTimestamp or time_utils.getCurrentTimestamp()
     minLimit = rootTimestamp - cls.TIME_LIMITS.LOW
     dayStart, _ = time_utils.getDayTimeBoundsForLocal(minLimit)
     minLimit = dayStart
     maxLimit = rootTimestamp + cls.TIME_LIMITS.HIGH
     _, dayEnd = time_utils.getDayTimeBoundsForLocal(maxLimit)
     maxLimit = dayEnd
     return minLimit < timestampToCheck < maxLimit
 def accessToken(self, cmd):
     accessTokenData = yield self.webCtrl.getAccessTokenData(force=cmd.force)
     if accessTokenData is not None:
         yield {'spa_id': str(self.connectionMgr.databaseID),
          'access_token': str(accessTokenData.accessToken),
          'expires_in': accessTokenData.expiresAt - time_utils.getCurrentTimestamp(),
          'periphery_id': str(self.connectionMgr.peripheryID)}
     else:
         yield {'error': 'Unable to obtain access token.'}
     return
Ejemplo n.º 29
0
 def __setData(self):
     dayStartUTC, _ = time_utils.getDayTimeBoundsForUTC(
         time_utils.getCurrentTimestamp())
     vacationStart = dayStartUTC + time_utils.ONE_DAY + fortified_regions.g_cache.minVacationPreorderTime
     self.as_setDataS({
         'startVacation': vacationStart,
         'vacationDuration': -1,
         'isAmericanStyle': False,
         'showMonth': SHOW_MAX_MONTH
     })
Ejemplo n.º 30
0
    def canPlanAttackOn(self, dayTimestamp, clanFortInfo):
        if self.isFrozen():
            return ATTACK_PLAN_RESULT.MY_FROZEN
        currentDefHourTimestamp = time_utils.getTimeForLocal(dayTimestamp, *clanFortInfo.getLocalDefHour())
        enemyDefHourTimestamp = time_utils.getTimeForLocal(dayTimestamp, *clanFortInfo.getDefHourFor(currentDefHourTimestamp))
        if enemyDefHourTimestamp - time_utils.getCurrentTimestamp() <= fortified_regions.g_cache.attackPreorderTime:
            return ATTACK_PLAN_RESULT.PREORDER_TIME
        if self.isOnVacationAt(enemyDefHourTimestamp):
            return ATTACK_PLAN_RESULT.MY_VACATION
        vacationStart, vacationEnd = clanFortInfo.getVacationPeriod()
        if vacationStart <= enemyDefHourTimestamp <= vacationEnd:
            return ATTACK_PLAN_RESULT.OPP_VACATION
        dayDate = time_utils.getDateTimeInLocal(dayTimestamp)
        localOffDay = clanFortInfo.getLocalOffDayFor(currentDefHourTimestamp)
        if dayDate.weekday() == localOffDay:
            return ATTACK_PLAN_RESULT.OPP_OFF_DAY
        if self.defenceHour == clanFortInfo.getStartDefHour():
            return ATTACK_PLAN_RESULT.DEFENCE_HOUR_SAME

        def filterInFight(item):
            if enemyDefHourTimestamp <= item.getStartTime() < enemyDefHourTimestamp + time_utils.ONE_HOUR:
                return True
            return False

        attacksInFight = self.getAttacks(clanFortInfo.getClanDBID(), filterInFight)
        if attacksInFight:
            return ATTACK_PLAN_RESULT.WAR_DECLARED
        if clanFortInfo.closestAttackInCooldown is not None and dayTimestamp < clanFortInfo.closestAttackInCooldown.getStartTime() + time_utils.ONE_DAY * 7 and not clanFortInfo.counterAttacked:
            return ATTACK_PLAN_RESULT.IN_COOLDOWN
        hasAvailableDirections, hasFreeDirections = False, False
        for direction in self.getOpenedDirections():
            eventTypeID = FORT_EVENT_TYPE.DIR_OPEN_ATTACKS_BASE + direction
            availableTime, _, _ = self.events.get(eventTypeID, (None, None, None))
            if availableTime is None or availableTime <= enemyDefHourTimestamp:
                hasAvailableDirections = True

                def filterAttacks(item):
                    if enemyDefHourTimestamp <= item.getStartTime() <= enemyDefHourTimestamp + time_utils.ONE_HOUR and direction == item.getDirection() and not item.isEnded():
                        return True
                    return False

                if not self.getAttacks(filterFunc=filterAttacks):
                    hasFreeDirections = True
                    break

        if not hasAvailableDirections:
            return ATTACK_PLAN_RESULT.MY_NO_DIR
        if not hasFreeDirections:
            return ATTACK_PLAN_RESULT.MY_BUSY
        isBusy, isAvailable = clanFortInfo.isAvailableForAttack(enemyDefHourTimestamp)
        if not isAvailable:
            return ATTACK_PLAN_RESULT.OPP_NO_DIR
        if isBusy:
            return ATTACK_PLAN_RESULT.OPP_BUSY
        return ATTACK_PLAN_RESULT.OK
Ejemplo n.º 31
0
 def getAccessTokenData(self, force, callback):
     yield lambda callback: callback(True)
     timeOut = self.__accessTokenData is None or time_utils.getCurrentTimestamp() > self.__accessTokenData.expiresAt
     if force or timeOut:
         if self.__loginState is LOGIN_STATE.LOGGING_IN:
             self.__accessTokenCallbacks.append(callback)
             return
         self.__loginState = LOGIN_STATE.LOGGED_OFF
         yield self.__doLogin()
     callback(self.__accessTokenData)
     return
Ejemplo n.º 32
0
    def __doSubscribe(self):

        def _onSubscribed(result):
            if result.isSuccess():
                self._changeState(SUBSCRIPTION_STATE.SUBSCRIBED)
                self._onClubUpdated(self.__clubDbID, result.data)

        self._request(club_ctx.SubscribeCtx(self.__clubDbID, self.__subscriptionType, self._onClubUpdated), callback=_onSubscribed)
        if self.isNotSubscribed():
            self._changeState(SUBSCRIPTION_STATE.SUBSCRIBING)
        self.__lastRequestTime = getCurrentTimestamp()
Ejemplo n.º 33
0
def _requestAccessToken(command, callback, connectionMgr = None):
    ctrl = dependency.instance(IClanController)
    accessTokenData = yield ctrl.getAccessTokenData(force=command.force)
    if accessTokenData is not None:
        callback({'spa_id': str(connectionMgr.databaseID),
         'access_token': str(accessTokenData.accessToken),
         'expires_in': accessTokenData.expiresAt - time_utils.getCurrentTimestamp(),
         'periphery_id': str(connectionMgr.peripheryID)})
    else:
        callback({'error': 'Unable to obtain access token.'})
    return
Ejemplo n.º 34
0
    def __doSubscribe(self):

        def _onSubscribed(result):
            if result.isSuccess():
                self._changeState(SUBSCRIPTION_STATE.SUBSCRIBED)
                self._onClubUpdated(self.__clubDbID, result.data)

        self._request(club_ctx.SubscribeCtx(self.__clubDbID, self.__subscriptionType, self._onClubUpdated), callback=_onSubscribed)
        if self.isNotSubscribed():
            self._changeState(SUBSCRIPTION_STATE.SUBSCRIBING)
        self.__lastRequestTime = getCurrentTimestamp()
Ejemplo n.º 35
0
 def _packBlocks(self, *args, **kwargs):
     blocks = super(MapboxCalendarTooltip, self)._packBlocks(args, kwargs)
     blocks.append(
         formatters.packBuildUpBlockData([
             self.__packHeader(),
             self.__packTimeTableHeaderBlock(),
             formatters.packBuildUpBlockData(
                 packCalendarBlock(self.__mapboxCtrl,
                                   time_utils.getCurrentTimestamp(),
                                   SELECTOR_BATTLE_TYPES.MAPBOX))
         ]))
     return blocks
Ejemplo n.º 36
0
 def __getVehicleVO(self, vehicle, vehicleInfo, iconGetter):
     tmanRoleLevel = self.getTmanRoleLevel(vehicleInfo)
     rentDays = self.getRentDays(vehicleInfo)
     if rentDays:
         iconName = 'vehicles_rent'
         rentExpiryTime = time_utils.getCurrentTimestamp() + rentDays * time_utils.ONE_DAY
     else:
         iconName = 'vehicles'
         rentExpiryTime = 0
     return {'imgSource': iconGetter(iconName),
      'isSpecial': True,
      'specialAlias': TOOLTIPS_CONSTANTS.AWARD_VEHICLE,
      'specialArgs': [vehicle.intCD, tmanRoleLevel, rentExpiryTime]}
Ejemplo n.º 37
0
 def _getCompleteWeeklyStatus(self, completeKey):
     curTime = time_utils.getTimeStructInUTC(
         time_utils.getCurrentTimestamp())
     resetDay, resetSeconds = self._getWeeklyProgressResetTimeUTC()
     dayDelta = (resetDay - curTime.tm_wday) % 7
     if dayDelta == 0:
         dayDelta = 7
     timeDelta = dayDelta * time_utils.ONE_DAY + resetSeconds - (
         curTime.tm_hour * time_utils.ONE_HOUR +
         curTime.tm_min * time_utils.ONE_MINUTE + curTime.tm_sec)
     if timeDelta > time_utils.ONE_WEEK:
         timeDelta -= time_utils.ONE_WEEK
     return backport.text(completeKey,
                          time=self._getTillTimeString(timeDelta))
Ejemplo n.º 38
0
 def onLobbyStarted(self, ctx):
     self.__sessionStartedAt = ctx.get('aogasStartedAt', -1)
     LOG_DEBUG('GameSessionController::start', self.__sessionStartedAt)
     if self.__lastNotifyTime is None:
         self.__lastNotifyTime = time_utils.getCurrentTimestamp()
     self.__curfewBlockTime, self.__curfewUnblockTime = self.__getCurfewBlockTime(self._stats.restrictions)
     if self.__doNotifyInStart:
         self.__notifyClient()
     self.startNotification()
     self.__loadBanCallback()
     g_clientUpdateManager.addCallbacks({'account': self.__onAccountChanged,
      'stats.restrictions': self.__onRestrictionsChanged,
      'stats.playLimits': self.__onPlayLimitsChanged})
     return
Ejemplo n.º 39
0
 def _packBlocks(self, *args, **kwargs):
     self.item = self.context.buildItem(*args, **kwargs)
     items = super(VehicleInfoTooltipData, self)._packBlocks()
     vehicle = self.item
     statsConfig = self.context.getStatsConfiguration(vehicle)
     paramsConfig = self.context.getParamsConfiguration(vehicle)
     statusConfig = self.context.getStatusConfiguration(vehicle)
     leftPadding = 20
     rightPadding = 20
     bottomPadding = 20
     blockTopPadding = -4
     leftRightPadding = formatters.packPadding(left=leftPadding, right=rightPadding)
     blockPadding = formatters.packPadding(left=leftPadding, right=rightPadding, top=blockTopPadding)
     valueWidth = 75
     textGap = -2
     items.append(formatters.packBuildUpBlockData(HeaderBlockConstructor(vehicle, statsConfig, leftPadding, rightPadding).construct(), padding=leftRightPadding))
     telecomBlock = TelecomBlockConstructor(vehicle, valueWidth, leftPadding, rightPadding).construct()
     if telecomBlock:
         items.append(formatters.packBuildUpBlockData(telecomBlock, padding=leftRightPadding))
     priceBlock, invalidWidth = PriceBlockConstructor(vehicle, statsConfig, self.context.getParams(), valueWidth, leftPadding, rightPadding).construct()
     if priceBlock:
         self._setWidth(_TOOLTIP_MAX_WIDTH if invalidWidth else _TOOLTIP_MIN_WIDTH)
         items.append(formatters.packBuildUpBlockData(priceBlock, gap=textGap, padding=blockPadding))
     simplifiedStatsBlock = SimplifiedStatsBlockConstructor(vehicle, paramsConfig, leftPadding, rightPadding).construct()
     if simplifiedStatsBlock:
         items.append(formatters.packBuildUpBlockData(simplifiedStatsBlock, gap=-4, linkage=BLOCKS_TOOLTIP_TYPES.TOOLTIP_BUILDUP_BLOCK_WHITE_BG_LINKAGE, padding=leftRightPadding))
     if not vehicle.isRotationGroupLocked:
         commonStatsBlock = CommonStatsBlockConstructor(vehicle, paramsConfig, valueWidth, leftPadding, rightPadding).construct()
         if commonStatsBlock:
             items.append(formatters.packBuildUpBlockData(commonStatsBlock, gap=textGap, padding=blockPadding))
     footnoteBlock = FootnoteBlockConstructor(vehicle, paramsConfig, leftPadding, rightPadding).construct()
     if footnoteBlock:
         items.append(formatters.packBuildUpBlockData(footnoteBlock, gap=textGap, padding=blockPadding))
     if vehicle.isRotationGroupLocked:
         statsBlockConstructor = RotationLockAdditionalStatsBlockConstructor
     elif vehicle.isDisabledInRoaming:
         statsBlockConstructor = RoamingLockAdditionalStatsBlockConstructor
     elif vehicle.clanLock and vehicle.clanLock > time_utils.getCurrentTimestamp():
         statsBlockConstructor = ClanLockAdditionalStatsBlockConstructor
     else:
         statsBlockConstructor = AdditionalStatsBlockConstructor
     items.append(formatters.packBuildUpBlockData(statsBlockConstructor(vehicle, paramsConfig, self.context.getParams(), valueWidth, leftPadding, rightPadding).construct(), gap=textGap, padding=blockPadding))
     if not vehicle.isRotationGroupLocked:
         statusBlock = StatusBlockConstructor(vehicle, statusConfig).construct()
         if statusBlock:
             items.append(formatters.packBuildUpBlockData(statusBlock, padding=blockPadding))
         else:
             self._setContentMargin(bottom=bottomPadding)
     return items
 def onLobbyInited(self, event):
     if self.__lastNotifyTime is None:
         self.__lastNotifyTime = time_utils.getCurrentTimestamp()
     self.__curfewBlockTime, self.__curfewUnblockTime = self.__getCurfewBlockTime(self._stats.restrictions)
     if self.__doNotifyInStart:
         self.__notifyClient()
     self.startNotification()
     self.__loadBanCallback()
     g_clientUpdateManager.addCallbacks({'premium': self.__onAccountChanged,
      'stats.restrictions': self.__onRestrictionsChanged,
      'stats.playLimits': self.__onPlayLimitsChanged,
      'cache.gameRestrictions.session': self.__onParentControlChanged,
      'cache.gameRestrictions.session_r': self.__onParentControlChanged})
     self.startGlobalListening()
     return
Ejemplo n.º 41
0
 def _onProxyDataItemShow(self, notID, item):
     if not self._canBeShown():
         return True
     elif self._getNewReceivediItemType() == item.getType():
         model = self._model()
         if self.__startTime:
             if time_utils.getCurrentTimestamp() - self.__startTime < 5:
                 multiNot = self._getMultiNotification()
                 if multiNot:
                     model.updateNotification(multiNot.getType(), multiNot.getID(), multiNot.getEntity() + 1, False)
                 else:
                     self._addSingleNotification(item)
             else:
                 self.__startTime = None
                 self._addSingleNotification(item)
         else:
             self._addSingleNotification(item)
         return True
     else:
         return False
Ejemplo n.º 42
0
    def __onMsgReceived(self, clientID, eventData):
        eType, battleID = eventData
        if eType == MsgCustomEvents.FORT_BATTLE_INVITE:
            self.__fortInvitesData[battleID] = clientID
        elif eType == MsgCustomEvents.FORT_BATTLE_FINISHED:
            model = self._model()
            if model:
                storedClientID = self.__fortInvitesData.get(battleID, None)
                if storedClientID:
                    _, formatted, settings = self.proto.serviceChannel.getMessage(storedClientID)
                    if formatted and settings:
                        if formatted['savedData']['battleFinishTime'] - time_utils.getCurrentTimestamp() < 0:
                            buttonsStates = {}
                            buttonsLayout = formatted.get('buttonsLayout', [])
                            for layout in buttonsLayout:
                                buttonsStates[layout['type']] = NOTIFICATION_BUTTON_STATE.VISIBLE

                            formatted['buttonsStates'] = buttonsStates
                            model.updateNotification(NOTIFICATION_TYPE.MESSAGE, storedClientID, formatted, False)
                            del self.__fortInvitesData[battleID]
Ejemplo n.º 43
0
    def __packStaffData(self):
        members = []
        membersCount = 7
        viewerIsOwner = self.isOwner(self.getViewerId())
        for i in range(membersCount):
            id = i
            if self.isOwner(id):
                memberType = FORMATION_MEMBER_TYPE.OWNER
            else:
                memberType = random.choice([FORMATION_MEMBER_TYPE.SOLDIER, FORMATION_MEMBER_TYPE.OFFICER, FORMATION_MEMBER_TYPE.INVITEE])
            orderNumber = i
            isIdOwner = self.isOwner(id)
            himself = self.getViewerId() == id
            canPromoted = viewerIsOwner
            canDemoted = viewerIsOwner
            canRemoved = not isIdOwner if membersCount > 1 and viewerIsOwner else himself
            canPassOwnership = viewerIsOwner and not isIdOwner and memberType != FORMATION_MEMBER_TYPE.INVITEE
            joinDate = time_utils.getCurrentTimestamp() - random.randint(0, 100) * time_utils.ONE_DAY
            canShowContextMenu = not himself
            name = 'Memberrrrrrrrrrrrrrrrrrr' + ('0' if i < 10 else '') + str(i)
            members.append(self.__packStaffItemData(id, orderNumber, name, memberType, canPromoted, canDemoted, canRemoved, canPassOwnership, canShowContextMenu, himself, joinDate))

        return {'members': members}
Ejemplo n.º 44
0
    def start(self, model):
        result = super(_ClanNotificationsCommonListener, self).start(model)
        self.startClanListening()
        g_wgncEvents.onProxyDataItemShowByDefault += self._onProxyDataItemShow
        self.__startTime = time_utils.getCurrentTimestamp()
        if not self._canBeShown():
            return
        else:
            newReceivedItemType = self._getNewReceivediItemType()
            itemsByType = []
            for notification in g_wgncProvider.getNotMarkedNots():
                proxyDataItem = notification.getProxyItemByType(newReceivedItemType)
                if proxyDataItem is None:
                    continue
                itemsByType.append(proxyDataItem)

            itemsByTypeCount = len(itemsByType)
            LOG_DEBUG('Clan WGNC new notifications count with type = %d: %d' % (newReceivedItemType, itemsByTypeCount))
            if itemsByTypeCount:
                if itemsByTypeCount > 1:
                    self._addMultiNotification(itemsByType)
                else:
                    self._addSingleNotification(itemsByType[0])
            return result
Ejemplo n.º 45
0
def isTimeToShowGoldFishPromo():
    return getCurrentTimestamp() - AccountSettings.getFilter(GOLD_FISH_LAST_SHOW_TIME) >= GUI_SETTINGS.goldFishActionShowCooldown
Ejemplo n.º 46
0
 def __init__(self, entityID, entity = None, settings = None):
     self._createdAt = time_utils.getCurrentTimestamp()
     super(_ClanBaseDecorator, self).__init__(entityID, entity, settings)
Ejemplo n.º 47
0
    def canSendApplication(self, profile, club = None):
        stateID = profile.getState().getStateID()
        if stateID == _CCB.HAS_CLUB:
            return error(_CCR.ACCOUNT_ALREADY_IN_TEAM)
        if stateID == _CCB.SENT_APP:
            return error(_CCR.APPLICATION_FOR_USER_EXCEEDED)
        if club:
            if club.getState().isClosed():
                return error(_CCR.CLUB_IS_CLOSED)
            for app in profile.getApplications().itervalues():
                if app.getClubDbID() == club.getClubDbID() and app.isDeclined() and app.getTimestamp() + THE_SAME_CLUB_SEND_APP_COOLDOWN > getCurrentTimestamp():
                    return error(_CCR.TEMPORARILY_RESTRICTED)

        return self._isClubRequestValid(_CRT.SEND_APPLICATION, club, 'canSendApplication')
Ejemplo n.º 48
0
 def isOnOffDay(self):
     return self.getLocalOffDay() == time_utils.getDateTimeInLocal(time_utils.getCurrentTimestamp()).weekday()
Ejemplo n.º 49
0
 def __init__(self, clubDBID, activeApps):
     self._createdAt = time_utils.getCurrentTimestamp()
     super(ClubAppsDecorator, self).__init__(clubDBID, activeApps)
Ejemplo n.º 50
0
 def isExpired(self):
     expiryTime = self.getExpiryTime()
     return expiryTime is not None and expiryTime < time_utils.getCurrentTimestamp()
Ejemplo n.º 51
0
 def onWindowClose(self):
     if isGoldFishActionActive():
         AccountSettings.setFilter(GOLD_FISH_LAST_SHOW_TIME, getCurrentTimestamp())
         self.fireEvent(events.CloseWindowEvent(events.CloseWindowEvent.GOLD_FISH_CLOSED), EVENT_BUS_SCOPE.LOBBY)
     self.destroy()
Ejemplo n.º 52
0
 def isInClanEnterCooldown(self):
     self.resyncWebClanInfo()
     if self._vitalWebInfo[SYNC_KEYS.CLAN_INFO]:
         return time_utils.getCurrentTimestamp() - self._vitalWebInfo[SYNC_KEYS.CLAN_INFO].getClanCooldownTill() <= 0
     return False
Ejemplo n.º 53
0
 def getExpiryTimeLeft(self):
     if not self.isInfinite():
         return self.expires - getCurrentTimestamp()
     else:
         return None
 def __init__(self, ctx):
     super(FortCalendarWindow, self).__init__()
     self.__selectedDate = ctx.get('dateSelected') or time_utils.getCurrentTimestamp()
Ejemplo n.º 55
0
 def isOnDefenceHour(self):
     if not self.isDefenceHourEnabled():
         return False
     start, finish = self.getDefencePeriod()
     return start <= time_utils.getCurrentTimestamp() < finish and not self.isOnVacation() and not self.isOnOffDay()
Ejemplo n.º 56
0
 def _put(self, key, data, lastModified, expires):
     self._cache[key] = (data,
      lastModified,
      expires,
      time_utils.getCurrentTimestamp())
Ejemplo n.º 57
0
 def isOnVacation(self):
     if not self.isVacationEnabled():
         return False
     start, finish = self.getVacationDate()
     return start <= time_utils.getCurrentTimestamp() < finish
Ejemplo n.º 58
0
def adjustDefenceHourToLocal(defenceHour, timestamp = None):
    timestamp = timestamp or time_utils.getCurrentTimestamp()
    localtime = time.localtime(time_utils.getTimeForUTC(timestamp, defenceHour))
    return (localtime.tm_hour, localtime.tm_min)
Ejemplo n.º 59
0
 def isExpired(cls, expires):
     ct = time_utils.getCurrentTimestamp()
     return not ct <= expires <= ct + cls.MAX
Ejemplo n.º 60
0
 def getLocalDefenceDate(self):
     if not self.isDefenceHourEnabled():
         return None
     else:
         return time.localtime(time_utils.getTimeForUTC(time_utils.getCurrentTimestamp(), self.defenceHour))