def _getDivisionLvls(self): _, unit = self.unitFunctional.getUnit(self.unitFunctional.getUnitIdx()) division = getDivisionNameByType(unit.getRosterTypeID()) level = getDivisionLevel(division) minLevel = fort_formatters.getTextLevel(1) maxLevel = fort_formatters.getTextLevel(level) return (minLevel, maxLevel)
def __makeDivisionsData(self, list): result = [] for item in list: divisionType = {} title = i18n.makeString(item['label']) profit = fort_formatters.getDefRes(item['profit']) minLevel = 1 maxLevel = item['level'] divisionType['divisionName'] = highTitle( i18n.makeString( I18N_FORTIFICATIONS.CHOICEDIVISION_DIVISIONFULLNAME, divisionType=title)) divisionType['divisionProfit'] = standard( i18n.makeString( I18N_FORTIFICATIONS.CHOICEDIVISION_DIVISIONPROFIT, defResCount=profit)) minLevelStr = main(fort_formatters.getTextLevel(minLevel)) maxLevelStr = main(fort_formatters.getTextLevel(maxLevel)) divisionType['vehicleLevel'] = standard( i18n.makeString( I18N_FORTIFICATIONS.CHOICEDIVISION_VEHICLELEVEL, minLevel=minLevelStr, maxLevel=maxLevelStr)) divisionType['divisionID'] = maxLevel if maxLevel == SORTIE_DIVISION.MIDDLE: minCount, maxCount = self.playersRange[0] elif maxLevel == SORTIE_DIVISION.CHAMPION: minCount, maxCount = self.playersRange[1] else: minCount, maxCount = self.playersRange[2] divisionType['playerRange'] = main('{0}-{1}'.format( str(minCount), str(maxCount))) result.append(divisionType) return result
def _getDivisionLvls(self): _, unit = self.unitFunctional.getUnit(self.unitFunctional.getUnitIdx()) division = getDivisionNameByType(unit.getRosterTypeID()) level = getDivisionLevel(division) minLevel = fort_formatters.getTextLevel(1) maxLevel = fort_formatters.getTextLevel(level) return (minLevel, maxLevel)
def _getDivisionLvls(self): _, unit = self.unitFunctional.getUnit(self.unitFunctional.getUnitIdx()) type_id = unit.getRosterTypeID() division = getDivisionNameByType(type_id) minLvl, maxLvl = MIN_MAX_VEH_LVLS_MAPPING[getDivisionLevel(division)].DEFAULT_LEVELS minLevel = fort_formatters.getTextLevel(minLvl) maxLevel = fort_formatters.getTextLevel(maxLvl) return (minLevel, maxLevel)
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 _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 _getCustomData(self): fort = self.fortCtrl.getFort() level = fort.level levelTxt = fort_formatters.getTextLevel(level) defResQuantity = fort.getTotalDefRes() defResPrefix = text_styles.main( i18n.makeString( FORTIFICATIONS.FORTMAINVIEW_COMMON_TOTALDEPOTQUANTITYTEXT)) return { 'clanName': g_clanCache.clanTag, 'levelTitle': i18n.makeString(FORTIFICATIONS.FORTMAINVIEW_HEADER_LEVELSLBL, buildLevel=levelTxt), 'defResText': defResPrefix + fort_formatters.getDefRes(defResQuantity, True), 'clanProfileBtnLbl': CLANS.FORT_HEADER_CLANPROFILEBTNLBL, 'clanListBtnTooltip': makeTooltip( i18n.makeString(TOOLTIPS.FORTIFICATION_HEADER_CLANLIST_HEADER, clanName=g_clanCache.clanTag), i18n.makeString(TOOLTIPS.FORTIFICATION_HEADER_CLANLIST_BODY)), 'orderSelectorVO': { 'isSelected': AccountSettings.getFilter(ORDERS_FILTER)['isSelected'], 'icon': RES_ICONS.MAPS_ICONS_LIBRARY_FORTIFICATION_AIM } }
def getUserLevel(self, nextLevel=False): from gui.Scaleform.daapi.view.lobby.fortifications.fort_utils import fort_formatters level = self.level if nextLevel: level += 1 return fort_formatters.getTextLevel(level)
def _getCustomData(self): fort = self.fortCtrl.getFort() level = fort.level levelTxt = fort_formatters.getTextLevel(level) defResQuantity = fort.getTotalDefRes() defResPrefix = text_styles.main( i18n.makeString( FORTIFICATIONS.FORTMAINVIEW_COMMON_TOTALDEPOTQUANTITYTEXT)) disabledTransporting = False if self.__currentMode in ( FORTIFICATION_ALIASES.MODE_TRANSPORTING_FIRST_STEP, FORTIFICATION_ALIASES.MODE_TRANSPORTING_NEXT_STEP, FORTIFICATION_ALIASES.MODE_TRANSPORTING_NOT_AVAILABLE): if not self.fortCtrl.getFort().isTransportationAvailable(): disabledTransporting = True return { 'clanName': g_clanCache.clanTag, 'levelTitle': i18n.makeString(FORTIFICATIONS.FORTMAINVIEW_HEADER_LEVELSLBL, buildLevel=levelTxt), 'defResText': defResPrefix + fort_formatters.getDefRes(defResQuantity, True), 'disabledTransporting': disabledTransporting, 'orderSelectorVO': { 'isSelected': AccountSettings.getFilter(ORDERS_FILTER)['isSelected'], 'icon': RES_ICONS.MAPS_ICONS_LIBRARY_FORTIFICATION_AIM } }
def _populate(self): super(FortOrderInfoWindow, self)._populate() self.as_setWindowDataS({ 'windowTitle': self.__order.userName, 'panelTitle': text_styles.middleTitle( '#fortifications:fortConsumableOrder/battleParams'), 'orderDescrTitle': text_styles.middleTitle( '#fortifications:fortConsumableOrder/titleDescr'), 'btnLbl': _ms('#fortifications:Orders/orderPopover/closeButton'), 'orderDescrBody': text_styles.main(self.__order.getOperationDescription()) }) fmtLvl = text_styles.main( _ms('#fortifications:fortConsumableOrder/params/level_lbl', level=fort_formatters.getTextLevel(self.__order.level))) self.as_setDynPropertiesS({ 'orderIcon': self.__order.icon, 'level': self.__order.level, 'orderLevel': fmtLvl, 'orderTitle': self.__order.userName, 'orderParams': self.__makeParams() })
def _populate(self): super(FortOrderInfoWindow, self)._populate() self.as_setWindowDataS( { "windowTitle": self.__order.userName, "panelTitle": text_styles.middleTitle("#fortifications:fortConsumableOrder/battleParams"), "orderDescrTitle": text_styles.middleTitle("#fortifications:fortConsumableOrder/titleDescr"), "btnLbl": _ms("#fortifications:Orders/orderPopover/closeButton"), "orderDescrBody": text_styles.main(self.__order.getOperationDescription()), } ) fmtLvl = text_styles.main( _ms( "#fortifications:fortConsumableOrder/params/level_lbl", level=fort_formatters.getTextLevel(self.__order.level), ) ) self.as_setDynPropertiesS( { "orderIcon": self.__order.icon, "level": self.__order.level, "orderLevel": fmtLvl, "orderTitle": self.__order.userName, "orderParams": self.__makeParams(), } )
def _requestFortLevel(self, callback): fortData = yield FortClanStatisticsData.getDataObject() if fortData is not None: fortLevel = fortData.fortCtrl.getFort().level fortLevelStr = fort_formatters.getTextLevel(fortLevel) else: fortLevel = 0 fortLevelStr = clan_fmts.DUMMY_UNAVAILABLE_DATA callback((fortLevel, fortLevelStr)) return
def _requestFortLevel(self, callback): fortData = yield FortClanStatisticsData.getDataObject() if fortData is not None: fortLevel = fortData.fortCtrl.getFort().level fortLevelStr = fort_formatters.getTextLevel(fortLevel) else: fortLevel = 0 fortLevelStr = clan_fmts.DUMMY_UNAVAILABLE_DATA callback((fortLevel, fortLevelStr)) return
def __makeColumnParamValues(self, level, isCurrentLevel = False, isShowSeparator = True): battleOrder = FortOrder(self.__orderID, level=level) if isCurrentLevel: paramsStyle, levelStyle = text_styles.stats, text_styles.neutral else: paramsStyle = levelStyle = text_styles.disabled levelStr = _ms('#fortifications:fortConsumableOrder/levelLbl', level=fort_formatters.getTextLevel(level)) return {'params': paramsStyle(_newLine(2).join(map(str, dict(battleOrder.getParams()).values()))), 'orderLevel': levelStyle(levelStr), 'isShowSeparator': isShowSeparator}
def __makeColumnParamValues(self, level, isCurrentLevel = False, isShowSeparator = True): battleOrder = FortOrder(self.__orderID, level=level) if isCurrentLevel: paramsStyle, levelStyle = text_styles.stats, text_styles.neutral else: paramsStyle = levelStyle = text_styles.disabled levelStr = _ms('#fortifications:fortConsumableOrder/levelLbl', level=fort_formatters.getTextLevel(level)) return {'params': paramsStyle(_newLine(2).join(map(str, dict(battleOrder.getParams()).values()))), 'orderLevel': levelStyle(levelStr), 'isShowSeparator': isShowSeparator}
def __updateNotActivatedView(self): _ms = i18n.makeString titleText = text_styles.promoTitle(_ms(FORTIFICATIONS.SETTINGSWINDOW_NOTACTIVATED_TITLE)) description = text_styles.main(_ms(FORTIFICATIONS.SETTINGSWINDOW_NOTACTIVATED_DESCRIPTION)) conditionTitle = text_styles.middleTitle(_ms(FORTIFICATIONS.SETTINGSWINDOW_NOTACTIVATED_CONDITIONTITLE)) firstConditionIcon = icons.checkmark() secondConditionIcon = icons.checkmark() conditionsText = text_styles.middleTitle(_ms(FORTIFICATIONS.SETTINGSWINDOW_NOTACTIVATED_CONDITIONS)) fortConditionsText = text_styles.main(_ms(FORTIFICATIONS.SETTINGSWINDOW_NOTACTIVATED_CONDITIONS_FORTLEVEL)) defenceConditionsText = text_styles.main(_ms(FORTIFICATIONS.SETTINGSWINDOW_NOTACTIVATED_CONDITIONS_DEFENCE)) attackConditionsText = text_styles.main(_ms(FORTIFICATIONS.SETTINGSWINDOW_NOTACTIVATED_CONDITIONS_ATTACK)) firstConditionNotReady = "" secondConditionNotReady = "" if not self.__checkBaseLevel(): firstConditionIcon = text_styles.standard("-") firstConditionNotReady = text_styles.error(_ms(FORTIFICATIONS.SETTINGSWINDOW_NOTACTIVATED_ISNOTREADY)) if not self.__checkPlayerCount(): secondConditionIcon = text_styles.standard("-") secondConditionNotReady = text_styles.error(_ms(FORTIFICATIONS.SETTINGSWINDOW_NOTACTIVATED_ISNOTREADY)) firstConditionMsg = text_styles.main( _ms( FORTIFICATIONS.SETTINGSWINDOW_NOTACTIVATED_BASELEVELCONDITION, level=fort_formatters.getTextLevel(g_fortCache.defenceConditions.minRegionLevel), isNotReady=firstConditionNotReady, ) ) secondConditionMsg = text_styles.main( _ms( FORTIFICATIONS.SETTINGSWINDOW_NOTACTIVATED_PLAYERCOUNTCONDITION, membersCount=BigWorld.wg_getNiceNumberFormat(g_fortCache.defenceConditions.minClanMembers), isNotReady=secondConditionNotReady, ) ) fortCondition = firstConditionMsg secondCondition = secondConditionMsg settingsBlockTop = self.__makeSettingsBlockVO(True) settingsBlockBottom = self.__makeSettingsBlockVO(False) result = { "titleText": titleText, "description": description, "conditionTitle": conditionTitle, "firstCondition": fortCondition, "secondCondition": secondCondition, "conditionsText": conditionsText, "fortConditionsText": fortConditionsText, "defenceConditionsText": defenceConditionsText, "attackConditionsText": attackConditionsText, "isBtnEnabled": self.__checkConditions(), "btnToolTipData": self.__getButtonToolTip(), "firstStatus": firstConditionIcon, "secondStatus": secondConditionIcon, "settingsBlockTop": settingsBlockTop, "settingsBlockBottom": settingsBlockBottom, } self.as_setDataForNotActivatedS(result)
def _getCustomData(self): fort = self.fortCtrl.getFort() level = fort.level levelTxt = fort_formatters.getTextLevel(level) defResQuantity = fort.getTotalDefRes() defResPrefix = text_styles.main(i18n.makeString(FORTIFICATIONS.FORTMAINVIEW_COMMON_TOTALDEPOTQUANTITYTEXT)) return {'clanName': g_clanCache.clanTag, 'levelTitle': i18n.makeString(FORTIFICATIONS.FORTMAINVIEW_HEADER_LEVELSLBL, buildLevel=levelTxt), 'defResText': defResPrefix + fort_formatters.getDefRes(defResQuantity, True), 'clanProfileBtnLbl': CLANS.FORT_HEADER_CLANPROFILEBTNLBL, 'clanListBtnTooltip': makeTooltip(i18n.makeString(TOOLTIPS.FORTIFICATION_HEADER_CLANLIST_HEADER, clanName=g_clanCache.clanTag), i18n.makeString(TOOLTIPS.FORTIFICATION_HEADER_CLANLIST_BODY)), 'orderSelectorVO': {'isSelected': AccountSettings.getFilter(ORDERS_FILTER)['isSelected'], 'icon': RES_ICONS.MAPS_ICONS_LIBRARY_FORTIFICATION_AIM}}
def __makeDivisionsData(self, list): result = [] for item in list: divisionType = {} title = i18n.makeString(item['label']) profit = fort_formatters.getDefRes(item['profit']) minLevel = 1 maxLevel = item['level'] divisionType['divisionName'] = highTitle(i18n.makeString(I18N_FORTIFICATIONS.CHOICEDIVISION_DIVISIONFULLNAME, divisionType=title)) divisionType['divisionProfit'] = standard(i18n.makeString(I18N_FORTIFICATIONS.CHOICEDIVISION_DIVISIONPROFIT, defResCount=profit)) minLevelStr = main(fort_formatters.getTextLevel(minLevel)) maxLevelStr = main(fort_formatters.getTextLevel(maxLevel)) divisionType['vehicleLevel'] = standard(i18n.makeString(I18N_FORTIFICATIONS.CHOICEDIVISION_VEHICLELEVEL, minLevel=minLevelStr, maxLevel=maxLevelStr)) divisionType['divisionID'] = maxLevel if maxLevel == SORTIE_DIVISION.MIDDLE: minCount, maxCount = self.playersRange[0] elif maxLevel == SORTIE_DIVISION.CHAMPION: minCount, maxCount = self.playersRange[1] else: minCount, maxCount = self.playersRange[2] divisionType['playerRange'] = main('{0}-{1}'.format(str(minCount), str(maxCount))) result.append(divisionType) return result
def _getCustomData(self): fort = self.fortCtrl.getFort() level = fort.level levelTxt = fort_formatters.getTextLevel(level) defResQuantity = fort.getTotalDefRes() defResPrefix = text_styles.main(i18n.makeString(FORTIFICATIONS.FORTMAINVIEW_COMMON_TOTALDEPOTQUANTITYTEXT)) disabledTransporting = False if self.__currentMode in (FORTIFICATION_ALIASES.MODE_TRANSPORTING_FIRST_STEP, FORTIFICATION_ALIASES.MODE_TRANSPORTING_NEXT_STEP, FORTIFICATION_ALIASES.MODE_TRANSPORTING_NOT_AVAILABLE): if not self.fortCtrl.getFort().isTransportationAvailable(): disabledTransporting = True return {'clanName': g_clanCache.clanTag, 'levelTitle': i18n.makeString(FORTIFICATIONS.FORTMAINVIEW_HEADER_LEVELSLBL, buildLevel=levelTxt), 'defResText': defResPrefix + fort_formatters.getDefRes(defResQuantity, True), 'disabledTransporting': disabledTransporting, 'orderSelectorVO': {'isSelected': AccountSettings.getFilter(ORDERS_FILTER)['isSelected'], 'icon': RES_ICONS.MAPS_ICONS_LIBRARY_FORTIFICATION_AIM}}
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 __makeTitle(self): text = i18n.makeString(ALIAS.DEMOUNTBUILDING_GENERALTEXT_TITLE, buildingName=self.__formattedBuildingName, buildingLevel=fort_formatters.getTextLevel(self.__buildingLevel)) return self.app.utilsManager.textManager.getText(TextType.STANDARD_TEXT, text)
def __prepareOrderInfo(self, increment = False, orderCount = 0, orderLevel = 1): result = {} if self.intBuildingID == FORT_BUILDING_TYPE.MILITARY_BASE: if increment: building_bonus = i18n.makeString(FORTIFICATIONS.BUILDINGPOPOVER_HEADER_LEVELSLBL, buildLevel=fort_formatters.getTextLevel(min(self.__baseBuildingLevel + 1, MAX_FORTIFICATION_LEVEL))) defresDescr = ''.join((text_styles.neutral(building_bonus + ' '), text_styles.main(i18n.makeString(FORTIFICATIONS.BUILDINGS_MODERNIZATIONDESCR_BASE_BUILDING)))) else: building_bonus = i18n.makeString(FORTIFICATIONS.BUILDINGPOPOVER_HEADER_LEVELSLBL, buildLevel=fort_formatters.getTextLevel(self.__baseBuildingLevel)) defresDescr = ''.join((text_styles.standard(building_bonus + ' '), text_styles.standard(i18n.makeString(FORTIFICATIONS.BUILDINGS_MODERNIZATIONDESCR_BASE_BUILDING)))) else: orderTypeID = self.fortCtrl.getFort().getBuildingOrder(self.intBuildingID) _, _, foundedLevel, orderData = self.fortCtrl.getFort().getOrderData(orderTypeID) if increment: bodyStyle = text_styles.main bonusStyle = text_styles.neutral foundedLevel += 1 _, _, _, orderData = self.fortCtrl.getFort().getOrderData(orderTypeID, foundedLevel) textPadding = ' ' else: bodyStyle = text_styles.standard bonusStyle = text_styles.standard textPadding = '' if orderTypeID == FORT_ORDER_TYPE.SPECIAL_MISSION: awardText = textPadding + i18n.makeString(FORTIFICATIONS.ORDERS_SPECIALMISSION_POSSIBLEAWARD) + ' ' bonusDescr = i18n.makeString(FORTIFICATIONS.orders_specialmission_possibleaward_description_level(foundedLevel)) defresDescr = ''.join((bonusStyle(awardText), bodyStyle(bonusDescr))) elif orderTypeID in FORT_ORDER_TYPE.CONSUMABLES: battleOrder = FortOrder(orderTypeID, level=orderLevel) defresDescr = fort_formatters.getBonusText(textPadding, self.__uid, ctx=dict(battleOrder.getParams()), textsStyle=(bonusStyle, bodyStyle)) else: colorStyle = (bonusStyle, bodyStyle) bonus = str(abs(orderData.effectValue)) defresDescr = fort_formatters.getBonusText('%s+%s%%' % (textPadding, bonus), self.__uid, colorStyle) result['ordersCount'] = orderCount result['description'] = defresDescr result['buildingType'] = self.__uid result['showAlertIcon'] = False isCombatOrderBuilding = self.__uid in [FORTIFICATION_ALIASES.FORT_ARTILLERY_SHOP_BUILDING, FORTIFICATION_ALIASES.FORT_BOMBER_SHOP_BUILDING] result['descriptionLink'] = increment and isCombatOrderBuilding if self.__uid != FORTIFICATION_ALIASES.FORT_BASE_BUILDING: order = self.fortCtrl.getFort().getOrder(self._buildingDescr.typeRef.orderType) result['iconSource'] = order.icon result['iconLevel'] = order.level if not increment else order.level + 1 if increment and self.__uid != FORTIFICATION_ALIASES.FORT_BASE_BUILDING: result['infoIconSource'] = RES_ICONS.MAPS_ICONS_LIBRARY_INFORMATIONICON toolTipData = {} toolTipData['header'] = i18n.makeString(TOOLTIPS.FORTIFICATION_DEFRESICONINFO_HEADER) toolTipData['body'] = i18n.makeString(TOOLTIPS.FORTIFICATION_DEFRESICONINFO_BODY, testData='test py var') result['infoIconToolTipData'] = toolTipData return result
def __convertBuildLevel(self, level): return str(fort_formatters.getTextLevel(level))
def __updateNotActivatedView(self): _ms = i18n.makeString titleText = text_styles.promoTitle( _ms(FORTIFICATIONS.SETTINGSWINDOW_NOTACTIVATED_TITLE)) description = text_styles.main( _ms(FORTIFICATIONS.SETTINGSWINDOW_NOTACTIVATED_DESCRIPTION)) conditionTitle = text_styles.middleTitle( _ms(FORTIFICATIONS.SETTINGSWINDOW_NOTACTIVATED_CONDITIONTITLE)) firstConditionIcon = icons.checkmark() secondConditionIcon = icons.checkmark() conditionsText = text_styles.middleTitle( _ms(FORTIFICATIONS.SETTINGSWINDOW_NOTACTIVATED_CONDITIONS)) fortConditionsText = text_styles.main( _ms(FORTIFICATIONS.SETTINGSWINDOW_NOTACTIVATED_CONDITIONS_FORTLEVEL )) defenceConditionsText = text_styles.main( _ms(FORTIFICATIONS.SETTINGSWINDOW_NOTACTIVATED_CONDITIONS_DEFENCE)) attackConditionsText = text_styles.main( _ms(FORTIFICATIONS.SETTINGSWINDOW_NOTACTIVATED_CONDITIONS_ATTACK)) firstConditionNotReady = '' secondConditionNotReady = '' if not self.__checkBaseLevel(): firstConditionIcon = text_styles.standard('-') firstConditionNotReady = text_styles.error( _ms(FORTIFICATIONS.SETTINGSWINDOW_NOTACTIVATED_ISNOTREADY)) if not self.__checkPlayerCount(): secondConditionIcon = text_styles.standard('-') secondConditionNotReady = text_styles.error( _ms(FORTIFICATIONS.SETTINGSWINDOW_NOTACTIVATED_ISNOTREADY)) firstConditionMsg = text_styles.main( _ms(FORTIFICATIONS.SETTINGSWINDOW_NOTACTIVATED_BASELEVELCONDITION, level=fort_formatters.getTextLevel( g_fortCache.defenceConditions.minRegionLevel), isNotReady=firstConditionNotReady)) secondConditionMsg = text_styles.main( _ms(FORTIFICATIONS. SETTINGSWINDOW_NOTACTIVATED_PLAYERCOUNTCONDITION, membersCount=BigWorld.wg_getNiceNumberFormat( g_fortCache.defenceConditions.minClanMembers), isNotReady=secondConditionNotReady)) fortCondition = firstConditionMsg secondCondition = secondConditionMsg settingsBlockTop = self.__makeSettingsBlockVO(True) settingsBlockBottom = self.__makeSettingsBlockVO(False) result = { 'titleText': titleText, 'description': description, 'conditionTitle': conditionTitle, 'firstCondition': fortCondition, 'secondCondition': secondCondition, 'conditionsText': conditionsText, 'fortConditionsText': fortConditionsText, 'defenceConditionsText': defenceConditionsText, 'attackConditionsText': attackConditionsText, 'isBtnEnabled': self.__checkConditions(), 'btnToolTipData': self.__getButtonToolTip(), 'firstStatus': firstConditionIcon, 'secondStatus': secondConditionIcon, 'settingsBlockTop': settingsBlockTop, 'settingsBlockBottom': settingsBlockBottom } self.as_setDataForNotActivatedS(result)
def __makeTitle(self): text = i18n.makeString(ALIAS.DEMOUNTBUILDING_GENERALTEXT_TITLE, buildingName=self.__formattedBuildingName, buildingLevel=fort_formatters.getTextLevel( self.__buildingLevel)) return text_styles.standard(text)
def __updateData(self): fort = self.fortCtrl.getFort() extra = self.unitFunctional.getExtra() result = [] activeConsumes = dict( ((otID, slotIdx) for slotIdx, (otID, level) in extra.getConsumables().iteritems())) for orderTypeID in constants.FORT_ORDER_TYPE.CONSUMABLES: orderItem = fort.getOrder(orderTypeID) building = fort.getBuilding(orderItem.buildingID) isBuildingReady = building is not None isSelected = orderTypeID in activeConsumes isSelectedInThisSlot = isSelected and activeConsumes[ orderTypeID] == self.__slotIdx isConsumableEnabled = isSelectedInThisSlot or not isSelected and orderItem.count > 0 showArsenalIcon = isBuildingReady and not isSelected if isSelectedInThisSlot: returnBtnLabel = FORTIFICATIONS.ORDERSELECTPOPOVER_RETURNBTNLABEL else: returnBtnLabel = '' orderLevelLabel = text_styles.main( _ms(FORTIFICATIONS.ORDERSELECTPOPOVER_ORDERLEVEL, orderLevel=fort_formatters.getTextLevel(orderItem.level))) if not isBuildingReady: icon = icons.makeImageTag( RES_ICONS.MAPS_ICONS_LIBRARY_REDNOTAVAILABLE, 16, 16, -2, 0) description = '%s %s' % ( icon, text_styles.error( _ms(FORTIFICATIONS.ORDERSELECTPOPOVER_NOTAVAILABLE))) orderCountText = '' elif not isSelected: description = orderLevelLabel if orderItem.count: orderCountText = text_styles.standard( _ms(FORTIFICATIONS.ORDERSELECTPOPOVER_ORDERCOUNT, orderNumber=text_styles.stats(str( orderItem.count)))) else: orderCountText = text_styles.standard( _ms(FORTIFICATIONS.ORDERSELECTPOPOVER_ORDERCOUNT, orderNumber=text_styles.error(str( orderItem.count)))) else: if isSelectedInThisSlot: description = '' else: description = orderLevelLabel icon = icons.nut() orderCountText = icon + text_styles.success( _ms(FORTIFICATIONS.ORDERSELECTPOPOVER_SELECTED)) result.append({ 'orderID': orderTypeID, 'orderIconSrc': orderItem.icon, 'headerText': text_styles.middleTitle(_ms(orderItem.userName)), 'descriptionText': description, 'orderCountText': orderCountText, 'isEnabled': isConsumableEnabled, 'isSelected': isSelectedInThisSlot, 'showArsenalIcon': showArsenalIcon, 'returnBtnLabel': returnBtnLabel, 'orderLevel': orderItem.level }) self.as_setDataS({'orders': result})
def getUserType(self): i18nKey = 'battleConsumable' if self.isConsumable else 'consumable' return i18n.makeString('#fortifications:orderType/%s' % i18nKey, level=fort_formatters.getTextLevel(self.level))
def __updateNotActivatedView(self): description = self.app.utilsManager.textManager.getText(TextType.MAIN_TEXT, i18n.makeString(FORTIFICATIONS.SETTINGSWINDOW_NOTACTIVATED_DESCRIPTION)) conditionTitle = self.app.utilsManager.textManager.getText(TextType.MIDDLE_TITLE, i18n.makeString(FORTIFICATIONS.SETTINGSWINDOW_NOTACTIVATED_CONDITIONTITLE)) firstConditionIcon = self.app.utilsManager.textManager.getIcon(TextIcons.CHECKMARK_ICON) secondConditionIcon = self.app.utilsManager.textManager.getIcon(TextIcons.CHECKMARK_ICON) if not self.__checkBaseLevel(): firstConditionIcon = self.app.utilsManager.textManager.getText(TextType.STANDARD_TEXT, '-') if not self.__checkPlayerCount(): secondConditionIcon = self.app.utilsManager.textManager.getText(TextType.STANDARD_TEXT, '-') firstConditionMsg = self.app.utilsManager.textManager.getText(TextType.MAIN_TEXT, i18n.makeString(FORTIFICATIONS.SETTINGSWINDOW_NOTACTIVATED_BASELEVELCONDITION, level=fort_formatters.getTextLevel(g_fortCache.defenceConditions.minRegionLevel))) secondConditionMsg = self.app.utilsManager.textManager.getText(TextType.MAIN_TEXT, i18n.makeString(FORTIFICATIONS.SETTINGSWINDOW_NOTACTIVATED_PLAYERCOUNTCONDITION, membersCount=BigWorld.wg_getNiceNumberFormat(g_fortCache.defenceConditions.minClanMembers))) fortCondition = firstConditionMsg secondCondition = secondConditionMsg result = {'description': description, 'conditionTitle': conditionTitle, 'firstCondition': fortCondition, 'secondCondition': secondCondition, 'isBtnEnabled': self.__checkConditions(), 'btnToolTipData': self.__getButtonToolTip(), 'firstStatus': firstConditionIcon, 'secondStatus': secondConditionIcon} self.as_setDataForNotActivatedS(result)
def __prepareOrderInfo(self, increment=False, orderCount=0, orderLevel=1): result = {} if self.intBuildingID == FORT_BUILDING_TYPE.MILITARY_BASE: if increment: building_bonus = i18n.makeString( FORTIFICATIONS.BUILDINGPOPOVER_HEADER_LEVELSLBL, buildLevel=fort_formatters.getTextLevel( min(self.__baseBuildingLevel + 1, MAX_FORTIFICATION_LEVEL))) defresDescr = ''.join( (text_styles.neutral(building_bonus + ' '), text_styles.main( i18n.makeString( FORTIFICATIONS. BUILDINGS_MODERNIZATIONDESCR_BASE_BUILDING)))) else: building_bonus = i18n.makeString( FORTIFICATIONS.BUILDINGPOPOVER_HEADER_LEVELSLBL, buildLevel=fort_formatters.getTextLevel( self.__baseBuildingLevel)) defresDescr = ''.join( (text_styles.standard(building_bonus + ' '), text_styles.standard( i18n.makeString( FORTIFICATIONS. BUILDINGS_MODERNIZATIONDESCR_BASE_BUILDING)))) else: orderTypeID = self.fortCtrl.getFort().getBuildingOrder( self.intBuildingID) _, _, foundedLevel, orderData = self.fortCtrl.getFort( ).getOrderData(orderTypeID) if increment: bodyStyle = text_styles.main bonusStyle = text_styles.neutral foundedLevel += 1 _, _, _, orderData = self.fortCtrl.getFort().getOrderData( orderTypeID, foundedLevel) textPadding = ' ' else: bodyStyle = text_styles.standard bonusStyle = text_styles.standard textPadding = '' if orderTypeID == FORT_ORDER_TYPE.SPECIAL_MISSION: awardText = textPadding + i18n.makeString( FORTIFICATIONS.ORDERS_SPECIALMISSION_POSSIBLEAWARD) + ' ' bonusDescr = i18n.makeString( FORTIFICATIONS. orders_specialmission_possibleaward_description_level( foundedLevel)) defresDescr = ''.join( (bonusStyle(awardText), bodyStyle(bonusDescr))) elif orderTypeID in FORT_ORDER_TYPE.CONSUMABLES: battleOrder = FortOrder(orderTypeID, level=orderLevel) defresDescr = fort_formatters.getBonusText( textPadding, self.__uid, ctx=dict(battleOrder.getParams()), textsStyle=(bonusStyle, bodyStyle)) else: colorStyle = (bonusStyle, bodyStyle) bonus = str(abs(orderData.effectValue)) defresDescr = fort_formatters.getBonusText( '%s+%s%%' % (textPadding, bonus), self.__uid, colorStyle) result['ordersCount'] = orderCount result['description'] = defresDescr result['buildingType'] = self.__uid result['showAlertIcon'] = False isCombatOrderBuilding = self.__uid in [ FORTIFICATION_ALIASES.FORT_ARTILLERY_SHOP_BUILDING, FORTIFICATION_ALIASES.FORT_BOMBER_SHOP_BUILDING ] result['descriptionLink'] = increment and isCombatOrderBuilding if self.__uid != FORTIFICATION_ALIASES.FORT_BASE_BUILDING: order = self.fortCtrl.getFort().getOrder( self._buildingDescr.typeRef.orderType) result['iconSource'] = order.icon result[ 'iconLevel'] = order.level if not increment else order.level + 1 if increment and self.__uid != FORTIFICATION_ALIASES.FORT_BASE_BUILDING: result[ 'infoIconSource'] = RES_ICONS.MAPS_ICONS_LIBRARY_INFORMATIONICON result['infoIconToolTip'] = makeTooltip( TOOLTIPS.FORTIFICATION_DEFRESICONINFO_HEADER, TOOLTIPS.FORTIFICATION_DEFRESICONINFO_BODY) return result
def __getDirectionTooltipData(self, dirName, buildings, attackerClanDBID, attackerClanName, attackTime, availableTime): infoMessage = '' bodyParts = [] if self.fortCtrl.getFort().isFrozen() or self.__weAreAtWar: return (None, None, None) else: buildingsMsgs = [] for building in buildings: if building is not None: extraInfo = '' if building['buildingLevel'] < FORTIFICATION_ALIASES.CLAN_BATTLE_BUILDING_MIN_LEVEL: extraInfo = _ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_BUILDINGLOWLEVEL, minLevel=fort_formatters.getTextLevel(FORTIFICATION_ALIASES.CLAN_BATTLE_BUILDING_MIN_LEVEL)) buildingsMsgs.insert(0, _ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_BUILDINGITEM, name=_ms(FORTIFICATIONS.buildings_buildingname(building['uid'])), level=_ms(FORTIFICATIONS.FORTMAINVIEW_HEADER_LEVELSLBL, buildLevel=str(fort_formatters.getTextLevel(building['buildingLevel']))), extraInfo=extraInfo)) buildingsNames = '\n'.join(buildingsMsgs) if availableTime is not None: infoMessage = _ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_NOTAVAILABLE, date=BigWorld.wg_getShortDateFormat(availableTime)) bodyParts.append(_ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_NOTAVAILABLE_INFO, date=BigWorld.wg_getShortDateFormat(availableTime))) header = _ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_NOTAVAILABLE_HEADER, direction=dirName) elif attackerClanDBID is None: if buildingsNames: bodyParts.append(_ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_BUILDINGS, buildings=buildingsNames)) if self.fortCtrl.getPermissions().canPlanAttack(): bodyParts.append(_ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_ATTACKINFO)) header = _ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_ATTACK, direction=dirName) else: bodyParts.append(_ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_NOTCOMMANDERINFO)) header = _ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_NOTCOMMANDER, direction=dirName) else: bodyParts.append(_ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_BUSY_INFO, date=BigWorld.wg_getShortDateFormat(attackTime), clanName=attackerClanName)) if buildingsNames: bodyParts.append(_ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_BUILDINGS, buildings=buildingsNames)) header = _ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_BUSY_HEADER, direction=dirName) return (header, '\n'.join(bodyParts), infoMessage)
def getUserType(self): i18nKey = "battleConsumable" if self.isConsumable else "consumable" return i18n.makeString("#fortifications:orderType/%s" % i18nKey, level=fort_formatters.getTextLevel(self.level))
def __updateData(self): fort = self.fortCtrl.getFort() extra = self.unitFunctional.getExtra() result = [] activeConsumes = dict(((otID, slotIdx) for slotIdx, (otID, level) in extra.getConsumables().iteritems())) for orderTypeID in constants.FORT_ORDER_TYPE.CONSUMABLES: orderItem = fort.getOrder(orderTypeID) building = fort.getBuilding(orderItem.buildingID) isBuildingReady = building is not None isSelected = orderTypeID in activeConsumes isSelectedInThisSlot = isSelected and activeConsumes[orderTypeID] == self.__slotIdx isConsumableEnabled = isSelectedInThisSlot or not isSelected and orderItem.count > 0 showArsenalIcon = isBuildingReady and not isSelected if isSelectedInThisSlot: returnBtnLabel = FORTIFICATIONS.ORDERSELECTPOPOVER_RETURNBTNLABEL else: returnBtnLabel = '' orderLevelLabel = text_styles.main(_ms(FORTIFICATIONS.ORDERSELECTPOPOVER_ORDERLEVEL, orderLevel=fort_formatters.getTextLevel(orderItem.level))) if not isBuildingReady: icon = icons.makeImageTag(RES_ICONS.MAPS_ICONS_LIBRARY_REDNOTAVAILABLE, 16, 16, -2, 0) description = '%s %s' % (icon, text_styles.error(_ms(FORTIFICATIONS.ORDERSELECTPOPOVER_NOTAVAILABLE))) orderCountText = '' elif not isSelected: description = orderLevelLabel if orderItem.count: orderCountText = text_styles.standard(_ms(FORTIFICATIONS.ORDERSELECTPOPOVER_ORDERCOUNT, orderNumber=text_styles.stats(str(orderItem.count)))) else: orderCountText = text_styles.standard(_ms(FORTIFICATIONS.ORDERSELECTPOPOVER_ORDERCOUNT, orderNumber=text_styles.error(str(orderItem.count)))) else: if isSelectedInThisSlot: description = '' else: description = orderLevelLabel icon = icons.nut() orderCountText = icon + text_styles.success(_ms(FORTIFICATIONS.ORDERSELECTPOPOVER_SELECTED)) result.append({'orderID': orderTypeID, 'orderIconSrc': orderItem.icon, 'headerText': text_styles.middleTitle(_ms(orderItem.userName)), 'descriptionText': description, 'orderCountText': orderCountText, 'isEnabled': isConsumableEnabled, 'isSelected': isSelectedInThisSlot, 'showArsenalIcon': showArsenalIcon, 'returnBtnLabel': returnBtnLabel, 'orderLevel': orderItem.level}) self.as_setDataS({'orders': result}) return
def getDisplayableData(self, buildingUID, isMine): ms = i18n.makeString fort = self.fortCtrl.getFort() battleID = getBattleID() battle = fort.getBattle(battleID) buildingTypeID = self.getBuildingIDbyUID(buildingUID) if battle.isDefence(): isAttack = not isMine else: isAttack = isMine if isAttack: buildingsList = battle.getAttackerBuildList() buildingsFullList = battle.getAttackerFullBuildList() else: buildingsList = battle.getDefenderBuildList() buildingsFullList = battle.getDefenderFullBuildList() buildingFullData = findFirst(lambda x: x[0] == buildingTypeID, buildingsFullList) _, status, buildingLevel, hpVal, defResVal = buildingFullData isReadyForBattle = status == constants.FORT_BUILDING_STATUS.READY_FOR_BATTLE buildingData = None resCount, arenaTypeID = (None, None) if isReadyForBattle: buildingData = findFirst(lambda x: x[0] == buildingTypeID, buildingsList) _, resCount, arenaTypeID = buildingData _, status, buildingLevel, hpVal, defResVal = buildingFullData progress = self._getProgress(buildingTypeID, buildingLevel) normLevel = max(buildingLevel, 1) buildingLevelData = fortified_regions.g_cache.buildings[buildingTypeID].levels[normLevel] hpTotalVal = buildingLevelData.hp maxDefResVal = buildingLevelData.storage buildingName = self.app.utilsManager.textManager.getText(TextType.HIGH_TITLE, ms(FORT.buildings_buildingname(buildingUID))) currentMapTxt = None buildingLevelTxt = self.app.utilsManager.textManager.getText(TextType.MAIN_TEXT, ms(FORT.FORTMAINVIEW_HEADER_LEVELSLBL, buildLevel=str(fort_formatters.getTextLevel(buildingLevel)))) descrActionTxt = None statusTxt = None statusLevel = None indicatorsModel = None infoMessage = None if status == constants.FORT_BUILDING_STATUS.LOW_LEVEL: minBuildingLevel = fortified_regions.g_cache.defenceConditions.minRegionLevel minLevel = fort_formatters.getTextLevel(1) maxLevel = fort_formatters.getTextLevel(minBuildingLevel - 1) infoMessage = ms(FORT.TOOLTIPBUILDINGINFO_LOWLEVELMESSAGE, minLevel=minLevel, maxLevel=maxLevel) else: indicatorsModel = makeBuildingIndicatorsVO(buildingLevel, progress, hpVal, hpTotalVal, defResVal, maxDefResVal) if isReadyForBattle: lootedBuildings = battle.getLootedBuildList() battleStatus = self.BATTLE_STATUSES.NO_BATTLE if (buildingData, isAttack) in lootedBuildings: battleStatus = self.BATTLE_STATUSES.LOST if battle.isDefence() and isAttack or not battle.isDefence() and not isAttack: battleStatus = self.BATTLE_STATUSES.WON arenaType = ArenaType.g_cache.get(arenaTypeID) prefix = self.app.utilsManager.textManager.getText(TextType.STANDARD_TEXT, ms(FORT.TOOLTIPBUILDINGINFO_MEP_MAPPREFIX)) mapName = self.app.utilsManager.textManager.getText(TextType.NEUTRAL_TEXT, arenaType.name) currentMapTxt = prefix + mapName statusLevel = battleStatus.level statusTxt = ms(battleStatus.msg) defResStatusTxt = self.app.utilsManager.textManager.concatStyles(((battleStatus.color, '%s %s' % (battleStatus.prefix, BigWorld.wg_getIntegralFormat(resCount))), (TextIcons.NUT_ICON,))) descrActionTxt = self.app.utilsManager.textManager.getText(TextType.MAIN_TEXT, ms(FORT.TOOLTIPBUILDINGINFO_DESCRACTION)) descrActionTxt = descrActionTxt % {'value': defResStatusTxt} else: minResCount = hpTotalVal * 0.2 minResStatusTxt = self.app.utilsManager.textManager.concatStyles(((TextType.NEUTRAL_TEXT, BigWorld.wg_getIntegralFormat(minResCount)), (TextIcons.NUT_ICON,))) infoMessage = self.app.utilsManager.textManager.getText(TextType.MAIN_TEXT, ms(FORT.TOOLTIPBUILDINGINFO_DESTROYEDMESSAGE)) infoMessage = infoMessage % {'value': minResStatusTxt} result = {'buildingUID': buildingUID, 'buildingName': buildingName, 'currentMap': currentMapTxt, 'buildingLevel': buildingLevelTxt, 'descrAction': descrActionTxt, 'statusMsg': statusTxt, 'statusLevel': statusLevel, 'indicatorModel': indicatorsModel, 'isAvailable': isReadyForBattle, 'infoMessage': infoMessage} return result
def __getDirectionTooltipData(self, dirName, buildings, attackerClanDBID, attackerClanName, attackTime, availableTime): infoMessage = '' bodyParts = [] if self.fortCtrl.getFort().isFrozen() or self.__weAreAtWar: return (None, None, None) else: buildingsMsgs = [] for building in buildings: if building is not None: extraInfo = '' if building['buildingLevel'] < FORTIFICATION_ALIASES.CLAN_BATTLE_BUILDING_MIN_LEVEL: extraInfo = _ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_BUILDINGLOWLEVEL, minLevel=fort_formatters.getTextLevel(FORTIFICATION_ALIASES.CLAN_BATTLE_BUILDING_MIN_LEVEL)) buildingsMsgs.insert(0, _ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_BUILDINGITEM, name=_ms(FORTIFICATIONS.buildings_buildingname(building['uid'])), level=_ms(FORTIFICATIONS.FORTMAINVIEW_HEADER_LEVELSLBL, buildLevel=str(fort_formatters.getTextLevel(building['buildingLevel']))), extraInfo=extraInfo)) buildingsNames = '\n'.join(buildingsMsgs) if availableTime is not None: infoMessage = _ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_NOTAVAILABLE, date=BigWorld.wg_getShortDateFormat(availableTime)) bodyParts.append(_ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_NOTAVAILABLE_INFO, date=BigWorld.wg_getShortDateFormat(availableTime))) header = _ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_NOTAVAILABLE_HEADER, direction=dirName) elif attackerClanDBID is None: if buildingsNames: bodyParts.append(_ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_BUILDINGS, buildings=buildingsNames)) if self.fortCtrl.getPermissions().canPlanAttack(): bodyParts.append(_ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_ATTACKINFO)) header = _ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_ATTACK, direction=dirName) else: bodyParts.append(_ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_NOTCOMMANDERINFO)) header = _ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_NOTCOMMANDER, direction=dirName) else: bodyParts.append(_ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_BUSY_INFO, date=BigWorld.wg_getShortDateFormat(attackTime), clanName=attackerClanName)) if buildingsNames: bodyParts.append(_ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_BUILDINGS, buildings=buildingsNames)) header = _ms(FORTIFICATIONS.FORTINTELLIGENCE_CLANDESCRIPTION_DIRECTION_TOOLTIP_BUSY_HEADER, direction=dirName) return (header, '\n'.join(bodyParts), infoMessage)
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 getUserType(self): i18nKey = 'battleConsumable' if self.isConsumable else 'consumable' return i18n.makeString('#fortifications:orderType/%s' % i18nKey, level=fort_formatters.getTextLevel(self.level))
def __convertBuildLevel(self, level): return str(fort_formatters.getTextLevel(level))
def _getLevelStr(self, level): formatedLvl = fort_formatters.getTextLevel(level) return i18n.makeString(FORTIFICATIONS.ORDERS_ORDERPOPOVER_LEVELSLBL, orderLevel=formatedLvl)
def _getLevelStr(self, level): formatedLvl = fort_formatters.getTextLevel(level) return i18n.makeString(FORTIFICATIONS.ORDERS_ORDERPOPOVER_LEVELSLBL, orderLevel=formatedLvl)
def getLevelColumnIcons(self): minLevelIcon = getTextLevel(FORTIFICATION_ALIASES.CLAN_FILTER_MIN_LEVEL) maxLevelIcon = getTextLevel(FORTIFICATION_ALIASES.CLAN_FILTER_MAX_LEVEL) return '%s - %s' % (minLevelIcon, maxLevelIcon)
def getLevelColumnIcons(self): minLevelIcon = getTextLevel( FORTIFICATION_ALIASES.CLAN_FILTER_MIN_LEVEL) maxLevelIcon = getTextLevel( FORTIFICATION_ALIASES.CLAN_FILTER_MAX_LEVEL) return '%s - %s' % (minLevelIcon, maxLevelIcon)
def __updateNotActivatedView(self): _gt = self.app.utilsManager.textManager.getText _ms = i18n.makeString titleText = _gt(TEXT_MANAGER_STYLES.PROMO_TITLE, _ms(FORTIFICATIONS.SETTINGSWINDOW_NOTACTIVATED_TITLE)) description = _gt(TEXT_MANAGER_STYLES.MAIN_TEXT, _ms(FORTIFICATIONS.SETTINGSWINDOW_NOTACTIVATED_DESCRIPTION)) conditionTitle = _gt(TEXT_MANAGER_STYLES.MIDDLE_TITLE, _ms(FORTIFICATIONS.SETTINGSWINDOW_NOTACTIVATED_CONDITIONTITLE)) firstConditionIcon = self.app.utilsManager.textManager.getIcon(TextIcons.CHECKMARK_ICON) secondConditionIcon = self.app.utilsManager.textManager.getIcon(TextIcons.CHECKMARK_ICON) conditionsText = _gt(TEXT_MANAGER_STYLES.MIDDLE_TITLE, _ms(FORTIFICATIONS.SETTINGSWINDOW_NOTACTIVATED_CONDITIONS)) fortConditionsText = _gt(TEXT_MANAGER_STYLES.MAIN_TEXT, _ms(FORTIFICATIONS.SETTINGSWINDOW_NOTACTIVATED_CONDITIONS_FORTLEVEL)) defenceConditionsText = _gt(TEXT_MANAGER_STYLES.MAIN_TEXT, _ms(FORTIFICATIONS.SETTINGSWINDOW_NOTACTIVATED_CONDITIONS_DEFENCE)) attackConditionsText = _gt(TEXT_MANAGER_STYLES.MAIN_TEXT, _ms(FORTIFICATIONS.SETTINGSWINDOW_NOTACTIVATED_CONDITIONS_ATTACK)) firstConditionNotReady = '' secondConditionNotReady = '' if not self.__checkBaseLevel(): firstConditionIcon = _gt(TEXT_MANAGER_STYLES.STANDARD_TEXT, '-') firstConditionNotReady = _gt(TEXT_MANAGER_STYLES.ERROR_TEXT, _ms(FORTIFICATIONS.SETTINGSWINDOW_NOTACTIVATED_ISNOTREADY)) if not self.__checkPlayerCount(): secondConditionIcon = _gt(TEXT_MANAGER_STYLES.STANDARD_TEXT, '-') secondConditionNotReady = _gt(TEXT_MANAGER_STYLES.ERROR_TEXT, _ms(FORTIFICATIONS.SETTINGSWINDOW_NOTACTIVATED_ISNOTREADY)) firstConditionMsg = _gt(TEXT_MANAGER_STYLES.MAIN_TEXT, _ms(FORTIFICATIONS.SETTINGSWINDOW_NOTACTIVATED_BASELEVELCONDITION, level=fort_formatters.getTextLevel(g_fortCache.defenceConditions.minRegionLevel), isNotReady=firstConditionNotReady)) secondConditionMsg = _gt(TEXT_MANAGER_STYLES.MAIN_TEXT, _ms(FORTIFICATIONS.SETTINGSWINDOW_NOTACTIVATED_PLAYERCOUNTCONDITION, membersCount=BigWorld.wg_getNiceNumberFormat(g_fortCache.defenceConditions.minClanMembers), isNotReady=secondConditionNotReady)) fortCondition = firstConditionMsg secondCondition = secondConditionMsg settingsBlockTop = self.__makeSettingsBlockVO(True) settingsBlockBottom = self.__makeSettingsBlockVO(False) result = {'titleText': titleText, 'description': description, 'conditionTitle': conditionTitle, 'firstCondition': fortCondition, 'secondCondition': secondCondition, 'conditionsText': conditionsText, 'fortConditionsText': fortConditionsText, 'defenceConditionsText': defenceConditionsText, 'attackConditionsText': attackConditionsText, 'isBtnEnabled': self.__checkConditions(), 'btnToolTipData': self.__getButtonToolTip(), 'firstStatus': firstConditionIcon, 'secondStatus': secondConditionIcon, 'settingsBlockTop': settingsBlockTop, 'settingsBlockBottom': settingsBlockBottom} self.as_setDataForNotActivatedS(result)
def getUserLevel(self, nextLevel=False): from gui.Scaleform.daapi.view.lobby.fortifications.fort_utils import fort_formatters level = self.level if nextLevel: level += 1 return fort_formatters.getTextLevel(level)
def _populate(self): super(FortOrderInfoWindow, self)._populate() self.as_setWindowDataS({'windowTitle': self.__order.userName, 'panelTitle': text_styles.middleTitle('#fortifications:fortConsumableOrder/battleParams'), 'orderDescrTitle': text_styles.middleTitle('#fortifications:fortConsumableOrder/titleDescr'), 'btnLbl': _ms('#fortifications:Orders/orderPopover/closeButton'), 'orderDescrBody': text_styles.main(self.__order.getOperationDescription())}) fmtLvl = text_styles.main(_ms('#fortifications:fortConsumableOrder/params/level_lbl', level=fort_formatters.getTextLevel(self.__order.level))) self.as_setDynPropertiesS({'orderIcon': self.__order.icon, 'level': self.__order.level, 'orderLevel': fmtLvl, 'orderTitle': self.__order.userName, 'orderParams': self.__makeParams()})
def __makeDivisionsData(self, list): result = [] for item in list: divisionType = {} title = i18n.makeString(item['label']) profit = fort_formatters.getDefRes(item['profit']) minLevel = 1 maxLevel = item['level'] divisionType['divisionName'] = self.app.utilsManager.textManager.getText(TextType.HIGH_TITLE, i18n.makeString(I18N_FORTIFICATIONS.CHOICEDIVISION_DIVISIONFULLNAME, divisionType=title)) divisionType['divisionProfit'] = self.app.utilsManager.textManager.getText(TextType.STANDARD_TEXT, i18n.makeString(I18N_FORTIFICATIONS.CHOICEDIVISION_DIVISIONPROFIT, defResCount=profit)) minLevelStr = self.app.utilsManager.textManager.getText(TextType.MAIN_TEXT, fort_formatters.getTextLevel(minLevel)) maxLevelStr = self.app.utilsManager.textManager.getText(TextType.MAIN_TEXT, fort_formatters.getTextLevel(maxLevel)) divisionType['vehicleLevel'] = self.app.utilsManager.textManager.getText(TextType.STANDARD_TEXT, i18n.makeString(I18N_FORTIFICATIONS.CHOICEDIVISION_VEHICLELEVEL, minLevel=minLevelStr, maxLevel=maxLevelStr)) divisionType['divisionID'] = maxLevel minCount, maxCount = self.__getPlayerLimits(maxLevel) divisionType['playerRange'] = self.__makePlayerCount(minCount, maxCount) result.append(divisionType) return result
def __makeData(self): baseBuildingMaxLevel = MAX_LEVEL.MAX_BASE_LEVEL_SECOND_ITERATION if self.__isFortBattleAvailable else 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)) if canUpgrade: isCanModernization = True else: isCanModernization = False if self.__buildingLevel == MAX_LEVEL.MAX_BUILD_LEVEL: if self.__isFortBattleAvailable: 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 self.__isFortBattleAvailable: cndPostfix = text_styles.error(i18n.makeString(FORTIFICATIONS.MODERNIZATION_CONDITIONS_NOTFULFILLED)) isCanModernization = False canUpgradeByDefPeriod = False conditionIcon = text_styles.standard('-') elif not self.__isFortBattleAvailable: 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: btnToolTip = {} if not canUpgradeByDefPeriod and self.__isFortBattleAvailable: btnToolTip['header'] = i18n.makeString(TOOLTIPS.FORTIFICATION_MODERNIZATION_NOTACTIVATEDDEFPERIOD_HEADER) btnToolTip['body'] = i18n.makeString(i18n.makeString(TOOLTIPS.FORTIFICATION_MODERNIZATION_NOTACTIVATEDDEFPERIOD_BODY)) else: btnToolTip['header'] = i18n.makeString(TOOLTIPS.FORTIFICATION_MODERNIZATION_APPLYBUTTON_HEADER) if not self.__isFortBattleAvailable and isBaseBuilding and self.__buildingLevel == baseBuildingMaxLevel: btnToolTip['header'] = i18n.makeString('#tooltips:fortification/popOver/upgradeFoundationBtn_Disabled/header') btnToolTip['body'] = i18n.makeString(FORTIFICATIONS.MODERNIZATION_CONDITIONS_FORTMAXLEVEL) elif upgradeRestriction == FORT_RESTRICTION.BUILDING_NOT_ENOUGH_RESOURCE_AND_LOW_LEVEL: btnToolTip['body'] = i18n.makeString(TOOLTIPS.FORTIFICATION_MODERNIZATION_APPLYBUTTON_LOWLEVELANDRESOURCE, baseLevel=fort_formatters.getTextLevel(self.__baseBuildingLevel + 1)) elif upgradeRestriction == FORT_RESTRICTION.BUILDING_FORT_LEVEL_TOO_LOW: btnToolTip['body'] = i18n.makeString(TOOLTIPS.FORTIFICATION_MODERNIZATION_APPLYBUTTON_LOWBASELEVEL, baseLevel=fort_formatters.getTextLevel(self.__baseBuildingLevel + 1)) elif upgradeRestriction == FORT_RESTRICTION.BUILDING_NOT_ENOUGH_RESOURCE: btnToolTip['body'] = i18n.makeString(TOOLTIPS.FORTIFICATION_MODERNIZATION_APPLYBUTTON_NETENOUGHRESOURCE) result['btnToolTip'] = btnToolTip 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['buildingType'] = self.__uid 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['buildingType'] = self.__uid 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 _getTextLevels(lvl): return main(fort_formatters.getTextLevel(lvl))
def __makeTitle(self): text = i18n.makeString(ALIAS.DEMOUNTBUILDING_GENERALTEXT_TITLE, buildingName=self.__formattedBuildingName, buildingLevel=fort_formatters.getTextLevel(self.__buildingLevel)) return text_styles.standard(text)
def __getLevelsStr(self, maxlvl): minLevel = 1 minLevelStr = fort_formatters.getTextLevel(minLevel) maxLevelStr = fort_formatters.getTextLevel(maxlvl) return self.app.utilsManager.textManager.getText(TextType.MAIN_TEXT, minLevelStr + ' - ' + maxLevelStr)