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 _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 getAvailability(self): from ClientFortifiedRegion import ATTACK_PLAN_RESULT maxPreorderLimit = FORTIFICATION_ALIASES.ACTIVE_EVENTS_FUTURE_LIMIT * time_utils.ONE_DAY initialTime = time_utils.getTimeTodayForLocal(*self.getLocalDefHour()) availableTimestamp = initialTime while not self.__fort.canPlanAttackOn(availableTimestamp, self) == ATTACK_PLAN_RESULT.OK: if time_utils.getTimeDeltaFromNow(availableTimestamp) <= maxPreorderLimit: availableTimestamp += time_utils.ONE_DAY else: availableTimestamp = initialTime break currentDayStart, _ = time_utils.getDayTimeBoundsForLocal() availableDayStart, _ = time_utils.getDayTimeBoundsForLocal(availableTimestamp) return availableTimestamp
def __packScheduleBlock(self): primeTime = self.__eventProgression.getPrimeTimes().get( self.__connectionMgr.peripheryID) if primeTime is None or self.__eventProgression.hasAnySeason() is None: return else: timeTableBlocks = [self.__packTimeTableHeaderBlock()] todayStart, todayEnd = time_utils.getDayTimeBoundsForLocal() todayEnd += 1 tomorrowStart, tomorrowEnd = todayStart + time_utils.ONE_DAY, todayEnd + time_utils.ONE_DAY boundaryTime, _ = self.__eventProgression.getCurrentCycleInfo() tomorrowPeriods = () todayPeriods = primeTime.getPeriodsBetween( todayStart, min(todayEnd, boundaryTime)) if tomorrowStart < boundaryTime: tomorrowPeriods = primeTime.getPeriodsBetween( tomorrowStart, min(tomorrowEnd, boundaryTime)) todayStr = self.__packPeriods(todayPeriods) timeTableBlocks.append( self.__packTimeBlock(message=text_styles.main( backport.text(_R_TIMETABLE.today())), timeStr=text_styles.stats(todayStr))) tomorrowStr = self.__packPeriods(tomorrowPeriods) timeTableBlocks.append( self.__packTimeBlock(message=text_styles.main( backport.text(_R_TIMETABLE.tomorrow())), timeStr=text_styles.main(tomorrowStr))) return formatters.packBuildUpBlockData(timeTableBlocks)
def _populatePreviewBlock(self): fort = self.fortCtrl.getFort() localDateTime = time_utils.getDateTimeInLocal(self.__selectedDate) targetDayStartTimestamp, _ = time_utils.getDayTimeBoundsForLocal(self.__selectedDate) eventItems, dateInfo, noEventsText = [], None, None dateString = _ms(MENU.DATETIME_SHORTDATEFORMATWITHOUTYEAR, weekDay=_ms('#menu:dateTime/weekDays/full/%d' % localDateTime.isoweekday()), monthDay=localDateTime.day, month=toLower(_ms('#menu:dateTime/months/full/%d' % localDateTime.month))) if fort.isOnVacationAt(self.__selectedDate): noEventsText = _ms(FORTIFICATIONS.FORTCALENDARWINDOW_EVENTSLIST_EMPTY_VACATION, date=fort.getVacationDateStr()) elif not self._isValidTime(self.__selectedDate): noEventsText = _ms(FORTIFICATIONS.FORTCALENDARWINDOW_EVENTSLIST_EMPTY_NOTAVAILABLE) else: for dayStartTimestamp, battles in self._getBattlesByDay().iteritems(): if dayStartTimestamp == targetDayStartTimestamp: for battle in sorted(battles): startTimestamp = battle.getStartTime() battleHasEnded = battle.isEnded() opponentsClanInfo = battle.getOpponentClanInfo() if battle.getType() == BATTLE_ITEM_TYPE.ATTACK: if battleHasEnded: icon = RES_ICONS.MAPS_ICONS_LIBRARY_FORTIFICATION_OFFENCEPAST else: icon = RES_ICONS.MAPS_ICONS_LIBRARY_FORTIFICATION_OFFENCEFUTURE titleTpl = _ms(FORTIFICATIONS.FORTCALENDARWINDOW_EVENTSLIST_ITEM_TITLE_OFFENCE) else: if battleHasEnded: icon = RES_ICONS.MAPS_ICONS_LIBRARY_FORTIFICATION_DEFENCEPAST else: icon = RES_ICONS.MAPS_ICONS_LIBRARY_FORTIFICATION_DEFENCEFUTURE titleTpl = _ms(FORTIFICATIONS.FORTCALENDARWINDOW_EVENTSLIST_ITEM_TITLE_DEFENCE) tankIconVO = getDivisionIcon(battle.defenderFortLevel, battle.attackerFortLevel, determineAlert=battle.getType() == BATTLE_ITEM_TYPE.ATTACK) if battle.isWin(): background = RES_ICONS.MAPS_ICONS_LIBRARY_FORTIFICATION_BATTLEFORTVICTORY resultLabel = 'win' elif battle.isLose(): background = RES_ICONS.MAPS_ICONS_LIBRARY_FORTIFICATION_BATTLEFORTDEFEAT resultLabel = 'lose' else: background, resultLabel = (None, None) eventItem = {'icon': icon, 'title': titleTpl % {'clanName': '[%s]' % opponentsClanInfo[1]}, 'clanID': opponentsClanInfo[0], 'direction': _ms(FORTIFICATIONS.GENERAL_DIRECTION, value=_ms('#fortifications:General/directionName%d' % battle.getDirection())), 'timeInfo': _ms(FORTIFICATIONS.FORTCALENDARWINDOW_EVENTSLIST_ITEM_TIMEINFO) % {'startTime': BigWorld.wg_getShortTimeFormat(startTimestamp), 'endTime': BigWorld.wg_getShortTimeFormat(startTimestamp + time_utils.ONE_HOUR)}, 'background': background, 'tankIconVO': tankIconVO, 'showTankIcon': not battleHasEnded} if battleHasEnded and resultLabel: resultText = makeHtmlString('html_templates:lobby/fortifications', 'battleResult', {'result': _ms(MENU.finalstatistic_commonstats_resultlabel(resultLabel))}) eventItem.update({'result': resultText}) eventItems.append(eventItem) if not len(eventItems): noEventsText = _ms(FORTIFICATIONS.FORTCALENDARWINDOW_EVENTSLIST_EMPTY_NOEVENTS) if len(eventItems) > 0: dateInfo = _ms(FORTIFICATIONS.FORTCALENDARWINDOW_EVENTSLIST_INFO_BATTLESCOUNT, eventsCount=len(eventItems)) self.as_updatePreviewDataS({'dateString': dateString, 'dateInfo': dateInfo, 'noEventsText': noEventsText, 'events': eventItems})
def getPrimeTimesForDay(self, selectedTime, groupIdentical=False): hostsList = g_preDefinedHosts.getSimpleHostsList(g_preDefinedHosts.hostsWithRoaming(), withShortName=True) if self.connectionMgr.peripheryID == 0: hostsList.insert(0, (self.connectionMgr.url, self.connectionMgr.serverUserName, self.connectionMgr.serverUserNameShort, HOST_AVAILABILITY.IGNORED, 0)) primeTimes = self.getPrimeTimes() dayStart, dayEnd = time_utils.getDayTimeBoundsForLocal(selectedTime) dayEnd += 1 serversPeriodsMapping = {} for _, _, serverShortName, _, peripheryID in hostsList: if peripheryID not in primeTimes: continue dayPeriods = primeTimes[peripheryID].getPeriodsBetween(dayStart, dayEnd) if groupIdentical and dayPeriods in serversPeriodsMapping.values(): for name, period in serversPeriodsMapping.iteritems(): serverInMapping = name if period == dayPeriods else None if serverInMapping: newName = '{0}, {1}'.format(serverInMapping, serverShortName) serversPeriodsMapping[newName] = serversPeriodsMapping.pop(serverInMapping) break serversPeriodsMapping[serverShortName] = dayPeriods return serversPeriodsMapping
def getPrimeTimesForDay(self, selectedTime, groupIdentical=False): primeTimes = self.getPrimeTimes() dayStart, dayEnd = time_utils.getDayTimeBoundsForLocal(selectedTime) dayEnd += 1 serversPeriodsMapping = {} hostsList = self._getHostList() for _, _, serverShortName, _, peripheryID in hostsList: if peripheryID not in primeTimes: continue dayPeriods = primeTimes[peripheryID].getPeriodsBetween( dayStart, dayEnd) if groupIdentical and dayPeriods in serversPeriodsMapping.values(): for name, period in serversPeriodsMapping.iteritems(): serverInMapping = name if period == dayPeriods else None if serverInMapping: newName = '{0}, {1}'.format(serverInMapping, serverShortName) serversPeriodsMapping[ newName] = serversPeriodsMapping.pop( serverInMapping) break serversPeriodsMapping[serverShortName] = dayPeriods return serversPeriodsMapping
def _populateDays(self): calendar = self.getCalendar() if calendar is not None: _ms = i18n.makeString dayStartTimestamp, _ = time_utils.getDayTimeBoundsForLocal(self.__lowerTimeBound) daysData = [] publicCache = self.fortCtrl.getPublicInfoCache() clanCard = publicCache.getSelectedClanCard() if clanCard: fort = self.fortCtrl.getFort() for dayIdx in xrange(FORTIFICATION_ALIASES.ACTIVE_EVENTS_FUTURE_LIMIT): dayTimestamp = dayStartTimestamp + dayIdx * time_utils.ONE_DAY result = fort.canPlanAttackOn(dayTimestamp, clanCard) if result == ATTACK_PLAN_RESULT.OK: dayData = {'tooltipHeader': _ms(FORTIFICATIONS.FORTDATEPICKERPOPOVER_CALENDAR_DAYTOOLTIP_AVAILABLE_HEADER), 'tooltipBody': _ms(FORTIFICATIONS.FORTDATEPICKERPOPOVER_CALENDAR_DAYTOOLTIP_AVAILABLE_BODY)} elif result == ATTACK_PLAN_RESULT.OPP_BUSY: dayData = {'tooltipHeader': _ms(FORTIFICATIONS.FORTDATEPICKERPOPOVER_CALENDAR_DAYTOOLTIP_BUSY_HEADER), 'tooltipBody': _ms(FORTIFICATIONS.FORTDATEPICKERPOPOVER_CALENDAR_DAYTOOLTIP_BUSY_BODY), 'iconSource': RES_ICONS.MAPS_ICONS_LIBRARY_FORTIFICATION_NOTAVAILABLEBG} else: dayData = {'tooltipHeader': _ms(FORTIFICATIONS.FORTDATEPICKERPOPOVER_CALENDAR_DAYTOOLTIP_NOTAVAILABLE_HEADER), 'tooltipBody': _ms(FORTIFICATIONS.FORTDATEPICKERPOPOVER_CALENDAR_DAYTOOLTIP_NOTAVAILABLE_BODY), 'available': False} dayData.update({'rawDate': dayTimestamp}) daysData.append(dayData) calendar.as_updateMonthEventsS(daysData) return
def getPrimeTableBlocks(primeTime, currentCycleEnd, resRoot): primeTableBlocks = [_packTimeTableHeaderBlock(resRoot)] todayStart, todayEnd = time_utils.getDayTimeBoundsForLocal() todayEnd += 1 tomorrowStart, tomorrowEnd = todayStart + time_utils.ONE_DAY, todayEnd + time_utils.ONE_DAY tomorrowEnd += 1 todayPeriods = () tomorrowPeriods = () if primeTime is not None: todayPeriods = primeTime.getPeriodsBetween( todayStart, min(todayEnd, currentCycleEnd)) if tomorrowStart < currentCycleEnd: tomorrowPeriods = primeTime.getPeriodsBetween( tomorrowStart, min(tomorrowEnd, currentCycleEnd)) todayStr = _packPeriods(todayPeriods, resRoot) primeTableBlocks.append( _packTimeBlock(message=text_styles.main( backport.text(resRoot.timeTable.today())), timeStr=text_styles.bonusPreviewText(todayStr))) tomorrowStr = _packPeriods(tomorrowPeriods, resRoot) primeTableBlocks.append( _packTimeBlock(message=text_styles.main( backport.text(resRoot.timeTable.tomorrow())), timeStr=text_styles.stats(tomorrowStr))) return primeTableBlocks
def getTimeTableBlock(modeCtrl, modeName, leftPadding=0, connectionMgr=None): timeTableBlocks = [packTimeTableHeaderBlock(modeName)] primeTime = modeCtrl.getPrimeTimes().get(connectionMgr.peripheryID) currentCycleEnd = modeCtrl.getCurrentSeason().getCycleEndDate() todayStart, todayEnd = time_utils.getDayTimeBoundsForLocal() todayEnd += 1 tomorrowStart, tomorrowEnd = todayStart + time_utils.ONE_DAY, todayEnd + time_utils.ONE_DAY tomorrowEnd += 1 todayPeriods = () tomorrowPeriods = () if primeTime is not None: todayPeriods = primeTime.getPeriodsBetween( todayStart, min(todayEnd, currentCycleEnd)) if tomorrowStart < currentCycleEnd: tomorrowPeriods = primeTime.getPeriodsBetween( tomorrowStart, min(tomorrowEnd, currentCycleEnd)) todayStr = _packPeriods(todayPeriods, modeName) timeTableBlocks.append( _packTimeBlock(message=text_styles.main( backport.text( R.strings.dyn(modeName).selectorTooltip.timeTable.today())), timeStr=text_styles.bonusPreviewText(todayStr))) tomorrowStr = _packPeriods(tomorrowPeriods, modeName) timeTableBlocks.append( _packTimeBlock(message=text_styles.main( backport.text( R.strings.dyn(modeName).selectorTooltip.timeTable.tomorrow())), timeStr=text_styles.stats(tomorrowStr))) return formatters.packBuildUpBlockData( timeTableBlocks, 7, BLOCKS_TOOLTIP_TYPES.TOOLTIP_BUILDUP_BLOCK_WHITE_BG_LINKAGE, padding=formatters.packPadding(left=leftPadding))
def __onCalendarDataSelected(self, event): timestamp = event.getTimestamp() if timestamp: self.__selectedDayStart, self.__selectedDayEnd = time_utils.getDayTimeBoundsForLocal(timestamp) self.__selectedDefencePeriodStart, self.__selectedDefencePeriodEnd = self.__selectedDayStart, self.__selectedDayEnd LOG_DEBUG(time.strftime('Attack time has been changed by user, %d.%m.%Y %H:%M', time_utils.getTimeStructInLocal(timestamp))) self.__calculateDefencePeriod() self.__makeData()
def __setSelectedDate(self): if self.__upcomingAttack is not None: self.__selectedDayStart, self.__selectedDayEnd = time_utils.getDayTimeBoundsForLocal(self.__upcomingAttack.getStartTime()) elif self.__hasBeenCounterAttacked: currentUserTime = time.time() timestampToUseForDateSelection = self.__defenseInCooldown.getStartTime() + time_utils.ONE_DAY if time.localtime(timestampToUseForDateSelection).tm_hour > self.__item.getStartDefHour(): timestampToUseForDateSelection += time_utils.ONE_DAY if timestampToUseForDateSelection < currentUserTime: timestampToUseForDateSelection = currentUserTime self.__selectedDayStart, self.__selectedDayEnd = time_utils.getDayTimeBoundsForLocal(timestampToUseForDateSelection) elif self.__attackInCooldown is not None: self.__selectedDayStart, self.__selectedDayEnd = time_utils.getDayTimeBoundsForLocal(self.__attackInCooldown.getStartTime()) else: timestamp = self.__item.getAvailability() self.__selectedDayStart, self.__selectedDayEnd = time_utils.getDayTimeBoundsForLocal(timestamp) self.__selectedDefencePeriodStart, self.__selectedDefencePeriodEnd = self.__selectedDayStart, self.__selectedDayEnd
def __setSelectedDate(self): if self.__upcomingAttack is not None: self.__selectedDayStart, self.__selectedDayEnd = time_utils.getDayTimeBoundsForLocal(self.__upcomingAttack.getStartTime()) elif self.__hasBeenCounterAttacked: currentUserTime = time.time() timestampToUseForDateSelection = self.__defenseInCooldown.getStartTime() + time_utils.ONE_DAY if time.localtime(timestampToUseForDateSelection).tm_hour > self.__item.getStartDefHour(): timestampToUseForDateSelection += time_utils.ONE_DAY if timestampToUseForDateSelection < currentUserTime: timestampToUseForDateSelection = currentUserTime self.__selectedDayStart, self.__selectedDayEnd = time_utils.getDayTimeBoundsForLocal(timestampToUseForDateSelection) elif self.__attackInCooldown is not None: self.__selectedDayStart, self.__selectedDayEnd = time_utils.getDayTimeBoundsForLocal(self.__attackInCooldown.getStartTime()) else: timestamp = self.__item.getAvailability() self.__selectedDayStart, self.__selectedDayEnd = time_utils.getDayTimeBoundsForLocal(timestamp) self.__selectedDefencePeriodStart, self.__selectedDefencePeriodEnd = self.__selectedDayStart, self.__selectedDayEnd return
def _getBattlesByDay(self): result, fort = defaultdict(list), self.fortCtrl.getFort() for battle in fort.getAttacks() + fort.getDefences(): startTimestamp = battle.getStartTime() if self._isValidTime(startTimestamp): dayStartTimestamp, _ = time_utils.getDayTimeBoundsForLocal(startTimestamp) result[dayStartTimestamp].append(battle) return result
def _packBlocks(self, *args): items = super(EpicMetaGameUnavailableTooltip, self)._packBlocks() items.append(self._packHeaderBlock()) timeTableBlocks = [self._packTimeTableHeaderBlock()] primeTime = self.epicController.getPrimeTimes().get( self.connectionMgr.peripheryID, None) if primeTime is None or self.epicController.hasAnySeason() is None: return items else: todayStart, todayEnd = time_utils.getDayTimeBoundsForLocal() todayEnd += 1 tomorrowStart, tomorrowEnd = todayStart + time_utils.ONE_DAY, todayEnd + time_utils.ONE_DAY todayPeriods = () tomorrowPeriods = () time, status = self.epicController.getSeasonEndTime() if status: todayPeriods = primeTime.getPeriodsBetween( todayStart, min(todayEnd, time)) if tomorrowStart < time: tomorrowPeriods = primeTime.getPeriodsBetween( tomorrowStart, min(tomorrowEnd, time)) todayStr = self._packPeriods(todayPeriods) timeTableBlocks.append( self._packTimeBlock(message=text_styles.main( EPIC_BATTLE. SELECTORTOOLTIP_EPICBATTLE_DISABLED_TIMETABLE_TODAY), timeStr=text_styles.bonusPreviewText( todayStr))) tomorrowStr = self._packPeriods(tomorrowPeriods) timeTableBlocks.append( self._packTimeBlock(message=text_styles.main( EPIC_BATTLE. SELECTORTOOLTIP_EPICBATTLE_DISABLED_TIMETABLE_TOMORROW ), timeStr=text_styles.stats( tomorrowStr))) items.append( formatters.packBuildUpBlockData( timeTableBlocks, 7, BLOCKS_TOOLTIP_TYPES. TOOLTIP_BUILDUP_BLOCK_WHITE_BG_LINKAGE)) items.append( self._getTillEndBlock( time_utils.getTimeDeltaFromNow( time_utils.makeLocalServerTime(time)))) return items
def _packBlocks(self, *args): items = super(RankedSelectorTooltip, self)._packBlocks() items.append(self._packHeaderBlock()) timeTableBlocks = [self._packTimeTableHeaderBlock()] primeTime = self.rankedController.getPrimeTimes().get( self.connectionMgr.peripheryID) currentCycleEnd = self.rankedController.getCurrentSeason( ).getCycleEndDate() todayStart, todayEnd = time_utils.getDayTimeBoundsForLocal() todayEnd += 1 tomorrowStart, tomorrowEnd = todayStart + time_utils.ONE_DAY, todayEnd + time_utils.ONE_DAY tomorrowEnd += 1 todayPeriods = () tomorrowPeriods = () if primeTime is not None: todayPeriods = primeTime.getPeriodsBetween( todayStart, min(todayEnd, currentCycleEnd)) if tomorrowStart < currentCycleEnd: tomorrowPeriods = primeTime.getPeriodsBetween( tomorrowStart, min(tomorrowEnd, currentCycleEnd)) todayStr = self._packPeriods(todayPeriods) timeTableBlocks.append( self._packTimeBlock( message=text_styles.main( backport.text(R.strings.ranked_battles.selectorTooltip. timeTable.today())), timeStr=text_styles.bonusPreviewText(todayStr))) tomorrowStr = self._packPeriods(tomorrowPeriods) timeTableBlocks.append( self._packTimeBlock(message=text_styles.main( backport.text(R.strings.ranked_battles.selectorTooltip. timeTable.tomorrow())), timeStr=text_styles.stats(tomorrowStr))) items.append( formatters.packBuildUpBlockData( timeTableBlocks, 7, BLOCKS_TOOLTIP_TYPES.TOOLTIP_BUILDUP_BLOCK_WHITE_BG_LINKAGE)) items.append( self._getTillEndBlock( time_utils.getTimeDeltaFromNow( time_utils.makeLocalServerTime(currentCycleEnd)))) return items
def __doClockworkLogic(self, mode): if not self.isStrongholdSettingsValid(): if mode & self.CWL_RETURN_MATCHING_BUTTON_STATUS == self.CWL_RETURN_MATCHING_BUTTON_STATUS: return True return isInBattle = self._hasInArenaMembers() isInQueue = self._isInQueue() dtime = None peripheryStartTimestampUTC = 0 currentTimestampUTC = 0 matchmakerNextTick = None inactiveMatchingButton = True forceUpdateBuildings = mode & self.CWL_FORCE_UPDATE_BUILDINGS == self.CWL_FORCE_UPDATE_BUILDINGS currentTimeUTC, clientTimeUTC = self._getCurrentUTCTime() timer = self.__strongholdSettings.getTimer() peripheryStartTimeUTC = currentTimeUTC.replace(hour=0, minute=0, second=0, microsecond=0) peripheryEndTimeUTC = currentTimeUTC.replace(hour=0, minute=0, second=0, microsecond=0) if timer.getBattlesStartTime() and timer.getBattlesEndTime(): isInactivePeriphery = False peripheryStartTimeUTC, peripheryEndTimeUTC = self.__calculatePeripheryTimeHelper(currentTimeUTC) peripheryStartTimestampUTC = int(time_utils.getTimestampFromUTC(peripheryStartTimeUTC.timetuple())) currentTimestampUTC = int(time_utils.getTimestampFromUTC(currentTimeUTC.timetuple())) else: peripheryEndTimeUTC -= datetime.timedelta(days=1) peripheryStartTimeUTC -= datetime.timedelta(days=1) isInactivePeriphery = True dtime = 0 if self.__strongholdSettings.isSortie(): textid = FORTIFICATIONS.SORTIE_INTROVIEW_FORTBATTLES_UNAVAILABLE if isInQueue: textid = TOOLTIPS.STRONGHOLDS_TIMER_SQUADINQUEUE dtime = peripheryStartTimestampUTC - currentTimestampUTC if dtime < 0 or dtime > timer.getSortiesBeforeStartLag(): dtime = 0 elif isInBattle: textid = TOOLTIPS.STRONGHOLDS_TIMER_SQUADINBATTLE elif self.isStrongholdUnitWaitingForData(): textid = TOOLTIPS.STRONGHOLDS_TIMER_WAITINGFORDATA elif peripheryStartTimeUTC <= currentTimeUTC <= peripheryEndTimeUTC: dtime = int((peripheryEndTimeUTC - currentTimeUTC).total_seconds()) inactiveMatchingButton = False if dtime <= timer.getSortiesBeforeEndLag(): textid = FORTIFICATIONS.SORTIE_INTROVIEW_FORTBATTLES_ENDOFBATTLESOON else: textid = FORTIFICATIONS.SORTIE_INTROVIEW_FORTBATTLES_AVAILABLE elif isInactivePeriphery: dtime = 0 else: dtime = peripheryStartTimestampUTC - currentTimestampUTC if dtime <= timer.getSortiesBeforeStartLag(): if dtime < 0: dtime = 0 textid = FORTIFICATIONS.SORTIE_INTROVIEW_FORTBATTLES_NEXTTIMEOFBATTLESOON if dtime <= self.MATCHMAKING_BATTLE_BUTTON_SORTIE: inactiveMatchingButton = False else: peripheryStartTimeUTC, _ = self.__calculatePeripheryTimeHelper(clientTimeUTC) peripheryStartTimestampUTC = int(time_utils.getTimestampFromUTC(peripheryStartTimeUTC.timetuple())) currentTimestampUTC = int(time_utils.getTimestampFromUTC(clientTimeUTC.timetuple())) peripheryStartTimestamp = self._convertUTCStructToLocalTimestamp(peripheryStartTimeUTC) currentTimestamp = self._convertUTCStructToLocalTimestamp(clientTimeUTC) dtime = peripheryStartTimestampUTC - currentTimestampUTC currDayStart, currDayEnd = time_utils.getDayTimeBoundsForLocal(peripheryStartTimestamp) if currDayStart - time_utils.ONE_DAY <= currentTimestamp <= currDayEnd - time_utils.ONE_DAY: textid = FORTIFICATIONS.SORTIE_INTROVIEW_FORTBATTLES_NEXTTIMEOFBATTLETOMORROW elif currDayStart <= currentTimestamp <= currDayEnd: textid = FORTIFICATIONS.SORTIE_INTROVIEW_FORTBATTLES_NEXTTIMEOFBATTLETODAY else: textid = FORTIFICATIONS.ROSTERINTROWINDOW_INTROVIEW_FORTBATTLES_UNAVAILABLE if not isInactivePeriphery: dtime = time_utils.ONE_YEAR matchmakerNextTick = timer.getTimeToReady() if matchmakerNextTick is not None: dtime = int(matchmakerNextTick - currentTimestampUTC) else: matchmakerNextTick = timer.getMatchmakerNextTick() if matchmakerNextTick is not None: dtime = int(matchmakerNextTick - currentTimestampUTC) battlesBeforeStartLag = timer.getFortBattlesBeforeStartLag() if self.__prevMatchmakingTimerState == FORTIFICATIONS.ROSTERINTROWINDOW_INTROVIEW_FORTBATTLES_NEXTTIMEOFBATTLESOON and 0 <= int(dtime - battlesBeforeStartLag) < self.MATCHMAKING_ZERO_TIME_WAITING_FOR_DATA and mode & self.CWL_REGULAR_MODE == self.CWL_REGULAR_MODE: dtime = battlesBeforeStartLag if isInQueue: textid = TOOLTIPS.STRONGHOLDS_TIMER_SQUADINQUEUE if dtime < 0 or dtime > battlesBeforeStartLag: dtime = 0 elif isInBattle: textid = TOOLTIPS.STRONGHOLDS_TIMER_SQUADINBATTLE elif self.isStrongholdUnitWaitingForData(): textid = TOOLTIPS.STRONGHOLDS_TIMER_WAITINGFORDATA elif dtime > battlesBeforeStartLag: textid = FORTIFICATIONS.ROSTERINTROWINDOW_INTROVIEW_FORTBATTLES_UNAVAILABLE if matchmakerNextTick is not None: peripheryStartTimeUTC, _ = self.__calculatePeripheryTimeHelper(clientTimeUTC) peripheryStartTimestampUTC = int(time_utils.getTimestampFromUTC(peripheryStartTimeUTC.timetuple())) currentTimestampUTC = int(time_utils.getTimestampFromUTC(clientTimeUTC.timetuple())) currentTimestamp = self._convertUTCStructToLocalTimestamp(clientTimeUTC) dtime = int(matchmakerNextTick - currentTimestampUTC) matchmakerNextTickLocal = time_utils.getDateTimeInUTC(matchmakerNextTick) matchmakerNextTickLocal = self._convertUTCStructToLocalTimestamp(matchmakerNextTickLocal) currDayStart, currDayEnd = time_utils.getDayTimeBoundsForLocal(matchmakerNextTickLocal) if currDayStart - time_utils.ONE_DAY <= currentTimestamp <= currDayEnd - time_utils.ONE_DAY: textid = FORTIFICATIONS.SORTIE_INTROVIEW_FORTBATTLES_NEXTTIMEOFBATTLETOMORROW elif currDayStart <= currentTimestamp <= currDayEnd: textid = FORTIFICATIONS.SORTIE_INTROVIEW_FORTBATTLES_NEXTTIMEOFBATTLETODAY elif dtime >= 0: textid = FORTIFICATIONS.ROSTERINTROWINDOW_INTROVIEW_FORTBATTLES_NEXTTIMEOFBATTLESOON if dtime <= self.MATCHMAKING_BATTLE_BUTTON_BATTLE or not self.__strongholdSettings.isFirstBattle(): inactiveMatchingButton = False else: dtimeWD = dtime + self.MATCHMAKING_ZERO_TIME_WAITING_FOR_DATA if dtimeWD >= 0: textid = FORTIFICATIONS.ROSTERINTROWINDOW_INTROVIEW_FORTBATTLES_NEXTTIMEOFBATTLESOON dtime = 0 if mode & self.CWL_REGULAR_MODE == self.CWL_REGULAR_MODE: self.__prevMatchmakingTimerState = textid if mode & self.CWL_INVOKE_LISTENERS == self.CWL_INVOKE_LISTENERS: header = self.__strongholdSettings.getHeader() g_eventDispatcher.strongholdsOnTimer({'peripheryStartTimestamp': peripheryStartTimestampUTC, 'matchmakerNextTick': matchmakerNextTick, 'clan': header.getClan(), 'enemyClan': header.getEnemyClan(), 'textid': textid, 'dtime': dtime, 'isSortie': self.__strongholdSettings.isSortie(), 'isFirstBattle': self.__strongholdSettings.isFirstBattle(), 'currentBattle': header.getCurrentBattle(), 'maxLevel': header.getMaxLevel(), 'direction': header.getDirection(), 'forceUpdateBuildings': forceUpdateBuildings}) if mode & self.CWL_RETURN_MATCHING_BUTTON_STATUS == self.CWL_RETURN_MATCHING_BUTTON_STATUS: return inactiveMatchingButton elif mode & self.CWL_RETURN_MATCHMAKER_NEXT_TICK == self.CWL_RETURN_MATCHMAKER_NEXT_TICK: return matchmakerNextTick else: return