def start(self, clanCache): if self.isStarted(): LOG_WARNING('Fort provider already is ready') return else: self.__initial |= FORT_PROVIDER_INITIAL_FLAGS.STARTED self.__clan = weakref.proxy(clanCache) self.__listeners = _ClientFortListeners() self.__keeper = FortSubscriptionKeeper() self.__keeper.onAutoUnsubscribed += self.__onAutoUnsubscribed fortMgr = getClientFortMgr() if fortMgr: fortMgr.onFortResponseReceived += self.__onFortResponseReceived fortMgr.onFortUpdateReceived += self.__onFortUpdateReceived fortMgr.onFortStateChanged += self.__onFortStateChanged else: LOG_ERROR('Fort manager is not found') g_lobbyContext.getServerSettings().onServerSettingsChange += self.__onServerSettingChanged g_playerEvents.onCenterIsLongDisconnected += self.__onCenterIsLongDisconnected self.__controller = controls.createInitial() self.__controller.init(self.__clan, self.__listeners) states.create(self) if not g_lobbyContext.getServerSettings().isFortsEnabled() and self.__cachedState is not None: if self.__cachedState.getStateID() not in (CLIENT_FORT_STATE.UNSUBSCRIBED, CLIENT_FORT_STATE.DISABLED): SystemMessages.pushI18nMessage(I18N_SM.FORTIFICATION_NOTIFICATION_TURNEDOFF, type=SystemMessages.SM_TYPE.Warning) showFortDisabledDialog() return
def _dispose(self): battle_selector_items.clear() g_clientUpdateManager.removeObjectCallbacks(self) self.stopGlobalListening() self.removeListener(events.FightButtonEvent.FIGHT_BUTTON_UPDATE, self.__handleFightButtonUpdated, scope=EVENT_BUS_SCOPE.LOBBY) self.removeListener(events.CoolDownEvent.PREBATTLE, self.__handleSetPrebattleCoolDown, scope=EVENT_BUS_SCOPE.LOBBY) self.removeListener(events.BubbleTooltipEvent.SHOW, self.__showBubbleTooltip, scope=EVENT_BUS_SCOPE.LOBBY) self.removeListener(events.CloseWindowEvent.GOLD_FISH_CLOSED, self.__onGoldFishWindowClosed, scope=EVENT_BUS_SCOPE.LOBBY) game_control.g_instance.gameSession.onPremiumNotify -= self.__onPremiumTimeChanged game_control.g_instance.wallet.onWalletStatusChanged -= self.__onWalletChanged game_control.g_instance.igr.onIgrTypeChanged -= self.__onIGRChanged g_lobbyContext.getServerSettings().onServerSettingsChange -= self.__onServerSettingChanged g_currentVehicle.onChanged -= self.__onVehicleChanged g_currentPreviewVehicle.onChanged -= self.__onVehicleChanged g_eventsCache.onSyncCompleted -= self.__onEventsCacheResync g_itemsCache.onSyncCompleted -= self.__onItemsChanged self.__falloutCtrl.onVehiclesChanged -= self.__updateFalloutSettings self.__falloutCtrl.onSettingsChanged -= self.__updateFalloutSettings self.__falloutCtrl = None self.app.containerManager.onViewAddedToContainer -= self.__onViewAddedToContainer game_control.g_instance.boosters.onBoosterChangeNotify -= self.__onUpdateGoodies g_preDefinedHosts.onPingPerformed -= self.__onPingPerformed g_settingsCore.onSettingsChanged -= self.__onSettingsChanged super(LobbyHeader, self)._dispose() return
def fini(self, woEvents = False): if self.__watcher is not None: self.__watcher.stop() self.__watcher = None g_lobbyContext.getServerSettings().onServerSettingsChange -= self.__onServerSettingChanged super(SandboxQueueFunctional, self).fini(woEvents) return
def _populate(self): battle_selector_items.create() super(LobbyHeader, self)._populate() self.startGlobalListening() self.app.containerManager.onViewAddedToContainer += self.__onViewAddedToContainer game_control.g_instance.wallet.onWalletStatusChanged += self.__onWalletChanged game_control.g_instance.gameSession.onPremiumNotify += self.__onPremiumTimeChanged game_control.g_instance.igr.onIgrTypeChanged += self.__onIGRChanged g_lobbyContext.getServerSettings().onServerSettingsChange += self.__onServerSettingChanged g_currentVehicle.onChanged += self.__onVehicleChanged g_eventsCache.onSyncCompleted += self.__onEventsCacheResync g_itemsCache.onSyncCompleted += self.__onItemsChanged self.__falloutCtrl = getFalloutCtrl() self.__falloutCtrl.onVehiclesChanged += self.__updateFalloutSettings self.__falloutCtrl.onSettingsChanged += self.__updateFalloutSettings self.addListener(events.FightButtonEvent.FIGHT_BUTTON_UPDATE, self.__handleFightButtonUpdated, scope=EVENT_BUS_SCOPE.LOBBY) self.addListener(events.CoolDownEvent.PREBATTLE, self.__handleSetPrebattleCoolDown, scope=EVENT_BUS_SCOPE.LOBBY) self.addListener(events.BubbleTooltipEvent.SHOW, self.__showBubbleTooltip, scope=EVENT_BUS_SCOPE.LOBBY) self.addListener(events.CloseWindowEvent.GOLD_FISH_CLOSED, self.__onGoldFishWindowClosed, scope=EVENT_BUS_SCOPE.LOBBY) g_clientUpdateManager.addCallbacks({'stats.credits': self.__setCredits, 'stats.gold': self.__setGold, 'stats.freeXP': self.__setFreeXP, 'stats.clanInfo': self.__setClanInfo, 'goodies': self.__updateGoodies, 'account.premiumExpiryTime': self.__onPremiumExpireTimeChanged, 'cache.SPA': self.__onSPAUpdated}) self.as_setFightButtonS(i18n.makeString('#menu:headerButtons/battle')) self.as_setWalletStatusS(game_control.g_instance.wallet.componentsStatuses) self.updateAccountInfo() self.__updateServerName() if not isTimeToShowGoldFishPromo(): enabledVal = isGoldFishActionActive() tooltip = TOOLTIPS.HEADER_REFILL_ACTION if enabledVal else TOOLTIPS.HEADER_REFILL self.as_setGoldFishEnabledS(enabledVal, False, tooltip, TOOLTIP_TYPES.COMPLEX) Waiting.hide('enter')
def getEnabledPQTabs(): tabs = list(PQ_TABS) if not g_lobbyContext.getServerSettings().isRegularQuestEnabled(): tabs.remove(_QA.SEASON_VIEW_TAB_RANDOM) if not g_lobbyContext.getServerSettings().isFalloutQuestEnabled(): tabs.remove(_QA.SEASON_VIEW_TAB_FALLOUT) return tabs
def _getDetailedData(self, data): targetData = data[0] dataList = [] if g_lobbyContext.getServerSettings().isFortsEnabled(): dataList.append(_getDetailedStatisticsData(PROFILE.SECTION_STATISTICS_BODYBAR_LABEL_FORTBATTLES, self.__fortBattlesTargetData, isCurrentUser=self._isCurrentUser, layout=FORT_STATISTICS_LAYOUT)) dataList.append(_getDetailedStatisticsData(PROFILE.SECTION_STATISTICS_BODYBAR_LABEL_FORTSORTIE, targetData, isCurrentUser=self._isCurrentUser)) specificData = [] battlesCount = self.__fortBattlesTargetData.getBattlesCount() lossesCount = self.__fortBattlesTargetData.getLossesCount() winsCount = self.__fortBattlesTargetData.getWinsCount() formattedBattlesCount = BigWorld.wg_getIntegralFormat(battlesCount) specificDataColumn1 = [] if g_lobbyContext.getServerSettings().isFortsEnabled(): specificDataColumn1.append(PUtils.getLabelDataObject(PROFILE.SECTION_STATISTICS_BODYPARAMS_LABEL_FORTBATTLES, (DSUtils.getDetailedDataObject(PROFILE.SECTION_STATISTICS_SCORES_FORTTOTALBATTLES, formattedBattlesCount, PROFILE.PROFILE_PARAMS_TOOLTIP_FORT_BATTLES, PUtils.createToolTipData((BigWorld.wg_getIntegralFormat(winsCount), BigWorld.wg_getIntegralFormat(lossesCount)))), DSUtils.getDetailedDataObject(PROFILE.SECTION_STATISTICS_SCORES_FORTBATTLESTOTALWINS, PUtils.getFormattedWinsEfficiency(self.__fortBattlesTargetData), PROFILE.PROFILE_PARAMS_TOOLTIP_FORTBATTLESWINS), DSUtils.getDetailedDataObject(PROFILE.SECTION_STATISTICS_SCORES_LOOTING, self.__fortMiscTargetData.getEnemyBasePlunderNumber(), PROFILE.PROFILE_PARAMS_TOOLTIP_FORT_LOOTING), DSUtils.getDetailedDataObject(PROFILE.SECTION_STATISTICS_SCORES_FORTBATTLES_ATTACKS, self.__fortMiscTargetData.getAttackNumber(), PROFILE.PROFILE_PARAMS_TOOLTIP_FORTBATTLES_ATTACKS), DSUtils.getDetailedDataObject(PROFILE.SECTION_STATISTICS_SCORES_FORTBATTLES_DEFENCES, self.__fortMiscTargetData.getDefenceHours(), PROFILE.PROFILE_PARAMS_TOOLTIP_FORTBATTLES_DEFENCES)))) battlesCount = targetData.getBattlesCount() lossesCount = targetData.getLossesCount() winsCount = targetData.getWinsCount() drawsCount = targetData.getDrawsCount() formattedBattlesCount = BigWorld.wg_getIntegralFormat(battlesCount) specificDataColumn1.append(PUtils.getLabelDataObject(PROFILE.SECTION_STATISTICS_BODYPARAMS_LABEL_FORTSORTIE, (DSUtils.getDetailedDataObject(PROFILE.SECTION_STATISTICS_SCORES_FORT_SORTIE, formattedBattlesCount, PROFILE.PROFILE_PARAMS_TOOLTIP_FORT_SORTIE, PUtils.createToolTipData((BigWorld.wg_getIntegralFormat(winsCount), BigWorld.wg_getIntegralFormat(lossesCount), BigWorld.wg_getIntegralFormat(drawsCount)))), DSUtils.getDetailedDataObject(PROFILE.SECTION_STATISTICS_SCORES_FORTSORTIETOTALWINS, self._formattedWinsEfficiency, PROFILE.PROFILE_PARAMS_TOOLTIP_FORTSORTIEWINS)))) specificData.append(specificDataColumn1) resourcesDataList = [DSUtils.getDetailedDataObject(PROFILE.SECTION_STATISTICS_SCORES_FORTSORTIES_AVGRESOURCES, self.__avgFortSortiesLoot, PROFILE.PROFILE_PARAMS_TOOLTIP_FORTSORTIES_AVGRESOURCES), DSUtils.getDetailedDataObject(PROFILE.SECTION_STATISTICS_SCORES_FORTSORTIES_TOTALRESOURCES, BigWorld.wg_getIntegralFormat(self.__totalSortiesLoot), PROFILE.PROFILE_PARAMS_TOOLTIP_FORTSORTIES_TOTALRESOURCES)] specificDataColumn2 = [] if g_lobbyContext.getServerSettings().isFortsEnabled(): resourcesDataList.append(DSUtils.getDetailedDataObject(PROFILE.SECTION_STATISTICS_SCORES_FORTBATTLES_TOTALRESOURCES, BigWorld.wg_getIntegralFormat(self.__fortMiscTargetData.getLootInBattles()), PROFILE.PROFILE_PARAMS_TOOLTIP_FORTBATTLES_TOTALRESOURCES)) resourcesDataList.append(DSUtils.getDetailedDataObject(PROFILE.SECTION_STATISTICS_SCORES_FORTBATTLES_MAXRESOURCES, BigWorld.wg_getIntegralFormat(self.__fortMiscTargetData.getMaxLootInBattles()), PROFILE.PROFILE_PARAMS_TOOLTIP_FORTBATTLES_MAXRESOURCES)) specificDataColumn2.append(PUtils.getLabelDataObject(PROFILE.SECTION_STATISTICS_BODYPARAMS_LABEL_RESOURCE, resourcesDataList)) specificData.append(specificDataColumn2) dataList.append(PUtils.getLabelViewTypeDataObject(PROFILE.SECTION_STATISTICS_BODYBAR_LABEL_SPECIFIC, specificData, PUtils.VIEW_TYPE_TABLES)) return dataList
def _getNextState(self): state = None if connectionManager.isConnected(): if g_lobbyContext.getServerSettings().roaming.isInRoaming(): state = ClanRoamingState(self._clanCtrl) elif not g_lobbyContext.getServerSettings().clanProfile.isEnabled(): state = ClanDisabledState(self._clanCtrl) else: state = ClanUndefinedState(self._clanCtrl) return state
def fini(self, woEvents = False): if self.__watcher is not None: self.__watcher.stop() self.__watcher = None if not woEvents and self._flags & FUNCTIONAL_FLAG.SWITCH == 0: if self._flags & FUNCTIONAL_FLAG.RANDOM_BATTLES == FUNCTIONAL_FLAG.RANDOM_BATTLES: self.storage.suspend() g_lobbyContext.getServerSettings().onServerSettingsChange -= self.__onServerSettingChanged super(SandboxQueueFunctional, self).fini(woEvents) return
def _populate(self): super(FortBattlesRoomView, self)._populate() self.startFortListening() minLevel, maxLvl = self._getDivisionLvls() if maxLvl == minLevel: self.__updateVehiclesLabelSingle(fort_formatters.getTextLevel(maxLvl)) else: self._updateVehiclesLabel(fort_formatters.getTextLevel(minLevel), fort_formatters.getTextLevel(maxLvl)) g_lobbyContext.getServerSettings().onServerSettingsChange += self.__onSettingsChanged self.addListener(events.CoolDownEvent.PREBATTLE, self._handleChangedDivision, scope=EVENT_BUS_SCOPE.LOBBY) self._setChangeDivisionCooldown()
def stop(self): if not self.isStarted(): LOG_DEBUG('Fort provider already is stopped') return self.__cachedState = self.__state self.__initial = 0 self.clear() fortMgr = getClientFortMgr() if fortMgr: fortMgr.onFortResponseReceived -= self.__onFortResponseReceived fortMgr.onFortUpdateReceived -= self.__onFortUpdateReceived fortMgr.onFortStateChanged -= self.__onFortStateChanged g_playerEvents.onCenterIsLongDisconnected -= self.__onCenterIsLongDisconnected g_lobbyContext.getServerSettings().onServerSettingsChange -= self.__onServerSettingChanged
def _populate(self): self.__updateHangarMenuData() battle_selector_items.create() super(LobbyHeader, self)._populate() self.startGlobalListening() self.app.containerManager.onViewAddedToContainer += self.__onViewAddedToContainer game_control.g_instance.wallet.onWalletStatusChanged += self.__onWalletChanged game_control.g_instance.gameSession.onPremiumNotify += self.__onPremiumTimeChanged game_control.g_instance.igr.onIgrTypeChanged += self.__onIGRChanged g_lobbyContext.getServerSettings().onServerSettingsChange += self.__onServerSettingChanged g_currentVehicle.onChanged += self.__onVehicleChanged g_currentPreviewVehicle.onChanged += self.__onVehicleChanged g_eventsCache.onSyncCompleted += self.__onEventsCacheResync g_itemsCache.onSyncCompleted += self.__onItemsChanged game_control.g_instance.boosters.onBoosterChangeNotify += self.__onUpdateGoodies self.__falloutCtrl = getFalloutCtrl() self.__falloutCtrl.onVehiclesChanged += self.__updateFalloutSettings self.__falloutCtrl.onSettingsChanged += self.__updateFalloutSettings self.addListener(events.FightButtonEvent.FIGHT_BUTTON_UPDATE, self.__handleFightButtonUpdated, scope=EVENT_BUS_SCOPE.LOBBY) self.addListener(events.CoolDownEvent.PREBATTLE, self.__handleSetPrebattleCoolDown, scope=EVENT_BUS_SCOPE.LOBBY) self.addListener(events.BubbleTooltipEvent.SHOW, self.__showBubbleTooltip, scope=EVENT_BUS_SCOPE.LOBBY) self.addListener(events.CloseWindowEvent.GOLD_FISH_CLOSED, self.__onGoldFishWindowClosed, scope=EVENT_BUS_SCOPE.LOBBY) g_clientUpdateManager.addCallbacks({'stats.credits': self.__setCredits, 'stats.gold': self.__setGold, 'stats.freeXP': self.__setFreeXP, 'stats.clanInfo': self.__setClanInfo, 'goodies': self.__updateGoodies, 'account.premiumExpiryTime': self.__onPremiumExpireTimeChanged, 'cache.SPA': self.__onSPAUpdated}) self.as_setFightButtonS(i18n.makeString('#menu:headerButtons/battle')) self.as_setWalletStatusS(game_control.g_instance.wallet.componentsStatuses) self.as_setPremShopDataS(RES_ICONS.MAPS_ICONS_LOBBY_ICON_PREMSHOP, MENU.HEADERBUTTONS_BTNLABEL_PREMSHOP, TOOLTIPS.HEADER_PREMSHOP, TOOLTIP_TYPES.COMPLEX) self.as_initOnlineCounterS(constants.IS_SHOW_SERVER_STATS) if constants.IS_SHOW_SERVER_STATS: game_control.g_instance.serverStats.onStatsReceived += self.__onStatsReceived self.__onStatsReceived() self.updateAccountInfo() self.__updateServerData() if not isTimeToShowGoldFishPromo(): enabledVal = isGoldFishActionActive() tooltip = TOOLTIPS.HEADER_REFILL_ACTION if enabledVal else TOOLTIPS.HEADER_REFILL self.as_setGoldFishEnabledS(enabledVal, False, tooltip, TOOLTIP_TYPES.COMPLEX) g_preDefinedHosts.onPingPerformed += self.__onPingPerformed g_preDefinedHosts.requestPing() g_settingsCore.onSettingsChanged += self.__onSettingsChanged encyclopediaController = game_control.getEncyclopediaController() encyclopediaController.onNewRecommendationReceived += self.__onNewEncyclopediaRecommendation encyclopediaController.onStateChanged += self.__updateHangarMenuData Waiting.hide('enter')
def _getClanBtnsParams(self, appsCount): if self.clansCtrl.isAvailable(): isAvailable = True searchClanTooltip = TOOLTIPS.HEADER_ACCOUNTPOPOVER_SEARCHCLAN requestInviteBtnTooltip = TOOLTIPS.HEADER_ACCOUNTPOPOVER_INVITEREQUESTBTN btnTooltip = str() else: isAvailable = False searchClanTooltip = TOOLTIPS.HEADER_ACCOUNTPOPOVER_SEARCHCLAN_UNAVAILABLE requestInviteBtnTooltip = TOOLTIPS.HEADER_ACCOUNTPOPOVER_INVITEREQUESTBTN_UNAVAILABLE btnTooltip = str() btnEnabled = not BigWorld.player().isLongDisconnectedFromCenter and self.__infoBtnEnabled if self.clansCtrl.isEnabled(): btnEnabled = self.clansCtrl.isAvailable() if not btnEnabled: btnTooltip = TOOLTIPS.HEADER_ACCOUNTPOPOVER_CLANPROFILE_UNAVAILABLE elif not g_lobbyContext.getServerSettings().isFortsEnabled(): btnEnabled = False btnTooltip = TOOLTIPS.HEADER_ACCOUNTPOPOVER_CLANPROFILE_UNAVAILABLE return {'searchClanTooltip': searchClanTooltip, 'btnEnabled': btnEnabled, 'requestInviteBtnTooltip': requestInviteBtnTooltip, 'btnTooltip': btnTooltip, 'isOpenInviteBtnEnabled': isAvailable, 'isSearchClanBtnEnabled': isAvailable}
def _getNecessaryStats(self, accountDossier = None): if accountDossier is None: accountDossier = g_itemsCache.items.getAccountDossier(self._userID) if self._battlesType == PROFILE_DROPDOWN_KEYS.ALL: data = self._getTotalStatsBlock(accountDossier) elif self._battlesType == PROFILE_DROPDOWN_KEYS.TEAM: data = accountDossier.getTeam7x7Stats() elif self._battlesType == PROFILE_DROPDOWN_KEYS.STATICTEAM: if self._seasonID is not None: data = accountDossier.getSeasonRated7x7Stats(int(self._seasonID)) else: data = accountDossier.getRated7x7Stats() elif self._battlesType == PROFILE_DROPDOWN_KEYS.STATICTEAM_SEASON: currentSeasonID = g_lobbyContext.getServerSettings().eSportCurrentSeason.getID() data = accountDossier.getSeasonRated7x7Stats(currentSeasonID) elif self._battlesType == PROFILE_DROPDOWN_KEYS.HISTORICAL: data = accountDossier.getHistoricalStats() elif self._battlesType == PROFILE_DROPDOWN_KEYS.FORTIFICATIONS: data = self._receiveFortDossier(accountDossier) elif self._battlesType == PROFILE_DROPDOWN_KEYS.FORTIFICATIONS_SORTIES: data = accountDossier.getFortSortiesStats() elif self._battlesType == PROFILE_DROPDOWN_KEYS.FORTIFICATIONS_BATTLES: data = accountDossier.getFortBattlesStats() elif self._battlesType == PROFILE_DROPDOWN_KEYS.COMPANY: data = accountDossier.getCompanyStats() elif self._battlesType == PROFILE_DROPDOWN_KEYS.CLAN: data = accountDossier.getGlobalMapStats() elif self._battlesType == PROFILE_DROPDOWN_KEYS.FALLOUT: data = accountDossier.getFalloutStats() else: raise ValueError('ProfileSection: Unknown battle type: ' + self._battlesType) return data
def __isEnabledInRoaming(self, dbID): roaming = g_lobbyContext.getServerSettings().roaming if g_settings.server.XMPP.isEnabled(): isEnabled = roaming.isSameRealm(dbID) else: isEnabled = not roaming.isInRoaming() and not roaming.isPlayerInRoaming(dbID) return isEnabled
def getTooltipData(self, itemData): if itemData is None: return '' elif itemData == PREBATTLE_ACTION_NAME.RANDOM_QUEUE: return TOOLTIPS.BATTLETYPES_STANDART elif itemData == PREBATTLE_ACTION_NAME.UNIT: return TOOLTIPS.BATTLETYPES_UNIT elif itemData == PREBATTLE_ACTION_NAME.COMPANY: return self.__getCompanyAvailabilityData() else: if itemData == PREBATTLE_ACTION_NAME.FORT: if not g_lobbyContext.getServerSettings().isFortsEnabled(): return TOOLTIPS.BATTLETYPES_FORTIFICATION_DISABLED elif not g_clanCache.isInClan: return '#tooltips:fortification/disabled/no_clan' elif not isStartingScriptDone(): return '#tooltips:fortification/disabled/no_fort' else: return TOOLTIPS.BATTLETYPES_FORTIFICATION else: if itemData == PREBATTLE_ACTION_NAME.TRAINING: return TOOLTIPS.BATTLETYPES_TRAINING if itemData == PREBATTLE_ACTION_NAME.SPEC_BATTLE: return TOOLTIPS.BATTLETYPES_SPEC if itemData == PREBATTLE_ACTION_NAME.BATTLE_TUTORIAL: return TOOLTIPS.BATTLETYPES_BATTLETUTORIAL if itemData == PREBATTLE_ACTION_NAME.FALLOUT: return TOOLTIPS.BATTLETYPES_FALLOUT if itemData == PREBATTLE_ACTION_NAME.SANDBOX: return makeTooltip(TOOLTIPS.BATTLETYPES_BATTLETEACHING_HEADER, i18n.makeString(TOOLTIPS.BATTLETYPES_BATTLETEACHING_BODY, map1=i18n.makeString(ARENAS.C_100_THEPIT_NAME), map2=i18n.makeString(ARENAS.C_10_HILLS_NAME), battles=BATTLES_TO_SELECT_RANDOM_MIN_LIMIT)) return ''
def _setInitData(self, battlesType, accountDossier = None): dropDownProvider = [self._dataProviderEntryAutoTranslate(PROFILE_DROPDOWN_KEYS.ALL), self._dataProviderEntryAutoTranslate(PROFILE_DROPDOWN_KEYS.FALLOUT), self._dataProviderEntryAutoTranslate(PROFILE_DROPDOWN_KEYS.HISTORICAL), self._dataProviderEntryAutoTranslate(PROFILE_DROPDOWN_KEYS.TEAM), self._dataProviderEntryAutoTranslate(PROFILE_DROPDOWN_KEYS.STATICTEAM), self._dataProviderEntryAutoTranslate(PROFILE_DROPDOWN_KEYS.CLAN)] if g_lobbyContext.getServerSettings().isFortsEnabled(): dropDownProvider.append(self._dataProviderEntryAutoTranslate(PROFILE_DROPDOWN_KEYS.FORTIFICATIONS)) seasonItems = [self._dataProviderEntry(PROFILE_DROPDOWN_KEYS.STATICTEAM, PROFILE.PROFILE_SEASONSDROPDOWN_ALL)] if accountDossier is not None: seasons = accountDossier.getRated7x7Seasons() if len(seasons): seasonItems.append(self._dataProviderEntry(PROFILE_DROPDOWN_KEYS.STATICTEAM_SEASON, PROFILE.PROFILE_SEASONSDROPDOWN_CURRENT)) completedSeasons = self.clubsCtrl.getCompletedSeasons() for seasonID, _ in accountDossier.getRated7x7Seasons().iteritems(): if seasonID in completedSeasons: sID = _packProviderType(PROFILE_DROPDOWN_KEYS.STATICTEAM, seasonID) seasonUserName = self.clubsCtrl.getSeasonUserName(seasonID) if seasonUserName: seasonItems.append(self._dataProviderEntry(sID, seasonUserName)) seasonIndex = 0 for idx, season in enumerate(seasonItems): if season['key'] == _packProviderType(self._battlesType, self._seasonID): seasonIndex = idx self.as_setInitDataS({'dropDownProvider': dropDownProvider, 'seasonItems': seasonItems, 'seasonIndex': seasonIndex, 'seasonEnabled': len(seasonItems) > 1}) return
def __createData(self): fort = self.fortCtrl.getFort() peripheryList = self.__getPeripheryList() currentPeripheryID = fort.peripheryID isServerValid = False for i in xrange(len(peripheryList)): if peripheryList[i]['id'] == currentPeripheryID: isServerValid = True break if not isServerValid: currentPeripheryID = -1 _, defenceMin = adjustDefenceHourToLocal(0) return { 'peripheryData': peripheryList, 'peripherySelectedID': currentPeripheryID, 'holidayData': self._getDayoffsList(), 'holidaySelectedID': fort.getLocalOffDay(), 'hour': -1, 'minutes': defenceMin, 'isWrongLocalTime': self._isWrongLocalTime(), 'skipValues': adjustDefenceHoursListToLocal(g_lobbyContext.getServerSettings(). getForbiddenFortDefenseHours()), 'isTwelveHoursFormat': self.app.utilsManager.isTwelveHoursFormat() }
def isServerAvailable(self, serverID = None): if serverID is None: serverID = connectionManager.peripheryID servSettings = g_lobbyContext.getServerSettings() if servSettings is not None and len(self.getForbiddenHours(serverID)) == time_utils.HOURS_IN_DAY + 1: return False return True
def attachStickers(self, model, parentNode, isDamaged): self.detachStickers() self.__model = model self.__parentNode = parentNode self.__isDamaged = isDamaged self.__parentNode.attach(self.__stickerModel) replayCtrl = BattleReplay.g_replayCtrl for slotType, slots in self.__slotsByType.iteritems(): if slotType != SlotTypes.CLAN or self.__clanID == 0 or replayCtrl.isPlaying and replayCtrl.isOffline: if slotType != SlotTypes.CLAN: self.__doAttachStickers(slotType) elif slotType == SlotTypes.CLAN: serverSettings = g_lobbyContext.getServerSettings() if serverSettings is not None and serverSettings.roaming.isInRoaming() or self.__isLoadingClanEmblems: continue self.__isLoadingClanEmblems = True accountRep = Account.g_accountRepository if accountRep is None: LOG_ERROR('Failed to attach stickers to the vehicle - account repository is not initialized') continue fileCache = accountRep.customFilesCache fileServerSettings = accountRep.fileServerSettings clan_emblems = fileServerSettings.get('clan_emblems') if clan_emblems is None: continue url = None try: url = clan_emblems['url_template'] % self.__clanID except: LOG_ERROR('Failed to attach stickers to the vehicle - server returned incorrect url format: %s' % clan_emblems['url_template']) continue fileCache.get(url, self.__onClanEmblemLoaded) return
def __getStatsBlock(self, dossier): if self._battlesType == PROFILE_DROPDOWN_KEYS.ALL: return dossier.getRandomStats() elif self._battlesType == PROFILE_DROPDOWN_KEYS.FALLOUT: return dossier.getFalloutStats() elif self._battlesType == PROFILE_DROPDOWN_KEYS.HISTORICAL: return dossier.getHistoricalStats() elif self._battlesType == PROFILE_DROPDOWN_KEYS.TEAM: return dossier.getTeam7x7Stats() elif self._battlesType == PROFILE_DROPDOWN_KEYS.STATICTEAM: return dossier.getRated7x7Stats() elif self._battlesType == PROFILE_DROPDOWN_KEYS.FORTIFICATIONS: return dossier.getFortSortiesStats() elif self._battlesType == PROFILE_DROPDOWN_KEYS.CLAN: return dossier.getGlobalMapStats() elif self._battlesType == PROFILE_DROPDOWN_KEYS.STATICTEAM_SEASON: currentSeasonID = g_lobbyContext.getServerSettings().eSportCurrentSeason.getID() return dossier.getSeasonRated7x7Stats(currentSeasonID) elif self._battlesType == PROFILE_DROPDOWN_KEYS.FORTIFICATIONS_BATTLES: return dossier.getFortBattlesStats() elif self._battlesType == PROFILE_DROPDOWN_KEYS.FORTIFICATIONS_SORTIES: return dossier.getFortSortiesStats() elif self._battlesType == PROFILE_DROPDOWN_KEYS.COMPANY: return dossier.getCompanyStats() raise ValueError('_Dossier: Unknown battle type: ' + self._battlesType)
def canCreateChannel(self): roaming = g_lobbyContext.getServerSettings().roaming if g_settings.server.XMPP.isEnabled(): canCreate = roaming.isSameRealm(self.databaseID) else: canCreate = not roaming.isInRoaming() and not roaming.isPlayerInRoaming(self.databaseID) and self.isOnline return canCreate
def __getCommonQuestsIterator(self): questsData = self.__getQuestsData() questsData.update(self.__getFortQuestsData()) questsData.update(self.__getPersonalQuestsData()) questsData.update(self.__getPotapovHiddenQuests()) for qID, qData in questsData.iteritems(): yield (qID, self._makeQuest(qID, qData)) currentESportSeasonID = g_lobbyContext.getServerSettings().eSportCurrentSeason.getID() eSportQuests = clubs_quests.g_cache.getLadderQuestsBySeasonID(currentESportSeasonID) or [] for questDescr in eSportQuests: yield ( questDescr.questID, self._makeQuest( questDescr.questID, questDescr.questData, maker=_clubsQuestMaker, seasonID=currentESportSeasonID, questDescr=questDescr, ), ) motiveQuests = motivation_quests.g_cache.getAllQuests() or [] for questDescr in motiveQuests: yield ( questDescr.questID, self._makeQuest(questDescr.questID, questDescr.questData, maker=_motiveQuestMaker), )
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 __updateHangarMenuData(self): tabDataProvider = [{'label': MENU.HEADERBUTTONS_HANGAR, 'value': self.TABS.HANGAR, 'textColor': 16764006, 'textColorOver': 16768409, 'tooltip': TOOLTIPS.HEADER_BUTTONS_HANGAR}, {'label': MENU.HEADERBUTTONS_SHOP, 'value': STORE_CONSTANTS.STORE, 'tooltip': TOOLTIPS.HEADER_BUTTONS_SHOP}, {'label': MENU.HEADERBUTTONS_PROFILE, 'value': self.TABS.PROFILE, 'tooltip': TOOLTIPS.HEADER_BUTTONS_PROFILE}, {'label': MENU.HEADERBUTTONS_TECHTREE, 'value': self.TABS.TECHTREE, 'tooltip': TOOLTIPS.HEADER_BUTTONS_TECHTREE, 'subValues': [self.TABS.RESEARCH]}, {'label': MENU.HEADERBUTTONS_BARRACKS, 'value': self.TABS.BARRACKS, 'tooltip': TOOLTIPS.HEADER_BUTTONS_BARRACKS}] if constants.IS_CHINA: tabDataProvider.append({'label': MENU.HEADERBUTTONS_BROWSER, 'value': self.TABS.BROWSER, 'tooltip': TOOLTIPS.HEADER_BUTTONS_BROWSER}) fortEnabled = g_lobbyContext.getServerSettings().isFortsEnabled() tabDataProvider.append({'label': MENU.HEADERBUTTONS_FORTS, 'value': FORTIFICATION_ALIASES.FORTIFICATIONS_VIEW_ALIAS, 'tooltip': TOOLTIPS.HEADER_BUTTONS_FORTS if fortEnabled else TOOLTIPS.HEADER_BUTTONS_FORTS_TURNEDOFF, 'enabled': fortEnabled}) self.as_setHangarMenuDataS({'tabDataProvider': tabDataProvider})
def getRegionCode(self, dbID): regionCode = None serverSettings = g_lobbyContext.getServerSettings() if serverSettings: roaming = serverSettings.roaming if dbID and not roaming.isSameRealm(dbID): _, regionCode = roaming.getPlayerHome(dbID) return regionCode
def isInRoaming(self): if not self.isCurrentUser(): from gui.LobbyContext import g_lobbyContext serverSettings = g_lobbyContext.getServerSettings() if serverSettings is not None: roaming = serverSettings.roaming return roaming.isInRoaming() or roaming.isPlayerInRoaming(self._playerDBID) return False
def getRegionCode(accountDBID): regionCode = None serverSettings = g_lobbyContext.getServerSettings() if serverSettings is not None: roaming = serverSettings.roaming if accountDBID and not roaming.isSameRealm(accountDBID): _, regionCode = roaming.getPlayerHome(accountDBID) return regionCode
def _selectLastTab(self): tabID = self._navInfo.tabID if not tabID: if g_lobbyContext.getServerSettings().isPotapovQuestEnabled(): tabID = _QA.TAB_PERSONAL_QUESTS else: tabID = _QA.TAB_COMMON_QUESTS self.as_selectTabS(tabID) return tabID
def _getInitData(self, accountDossier = None, isFallout = False): dropDownProvider = [self._dataProviderEntryAutoTranslate(PROFILE_DROPDOWN_KEYS.ALL), self._dataProviderEntryAutoTranslate(PROFILE_DROPDOWN_KEYS.FALLOUT)] if accountDossier is not None and accountDossier.getHistoricalStats().getVehicles(): dropDownProvider.append(self._dataProviderEntryAutoTranslate(PROFILE_DROPDOWN_KEYS.HISTORICAL)) dropDownProvider.extend((self._dataProviderEntryAutoTranslate(PROFILE_DROPDOWN_KEYS.TEAM), self._dataProviderEntryAutoTranslate(PROFILE_DROPDOWN_KEYS.STATICTEAM), self._dataProviderEntryAutoTranslate(PROFILE_DROPDOWN_KEYS.CLAN))) if g_lobbyContext.getServerSettings().isFortsEnabled(): dropDownProvider.extend((self._dataProviderEntryAutoTranslate(PROFILE_DROPDOWN_KEYS.FORTIFICATIONS_SORTIES), self._dataProviderEntryAutoTranslate(PROFILE_DROPDOWN_KEYS.FORTIFICATIONS_BATTLES))) return {'dropDownProvider': dropDownProvider, 'tableHeader': self._getTableHeader(isFallout)}
def openClanStatistic(self): if g_lobbyContext.getServerSettings().clanProfile.isEnabled(): clanID, _ = g_itemsCache.items.getClanInfo(self._userID) if clanID != 0: shared_events.showClanProfileWindow(clanID) elif self.__isFortClanProfileAvailable(): self.fireEvent(events.LoadViewEvent(FORTIFICATION_ALIASES.FORT_CLAN_STATISTICS_WINDOW_ALIAS), EVENT_BUS_SCOPE.LOBBY) else: LOG_ERROR('Fort Clan Profile Statistics is Unavailable for current user profile')
def _stripVehCompDescrIfRoaming(vehCompDescr): serverSettings = g_lobbyContext.getServerSettings() if serverSettings: if serverSettings.roaming.isInRoaming(): vehCompDescr = vehicles.stripCustomizationFromVehicleCompactDescr(vehCompDescr, True, True, False)[0] return vehCompDescr
def __makeRequest(self, clanDbID, size, requestHandler): svrSettings = g_lobbyContext.getServerSettings() url = svrSettings.fileServer.getClanEmblemBySize(clanDbID, size) if svrSettings is not None else None self._requestClanEmblem(clanDbID, url, size, requestHandler) return
def requiresFortification(): from gui.LobbyContext import g_lobbyContext return g_lobbyContext.getServerSettings().isFortsEnabled()
def isModeSelected(self): return self._isSelected and g_lobbyContext.getServerSettings( ).isSandboxEnabled()
def _regionals(): return g_lobbyContext.getServerSettings().regionals
def isEnabled(self): serverSettings = g_lobbyContext.getServerSettings() if serverSettings is not None and serverSettings.roaming.isInRoaming(): return False return self._isEnabled
def isSameRealm(self): return g_lobbyContext.getServerSettings().roaming.isSameRealm(self.databaseID)
def _needShowLongWaitingWarning(): vehicle = g_currentVehicle.item return g_lobbyContext.getServerSettings().isTemplateMatchmakerEnabled() and vehicle.type == VEHICLE_CLASS_NAME.SPG and vehicle.level in _LONG_WAITING_LEVELS
def getForbiddenPeripherieIDs(self): return g_lobbyContext.getServerSettings( ).getForbiddenSortiePeripheryIDs()
def isDisabledInRoaming(self): from gui.LobbyContext import g_lobbyContext return _checkForTags( self.tags, VEHICLE_TAGS.DISABLED_IN_ROAMING ) and g_lobbyContext.getServerSettings().roaming.isInRoaming()
def isInRoaming(self): return g_lobbyContext.getServerSettings().roaming.isInRoaming()
def _update(self, state): self._isDisabled = state.hasLockedState self._isSelected = state.isQueueSelected(queueType=QUEUE_TYPE.SANDBOX) self._isVisible = g_lobbyContext.getServerSettings().isSandboxEnabled()
def _update(self, state): self._isSelected = state.isInUnit(PREBATTLE_TYPE.SORTIE) or state.isInUnit(PREBATTLE_TYPE.FORT_BATTLE) if g_lobbyContext.getServerSettings().isFortsEnabled() or self._isSelected: self._isDisabled = not isSortieEnabled() or state.hasLockedState else: self._isDisabled = True
def _getDetailedData(self, data): targetData = data[0] dataList = [] if g_lobbyContext.getServerSettings().isFortsEnabled(): dataList.append( _getDetailedStatisticsData( PROFILE.SECTION_STATISTICS_BODYBAR_LABEL_FORTBATTLES, self.__fortBattlesTargetData, isCurrentUser=self._isCurrentUser, layout=FORT_STATISTICS_LAYOUT)) dataList.append( _getDetailedStatisticsData( PROFILE.SECTION_STATISTICS_BODYBAR_LABEL_FORTSORTIE, targetData, isCurrentUser=self._isCurrentUser)) specificData = [] battlesCount = self.__fortBattlesTargetData.getBattlesCount() lossesCount = self.__fortBattlesTargetData.getLossesCount() winsCount = self.__fortBattlesTargetData.getWinsCount() formattedBattlesCount = BigWorld.wg_getIntegralFormat(battlesCount) specificDataColumn1 = [] if g_lobbyContext.getServerSettings().isFortsEnabled(): specificDataColumn1.append( PUtils.getLabelDataObject( PROFILE.SECTION_STATISTICS_BODYPARAMS_LABEL_FORTBATTLES, (DSUtils.getDetailedDataObject( PROFILE.SECTION_STATISTICS_SCORES_FORTTOTALBATTLES, formattedBattlesCount, PROFILE.PROFILE_PARAMS_TOOLTIP_FORT_BATTLES, PUtils.createToolTipData( (BigWorld.wg_getIntegralFormat(winsCount), BigWorld.wg_getIntegralFormat(lossesCount)))), DSUtils.getDetailedDataObject( PROFILE. SECTION_STATISTICS_SCORES_FORTBATTLESTOTALWINS, PUtils.getFormattedWinsEfficiency( self.__fortBattlesTargetData), PROFILE.PROFILE_PARAMS_TOOLTIP_FORTBATTLESWINS), DSUtils.getDetailedDataObject( PROFILE.SECTION_STATISTICS_SCORES_LOOTING, self.__fortMiscTargetData.getEnemyBasePlunderNumber(), PROFILE.PROFILE_PARAMS_TOOLTIP_FORT_LOOTING), DSUtils.getDetailedDataObject( PROFILE.SECTION_STATISTICS_SCORES_FORTBATTLES_ATTACKS, self.__fortMiscTargetData.getAttackNumber(), PROFILE.PROFILE_PARAMS_TOOLTIP_FORTBATTLES_ATTACKS), DSUtils.getDetailedDataObject( PROFILE. SECTION_STATISTICS_SCORES_FORTBATTLES_DEFENCES, self.__fortMiscTargetData.getDefenceHours(), PROFILE.PROFILE_PARAMS_TOOLTIP_FORTBATTLES_DEFENCES) ))) battlesCount = targetData.getBattlesCount() lossesCount = targetData.getLossesCount() winsCount = targetData.getWinsCount() drawsCount = targetData.getDrawsCount() formattedBattlesCount = BigWorld.wg_getIntegralFormat(battlesCount) specificDataColumn1.append( PUtils.getLabelDataObject( PROFILE.SECTION_STATISTICS_BODYPARAMS_LABEL_FORTSORTIE, (DSUtils.getDetailedDataObject( PROFILE.SECTION_STATISTICS_SCORES_FORT_SORTIE, formattedBattlesCount, PROFILE.PROFILE_PARAMS_TOOLTIP_FORT_SORTIE, PUtils.createToolTipData( (BigWorld.wg_getIntegralFormat(winsCount), BigWorld.wg_getIntegralFormat(lossesCount), BigWorld.wg_getIntegralFormat(drawsCount)))), DSUtils.getDetailedDataObject( PROFILE.SECTION_STATISTICS_SCORES_FORTSORTIETOTALWINS, self._formattedWinsEfficiency, PROFILE.PROFILE_PARAMS_TOOLTIP_FORTSORTIEWINS)))) specificData.append(specificDataColumn1) resourcesDataList = [ DSUtils.getDetailedDataObject( PROFILE.SECTION_STATISTICS_SCORES_FORTSORTIES_AVGRESOURCES, self.__avgFortSortiesLoot, PROFILE.PROFILE_PARAMS_TOOLTIP_FORTSORTIES_AVGRESOURCES), DSUtils.getDetailedDataObject( PROFILE.SECTION_STATISTICS_SCORES_FORTSORTIES_TOTALRESOURCES, BigWorld.wg_getIntegralFormat(self.__totalSortiesLoot), PROFILE.PROFILE_PARAMS_TOOLTIP_FORTSORTIES_TOTALRESOURCES) ] specificDataColumn2 = [] if g_lobbyContext.getServerSettings().isFortsEnabled(): resourcesDataList.append( DSUtils.getDetailedDataObject( PROFILE. SECTION_STATISTICS_SCORES_FORTBATTLES_TOTALRESOURCES, BigWorld.wg_getIntegralFormat( self.__fortMiscTargetData.getLootInBattles()), PROFILE.PROFILE_PARAMS_TOOLTIP_FORTBATTLES_TOTALRESOURCES)) resourcesDataList.append( DSUtils.getDetailedDataObject( PROFILE.SECTION_STATISTICS_SCORES_FORTBATTLES_MAXRESOURCES, BigWorld.wg_getIntegralFormat( self.__fortMiscTargetData.getMaxLootInBattles()), PROFILE.PROFILE_PARAMS_TOOLTIP_FORTBATTLES_MAXRESOURCES)) specificDataColumn2.append( PUtils.getLabelDataObject( PROFILE.SECTION_STATISTICS_BODYPARAMS_LABEL_RESOURCE, resourcesDataList)) specificData.append(specificDataColumn2) dataList.append( PUtils.getLabelViewTypeDataObject( PROFILE.SECTION_STATISTICS_BODYBAR_LABEL_SPECIFIC, specificData, PUtils.VIEW_TYPE_TABLES)) return dataList
def isClubsEnabled(): return g_lobbyContext.getServerSettings().isClubsEnabled()
def _isSupported(self, orderID): if not g_lobbyContext.getServerSettings().isFortsEnabled(): if orderID in (FORT_ORDER_TYPE.EVACUATION, FORT_ORDER_TYPE.REQUISITION): return False return True
def _addClanProfileInfo(self, options, userCMInfo): if g_lobbyContext.getServerSettings().clanProfile.isEnabled() and userCMInfo.hasClan and self.showClanProfile: options.append(self._makeItem(USER.CLAN_INFO, MENU.contextmenu(USER.CLAN_INFO), optInitData={'enabled': self.clanCtrl.isAvailable()})) return options
def _areQuestsEnabled(self): return g_lobbyContext.getServerSettings().isFalloutQuestEnabled()
def _dispose(self): super(FortBattlesRoomView, self)._dispose() self.stopFortListening() g_lobbyContext.getServerSettings().onServerSettingsChange -= self.__onSettingsChanged self.removeListener(events.CoolDownEvent.PREBATTLE, self._handleChangedDivision, scope=EVENT_BUS_SCOPE.LOBBY) self._cancelChangeDivisionCooldown()
def isPromoAutoViewsEnabled(cls): return getAccountDatabaseID( ) % cls.PROMO_AUTO_VIEWS_TEST_VALUE != 0 and g_lobbyContext.getServerSettings( ).isPromoAutoViewsEnabled()
def isGoldFishActionActive(): from gui.LobbyContext import g_lobbyContext from gui.shared.ItemsCache import g_itemsCache outOfSessionWallet = constants.ACCOUNT_ATTR.OUT_OF_SESSION_WALLET return not g_itemsCache.items.stats.isGoldFishBonusApplied and g_lobbyContext.getServerSettings().isGoldFishEnabled() and not g_itemsCache.items.stats.attributes & outOfSessionWallet != 0
def init(self, ctx = None): self.storage.release() self.__watcher = _VehiclesWatcher() self.__watcher.start() g_lobbyContext.getServerSettings().onServerSettingsChange += self.__onServerSettingChanged return super(SandboxQueueFunctional, self).init(ctx)
def isEnabledInRoaming(self, uid): roaming = g_lobbyContext.getServerSettings().roaming return not roaming.isInRoaming() and not roaming.isPlayerInRoaming(uid)
def _areQuestsEnabled(self): return g_lobbyContext.getServerSettings().isRegularQuestEnabled()
def simEnableClan(self, enable): settings = g_lobbyContext.getServerSettings() clanSettings = {'clanProfile': {'isEnabled': enable, 'gateUrl': settings.clanProfile.getGateUrl()}} settings.update(clanSettings) g_clientUpdateManager.update({'serverSettings': clanSettings})
def isEnabled(self): settings = g_lobbyContext.getServerSettings() if settings is not None: return settings.clanProfile.isEnabled() else: return True
def __makeData(self): isFortsEnabled = g_lobbyContext.getServerSettings().isFortsEnabled() if isFortsEnabled: baseBuildingMaxLevel = MAX_LEVEL.MAX_BASE_LEVEL_SECOND_ITERATION else: baseBuildingMaxLevel = MAX_LEVEL.MAX_BASE_LEVEL_FIRST_ITERATION result = {} cndBody = '' limits = self.fortCtrl.getLimits() canUpgrade, upgradeRestriction = limits.canUpgrade(self.intBuildingID) LOG_DEBUG(upgradeRestriction) cndPostfix = '' isCanModernization = canUpgrade conditionIcon = icons.checkmark() canUpgradeByDefPeriod = True isBaseBuilding = self.__uid == FORTIFICATION_ALIASES.FORT_BASE_BUILDING if self.__uid != FORTIFICATION_ALIASES.FORT_BASE_BUILDING: cndBody = i18n.makeString( FORTIFICATIONS.MODERNIZATION_CONDITIONS_GENERALCONDITION, level=fort_formatters.getTextLevel(self.__buildingLevel + 1)) canUpgrade = isCanModernization if self.__buildingLevel == MAX_LEVEL.MAX_BUILD_LEVEL: if isFortsEnabled: cndBody = i18n.makeString( FORTIFICATIONS. MODERNIZATION_CONDITIONS_DEFENCEPERIODANDBASEBUILDING, level=fort_formatters.getTextLevel( self.__buildingLevel + 1)) if not self.__defencePeriod or self.__baseBuildingLevel < MAX_LEVEL.MAX_BASE_LEVEL_SECOND_ITERATION: cndPostfix = text_styles.error( i18n.makeString( FORTIFICATIONS. MODERNIZATION_CONDITIONS_NOTFULFILLED)) isCanModernization = False canUpgradeByDefPeriod = False conditionIcon = text_styles.standard('-') elif self.__buildingLevel == self.__baseBuildingLevel: cndPostfix = text_styles.error( i18n.makeString(FORTIFICATIONS. MODERNIZATION_CONDITIONS_NOTFULFILLED)) elif self.__buildingLevel == self.__baseBuildingLevel: cndPostfix = text_styles.error( i18n.makeString( FORTIFICATIONS.MODERNIZATION_CONDITIONS_NOTFULFILLED)) isCanModernization = False elif self.__buildingLevel == baseBuildingMaxLevel: cndBody = i18n.makeString( FORTIFICATIONS.MODERNIZATION_CONDITIONS_BASEBUILDINGFIVELEVEL) if not self.__defencePeriod and isFortsEnabled: cndPostfix = text_styles.error( i18n.makeString( FORTIFICATIONS.MODERNIZATION_CONDITIONS_NOTFULFILLED)) isCanModernization = False canUpgradeByDefPeriod = False conditionIcon = text_styles.standard('-') elif not isFortsEnabled: isCanModernization = False canUpgradeByDefPeriod = False cndBody = text_styles.alert( i18n.makeString( FORTIFICATIONS.MODERNIZATION_CONDITIONS_FORTMAXLEVEL)) conditionIcon = '' prefixBody = text_styles.main(cndBody) result['condition'] = prefixBody + cndPostfix result['costUpgrade'] = text_styles.defRes( i18n.makeString( FORTIFICATIONS.MODERNIZATION_MODERNIZATIONINFO_COUNTCOST)) result['intBuildingID'] = self.intBuildingID if not canUpgrade and upgradeRestriction != FORT_RESTRICTION.BUILDING_NOT_ENOUGH_RESOURCE: conditionIcon = text_styles.standard('-') if self._buildingDescr.storage < self.__cost: costMsg = text_styles.error( BigWorld.wg_getIntegralFormat(self.__cost)) constIcon = icons.nut() costMsg = costMsg + ' ' + constIcon else: costMsg = fort_formatters.getDefRes(self.__cost, True) result['costValue'] = costMsg if cndBody != '': result['conditionIcon'] = conditionIcon result['canUpgrade'] = isCanModernization if not isCanModernization: ttHeader = '' ttBody = '' if not canUpgradeByDefPeriod and isFortsEnabled: ttHeader = i18n.makeString( TOOLTIPS. FORTIFICATION_MODERNIZATION_NOTACTIVATEDDEFPERIOD_HEADER) ttBody = i18n.makeString( i18n.makeString( TOOLTIPS. FORTIFICATION_MODERNIZATION_NOTACTIVATEDDEFPERIOD_BODY) ) else: ttHeader = i18n.makeString( TOOLTIPS.FORTIFICATION_MODERNIZATION_APPLYBUTTON_HEADER) if not isFortsEnabled and isBaseBuilding and self.__buildingLevel == baseBuildingMaxLevel: ttHeader = i18n.makeString( '#tooltips:fortification/popOver/upgradeFoundationBtn_Disabled/header' ) ttBody = i18n.makeString( FORTIFICATIONS.MODERNIZATION_CONDITIONS_FORTMAXLEVEL) elif upgradeRestriction == FORT_RESTRICTION.BUILDING_NOT_ENOUGH_RESOURCE_AND_LOW_LEVEL: ttBody = i18n.makeString( TOOLTIPS. FORTIFICATION_MODERNIZATION_APPLYBUTTON_LOWLEVELANDRESOURCE, baseLevel=fort_formatters.getTextLevel( self.__baseBuildingLevel + 1)) elif upgradeRestriction == FORT_RESTRICTION.BUILDING_FORT_LEVEL_TOO_LOW: ttBody = i18n.makeString( TOOLTIPS. FORTIFICATION_MODERNIZATION_APPLYBUTTON_LOWBASELEVEL, baseLevel=fort_formatters.getTextLevel( self.__baseBuildingLevel + 1)) elif upgradeRestriction == FORT_RESTRICTION.BUILDING_NOT_ENOUGH_RESOURCE: ttBody = i18n.makeString( TOOLTIPS. FORTIFICATION_MODERNIZATION_APPLYBUTTON_NETENOUGHRESOURCE ) result['btnToolTip'] = makeTooltip(ttHeader, ttBody) fort = self.fortCtrl.getFort() newCount = 0 resLeft = 0 orderCount = 0 if self.__uid != FORTIFICATION_ALIASES.FORT_BASE_BUILDING: order = fort.getOrder(self._buildingDescr.typeRef.orderType) orderCount = order.count newCount, resLeft = fort.recalculateOrder(order.orderID, order.count, order.level, order.level + 1) inProcess, _ = fort.getDefenceHourProcessing() isDefenceOn = fort.isDefenceHourEnabled() or inProcess before = {} before['buildingLevel'] = self.__buildingLevel before['buildingIcon'] = FortViewHelper.getMapIconSource( self.__uid, self.__buildingLevel, isDefenceOn=isDefenceOn) before['buildingIndicators'] = self.__prepareIndicatorData( isCanModernization, False) before['defResInfo'] = self.__prepareOrderInfo(False, orderCount, self.__buildingLevel) before['titleText'] = text_styles.middleTitle( i18n.makeString( FORTIFICATIONS.MODERNIZATION_MODERNIZATIONINFO_BEFORELABEL)) result['beforeUpgradeData'] = before after = {} after['buildingLevel'] = self.__buildingLevel + 1 after['buildingIcon'] = FortViewHelper.getMapIconSource( self.__uid, self.__buildingLevel + 1) after['buildingIndicators'] = self.__prepareIndicatorData( isCanModernization, True, resLeft) after['defResInfo'] = self.__prepareOrderInfo(True, newCount, self.__buildingLevel + 1) after['titleText'] = text_styles.middleTitle( i18n.makeString( FORTIFICATIONS.MODERNIZATION_MODERNIZATIONINFO_AFTERLABEL)) result['afterUpgradeData'] = after return result
def _successHandler(self, code, ctx = None): restoreInfo = '' if self.vehicle.isPremium and not self.vehicle.isUnique and not self.vehicle.isUnrecoverable and g_lobbyContext.getServerSettings().isVehicleRestoreEnabled() and not self.vehicle.sellForGold: timeKey, formattedTime = getTimeLeftInfo(g_itemsCache.items.shop.vehiclesRestoreConfig.restoreDuration) restoreInfo = makeString('#system_messages:vehicle/restoreDuration/%s' % timeKey, time=formattedTime) if self.isDismantlingForGold: localKey = 'vehicle_sell/success_dismantling' smType = SM_TYPE.Selling if self.isRemovedAfterRent: localKey = 'vehicle_remove/success_dismantling' smType = SM_TYPE.Remove return makeI18nSuccess(localKey, vehName=self.vehicle.userName, gainMoney=formatPrice(self.gainMoney), spendMoney=formatPrice(self.spendMoney), restoreInfo=restoreInfo, type=smType) else: localKey = 'vehicle_sell/success' smType = SM_TYPE.Selling if self.isRemovedAfterRent: localKey = 'vehicle_remove/success' smType = SM_TYPE.Remove return makeI18nSuccess(localKey, vehName=self.vehicle.userName, money=formatPrice(self.gainMoney), restoreInfo=restoreInfo, type=smType)