def _onMatchmakingTimerChanged(self, event): data = event.ctx isBattleTimerVisible = False wfbDescr = None playerClanName = None enemyClanName = None currentBattle = data['currentBattle'] mapId = currentBattle.getMapId() if currentBattle else 0 enemyclanData = data['enemyClan'] enemyVisible = enemyclanData is not None isInBattle = self.prbEntity.getFlags().isInArena() textid = data['textid'] maxLvl = data['maxLevel'] level = int2roman(maxLvl) if data['isSortie']: headerDescr = i18n.makeString(FORTIFICATIONS.STRONGHOLDINFO_SORTIE) % {'level': level} timetext = None if textid == FORTIFICATIONS.SORTIE_INTROVIEW_FORTBATTLES_ENDOFBATTLESOON: timetext = time_utils.getTimeLeftFormat(data['dtime']) elif textid == FORTIFICATIONS.SORTIE_INTROVIEW_FORTBATTLES_NEXTTIMEOFBATTLESOON: timetext = time_utils.getTimeLeftFormat(data['dtime']) elif textid == FORTIFICATIONS.SORTIE_INTROVIEW_FORTBATTLES_NEXTTIMEOFBATTLETOMORROW: timetext = BigWorld.wg_getShortTimeFormat(data['peripheryStartTimestamp']) elif textid == FORTIFICATIONS.SORTIE_INTROVIEW_FORTBATTLES_NEXTTIMEOFBATTLETODAY: timetext = BigWorld.wg_getShortTimeFormat(data['peripheryStartTimestamp']) wfbDescr = i18n.makeString(textid, nextDate=timetext) else: direction = vo_converters.getDirection(data['direction']) headerDescr = i18n.makeString(FORTIFICATIONS.STRONGHOLDINFO_STRONGHOLD) % {'direction': direction} if textid != FORTIFICATIONS.ROSTERINTROWINDOW_INTROVIEW_FORTBATTLES_NEXTTIMEOFBATTLESOON: timetext = None if textid == FORTIFICATIONS.SORTIE_INTROVIEW_FORTBATTLES_NEXTTIMEOFBATTLETOMORROW: timetext = BigWorld.wg_getShortTimeFormat(data['matchmakerNextTick']) elif textid == FORTIFICATIONS.SORTIE_INTROVIEW_FORTBATTLES_NEXTTIMEOFBATTLETODAY: timetext = BigWorld.wg_getShortTimeFormat(data['matchmakerNextTick']) wfbDescr = i18n.makeString(textid, nextDate=timetext) else: isBattleTimerVisible = True fontColors = GUI_SETTINGS.lookup('StrongholdsTimerColors') colorRegular = fontColors.get('regular', '#FFDD99') colorAlarm = fontColors.get('alarm', '#ff7f00') enemyClanName = '?' if enemyVisible: clColor = enemyclanData.getColor() clColor = '#%06x' % clColor if clColor else '#ffffff' enemyClanName = "<b><font face='$FieldFont' color='{0}'>[{1}]</font></b>".format(clColor, enemyclanData.getTag()) clan = data['clan'] if clan: clColor = clan.getColor() clColor = '#%06x' % clColor if clColor else '#ffffff' playerClanName = "<b><font face='$FieldFont' color='{0}'>[{1}]</font></b>".format(clColor, clan.getTag()) self.as_setTimerDeltaS(vo_converters.makeClanBattleTimerVO(data['dtime'] if not isInBattle else 0, "<font face='$FieldFont' size='18' color='{0}'>###</font>".format(colorRegular), "<font face='$FieldFont' size='18' color='{0}'>###</font>".format(colorAlarm), self.TIMER_GLOW_COLORS.NORMAL, self.TIMER_GLOW_COLORS.ALERT, '00', 0 if data['isFirstBattle'] else 1)) self.as_updateReadyStatusS(self.prbEntity.getFlags().isInQueue(), self.__enemyReadyIndicator) self.as_setBattleRoomDataS(vo_converters.makeFortClanBattleRoomVO(mapId, headerDescr, playerClanName, enemyClanName, wfbDescr, enemyVisible, isBattleTimerVisible, data['isSortie'])) if data['forceUpdateBuildings']: self.__forceUpdateBuildings() return
def getSlotsStatesData(vehs, cooldowns, disabled, limits={}): result = [] for v in vehs.itervalues(): compactDescr = v.intCD cooldownTime = cooldowns.get(compactDescr, 0) cooldownStr = '' cooldown = cooldownTime - BigWorld.serverTime() enabled = cooldown <= 0 and not disabled and compactDescr not in limits if not enabled: if cooldown > 0: if disabled: cooldownStr = backport.text( R.strings.ingame_gui.respawnView.disabledLbl()) else: cooldownStr = backport.text( R.strings.ingame_gui.respawnView.cooldownLbl(), time=time_utils.getTimeLeftFormat(cooldown)) else: cooldownStr = backport.text( R.strings.ingame_gui.respawnView.classNotAvailable()) result.append({ 'vehicleID': compactDescr, 'enabled': enabled, 'cooldown': cooldownStr, 'settings': v.settings }) return result
def _makeData(self): result = [] arenaDP = g_sessionProvider.getArenaDP() for pointID, point in g_ctfManager.getResourcePoints(): pointState = point['state'] timeLeft = '' amount = point['amount'] progress = float(amount) / point['totalAmount'] * 100 if pointState == RESOURCE_POINT_STATE.FREE: state = _POINTS_STATE.READY elif pointState == RESOURCE_POINT_STATE.COOLDOWN: self.__plugin.setUpdateRequired(True) state = _POINTS_STATE.COOLDOWN timeDelta = max(0, point['cooldownTime'] - BigWorld.serverTime()) timeLeft = time_utils.getTimeLeftFormat(timeDelta) elif pointState == RESOURCE_POINT_STATE.CAPTURED: state = _CAPTURE_STATE_BY_TEAMS[arenaDP.isAllyTeam(point['team'])] elif pointState == RESOURCE_POINT_STATE.CAPTURED_LOCKED: state = _CAPTURE_FROZEN_STATE_BY_TEAMS[arenaDP.isAllyTeam(point['team'])] elif pointState == RESOURCE_POINT_STATE.BLOCKED: state = _POINTS_STATE.CONFLICT else: state = _POINTS_STATE.FREEZE result.append(self._makeItem(progress, state, amount, timeLeft)) return result
def __updateSafeZone(self): if self.__safeZoneUI is not None: if self.__state.state == GAS_ATTACK_STATE.NEAR_SAFE: self.__safeZoneUI.showTimer(time_utils.getTimeLeftFormat(self.__state.timeLeft)) elif self.__state.state != self.__state.prevState: self.__safeZoneUI.hideTimer() return
def __startCountdownTimer(self): self.__killTimeCallback() diffTime = self.__currentEndTime - BigWorld.serverTime() if diffTime >= 0: timeStr = time_utils.getTimeLeftFormat(diffTime) self.as_setMissionDescriptionValueS(timeStr) self.delayCallback(0, self.__tick)
def __getSlotsStatesData(self, vehsList, cooldowns): result = [] for v in vehsList: compactDescr = v.intCD cooldownTime = cooldowns.get(compactDescr, 0) cooldownStr = None cooldown = cooldownTime - BigWorld.serverTime() enabled = cooldown <= 0 and not self.__disabled if not enabled: if self.__disabled: cooldownStr = i18n.makeString( '#ingame_gui:respawnView/disabledLbl') elif cooldownTime > g_sessionProvider.shared.arenaPeriod.getEndTime( ): cooldownStr = i18n.makeString( '#ingame_gui:respawnView/destroyedLbl') else: cooldownStr = i18n.makeString( '#ingame_gui:respawnView/cooldownLbl', time=time_utils.getTimeLeftFormat(cooldown)) result.append({ 'vehicleID': compactDescr, 'selected': compactDescr == self.__selectedVehicleID, 'enabled': enabled, 'cooldown': cooldownStr }) return result
def __tick(self): diffTime = math.ceil(self.__currentEndTime - BigWorld.serverTime()) if diffTime >= 0: timeStr = time_utils.getTimeLeftFormat(diffTime) self.as_setMissionDescriptionValueS(timeStr) return 1 self.as_setMissionDescriptionValueS('')
def __onTransitionTimerUpdated(self, sectorGroupID, seconds): if self.__markerActiveState and self.__currentWaypointSector and self.__currentWaypointSector.groupID == sectorGroupID and self.__marker: if seconds >= 0: timeStr = time_utils.getTimeLeftFormat(seconds) self._invokeMarker(self.__marker, 'setCountdown', timeStr) else: self._invokeMarker(self.__marker, 'clearCountdown')
def __showTimer(self, timeLeft): self.__timerCallbackID = None self.as_setStartTimeS(time_utils.getTimeLeftFormat(timeLeft)) if timeLeft > 0: self.__timerCallbackID = BigWorld.callback( 1, functools.partial(self.__showTimer, timeLeft - 1)) return
def getSlotsStatesData(vehsList, cooldowns, disabled, limits={}): result = [] for v in vehsList: compactDescr = v.intCD cooldownTime = cooldowns.get(compactDescr, 0) cooldownStr = '' cooldown = cooldownTime - BigWorld.serverTime() enabled = cooldown <= 0 and not disabled and compactDescr not in limits if not enabled: if cooldownTime is not 0: if disabled: cooldownStr = i18n.makeString( '#ingame_gui:respawnView/disabledLbl') else: cooldownStr = i18n.makeString( '#ingame_gui:respawnView/cooldownLbl', time=time_utils.getTimeLeftFormat(cooldown)) else: cooldownStr = i18n.makeString( '#ingame_gui:respawnView/classNotAvailable') result.append({ 'vehicleID': compactDescr, 'enabled': enabled, 'cooldown': cooldownStr, 'settings': v.settings }) return result
def addCapturedTeamBase(self, clientID, playerTeam, timeLeft, invadersCnt): item = _getSettingItem(clientID, playerTeam, g_sessionProvider.arenaVisitor.type.getID()) self.as_addS(clientID, item.getWeight(), item.getColor(), item.getCapturingString(), 100, time_utils.getTimeLeftFormat(timeLeft), self.__getInvadersCountStr(invadersCnt))
def updateTeamBasePoints(self, clientID, points, rate, timeLeft, invadersCnt): self.__callFlash('updateCaptureData', [ clientID, points, rate, time_utils.getTimeLeftFormat(timeLeft), self.__getInvadersCountStr(invadersCnt) ])
def __updateBattleGasItems(self): isSafeZoneTimerVisible = self.__state.state == GAS_ATTACK_STATE.NEAR_SAFE minimapGasIsVisible = self.__state.state != GAS_ATTACK_STATE.PREPEARING timeStr = time_utils.getTimeLeftFormat(self.__state.timeLeft) if self.__falloutItems is not None: self.__falloutItems.as_gasAtackUpdate(self.__state.state, minimapGasIsVisible, self.__state.currentRadius, isSafeZoneTimerVisible, timeStr) return
def updateTeamBasePoints(self, clientID, points, rate, timeLeft, invadersCnt): item = self.__basesDict.get(clientID, None) if not item: return else: capturingString = item.getCapturingString(points) self.as_updateCaptureDataS(clientID, points, rate, time_utils.getTimeLeftFormat(timeLeft), self.__getInvadersCountStr(invadersCnt), capturingString, item.getColor()) return
def updateTeamBasePoints(self, clientID, points, rate, timeLeft, invadersCnt): item = self.basesDict.get(clientID, None) if item: self.as_updateBaseS(item.getColor(), points, rate, self.getInvadersCountStr(invadersCnt), time_utils.getTimeLeftFormat(timeLeft), item.getCapturingString(points))
def addCapturingTeamBase(self, clientID, playerTeam, points, _, timeLeft, invadersCnt, capturingStopped): item = _getSettingItem(clientID, playerTeam, self.sessionProvider.arenaVisitor.type.getID()) title = item.getCapturingString(points) self.as_addS(clientID, item.getWeight(), item.getColor(), title, points, time_utils.getTimeLeftFormat(timeLeft), self.__getInvadersCountStr(invadersCnt)) self.__basesDict[clientID] = item if capturingStopped: if invadersCnt > 0: self.blockTeamBaseCapturing(clientID, points) else: self.stopTeamBaseCapturing(clientID, points)
def __showTimer(self, timeLeft): self.__timerCallback = None templateName = self.TIME_TEMPLATES.WARNING if timeLeft <= self.WARNING_TIME else self.TIME_TEMPLATES.NORMAL timeLeftMsg = makeHtmlString( 'html_templates:lobby/cyberSport/respawn', templateName, {'time': time_utils.getTimeLeftFormat(timeLeft)}) self.as_timerUpdateS(timeLeftMsg) if timeLeft > 0: self.__timerCallback = BigWorld.callback( 1, functools.partial(self.__showTimer, timeLeft - 1))
def addCapturingTeamBase(self, clientID, playerTeam, points, _, timeLeft, invadersCnt, capturingStopped): item = _getSettingItem(clientID, playerTeam, g_sessionProvider.arenaVisitor.type.getID()) self.as_addS(clientID, item.getWeight(), item.getColor(), item.getCapturingString(), points, time_utils.getTimeLeftFormat(timeLeft), self.__getInvadersCountStr(invadersCnt)) if capturingStopped: self.stopTeamBaseCapturing(clientID, points)
def __showTimer(self, timeLeft): self.__timerCallback = None templateName = self.TIME_TEMPLATES.WARNING if timeLeft <= self.WARNING_TIME else self.TIME_TEMPLATES.NORMAL timeLeftMsg = makeHtmlString( "html_templates:lobby/cyberSport/respawn", templateName, {"time": time_utils.getTimeLeftFormat(timeLeft)} ) self.as_timerUpdateS(timeLeftMsg) if timeLeft > 0: self.__timerCallback = BigWorld.callback(1, functools.partial(self.__showTimer, timeLeft - 1)) return
def __updateFreeze(self): lock = g_ctfManager.getResourcePointLock() if lock is not None: timeDelta = max(0, g_ctfManager.getResourcePointLock() - BigWorld.serverTime()) else: timeDelta = 0 timeStr = time_utils.getTimeLeftFormat(timeDelta) if self.__resourceIndicator is not None: self.__resourceIndicator.setFreeze(True, timeStr) self.__initFreezeCallback()
def __tick(self): diffTime = self.__timestamp - BigWorld.serverTime() if diffTime <= 0: self.__timeCB = None self.as_setTimerS('0:00') else: timeStr = time_utils.getTimeLeftFormat(diffTime) self.as_setTimerS(timeStr) if self.__timeCB is not None: self.__timeCB = BigWorld.callback(1, self.__tick) return
def __updateFreeze(self): lock = g_ctfManager.getResourcePointLock() if lock is not None: timeDelta = max(0, g_ctfManager.getResourcePointLock() - BigWorld.serverTime()) else: timeDelta = 0 timeStr = time_utils.getTimeLeftFormat(timeDelta) if self.__resourceIndicator is not None: self.__resourceIndicator.setFreeze(True, timeStr) self.__initFreezeCallback() return
def __initTimer(self, timer, repairID): timer -= 1 handle, _, repairPos, wasActive = self.__markers[repairID] if timer < 0: self.__markers[repairID] = (handle, None, repairPos, wasActive) return self._parentObj.invokeMarker(handle, 'setLabel', [time_utils.getTimeLeftFormat(timer)]) callbackId = BigWorld.callback( 1, partial(self.__initTimer, timer, repairID)) self.__markers[repairID] = (handle, callbackId, repairPos, wasActive)
def addCapturingTeamBase(self, clientID, playerTeam, points, rate, timeLeft, invadersCnt, capturingStopped): item = getSettingItem(clientID, playerTeam, g_sessionProvider.arenaVisitor.type.getID()) self.__callFlash('add', [clientID, item.getWeight(), item.getColor(), item.getCapturingString(), points, rate, time_utils.getTimeLeftFormat(timeLeft), self.__getInvadersCountStr(invadersCnt)]) if capturingStopped: self.__callFlash('stop', [clientID, points])
def addCapturingTeamBase(self, clientID, playerTeam, points, rate, timeLeft, invadersCnt, capturingStopped): item = getSettingItem(clientID, playerTeam) self.__callFlash('add', [clientID, item.getWeight(), item.getColor(), item.getCapturingString(), points, rate, time_utils.getTimeLeftFormat(timeLeft), self.__getInvadersCountStr(invadersCnt)]) if capturingStopped: self.__callFlash('stop', [clientID, points])
def addCapturedTeamBase(self, clientID, playerTeam, timeLeft, invadersCnt): item = self.basesDict.get(clientID, None) if item: self.as_updateCaptureTextS(item.getColor(), item.getCapturedString()) else: item = _getSettingItem( clientID, playerTeam, self.sessionProvider.arenaVisitor.type.getID()) self.basesDict[clientID] = item self.as_addTeamBaseS(item.getColor(), TEAM_BASES.HUNDRED, self.getInvadersCountStr(invadersCnt), time_utils.getTimeLeftFormat(timeLeft), item.getCapturedString())
def __initTimer(self, timer, repairID): timer -= 1 handle, _, repairPos, wasActive = self.__markers[repairID] if timer < 0: self.__markers[repairID] = (handle, None, repairPos, wasActive) return self._parentObj.invokeMarker(handle, 'setLabel', [time_utils.getTimeLeftFormat(timer)]) callbackId = BigWorld.callback(1, partial(self.__initTimer, timer, repairID)) self.__markers[repairID] = (handle, callbackId, repairPos, wasActive)
def __tick(self): if self.__nextActionTime > 0 and self.__recoveryActivated: diffTime = self.__nextActionTime - BigWorld.serverTime() timerText = time_utils.getTimeLeftFormat(diffTime) if diffTime > 0: self.__cooldownTimerCallback = BigWorld.callback(1, self.__tick) self.as_updateTimerS(i18n.makeString(INGAME_GUI.RECOVERY_COOLDOWN, cooldown=timerText)) else: self.__nextActionTime = -1 self.as_updateTimerS(i18n.makeString(INGAME_GUI.RECOVERY_COOLDOWN, cooldown=timerText)) self.__cooldownTimerCallback = None self.__cancelHideCallback(_CALLBACK_HIDE.COOLDOWN) self.as_displayCooldownS(False, False) elif self.__cooldownTimerCallback: BigWorld.cancelCallback(self.__cooldownTimerCallback) self.__cooldownTimerCallback = None return
def __onRepairPointTimerUpdated(self, pointIndex, stateID, timeLeft): if stateID == REPAIR_STATE_ID.COOLDOWN and pointIndex in self.__markers: self._parentObj.invokeMarker( self.__markers[pointIndex][0], 'setLabel', [time_utils.getTimeLeftFormat(timeLeft)])
def __showTimer(self, timeLeft): self.__timerCallbackID = None self.as_setStartTimeS(time_utils.getTimeLeftFormat(timeLeft)) if timeLeft > 0: self.__timerCallbackID = BigWorld.callback(1, functools.partial(self.__showTimer, timeLeft - 1)) return
def __onTimerUpdated(self, circleType, idx, timeLeft): if not self.__isPresentCircle(circleType, idx): return self.as_setAdditionalTimerTimeStringS( circleType, time_utils.getTimeLeftFormat(timeLeft))
def __onRepairPointTimerUpdated(self, pointIndex, stateID, timeLeft): if self.__isTimerShown and self.__pointIndex == pointIndex: self.as_setTimeStringS(time_utils.getTimeLeftFormat(timeLeft))
def updateTeamBasePoints(self, clientID, points, rate, timeLeft, invadersCnt): self.__callFlash('updateCaptureData', [clientID, points, rate, time_utils.getTimeLeftFormat(timeLeft), self.__getInvadersCountStr(invadersCnt)])
def __onRepairPointTimerUpdated(self, pointIndex, stateID, timeLeft): if stateID == REPAIR_STATE_ID.COOLDOWN and pointIndex in self.__markers: self._parentObj.invokeMarker(self.__markers[pointIndex][0], 'setLabel', [time_utils.getTimeLeftFormat(timeLeft)])
def updateTime(self, timeLeft): self.__flashObject.as_update(time_utils.getTimeLeftFormat(timeLeft))
def __onTimerUpdated(self, type_, pointId, timeLeft): if type_ is not PROGRESS_CIRCLE_TYPE.RESUPPLY_CIRCLE: return handle = self.__markers[pointId] self._parentObj.invokeMarker(handle, 'setCooldown', [time_utils.getTimeLeftFormat(timeLeft)])
def updateTimer(self, timeLeft, vehsList, cooldowns): mainTimer = time_utils.getTimeLeftFormat(timeLeft) slotsStateData = self.__getSlotsStatesData(vehsList, cooldowns) self.as_updateTimerS(mainTimer, slotsStateData)
def __getSlotsStatesData(self, vehsList, cooldowns): result = [] for v in vehsList: compactDescr = v.intCD cooldownTime = cooldowns.get(compactDescr, 0) cooldownStr = None cooldown = cooldownTime - BigWorld.serverTime() enabled = cooldown <= 0 and not self.__disabled if not enabled: if self.__disabled: cooldownStr = i18n.makeString('#ingame_gui:respawnView/disabledLbl') elif cooldownTime > g_sessionProvider.shared.arenaPeriod.getEndTime(): cooldownStr = i18n.makeString('#ingame_gui:respawnView/destroyedLbl') else: cooldownStr = i18n.makeString('#ingame_gui:respawnView/cooldownLbl', time=time_utils.getTimeLeftFormat(cooldown)) result.append({'vehicleID': compactDescr, 'selected': compactDescr == self.__selectedVehicleID, 'enabled': enabled, 'cooldown': cooldownStr}) return result
def __updateTimer(self, marker, seconds): if seconds > 0: timeStr = time_utils.getTimeLeftFormat(seconds) self._invokeMarker(marker.markerID, 'setCountdown', timeStr) else: self._invokeMarker(marker.markerID, 'clearCountdown')