def getProfileCommonInfo(userName, dossier, clanInfo, clanEmblemId): clanNameProp = 'clanName' clanNameDescrProp = 'clanNameDescr' clanJoinTimeProp = 'clanJoinTime' clanPositionProp = 'clanPosition' clanEmblemProp = 'clanEmblem' import cgi lastBattleTimeUserString = None if dossier['total']['lastBattleTime']: lbt = dossier['total']['lastBattleTime'] lastBattleTimeUserString = '%s %s' % (BigWorld.wg_getLongDateFormat(lbt), BigWorld.wg_getShortTimeFormat(lbt)) value = {'name': userName, 'registrationDate': '%s' % BigWorld.wg_getLongDateFormat(dossier['total']['creationTime']), 'lastBattleDate': lastBattleTimeUserString, clanNameProp: '', clanNameDescrProp: '', clanJoinTimeProp: '', clanPositionProp: '', clanEmblemProp: 'img://' + clanEmblemId if clanEmblemId is not None else None} def getGoldFmt(str): return str if clanInfo is not None: value[clanNameProp] = cgi.escape(clanInfo[1]) value[clanNameDescrProp] = cgi.escape(clanInfo[0]) value[clanJoinTimeProp] = makeString(MENU.PROFILE_HEADER_CLAN_JOINDATE) % getGoldFmt(BigWorld.wg_getLongDateFormat(clanInfo[4])) value[clanPositionProp] = getGoldFmt(getClanRoleString(clanInfo[3])) return value
def getCommonInfo(userName, dossier, clanInfo, clanEmblemFile): clanNameProp = 'clanName' clanNameDescrProp = 'clanNameDescr' clanJoinTimeProp = 'clanJoinTime' clanPositionProp = 'clanPosition' clanEmblemProp = 'clanEmblem' import cgi lastBattleTimeUserString = None if dossier['total']['lastBattleTime']: lastBattleTimeUserString = '%s' % BigWorld.wg_getLongDateFormat(dossier['total']['lastBattleTime']) value = {'name': userName, 'registrationDate': '%s' % BigWorld.wg_getLongDateFormat(dossier['total']['creationTime']), 'lastBattleDate': lastBattleTimeUserString, clanNameProp: '', clanNameDescrProp: '', clanJoinTimeProp: '', clanPositionProp: '', clanEmblemProp: None} def getGoldFmt(str): return str if clanInfo is not None: value[clanNameProp] = cgi.escape(clanInfo[1]) value[clanNameDescrProp] = cgi.escape(clanInfo[0]) value[clanJoinTimeProp] = makeString(MENU.PROFILE_HEADER_CLAN_JOINDATE) % getGoldFmt(BigWorld.wg_getLongDateFormat(clanInfo[4])) clanPosition = makeString('#menu:profile/header/clan/position/%s' % CLAN_MEMBERS[clanInfo[3]] if clanInfo[3] in CLAN_MEMBERS else '') value[clanPositionProp] = getGoldFmt(clanPosition) if clanInfo[3] in CLAN_MEMBERS else '' clanEmblemId = None if clanEmblemFile: clanEmblemId = 'userInfoId' + userName BigWorld.wg_addTempScaleformTexture(clanEmblemId, clanEmblemFile) value[clanEmblemProp] = clanEmblemId return value
def getProfileCommonInfo(userName, dossier): lastBattleTimeUserString = None if dossier['total']['lastBattleTime']: lbt = dossier['total']['lastBattleTime'] lastBattleTimeUserString = '%s %s' % (BigWorld.wg_getLongDateFormat(lbt), BigWorld.wg_getShortTimeFormat(lbt)) return {'name': userName, 'registrationDate': '%s' % BigWorld.wg_getLongDateFormat(dossier['total']['creationTime']), 'lastBattleDate': lastBattleTimeUserString}
def __makeData(self): fort = self.fortCtrl.getFort() data = {'numOfFavorites': len(fort.favorites), 'favoritesLimit': FORT_MAX_ELECTED_CLANS, 'canAttackDirection': self.fortCtrl.getPermissions().canPlanAttack(), 'canAddToFavorite': self.fortCtrl.getPermissions().canAddToFavorite(), 'isOurFortFrozen': self._isFortFrozen(), 'isSelected': self.__item is not None, 'haveResults': self.__hasResults} if self.__item is not None: clanID = self.__item.getClanDBID() selectedDefenceHour = time_utils.getDateTimeInLocal(self.__selectedDefencePeriodStart).hour if self.__item.getLocalDefHour()[0] != selectedDefenceHour and not self.__weAreAtWar: warTime = '%s - %s' % (BigWorld.wg_getShortTimeFormat(self.__selectedDefencePeriodStart), BigWorld.wg_getShortTimeFormat(self.__selectedDefencePeriodEnd)) warPlannedIcon = makeHtmlString('html_templates:lobby/iconText', 'alert', {}) warPlannedMsg = makeHtmlString('html_templates:lobby/textStyle', 'alertText', {'message': warTime}) warPlannedTime = _ms(warPlannedIcon + ' ' + warPlannedMsg) data.update({'warPlannedTime': warPlannedTime, 'warPlannedTimeTT': _ms(TOOLTIPS.FORTIFICATION_FORTINTELLIGENCECLANDESCRIPTION_WARTIME, warTime=warTime)}) if self.__weAreAtWar: closestAttack = self.__upcomingAttack or self.__attackInCooldown closestAttackTime = closestAttack.getStartTime() data.update({'isWarDeclared': self.__upcomingAttack is not None, 'isAlreadyFought': self.__attackInCooldown is not None and not self.__hasBeenCounterAttacked, 'warPlannedDate': BigWorld.wg_getLongDateFormat(closestAttackTime), 'warNextAvailableDate': BigWorld.wg_getLongDateFormat(closestAttackTime + time_utils.ONE_WEEK)}) isFrozen = fort.isFrozen() clanFortBattlesStats = self.__item.getStatistics().getBattlesStats() battlesCount = clanFortBattlesStats.getBattlesCount() battlesWinsEff = clanFortBattlesStats.getWinsEfficiency() MIN_VALUE = 0.01 clanAvgDefresValue = functions.roundToMinOrZero(clanFortBattlesStats.getProfitFactor(), MIN_VALUE) data.update({'dateSelected': BigWorld.wg_getLongDateFormat(self.__selectedDayStart), 'selectedDayTimestamp': self.__selectedDayStart, 'clanTag': '[%s]' % self.__item.getClanAbbrev(), 'clanName': self.__item.getClanName(), 'clanInfo': self.__item.getClanMotto(), 'clanId': clanID, 'clanEmblem': self.__clanEmblem, 'isFavorite': clanID in fort.favorites, 'isFrozen': isFrozen, 'selectedDateText': self.__getSelectedDateText(), 'clanBattles': {'value': BigWorld.wg_getNiceNumberFormat(battlesCount) if battlesCount else '--', 'icon': RES_ICONS.MAPS_ICONS_LIBRARY_DOSSIER_BATTLES40X32, 'ttHeader': _ms(TOOLTIPS.FORTIFICATION_FORTINTELLIGENCECLANDESCRIPTION_BATTLES_HEADER), 'ttBody': _ms(TOOLTIPS.FORTIFICATION_FORTINTELLIGENCECLANDESCRIPTION_BATTLES_BODY, wins=BigWorld.wg_getNiceNumberFormat(clanFortBattlesStats.getWinsCount()), defeats=BigWorld.wg_getNiceNumberFormat(clanFortBattlesStats.getLossesCount()))}, 'clanWins': {'value': '%s%%' % BigWorld.wg_getNiceNumberFormat(functions.roundToMinOrZero(battlesWinsEff, MIN_VALUE) * 100) if battlesWinsEff is not None else '--', 'icon': RES_ICONS.MAPS_ICONS_LIBRARY_DOSSIER_WINS40X32, 'ttHeader': _ms(TOOLTIPS.FORTIFICATION_FORTINTELLIGENCECLANDESCRIPTION_WINS_HEADER), 'ttBody': _ms(TOOLTIPS.FORTIFICATION_FORTINTELLIGENCECLANDESCRIPTION_WINS_BODY)}, 'clanAvgDefres': {'value': BigWorld.wg_getNiceNumberFormat(clanAvgDefresValue) if clanAvgDefresValue else '--', 'icon': RES_ICONS.MAPS_ICONS_LIBRARY_DOSSIER_DEFRESRATIO40X32, 'ttHeader': _ms(TOOLTIPS.FORTIFICATION_FORTINTELLIGENCECLANDESCRIPTION_AVGDEFRES_HEADER), 'ttBody': _ms(TOOLTIPS.FORTIFICATION_FORTINTELLIGENCECLANDESCRIPTION_AVGDEFRES_BODY)}, 'directions': self.__getDirectionsData()}) self.as_setDataS(data) return
def getCommonInfo(userName, dossier, clanInfo, clanEmblemFile): clanNameProp = 'clanName' clanNameDescrProp = 'clanNameDescr' clanJoinTimeProp = 'clanJoinTime' clanPositionProp = 'clanPosition' clanEmblemProp = 'clanEmblem' import cgi lastBattleTimeUserString = None if dossier['total']['lastBattleTime']: lastBattleTimeUserString = '%s' % BigWorld.wg_getLongDateFormat( dossier['total']['lastBattleTime']) value = { 'name': userName, 'registrationDate': '%s' % BigWorld.wg_getLongDateFormat(dossier['total']['creationTime']), 'lastBattleDate': lastBattleTimeUserString, clanNameProp: '', clanNameDescrProp: '', clanJoinTimeProp: '', clanPositionProp: '', clanEmblemProp: None } def getGoldFmt(str): return str if clanInfo is not None: value[clanNameProp] = cgi.escape(clanInfo[1]) value[clanNameDescrProp] = cgi.escape(clanInfo[0]) value[clanJoinTimeProp] = makeString( MENU.PROFILE_HEADER_CLAN_JOINDATE) % getGoldFmt( BigWorld.wg_getLongDateFormat(clanInfo[4])) clanPosition = makeString('#menu:profile/header/clan/position/%s' % CLAN_MEMBERS[clanInfo[3]] if clanInfo[3] in CLAN_MEMBERS else '') value[clanPositionProp] = getGoldFmt( clanPosition) if clanInfo[3] in CLAN_MEMBERS else '' clanEmblemId = None if clanEmblemFile: clanEmblemId = 'userInfoId' + userName BigWorld.wg_addTempScaleformTexture(clanEmblemId, clanEmblemFile) value[clanEmblemProp] = clanEmblemId return value
def __prepareAccountResult(self, dossier): res = {} if dossier is None: return res res = self.__prepareCommonResult(dossier) stats = self.__getStatsBlock(dossier) glob = dossier.getGlobalStats() lbt = glob.getLastBattleTime() res.update({ 'maxXPVehCD': stats.getMaxXpVehicle(), 'maxFragsVehCD': stats.getMaxFragsVehicle(), 'maxDamageVehCD': stats.getMaxDamageVehicle(), 'creationTime': glob.getCreationTime(), 'lastBattleTime': lbt, 'lastBattleTimeStr': makeString(MENU.PROFILE_HEADER_LASTBATTLEDATETITLE) + ' ' + ('%s %s' % (BigWorld.wg_getLongDateFormat(lbt), BigWorld.wg_getShortTimeFormat(lbt))), 'vehicles': {} }) vehicles = stats.getVehicles() for (vehCD, vdata) in vehicles.iteritems(): res['vehicles'][str(vehCD)] = { 'battles': vdata.battlesCount, 'wins': vdata.wins, 'mastery': vdata.markOfMastery, 'xp': vdata.xp, } return res
def __makeClanInfo(self): enemyClanDBID = g_clanCache.clanDBID tID = 'clanInfo%d' % enemyClanDBID self.__imageID = yield g_clanCache.getClanEmblemTextureID( enemyClanDBID, True, tID) creationDate = BigWorld.wg_getLongDateFormat(self.fortCtrl.getFort( ).getFortDossier().getGlobalStats().getCreationTime()) clanTag = g_clanCache.clanTag clanTagLocal = i18n.makeString( FORTIFICATIONS.SETTINGSWINDOW_CLANINFO_CLANTAG, clanTag=clanTag) clanTag = text_styles.highTitle(clanTagLocal) creationDateLocalize = i18n.makeString( FORTIFICATIONS.SETTINGSWINDOW_CLANINFO_CREATIONDATE, creationDate=creationDate) creationDate = text_styles.neutral(creationDateLocalize) buildingsCount = len(self.fortCtrl.getFort().getBuildingsCompleted()) buildingsCount = text_styles.neutral(buildingsCount) buildingsCountLocalize = i18n.makeString( FORTIFICATIONS.SETTINGSWINDOW_CLANINFO_BUILDINGSCOUNT, buildingsCount=str(buildingsCount)) buildingsCountLocalize = text_styles.standard(buildingsCountLocalize) FortSettingsClanInfoVO = { 'clanTag': clanTag, 'clanIcon': self.__imageID, 'creationDate': creationDate, 'buildingCount': buildingsCountLocalize } self.as_setFortClanInfoS(FortSettingsClanInfoVO)
def _requestClanInfo(self): if self.clansCtrl.isEnabled(): isShowClanProfileBtnVisible = True else: isShowClanProfileBtnVisible = self.__isFortClanProfileAvailable() clanDBID, clanInfo = g_itemsCache.items.getClanInfo(self._userID) if clanInfo is not None: clanInfo = ClanInfo(*clanInfo) clanData = { 'id': clanDBID, 'header': clanInfo.getClanName(), 'topLabel': _ms(PROFILE.PROFILE_SUMMARY_CLAN_POST), 'topValue': text_styles.main(getClanRoleString( clanInfo.getMembersFlags())), 'bottomLabel': _ms(PROFILE.PROFILE_SUMMARY_CLAN_JOINDATE), 'bottomValue': text_styles.main( BigWorld.wg_getLongDateFormat(clanInfo.getJoiningTime())) } btnParams = self._getClanBtnParams(isShowClanProfileBtnVisible) clanData.update(btnParams) self.as_setClanDataS(clanData) self.requestClanEmblem32x32(clanDBID) return
def getMessage(self): if self._endTime: banEndTime = BigWorld.wg_getLongDateFormat(self._endTime) + ' ' + BigWorld.wg_getShortTimeFormat(self._endTime) msg = i18n.makeString('#chat:errors/chatbanned', banEndTime=banEndTime, banReason=self._reason) else: msg = i18n.makeString('#chat:errors/chatbannedpermanent', banReason=self._reason) return msg
def __getButtonData(self): if self.fortState.getStateID() == CLIENT_FORT_STATE.HAS_FORT: fort = self.fortCtrl.getFort() if not fort.isDefenceHourEnabled(): if self.fortCtrl.getPermissions().canChangeDefHour(): fortBattleBtnTooltip = TOOLTIPS.FORTIFICATION_INTROVIEW_CLANBATTLEBTN_DISABLED_LEADER else: fortBattleBtnTooltip = TOOLTIPS.FORTIFICATION_INTROVIEW_CLANBATTLEBTN_DISABLED_NOTLEADER additionalText = i18n.makeString(FORTIFICATIONS.SORTIE_INTROVIEW_FORTBATTLES_NOTACTIVATEDDEFENCETIME) return (False, makeTooltip(None, fortBattleBtnTooltip), additionalText) attacksInOneDay = fort.getAttacksIn(timePeriod=time_utils.ONE_DAY) defencesInOneDay = fort.getDefencesIn(timePeriod=time_utils.ONE_DAY) if attacksInOneDay or defencesInOneDay: return (True, TOOLTIPS.FORTIFICATION_INTROVIEW_CLANBATTLEBTN_ENABLED, None) battlesInTwoWeeks = fort.getAttacksAndDefencesIn(timePeriod=2 * time_utils.ONE_WEEK) if battlesInTwoWeeks: closestBattle = battlesInTwoWeeks[0] battleDate = BigWorld.wg_getLongDateFormat(closestBattle.getStartTime()) additionalText = i18n.makeString(FORTIFICATIONS.SORTIE_INTROVIEW_FORTBATTLES_NEXTTIMEOFBATTLE, nextDate=battleDate) fortBattleBtnTooltip = i18n.makeString(TOOLTIPS.FORTIFICATION_INTROVIEW_CLANBATTLEBTN_DISABLED_NEXTBATTLE, currentDate=battleDate) return (False, makeTooltip(None, fortBattleBtnTooltip), additionalText) if self.fortCtrl.getPermissions().canPlanAttack(): fortBattleBtnTooltip = TOOLTIPS.FORTIFICATION_INTROVIEW_CLANBATTLEBTN_DISABLED_LEADERNOACTION else: fortBattleBtnTooltip = TOOLTIPS.FORTIFICATION_INTROVIEW_CLANBATTLEBTN_DISABLED_NOTLEADERNOACTION additionalText = i18n.makeString(FORTIFICATIONS.SORTIE_INTROVIEW_FORTBATTLES_NOTACTIVATED) return (False, makeTooltip(None, fortBattleBtnTooltip), additionalText) else: return (False, '', None)
def __makeClanInfo(self): enemyClanDBID = g_clanCache.clanDBID tID = "clanInfo%d" % enemyClanDBID self.__imageID = yield g_clanCache.getClanEmblemTextureID(enemyClanDBID, True, tID) creationDate = BigWorld.wg_getLongDateFormat( self.fortCtrl.getFort().getFortDossier().getGlobalStats().getCreationTime() ) clanTag = g_clanCache.clanTag clanTagLocal = i18n.makeString(FORTIFICATIONS.SETTINGSWINDOW_CLANINFO_CLANTAG, clanTag=clanTag) clanTag = text_styles.highTitle(clanTagLocal) creationDateLocalize = i18n.makeString( FORTIFICATIONS.SETTINGSWINDOW_CLANINFO_CREATIONDATE, creationDate=creationDate ) creationDate = text_styles.neutral(creationDateLocalize) buildingsCount = len(self.fortCtrl.getFort().getBuildingsCompleted()) buildingsCount = text_styles.neutral(buildingsCount) buildingsCountLocalize = i18n.makeString( FORTIFICATIONS.SETTINGSWINDOW_CLANINFO_BUILDINGSCOUNT, buildingsCount=str(buildingsCount) ) buildingsCountLocalize = text_styles.standard(buildingsCountLocalize) FortSettingsClanInfoVO = { "clanTag": clanTag, "clanIcon": self.__imageID, "creationDate": creationDate, "buildingCount": buildingsCountLocalize, } self.as_setFortClanInfoS(FortSettingsClanInfoVO)
def __updateHeader(self): event = self.__eventData name = event.getName() eType = event.getType() leaderboard = self.__leaderboard leaderboardValue = event.getLeaderboard(self.__leaderboardID) if event.isFinished(): date = BigWorld.wg_getLongDateFormat(event.getEndDateTs()) status = text_styles.main( _ms(EVENT_BOARDS.TIME_EVENTFINISHED, date=date)) statusTooltip = None elif leaderboard: recalculationTS = leaderboard.getLastLeaderboardRecalculationTS() recalculationInterval = leaderboard.getRecalculationInterval() interval = int(recalculationInterval / ONE_MINUTE) status = text_styles.main(formatUpdateTime(recalculationTS)) statusTooltip = _ms(TOOLTIPS.SUMMARY_STATUS_TOOLTIP, interval=interval) else: status = None statusTooltip = None self.as_setHeaderDataS( makeTableViewHeaderVO(eType, leaderboardValue, name, status, statusTooltip)) return
def handleLoginRejectedBan(self, status, message): try: LOG_DEBUG('handleLoginRejectedBan', message) msg_dict = json.loads(message) if not isinstance(msg_dict, dict): self.handleLoginCustomDefinedError(status, message) return self.__loginDataLoader.token2 = msg_dict.get('token2', '') self.__loginDataLoader.saveUserToken(self.__loginDataLoader.passLength, self.__loginDataLoader.token2) json_dict = msg_dict.get('bans') msg_dict = json.loads(json_dict) except Exception: LOG_CURRENT_EXCEPTION() self.handleLoginCustomDefinedError(status, message) return expiryTime = 0 reason = '' if isinstance(msg_dict, dict): expiryTime = int(msg_dict.get('expiryTime', 0)) reason = i18n.encodeUtf8(msg_dict.get('reason', '')) if reason == BAN_REASON.CHINA_MIGRATION: self.__handleMigrationNeeded() if reason.startswith('#'): reason = i18n.makeString(reason) if expiryTime > 0: expiryTime = makeLocalServerTime(expiryTime) expiryTime = BigWorld.wg_getLongDateFormat(expiryTime) + ' ' + BigWorld.wg_getLongTimeFormat(expiryTime) errorMessage = i18n.makeString(MENU.LOGIN_STATUS_LOGIN_REJECTED_BAN, time=expiryTime, reason=reason) else: errorMessage = i18n.makeString(MENU.LOGIN_STATUS_LOGIN_REJECTED_BAN_UNLIMITED, reason=reason) self.onSetStatus(errorMessage, self.ALL_VALID)
def _requestClanInfo(self): isShowClanProfileBtnVisible = self._databaseID is None and isStartingScriptDone( ) clanDBID, clanInfo = g_itemsCache.items.getClanInfo(self._userID) if clanInfo is not None: clanInfo = ClanInfo(*clanInfo) self.as_setClanDataS({ 'id': clanDBID, 'header': clanInfo.getClanName(), 'topLabel': _ms(PROFILE.PROFILE_SUMMARY_CLAN_POST), 'topValue': text_styles.main(getClanRoleString( clanInfo.getMembersFlags())), 'bottomLabel': _ms(PROFILE.PROFILE_SUMMARY_CLAN_JOINDATE), 'bottomValue': text_styles.main( BigWorld.wg_getLongDateFormat(clanInfo.getJoiningTime())), 'btnLabel': _ms(PROFILE.PROFILE_SUMMARY_CLAN_BTNLABEL), 'btnEnabled': True, 'btnVisible': isShowClanProfileBtnVisible }) self.requestClanEmblem32x32(clanDBID)
def formatUpdateTime(recalculationTS): statusDay = event_boards_timer.getUpdateStatus_ts(recalculationTS) statusTime = BigWorld.wg_getShortTimeFormat(recalculationTS) day = _ms( EVENT_BOARDS.time_day(statusDay) ) if statusDay else BigWorld.wg_getLongDateFormat(recalculationTS) status = _ms(EVENT_BOARDS.SUMMARY_STATUS, day=day, time=statusTime) return status
def onShopResync(): yield g_itemsCache.update() if not g_itemsCache.isSynced(): return Waiting.hide('sinhronize') import time now = time.time() SystemMessages.g_instance.pushI18nMessage(SYSTEM_MESSAGES.SHOP_RESYNC, date=BigWorld.wg_getLongDateFormat(now), time=BigWorld.wg_getShortTimeFormat(now), type=SystemMessages.SM_TYPE.Information)
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)
def _getActiveDateTimeString(self): name = self.discount.getParamName() if name == 'set_MarathonAnnounce': timeStr = BigWorld.wg_getLongDateFormat(self.getFinishTime()) if timeStr is not None and self._marathonEvent: return text_styles.main(i18n.makeString(self._marathonEvent.data.quests.announceTime, startTime=timeStr)) elif name == 'set_MarathonInProgress': return super(MarathonEventActionInfo, self)._getActiveDateTimeString() return ''
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)
def _getMissionDurationTooltipData(self): header = _ms(TOOLTIPS.QUESTS_UNAVAILABLE_TIME_STATUSTOOLTIP) body = _ms( QUESTS.MISSIONS_TAB_MARATHONS_HEADER_PERIOD, startDate=BigWorld.wg_getLongDateFormat(self.event.getStartTime()), endDate=BigWorld.wg_getLongDateFormat(self.event.getFinishTime())) note = None timeLeft = self.event.getNearestActivityTimeLeft() if timeLeft is not None: startTimeLeft = timeLeft[0] if startTimeLeft > 0: note = text_styles.neutral( _ms('#quests:missionDetails/status/notAvailable/nearestTime', time=self._getTillTimeString(startTimeLeft))) return { 'tooltip': makeTooltip(header, body, note), 'isSpecial': False, 'specialArgs': None }
def create(cls, chatAction): banInfo = chatAction['data'] banEndTime = makeLocalServerTime(banInfo.get('banEndTime', None)) if banEndTime is None: if banEndTime in banInfo: del banInfo['banEndTime'] bannedMessage = i18n.makeString('#chat:errors/chatbannedpermanent', **banInfo) else: banInfo['banEndTime'] = BigWorld.wg_getLongDateFormat(banEndTime) + ' ' + BigWorld.wg_getShortTimeFormat(banEndTime) bannedMessage = i18n.makeString('#chat:errors/chatbanned', **banInfo) return ChatBannedError(cls._makeTitle('chatBanned'), bannedMessage, isModal=True)
def _updateClanInfo(self): self.as_setClanInfoS({ 'name': self.clanProfile.getClanFullName(), 'bgIcon': RES_ICONS.MAPS_ICONS_CLANS_INVITESWINDOW_CC_HEADER_BACK, 'creationDate': i18n.makeString(CLANS.CLAN_HEADER_CREATIONDATE, creationDate=BigWorld.wg_getLongDateFormat( self.clanProfile.getJoinedAt())) })
def onShopResync(): yield g_itemsCache.update() if not g_itemsCache.isSynced(): return Waiting.hide('sinhronize') import time now = time.time() SystemMessages.g_instance.pushI18nMessage( SYSTEM_MESSAGES.SHOP_RESYNC, date=BigWorld.wg_getLongDateFormat(now), time=BigWorld.wg_getShortTimeFormat(now), type=SystemMessages.SM_TYPE.Information)
def __makeOffDayData(self): alertMessage = '' blockBtnEnabled = True fort = self.fortCtrl.getFort() inProcess, inCooldown = fort.getOffDayProcessing() dayOff = fort.getOffDayStr() if self._isFortFrozen(): conditionPostfix = text_styles.standard(dayOff) else: conditionPostfix = text_styles.neutral(dayOff) blockBtnToolTip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_WEEKENDBTNENABLED descriptionTooltip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_DAYOFFDESCRIPTION if inProcess: offDayChangeDate, nextOffDayUTC, _ = fort.events[ FORT_EVENT_TYPE.OFF_DAY_CHANGE] nextOffDayLocal = adjustOffDayToLocal( nextOffDayUTC, self.fortCtrl.getFort().getLocalDefenceHour()[0]) if nextOffDayLocal > NOT_ACTIVATED: value = i18n.makeString( MENU.datetime_weekdays_full(str(nextOffDayLocal + 1))) else: value = i18n.makeString( FORTIFICATIONS.SETTINGSWINDOW_BLOCKCONDITION_NOWEEKEND) msgString = i18n.makeString( FORTIFICATIONS.SETTINGSWINDOW_BLOCKCONDITION_INPROGRESS, value=value, date=BigWorld.wg_getLongDateFormat(offDayChangeDate)) alertMessage = text_styles.alert(msgString) blockBtnEnabled = False blockBtnToolTip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_WEEKENDBTNDISABLED elif inCooldown: msgString = i18n.makeString( FORTIFICATIONS.SETTINGSWINDOW_BLOCKCONDITION_RECENTLYSCHEDULED) alertMessage = text_styles.alert(msgString) blockBtnEnabled = False blockBtnToolTip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_WEEKENDBTNDISABLED conditionPrefix = text_styles.main( i18n.makeString( FORTIFICATIONS.settingswindow_blockcondition('weekEnd'))) blockDescr = text_styles.standard( i18n.makeString( FORTIFICATIONS.settingswindow_blockdescr('weekEnd'))) if alertMessage: alertMessage = icons.alert() + ' ' + alertMessage return { 'blockBtnEnabled': blockBtnEnabled, 'blockDescr': blockDescr, 'blockCondition': conditionPrefix + ' ' + conditionPostfix, 'alertMessage': alertMessage, 'blockBtnToolTip': blockBtnToolTip, 'descriptionTooltip': descriptionTooltip }
def _getActiveDateTimeString(self): name = self.discount.getParamName() if name == 'set_MarathonAnnounce': timeStr = BigWorld.wg_getLongDateFormat(self.getFinishTime()) if timeStr is not None: return text_styles.main( i18n.makeString(QUESTS.ACTION_MARATHON_ANNOUNCETIME, startTime=timeStr)) elif name == 'set_MarathonInProgress': return super(MarathonEventActionInfo, self)._getActiveDateTimeString() return ''
def getMessage(self): formatArgs = {'reason': '', 'expiryTime': ''} if self.reason: formatArgs['reason'] = i18n.makeString(DIALOGS.DISCONNECTED_REASON, i18n.makeString(self.reason)) if self.expiryTime: expiryTime = time_utils.makeLocalServerTime(int(self.expiryTime)) formatArgs['expiryTime'] = '%s %s' % (BigWorld.wg_getLongDateFormat(expiryTime), BigWorld.wg_getLongTimeFormat(expiryTime)) key = DIALOGS.DISCONNECTED_MESSAGEKICK if self.isBan: key = DIALOGS.DISCONNECTED_MESSAGEBANPERIOD if self.expiryTime else DIALOGS.DISCONNECTED_MESSAGEBAN return i18n.makeString(key, **formatArgs)
def show(self, reason = None, isBan = None, expiryTime = None): Waiting.close() g_cursorDelegator.syncMousePosition(self, None, None) params = {'reason': '', 'expiryTime': ''} if reason: params['reason'] = makeString('#dialogs:disconnected/reason', makeString(reason)) if expiryTime: from helpers.time_utils import makeLocalServerTime expiryTime = makeLocalServerTime(int(expiryTime)) params['expiryTime'] = BigWorld.wg_getLongDateFormat(expiryTime) + ' ' + BigWorld.wg_getLongTimeFormat(expiryTime) message = 'messageKick' if not isBan else 'messageBanPeriod' if expiryTime else 'messageBan' message = makeString('#dialogs:disconnected/' + message) % params self.setMovieVariable('_root._level0.setMessage', [message])
def getMessage(self): formatArgs = {'reason': '', 'expiryTime': ''} if self.reason: formatArgs['reason'] = i18n.makeString( DIALOGS.DISCONNECTED_REASON, i18n.makeString(self.reason)) if self.expiryTime: expiryTime = time_utils.makeLocalServerTime(int(self.expiryTime)) formatArgs['expiryTime'] = '%s %s' % ( BigWorld.wg_getLongDateFormat(expiryTime), BigWorld.wg_getLongTimeFormat(expiryTime)) key = DIALOGS.DISCONNECTED_MESSAGEKICK if self.isBan: key = DIALOGS.DISCONNECTED_MESSAGEBANPERIOD if self.expiryTime else DIALOGS.DISCONNECTED_MESSAGEBAN return i18n.makeString(key, **formatArgs)
def __prepareAccountResult(self, accountDBID, dossier): if dossier is None: return {} res = self.__prepareCommonResult(accountDBID, dossier) stats = self.__getStatsBlock(dossier) glob = dossier.getGlobalStats() lbt = glob.getLastBattleTime() res.update({ 'maxXPVehCD': stats.getMaxXpVehicle(), 'maxFragsVehCD': stats.getMaxFragsVehicle(), 'maxDamageVehCD': stats.getMaxDamageVehicle(), 'creationTime': glob.getCreationTime(), 'lastBattleTime': lbt, 'lastBattleTimeStr': makeString(MENU.PROFILE_HEADER_LASTBATTLEDATETITLE) + ' ' + ('%s %s' % (BigWorld.wg_getLongDateFormat(lbt), BigWorld.wg_getShortTimeFormat(lbt))), 'vehicles': {} }) vehicles = stats.getVehicles() for (vehCD, vdata) in vehicles.iteritems(): res['vehicles'][str(vehCD)] = { 'battles': vdata.battlesCount, 'wins': vdata.wins, 'mastery': stats.getMarkOfMasteryForVehicle(vehCD), 'xp': vdata.xp } # add tanks with 0 battles vehicles = self.itemsCache.items.getVehicles(REQ_CRITERIA.INVENTORY) for (vehCD, vdata) in vehicles.iteritems(): if str(vehCD) not in res['vehicles']: res['vehicles'][str(vehCD)] = { 'battles': 0, 'wins': 0, 'mastery': 0, 'xp': 0 } return res
def __loginRejectedBan(self, responseData): bansJSON = responseData.get('bans') bans = json.loads(bansJSON) expiryTime = int(bans.get('expiryTime', '0')) reason = bans.get('reason', '') if reason == BAN_REASON.CHINA_MIGRATION: g_eventBus.handleEvent(OpenLinkEvent(OpenLinkEvent.MIGRATION)) if reason.startswith('#'): reason = _ms(reason) if expiryTime > 0: expiryTime = makeLocalServerTime(expiryTime) expiryTime = BigWorld.wg_getLongDateFormat(expiryTime) + ' ' + BigWorld.wg_getLongTimeFormat(expiryTime) self.as_setErrorMessageS(_ms(MENU.LOGIN_STATUS_LOGIN_REJECTED_BAN, time=expiryTime, reason=reason), INVALID_FIELDS.ALL_VALID) else: self.as_setErrorMessageS(_ms(MENU.LOGIN_STATUS_LOGIN_REJECTED_BAN_UNLIMITED, reason=reason), INVALID_FIELDS.ALL_VALID)
def show(self, reason = None, isBan = None, expiryTime = None): Waiting.close() g_cursorDelegator.syncMousePosition(self, None, None) params = {'reason': '', 'expiryTime': ''} if reason: params['reason'] = makeString('#dialogs:disconnected/reason', makeString(reason)) if expiryTime: from helpers.time_utils import makeLocalServerTime expiryTime = makeLocalServerTime(int(expiryTime)) params['expiryTime'] = BigWorld.wg_getLongDateFormat(expiryTime) + ' ' + BigWorld.wg_getLongTimeFormat(expiryTime) message = 'messageKick' if not isBan else ('messageBanPeriod' if expiryTime else 'messageBan') message = makeString('#dialogs:disconnected/' + message) % params self.setMovieVariable('_root._level0.setMessage', [message]) return
def _requestClanInfo(self): isShowClanProfileBtnVisible = self._databaseID is None and isStartingScriptDone() clanDBID, clanInfo = g_itemsCache.items.getClanInfo(self._userID) if clanInfo is not None: clanInfo = ClanInfo(*clanInfo) self.as_setClanDataS({'id': clanDBID, 'header': clanInfo.getClanName(), 'topLabel': _ms(PROFILE.PROFILE_SUMMARY_CLAN_POST), 'topValue': text_styles.main(getClanRoleString(clanInfo.getMembersFlags())), 'bottomLabel': _ms(PROFILE.PROFILE_SUMMARY_CLAN_JOINDATE), 'bottomValue': text_styles.main(BigWorld.wg_getLongDateFormat(clanInfo.getJoiningTime())), 'btnLabel': _ms(PROFILE.PROFILE_SUMMARY_CLAN_BTNLABEL), 'btnEnabled': True, 'btnVisible': isShowClanProfileBtnVisible}) self.requestClanEmblem32x32(clanDBID)
def __getButtonData(self): if self.fortState.getStateID() == CLIENT_FORT_STATE.HAS_FORT: fort = self.fortCtrl.getFort() if not fort.isDefenceHourEnabled(): if self.fortCtrl.getPermissions().canChangeDefHour(): fortBattleBtnTooltip = TOOLTIPS.FORTIFICATION_INTROVIEW_CLANBATTLEBTN_DISABLED_LEADER else: fortBattleBtnTooltip = TOOLTIPS.FORTIFICATION_INTROVIEW_CLANBATTLEBTN_DISABLED_NOTLEADER additionalText = i18n.makeString( FORTIFICATIONS. SORTIE_INTROVIEW_FORTBATTLES_NOTACTIVATEDDEFENCETIME) return (False, makeTooltip(None, fortBattleBtnTooltip), additionalText) attacksInOneDay = fort.getAttacksIn(timePeriod=time_utils.ONE_DAY) defencesInOneDay = fort.getDefencesIn( timePeriod=time_utils.ONE_DAY) if attacksInOneDay or defencesInOneDay: return (True, TOOLTIPS.FORTIFICATION_INTROVIEW_CLANBATTLEBTN_ENABLED, None) battlesInTwoWeeks = fort.getAttacksAndDefencesIn( timePeriod=2 * time_utils.ONE_WEEK) if battlesInTwoWeeks: closestBattle = battlesInTwoWeeks[0] battleDate = BigWorld.wg_getLongDateFormat( closestBattle.getStartTime()) additionalText = i18n.makeString( FORTIFICATIONS. SORTIE_INTROVIEW_FORTBATTLES_NEXTTIMEOFBATTLE, nextDate=battleDate) fortBattleBtnTooltip = i18n.makeString( TOOLTIPS. FORTIFICATION_INTROVIEW_CLANBATTLEBTN_DISABLED_NEXTBATTLE, currentDate=battleDate) return (False, makeTooltip(None, fortBattleBtnTooltip), additionalText) if self.fortCtrl.getPermissions().canPlanAttack(): fortBattleBtnTooltip = TOOLTIPS.FORTIFICATION_INTROVIEW_CLANBATTLEBTN_DISABLED_LEADERNOACTION else: fortBattleBtnTooltip = TOOLTIPS.FORTIFICATION_INTROVIEW_CLANBATTLEBTN_DISABLED_NOTLEADERNOACTION additionalText = i18n.makeString( FORTIFICATIONS.SORTIE_INTROVIEW_FORTBATTLES_NOTACTIVATED) return (False, makeTooltip(None, fortBattleBtnTooltip), additionalText) else: return (False, '', None)
def __makeOffDayData(self): alertMessage = "" blockBtnEnabled = True fort = self.fortCtrl.getFort() inProcess, inCooldown = fort.getOffDayProcessing() dayOff = fort.getOffDayStr() if self._isFortFrozen(): conditionPostfix = text_styles.standard(dayOff) else: conditionPostfix = text_styles.neutral(dayOff) blockBtnToolTip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_WEEKENDBTNENABLED descriptionTooltip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_DAYOFFDESCRIPTION if inProcess: offDayChangeDate, nextOffDayUTC, _ = fort.events[FORT_EVENT_TYPE.OFF_DAY_CHANGE] nextOffDayLocal = adjustOffDayToLocal(nextOffDayUTC, self.fortCtrl.getFort().getLocalDefenceHour()[0]) if nextOffDayLocal > NOT_ACTIVATED: value = i18n.makeString(MENU.datetime_weekdays_full(str(nextOffDayLocal + 1))) else: value = i18n.makeString(FORTIFICATIONS.SETTINGSWINDOW_BLOCKCONDITION_NOWEEKEND) msgString = i18n.makeString( FORTIFICATIONS.SETTINGSWINDOW_BLOCKCONDITION_INPROGRESS, value=value, date=BigWorld.wg_getLongDateFormat(offDayChangeDate), ) alertMessage = text_styles.alert(msgString) blockBtnEnabled = False blockBtnToolTip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_WEEKENDBTNDISABLED elif inCooldown: msgString = i18n.makeString(FORTIFICATIONS.SETTINGSWINDOW_BLOCKCONDITION_RECENTLYSCHEDULED) alertMessage = text_styles.alert(msgString) blockBtnEnabled = False blockBtnToolTip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_WEEKENDBTNDISABLED conditionPrefix = text_styles.main(i18n.makeString(FORTIFICATIONS.settingswindow_blockcondition("weekEnd"))) blockDescr = text_styles.standard(i18n.makeString(FORTIFICATIONS.settingswindow_blockdescr("weekEnd"))) if alertMessage: alertMessage = icons.alert() + " " + alertMessage return { "blockBtnEnabled": blockBtnEnabled, "blockDescr": blockDescr, "blockCondition": conditionPrefix + " " + conditionPostfix, "alertMessage": alertMessage, "blockBtnToolTip": blockBtnToolTip, "descriptionTooltip": descriptionTooltip, }
def __makeClanInfo(self): enemyClanDBID = g_clanCache.clanDBID tID = 'clanInfo%d' % enemyClanDBID self.__imageID = yield g_clanCache.getClanEmblemTextureID(enemyClanDBID, True, tID) creationDate = BigWorld.wg_getLongDateFormat(self.fortCtrl.getFort().getFortDossier().getGlobalStats().getCreationTime()) clanTag = g_clanCache.clanTag clanTagLocal = i18n.makeString(FORTIFICATIONS.SETTINGSWINDOW_CLANINFO_CLANTAG, clanTag=clanTag) clanTag = self.app.utilsManager.textManager.getText(TextType.HIGH_TITLE, clanTagLocal) creationDateLocalize = i18n.makeString(FORTIFICATIONS.SETTINGSWINDOW_CLANINFO_CREATIONDATE, creationDate=creationDate) creationDate = self.app.utilsManager.textManager.getText(TextType.NEUTRAL_TEXT, creationDateLocalize) buildingsCount = len(self.fortCtrl.getFort().getBuildingsCompleted()) buildingsCount = self.app.utilsManager.textManager.getText(TextType.NEUTRAL_TEXT, buildingsCount) buildingsCountLocalize = i18n.makeString(FORTIFICATIONS.SETTINGSWINDOW_CLANINFO_BUILDINGSCOUNT, buildingsCount=str(buildingsCount)) buildingsCountLocalize = self.app.utilsManager.textManager.getText(TextType.STANDARD_TEXT, buildingsCountLocalize) FortSettingsClanInfoVO = {'clanTag': clanTag, 'clanIcon': self.__imageID, 'creationDate': creationDate, 'buildingCount': buildingsCountLocalize} self.as_setFortClanInfoS(FortSettingsClanInfoVO)
def _requestClanInfo(self): if self.clansCtrl.isEnabled(): isShowClanProfileBtnVisible = True else: isShowClanProfileBtnVisible = self.__isFortClanProfileAvailable() clanDBID, clanInfo = g_itemsCache.items.getClanInfo(self._userID) if clanInfo is not None: clanInfo = ClanInfo(*clanInfo) clanData = {'id': clanDBID, 'header': clanInfo.getClanName(), 'topLabel': _ms(PROFILE.PROFILE_SUMMARY_CLAN_POST), 'topValue': text_styles.main(getClanRoleString(clanInfo.getMembersFlags())), 'bottomLabel': _ms(PROFILE.PROFILE_SUMMARY_CLAN_JOINDATE), 'bottomValue': text_styles.main(BigWorld.wg_getLongDateFormat(clanInfo.getJoiningTime()))} btnParams = self._getClanBtnParams(isShowClanProfileBtnVisible) clanData.update(btnParams) self.as_setClanDataS(clanData) self.requestClanEmblem32x32(clanDBID) return
def handleLoginRejectedBan(self, status, message): try: LOG_DEBUG('handleLoginRejectedBan', message) msg_dict = json.loads(message) if not isinstance(msg_dict, dict): self.handleLoginCustomDefinedError(status, message) return self.__loginDataLoader.token2 = msg_dict.get('token2', '') self.__loginDataLoader.saveUserToken( self.__loginDataLoader.passLength, self.__loginDataLoader.token2) json_dict = msg_dict.get('bans') msg_dict = json.loads(json_dict) except Exception: LOG_CURRENT_EXCEPTION() self.handleLoginCustomDefinedError(status, message) return expiryTime = 0 reason = '' if isinstance(msg_dict, dict): expiryTime = int(msg_dict.get('expiryTime', 0)) reason = msg_dict.get('reason', '').encode('utf-8') if reason == BAN_REASON.CHINA_MIGRATION: self.__handleMigrationNeeded() if reason.startswith('#'): reason = i18n.makeString(reason) if expiryTime > 0: expiryTime = makeLocalServerTime(expiryTime) expiryTime = BigWorld.wg_getLongDateFormat( expiryTime) + ' ' + BigWorld.wg_getLongTimeFormat(expiryTime) errorMessage = i18n.makeString( MENU.LOGIN_STATUS_LOGIN_REJECTED_BAN, time=expiryTime, reason=reason) else: errorMessage = i18n.makeString( MENU.LOGIN_STATUS_LOGIN_REJECTED_BAN_UNLIMITED, reason=reason) self.onSetStatus(errorMessage, self.ALL_VALID)
def getTimerInfo(self): def formatToEnd(iconPath, text, dateType, isEndSoon): iconPath = icons.makeImageTag(iconPath) timeData = event.getFormattedRemainingTime(dateType) text = _ms(text, time=formatTimeToEnd(timeData[0], timeData[1])) if isEndSoon: formatedText = timeEndStyle(text) else: formatedText = text_styles.vehicleStatusInfoText(text) return '{} {}'.format(iconPath, formatedText) event = self._event sday, smonth, _ = event_boards_timer.getDayMonthYear(event.getStartDate()) eday, emonth, _ = event_boards_timer.getDayMonthYear(event.getEndDate()) finished = event.isFinished() if not finished: icon = icons.makeImageTag(RES_ICONS.MAPS_ICONS_EVENTBOARDS_FLAGICONS_DATE_ICON) timePeriod = '{} {} {} - {} {} {}'.format(str(sday), _ms(MENU.datetime_months(str(smonth))), event_boards_timer.getShortTimeString(event.getStartDate()), str(eday), _ms(MENU.datetime_months(str(emonth))), event_boards_timer.getShortTimeString(event.getEndDate())) result = '{} {} '.format(icon, text_styles.vehicleStatusInfoText(timePeriod)) startSoon = event.isStartSoon() if startSoon: result += formatToEnd(RES_ICONS.MAPS_ICONS_EVENTBOARDS_FLAGICONS_TIME_ICON, EVENT_BOARDS.TIME_TIMETO_START, EVENT_DATE_TYPE.START, startSoon) elif not self._joined and not event.isRegistrationFinished(): finishSoon = event.isRegistrationFinishSoon() if finishSoon: result += formatToEnd(RES_ICONS.MAPS_ICONS_EVENTBOARDS_FLAGICONS_TIME_ICON, EVENT_BOARDS.TIME_TIMETO_ENDREGISTRATION, EVENT_DATE_TYPE.PARTICIPANTS_FREEZE, finishSoon) else: result += formatToEnd(RES_ICONS.MAPS_ICONS_EVENTBOARDS_FLAGICONS_ICON_FLAG, EVENT_BOARDS.TIME_TIMETO_ENDREGISTRATION, EVENT_DATE_TYPE.PARTICIPANTS_FREEZE, finishSoon) else: endSoon = event.isEndSoon() if endSoon: result += formatToEnd(RES_ICONS.MAPS_ICONS_EVENTBOARDS_FLAGICONS_TIME_ICON, EVENT_BOARDS.TIME_TIMETO_END, EVENT_DATE_TYPE.END, endSoon) else: result += formatToEnd(RES_ICONS.MAPS_ICONS_EVENTBOARDS_FLAGICONS_ICON_FLAG, EVENT_BOARDS.TIME_TIMETO_END, EVENT_DATE_TYPE.END, endSoon) else: date = BigWorld.wg_getLongDateFormat(event.getEndDateTs()) result = text_styles.main(_ms(EVENT_BOARDS.TIME_EVENTFINISHED, date=date)) return {'timer': result}
def __makeOffDayData(self): alertMessage = '' blockBtnEnabled = True fort = self.fortCtrl.getFort() inProcess, inCooldown = fort.getOffDayProcessing() conditionPostfix = self.app.utilsManager.textManager.getText(TextType.NEUTRAL_TEXT, fort.getOffDayStr()) blockBtnToolTip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_WEEKENDBTNENABLED descriptionTooltip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_DAYOFFDESCRIPTION if inProcess: offDayChangeDate, nextOffDayUTC, _ = fort.events[FORT_EVENT_TYPE.OFF_DAY_CHANGE] nextOffDayLocal = adjustOffDayToLocal(nextOffDayUTC, self.fortCtrl.getFort().getLocalDefenceHour()[0]) if nextOffDayLocal > NOT_ACTIVATED: value = i18n.makeString(MENU.datetime_weekdays_full(str(nextOffDayLocal + 1))) else: value = i18n.makeString(FORTIFICATIONS.SETTINGSWINDOW_BLOCKCONDITION_NOWEEKEND) msgString = i18n.makeString(FORTIFICATIONS.SETTINGSWINDOW_BLOCKCONDITION_INPROGRESS, value=value, date=BigWorld.wg_getLongDateFormat(offDayChangeDate)) alertMessage = self.app.utilsManager.textManager.getText(TextType.ALERT_TEXT, msgString) blockBtnEnabled = False blockBtnToolTip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_WEEKENDBTNDISABLED elif inCooldown: msgString = i18n.makeString(FORTIFICATIONS.SETTINGSWINDOW_BLOCKCONDITION_RECENTLYSCHEDULED) alertMessage = self.app.utilsManager.textManager.getText(TextType.ALERT_TEXT, msgString) blockBtnEnabled = False blockBtnToolTip = TOOLTIPS.FORTIFICATION_FORTSETTINGSWINDOW_WEEKENDBTNDISABLED conditionPrefix = self.app.utilsManager.textManager.getText(TextType.MAIN_TEXT, i18n.makeString(FORTIFICATIONS.settingswindow_blockcondition('weekEnd'))) blockDescr = self.app.utilsManager.textManager.getText(TextType.STANDARD_TEXT, i18n.makeString(FORTIFICATIONS.settingswindow_blockdescr('weekEnd'))) if alertMessage: alertMessage = self.app.utilsManager.textManager.getIcon(TextIcons.ALERT_ICON) + ' ' + alertMessage return {'blockBtnEnabled': blockBtnEnabled, 'blockDescr': blockDescr, 'blockCondition': conditionPrefix + ' ' + conditionPostfix, 'alertMessage': alertMessage, 'blockBtnToolTip': blockBtnToolTip, 'descriptionTooltip': descriptionTooltip}
def getLongDatetimeFormat(time): return BigWorld.wg_getLongDateFormat( time) + ' ' + BigWorld.wg_getLongTimeFormat(time)
def _updateClanInfo(self): self.as_setClanInfoS({'name': self.clanProfile.getClanFullName(), 'bgIcon': RES_ICONS.MAPS_ICONS_CLANS_INVITESWINDOW_CC_HEADER_BACK, 'creationDate': i18n.makeString(CLANS.CLAN_HEADER_CREATIONDATE, creationDate=BigWorld.wg_getLongDateFormat(self.clanProfile.getJoinedAt()))})
def getExpiryDate(self): return BigWorld.wg_getLongDateFormat(self.expiryTime)
def getLongDateFormat(cls, value): return BigWorld.wg_getLongDateFormat(time_utils.makeLocalServerTime(value))
def getDisplayableData(self, clanDBID): fortCtrl = g_clanCache.fortProvider.getController() isFortFrozen = False if clanDBID is None: fort = fortCtrl.getFort() fortDossier = fort.getFortDossier() battlesStats = fortDossier.getBattlesStats() isFortFrozen = self._isFortFrozen() clanName, clanMotto, clanTag = g_clanCache.clanName, '', g_clanCache.clanTag clanLvl = fort.level if fort is not None else 0 homePeripheryID = fort.peripheryID playersAtClan, buildingsNum = len(g_clanCache.clanMembers), len(fort.getBuildingsCompleted()) wEfficiencyVal = ProfileUtils.getFormattedWinsEfficiency(battlesStats) combatCount, winsEff, profitEff = battlesStats.getBattlesCount(), ProfileUtils.UNAVAILABLE_SYMBOL if wEfficiencyVal == str(ProfileUtils.UNAVAILABLE_VALUE) else wEfficiencyVal, battlesStats.getProfitFactor() creationTime = fortDossier.getGlobalStats().getCreationTime() defence, vacation, offDay = fort.getDefencePeriod(), fort.getVacationDate(), fort.getLocalOffDay() elif type(clanDBID) in (types.IntType, types.LongType, types.FloatType): clanInfo = fortCtrl.getPublicInfoCache().getItem(clanDBID) if clanInfo is None: LOG_WARNING('Requested clan info is empty', clanDBID) return clanName, clanMotto = clanInfo.getClanName(), '' clanTag, clanLvl = '[%s]' % clanInfo.getClanAbbrev(), clanInfo.getLevel() homePeripheryID = clanInfo.getHomePeripheryID() playersAtClan, buildingsNum = (None, None) combatCount, profitEff = clanInfo.getBattleCount(), clanInfo.getProfitFactor() creationTime = None defence, offDay = clanInfo.getDefencePeriod(), clanInfo.getLocalOffDay() vacation = clanInfo.getVacationPeriod() winsEff = None else: LOG_WARNING('Invalid clanDBID identifier', clanDBID, type(clanDBID)) return topStats = [] host = g_preDefinedHosts.periphery(homePeripheryID) if host is not None: topStats.append((i18n.makeString(TOOLTIPS.FORTIFICATION_TOOLTIPENEMYCLANINFO_HOMEPEREPHIRY), host.name)) if playersAtClan is not None: topStats.append((i18n.makeString(TOOLTIPS.FORTIFICATION_TOOLTIPENEMYCLANINFO_PLAYERSATCLAN), playersAtClan)) if buildingsNum is not None: topStats.append((i18n.makeString(TOOLTIPS.FORTIFICATION_TOOLTIPENEMYCLANINFO_BUILDINGSATFORTIFICATION), buildingsNum)) if combatCount is not None: topStats.append((i18n.makeString(TOOLTIPS.FORTIFICATION_TOOLTIPENEMYCLANINFO_FIGHTSFORFORTIFICATION), combatCount)) if winsEff is not None: topStats.append((i18n.makeString(TOOLTIPS.FORTIFICATION_TOOLTIPENEMYCLANINFO_WINPERCENTAGE), winsEff)) if profitEff is not None: topStats.append((i18n.makeString(TOOLTIPS.FORTIFICATION_TOOLTIPENEMYCLANINFO_PROFITPERCENTAGE), BigWorld.wg_getNiceNumberFormat(profitEff) if profitEff > 0 else ProfileUtils.UNAVAILABLE_SYMBOL)) if creationTime is not None: fortCreationData = self.app.utilsManager.textManager.getText(TextType.NEUTRAL_TEXT, i18n.makeString(TOOLTIPS.FORTIFICATION_TOOLTIPCLANINFO_FORTCREATIONDATE, creationDate=BigWorld.wg_getLongDateFormat(creationTime))) else: fortCreationData = None def _makeLabels(stats, itemIdx): return '\n'.join((str(a[itemIdx]) for a in stats)) infoTexts, protectionHeader = [], '' if defence[0]: if isFortFrozen: protectionHeader = self.app.utilsManager.textManager.getText(TextType.ERROR_TEXT, i18n.makeString(TOOLTIPS.FORTIFICATION_TOOLTIPENEMYCLANINFO_DEFENSETIMESTOPPED)) else: protectionHeader = self.app.utilsManager.textManager.getText(TextType.HIGH_TITLE, i18n.makeString(TOOLTIPS.FORTIFICATION_TOOLTIPENEMYCLANINFO_DEFENSETIME)) statsValueColor = TextType.DISABLE_TEXT if isFortFrozen else TextType.STATS_TEXT defencePeriodString = i18n.makeString(TOOLTIPS.FORTIFICATION_TOOLTIPENEMYCLANINFO_PERIOD, startTime=BigWorld.wg_getShortTimeFormat(defence[0]), finishTime=BigWorld.wg_getShortTimeFormat(defence[1])) defencePeriodString = self.app.utilsManager.textManager.getText(statsValueColor, defencePeriodString) infoTexts.append(i18n.makeString(TOOLTIPS.FORTIFICATION_TOOLTIPENEMYCLANINFO_DEFENSEHOUR, period=defencePeriodString)) if offDay > -1: dayOffString = i18n.makeString('#menu:dateTime/weekDays/full/%d' % (offDay + 1)) else: dayOffString = i18n.makeString(TOOLTIPS.FORTIFICATION_TOOLTIPENEMYCLANINFO_NODAYOFF) dayOffString = self.app.utilsManager.textManager.getText(statsValueColor, dayOffString) infoTexts.append(i18n.makeString(TOOLTIPS.FORTIFICATION_TOOLTIPENEMYCLANINFO_DAYOFF, dayOff=dayOffString)) if vacation[0] and vacation[1]: vacationString = i18n.makeString(TOOLTIPS.FORTIFICATION_TOOLTIPENEMYCLANINFO_PERIOD, startTime=BigWorld.wg_getShortDateFormat(vacation[0]), finishTime=BigWorld.wg_getShortDateFormat(vacation[1])) else: vacationString = i18n.makeString(TOOLTIPS.FORTIFICATION_TOOLTIPENEMYCLANINFO_NOVACATION) vacationString = self.app.utilsManager.textManager.getText(statsValueColor, vacationString) infoTexts.append(i18n.makeString(TOOLTIPS.FORTIFICATION_TOOLTIPENEMYCLANINFO_VACATION, period=vacationString)) return {'headerText': self.app.utilsManager.textManager.getText(TextType.HIGH_TITLE, i18n.makeString(TOOLTIPS.FORTIFICATION_TOOLTIPENEMYCLANINFO_HEADER, clanTag=clanTag, clanLevel=fort_formatters.getTextLevel(clanLvl))), 'fullClanName': self.app.utilsManager.textManager.getText(TextType.NEUTRAL_TEXT, clanName), 'sloganText': self.app.utilsManager.textManager.getText(TextType.STANDARD_TEXT, clanMotto), 'infoDescriptionTopText': self.app.utilsManager.textManager.getText(TextType.MAIN_TEXT, _makeLabels(topStats, 0)), 'infoTopText': self.app.utilsManager.textManager.getText('statsText', _makeLabels(topStats, 1)), 'infoDescriptionBottomText': '', 'infoBottomText': '', 'protectionHeaderText': protectionHeader, 'infoText': makeHtmlString('html_templates:lobby/fortifications/tooltips/defense_description', 'main', {'text': '\n'.join(infoTexts)}), 'fortCreationDate': fortCreationData}
def getExpiryDate(self): if self.expiryTime is not None: return BigWorld.wg_getLongDateFormat(self.expiryTime) else: return ''
def _getValue(self, value): return BigWorld.wg_getLongDateFormat(self._getLocalTime(value))
def getExpiryDate(self): return BigWorld.wg_getLongDateFormat(self.expiryTime) if self.expiryTime is not None else ''
def __makeData(self): fort = self.fortCtrl.getFort() data = {'numOfFavorites': len(fort.favorites), 'favoritesLimit': FORT_MAX_ELECTED_CLANS, 'canAttackDirection': self.fortCtrl.getPermissions().canPlanAttack(), 'canAddToFavorite': self.fortCtrl.getPermissions().canAddToFavorite(), 'isOurFortFrozen': self._isFortFrozen(), 'isSelected': self.__item is not None, 'haveResults': self.__hasResults} isWarDeclared = False isAlreadyFought = False if self.__item is not None: clanID = self.__item.getClanDBID() selectedDefenceHour = time_utils.getDateTimeInLocal(self.__selectedDefencePeriodStart).hour if self.__item.getLocalDefHour()[0] != selectedDefenceHour and not self.__weAreAtWar: warTime = '%s - %s' % (BigWorld.wg_getShortTimeFormat(self.__selectedDefencePeriodStart), BigWorld.wg_getShortTimeFormat(self.__selectedDefencePeriodEnd)) warPlannedIcon = makeHtmlString('html_templates:lobby/iconText', 'alert', {}) warPlannedMsg = makeHtmlString('html_templates:lobby/textStyle', 'alertText', {'message': warTime}) warPlannedTime = _ms(warPlannedIcon + ' ' + warPlannedMsg) data.update({'warPlannedTime': warPlannedTime, 'warPlannedTimeTT': _ms(TOOLTIPS.FORTIFICATION_FORTINTELLIGENCECLANDESCRIPTION_WARTIME, warTime=warTime)}) if self.__weAreAtWar: closestAttack = self.__upcomingAttack or self.__attackInCooldown closestAttackTime = closestAttack.getStartTime() isWarDeclared = self.__upcomingAttack is not None isAlreadyFought = self.__attackInCooldown is not None and not self.__hasBeenCounterAttacked data.update({'isWarDeclared': isWarDeclared, 'isAlreadyFought': isAlreadyFought, 'warPlannedDate': BigWorld.wg_getLongDateFormat(closestAttackTime), 'warNextAvailableDate': BigWorld.wg_getLongDateFormat(closestAttackTime + time_utils.ONE_WEEK)}) isFrozen = fort.isFrozen() clanFortBattlesStats = self.__item.getStatistics().getBattlesStats() battlesCount = clanFortBattlesStats.getBattlesCount() battlesWinsEff = clanFortBattlesStats.getWinsEfficiency() MIN_VALUE = 0.01 clanAvgDefresValue = functions.roundToMinOrZero(clanFortBattlesStats.getProfitFactor(), MIN_VALUE) data.update({'dateSelected': BigWorld.wg_getLongDateFormat(self.__selectedDayStart), 'selectedDayTimestamp': self.__selectedDayStart, 'clanTag': '[%s]' % self.__item.getClanAbbrev(), 'clanName': self.__item.getClanName(), 'clanInfo': self.__item.getClanMotto(), 'clanId': clanID, 'clanEmblem': self.__clanEmblem, 'isFavorite': clanID in fort.favorites, 'isFrozen': isFrozen, 'selectedDateText': self.__getSelectedDateText(), 'clanBattles': {'value': BigWorld.wg_getNiceNumberFormat(battlesCount) if battlesCount else '--', 'icon': RES_ICONS.MAPS_ICONS_LIBRARY_DOSSIER_BATTLES40X32, 'ttHeader': _ms(TOOLTIPS.FORTIFICATION_FORTINTELLIGENCECLANDESCRIPTION_BATTLES_HEADER), 'ttBody': _ms(TOOLTIPS.FORTIFICATION_FORTINTELLIGENCECLANDESCRIPTION_BATTLES_BODY, wins=BigWorld.wg_getNiceNumberFormat(clanFortBattlesStats.getWinsCount()), defeats=BigWorld.wg_getNiceNumberFormat(clanFortBattlesStats.getLossesCount()))}, 'clanWins': {'value': '%s%%' % BigWorld.wg_getNiceNumberFormat(functions.roundToMinOrZero(battlesWinsEff, MIN_VALUE) * 100) if battlesWinsEff is not None else '--', 'icon': RES_ICONS.MAPS_ICONS_LIBRARY_DOSSIER_WINS40X32, 'ttHeader': _ms(TOOLTIPS.FORTIFICATION_FORTINTELLIGENCECLANDESCRIPTION_WINS_HEADER), 'ttBody': _ms(TOOLTIPS.FORTIFICATION_FORTINTELLIGENCECLANDESCRIPTION_WINS_BODY)}, 'clanAvgDefres': {'value': BigWorld.wg_getNiceNumberFormat(clanAvgDefresValue) if clanAvgDefresValue else '--', 'icon': RES_ICONS.MAPS_ICONS_LIBRARY_DOSSIER_DEFRESRATIO40X32, 'ttHeader': _ms(TOOLTIPS.FORTIFICATION_FORTINTELLIGENCECLANDESCRIPTION_AVGDEFRES_HEADER), 'ttBody': _ms(TOOLTIPS.FORTIFICATION_FORTINTELLIGENCECLANDESCRIPTION_AVGDEFRES_BODY)}, 'directions': self.__getDirectionsData()}) if self.fortCtrl.getPermissions().canPlanAttack() and not isWarDeclared and not isAlreadyFought: attackerLevel = self.fortCtrl.getFort().level defenderLevel = self.__item.getLevel() data['divisionIcon'] = getDivisionIcon(defenderLevel, attackerLevel) self.as_setDataS(data) return
def getPrebattleStartTimeString(startTime): startTimeString = BigWorld.wg_getLongTimeFormat(startTime) if startTime - time.time() > 8640: startTimeString = '{0:>s} {1:>s}'.format(BigWorld.wg_getLongDateFormat(startTime), startTimeString) return startTimeString
def getDateTimeFormat(timeValue): return '{0:>s} {1:>s}'.format(BigWorld.wg_getLongDateFormat(timeValue), BigWorld.wg_getShortTimeFormat(timeValue))
def _getDateTimeString(cls, timeValue): return '{0:>s} {1:>s}'.format( BigWorld.wg_getLongDateFormat(timeValue), BigWorld.wg_getShortTimeFormat(timeValue))
def _formatFinishTime(self): return '{} {}'.format( text_styles.main(i18n.makeString(QUESTS.ACTION_TIME_FINISH)), BigWorld.wg_getLongDateFormat(self.getFinishTime()))
def _getDateTimeString(cls, timeValue): return '{0:>s}'.format(BigWorld.wg_getLongDateFormat(timeValue))
def __prepareHeaderData(self): fort = self.fortCtrl.getFort() isDefencePeriodActivated = fort.isDefenceHourEnabled() inProcess, _ = fort.getDefenceHourProcessing() isDefenceOn = isDefencePeriodActivated or inProcess buildingIcon = FortViewHelper.getPopoverIconSource(self._buildingUID, self.__buildingLevel, isDefenceOn=isDefenceOn) result = {'buildingName': i18n.makeString(FORT.buildings_buildingname(self._buildingUID)), 'buildingIcon': buildingIcon} buildLevel = self.__convertBuildLevel(self.__buildingLevel) result['buildLevel'] = i18n.makeString(FORT.BUILDINGPOPOVER_HEADER_LEVELSLBL, buildLevel=buildLevel) upgradeBtnVisible = False upgradeBtnEnable = False localTooltip = '' if self._canModernization(self.__buildingDescr): upgradeBtnVisible = upgradeBtnEnable = True localTooltip = TOOLTIPS.FORTIFICATION_POPOVER_UPGRADEFOUNDATIONBTN if upgradeBtnVisible: if not self._isEnableModernizationBtnByDamaged(self.__buildingDescr): upgradeBtnEnable = False localTooltip = TOOLTIPS.FORTIFICATION_POPOVER_UPGRADEBTN_DISABLEDBYDESTROY elif not self._isEnableModernizationBtnByProgress(self.__buildingDescr): upgradeBtnEnable = False localTooltip = TOOLTIPS.FORTIFICATION_POPOVER_UPGRADEFOUNDATIONBTN_DISABLED result['upgradeButtonToolTip'] = localTooltip result['showUpgradeButton'] = upgradeBtnVisible result['enableUpgradeBtn'] = upgradeBtnEnable isVisibleDemountBtn = self._isVisibleDemountBtn(self.__buildingDescr) result['isVisibleDemountBtn'] = isVisibleDemountBtn if isVisibleDemountBtn: result['enableDemountBtn'] = self._isEnableDemountBtn(self.__buildingDescr) result['demountBtnTooltip'] = TOOLTIPS.FORTIFICATION_POPOVER_DEMOUNTBTN header, body, filterColor = self.__makeHeaderStatusMessage() result['titleStatus'] = header result['bodyStatus'] = body result['glowColor'] = int(filterColor, 16) result['isModernization'] = self.__canUpgrade result['canDeleteBuilding'] = self.fortCtrl.getPermissions().canDeleteBuilding() if self.__progress is ALIAS.STATE_BUILDING and isDefencePeriodActivated: nextMapTimestamp, nextMapID, curMapID = self.fortCtrl.getFort().getBuildingMaps(self._buildingID) isMapsInfoEnabled = nextMapTimestamp > 0 if self.__buildingLevel < fortified_regions.g_cache.defenceConditions.minRegionLevel: mapIcon = icons.alert() mapMsg = text_styles.alert(i18n.makeString(FORT.BUILDINGPOPOVER_MAPINFO_NOBATTLE)) header = i18n.makeString(TOOLTIPS.FORTIFICATION_FORTBUILDINGCARDPOPOVER_MAPINFO_NOBATTLE_HEADER) body = i18n.makeString(TOOLTIPS.FORTIFICATION_FORTBUILDINGCARDPOPOVER_MAPINFO_NOBATTLE_BODY) isToolTipSpecial = False elif isMapsInfoEnabled: currentMapUserName = self.__getMapUserName(curMapID) mapIcon = icons.info() mapMsg = text_styles.main(currentMapUserName) header = i18n.makeString(TOOLTIPS.FORTIFICATION_FORTBUILDINGCARDPOPOVER_MAPINFO_HEADER, currentMap=currentMapUserName) body = i18n.makeString(TOOLTIPS.FORTIFICATION_FORTBUILDINGCARDPOPOVER_MAPINFO_BODY, nextMap=self.__getMapUserName(nextMapID), changeDate=BigWorld.wg_getLongDateFormat(nextMapTimestamp), changeTime=BigWorld.wg_getShortTimeFormat(nextMapTimestamp)) isToolTipSpecial = True else: mapIcon = mapMsg = '' isToolTipSpecial = False mapInfo = i18n.makeString(mapIcon + ' ' + mapMsg) result['mapInfo'] = mapInfo result['isToolTipSpecial'] = isToolTipSpecial result['tooltipData'] = {'mapName': header, 'description': body, 'imageURL': self.__getMapImage(curMapID)} return result