def makeBuildingIndicatorsVO(buildingLevel, progress, hpVal, hpTotalVal, defResVal, maxDefResVal): FORMAT_PATTERN = '###' if progress == FORT_ALIAS.STATE_FOUNDATION_DEF or progress == FORT_ALIAS.STATE_FOUNDATION: hpValueFormatter = text_styles.alert(FORMAT_PATTERN) else: hpValueFormatter = text_styles.defRes(FORMAT_PATTERN) hpTotalFormatted = str(BigWorld.wg_getIntegralFormat(hpTotalVal)) + ' ' formattedHpTotal = ''.join((text_styles.standard(hpTotalFormatted), icons.nut())) defResValueFormatter = text_styles.defRes(FORMAT_PATTERN) maxDefDerFormatted = str(BigWorld.wg_getIntegralFormat(maxDefResVal)) + ' ' formattedDefResTotal = ''.join((text_styles.standard(maxDefDerFormatted), icons.nut())) hpProgressLabels = {'currentValue': str(BigWorld.wg_getIntegralFormat(hpVal)), 'currentValueFormatter': hpValueFormatter, 'totalValue': formattedHpTotal, 'separator': '/'} storeProgressLabels = {'currentValue': str(BigWorld.wg_getIntegralFormat(defResVal)), 'currentValueFormatter': defResValueFormatter, 'totalValue': formattedDefResTotal, 'separator': '/'} result = {'hpLabel': i18n.makeString(FORTIFICATIONS.BUILDINGPOPOVER_INDICATORS_HPLBL), 'defResLabel': i18n.makeString(FORTIFICATIONS.BUILDINGPOPOVER_INDICATORS_DEFRESLBL), 'hpCurrentValue': hpVal, 'hpTotalValue': hpTotalVal, 'defResCurrentValue': defResVal, 'defResTotalValue': maxDefResVal, 'hpProgressLabels': hpProgressLabels, 'defResProgressLabels': storeProgressLabels} return result
def _update(self): initData = { 'windowTitle': i18n.makeString(FORTIFICATIONS.FORTCLANLISTWINDOW_TITLE, clanName=g_clanCache.clanTag), 'members': self._getClanMembers(), 'tableHeader': [ self._createHeader( FORTIFICATIONS.CLANLISTWINDOW_TABLE_MEMBERNAME, 'userName', 181, 0, TOOLTIPS.FORTIFICATION_FIXEDPLAYERS_NIC, TEXT_ALIGN.LEFT, sortType='string'), self._createHeader( FORTIFICATIONS.CLANLISTWINDOW_TABLE_ROLE, 'playerRoleID', 203, 1, TOOLTIPS.FORTIFICATION_FIXEDPLAYERS_FORTROLE, TEXT_ALIGN.LEFT), self._createHeader( i18n.makeString( FORTIFICATIONS.FIXEDPLAYERS_LISTHEADER_FIELDWEEK, icon=icons.nut()), 'intWeekMining', 137, 2, TOOLTIPS.FORTIFICATION_FIXEDPLAYERS_WEEK, TEXT_ALIGN.RIGHT), self._createHeader( i18n.makeString( FORTIFICATIONS.FIXEDPLAYERS_LISTHEADER_FIELDALLTIME, icon=icons.nut()), 'intTotalMining', 147, 3, TOOLTIPS.FORTIFICATION_FIXEDPLAYERS_ALLTIME, TEXT_ALIGN.CENTER) ] } self.as_setDataS(initData)
def makeBuildingIndicatorsVO(buildingLevel, progress, hpVal, hpTotalVal, defResVal, maxDefResVal): FORMAT_PATTERN = '###' if progress == FORT_ALIAS.STATE_FOUNDATION_DEF or progress == FORT_ALIAS.STATE_FOUNDATION: hpValueFormatter = text_styles.alert(FORMAT_PATTERN) else: hpValueFormatter = text_styles.defRes(FORMAT_PATTERN) hpTotalFormatted = str(BigWorld.wg_getIntegralFormat(hpTotalVal)) + ' ' formattedHpTotal = ''.join((text_styles.standard(hpTotalFormatted), icons.nut())) defResValueFormatter = text_styles.alert(FORMAT_PATTERN) if defResVal > maxDefResVal else text_styles.defRes(FORMAT_PATTERN) maxDefDerFormatted = str(BigWorld.wg_getIntegralFormat(maxDefResVal)) + ' ' formattedDefResTotal = ''.join((text_styles.standard(maxDefDerFormatted), icons.nut())) hpProgressLabels = {'currentValue': str(BigWorld.wg_getIntegralFormat(hpVal)), 'currentValueFormatter': hpValueFormatter, 'totalValue': formattedHpTotal, 'separator': '/'} storeProgressLabels = {'currentValue': str(BigWorld.wg_getIntegralFormat(defResVal)), 'currentValueFormatter': defResValueFormatter, 'totalValue': formattedDefResTotal, 'separator': '/'} result = {'hpLabel': i18n.makeString(FORTIFICATIONS.BUILDINGPOPOVER_INDICATORS_HPLBL), 'defResLabel': i18n.makeString(FORTIFICATIONS.BUILDINGPOPOVER_INDICATORS_DEFRESLBL), 'hpCurrentValue': hpVal, 'hpTotalValue': hpTotalVal, 'defResCurrentValue': defResVal, 'defResCompensationValue': max(0, defResVal - maxDefResVal), 'defResTotalValue': maxDefResVal, 'hpProgressLabels': hpProgressLabels, 'defResProgressLabels': storeProgressLabels} return result
def __prepareIndicatorData(self, isCanModernization, increment = False, resLeft = 0): if increment: hpTotalVal = self.nextLevel.levelRef.hp hpVal = self.nextLevel.hp defResVal = self.__defResVal - self.__cost + resLeft maxDefResVal = self.nextLevel.levelRef.storage else: hpTotalVal = self.__hpTotalVal hpVal = self.__hpVal defResVal = self.__defResVal maxDefResVal = self.__maxDerResVal formatter = text_styles.defRes if self.__progress == FORTIFICATION_ALIASES.STATE_FOUNDATION_DEF or self.__progress == FORTIFICATION_ALIASES.STATE_FOUNDATION: formatter = text_styles.alert if not isCanModernization and increment: currentHpLabel = text_styles.main('--') currentHpValue = 0 else: currentHpLabel = str(BigWorld.wg_getIntegralFormat(hpVal)) currentHpValue = hpVal FORMAT_PATTERN = '###' formattedHpValue = formatter(FORMAT_PATTERN) formatter = text_styles.standard if increment: formatter = text_styles.neutral formattedHpTotal = formatter(str(BigWorld.wg_getIntegralFormat(hpTotalVal))) formattedHpTotal += ' ' + icons.nut() if not isCanModernization and increment: currentDefResLabel = text_styles.main('--') currentDefResValue = 0 else: currentDefResLabel = str(BigWorld.wg_getIntegralFormat(defResVal)) currentDefResValue = defResVal defResValueFormatter = text_styles.alert(FORMAT_PATTERN) if defResVal > maxDefResVal else text_styles.defRes(FORMAT_PATTERN) formattedDefResTotal = formatter(str(BigWorld.wg_getIntegralFormat(maxDefResVal))) formattedDefResTotal += ' ' + icons.nut() result = {} result['hpLabel'] = i18n.makeString(FORTIFICATIONS.BUILDINGPOPOVER_INDICATORS_HPLBL) result['defResLabel'] = i18n.makeString(FORTIFICATIONS.BUILDINGPOPOVER_INDICATORS_DEFRESLBL) result['hpCurrentValue'] = currentHpValue result['hpTotalValue'] = hpTotalVal result['defResCurrentValue'] = currentDefResValue result['defResTotalValue'] = maxDefResVal result['defResTotalValue'] = maxDefResVal result['defResCompensationValue'] = max(0, defResVal - maxDefResVal) hpProgressLabels = {} hpProgressLabels['currentValue'] = currentHpLabel hpProgressLabels['currentValueFormatter'] = formattedHpValue hpProgressLabels['totalValue'] = formattedHpTotal hpProgressLabels['separator'] = '/' storeProgressLabels = {} storeProgressLabels['currentValue'] = currentDefResLabel storeProgressLabels['currentValueFormatter'] = defResValueFormatter storeProgressLabels['totalValue'] = formattedDefResTotal storeProgressLabels['separator'] = '/' result['hpProgressLabels'] = hpProgressLabels result['defResProgressLabels'] = storeProgressLabels return result
def getDefRes(value, addIcon = True): text = text_styles.defRes(BigWorld.wg_getIntegralFormat(value)) if addIcon: icon = icons.nut() return text + ' ' + icon else: return text
def __makeData(self): sourceCount = text_styles.defRes(str(fortified_regions.g_cache.startResource)) sourceCount += ' ' + icons.nut() sourceCount = text_styles.standard(i18n.makeString(FORTIFICATIONS.CONGRATULATIONWINDOW_TEXTBODY, sourceCount=sourceCount)) self.as_setTextS(sourceCount) self.as_setTitleS(i18n.makeString(FORTIFICATIONS.CONGRATULATIONWINDOW_TEXTTITLE)) self.as_setButtonLblS(i18n.makeString(FORTIFICATIONS.CONGRATULATIONWINDOW_BUTTONLBL)) self.as_setWindowTitleS(i18n.makeString(FORTIFICATIONS.CONGRATULATIONWINDOW_TITLELBL))
def getBuildingTooltipBody(self, hpVal, maxHpValue, defResVal, maxDefResValue): nutIcon = ' ' + icons.nut() labelOne = i18n.makeString(FORTIFICATIONS.BUILDINGS_BUILDINGTOOLTIP_STRENGTH) labelTwo = i18n.makeString(FORTIFICATIONS.BUILDINGS_BUILDINGTOOLTIP_STORE) fstLine = labelOne + self.__toFormattedStr(hpVal) + '/' + self.__toFormattedStr(maxHpValue) + nutIcon secLine = labelTwo + self.__toFormattedStr(defResVal) + '/' + self.__toFormattedStr(maxDefResValue) + nutIcon toolTipData = fstLine + secLine return toolTipData
def getBuildingTooltipBody(self, hpVal, maxHpValue, defResVal, maxDefResValue): nutIcon = ' ' + icons.nut() labelOne = text_styles.main(i18n.makeString(FORTIFICATIONS.BUILDINGS_BUILDINGTOOLTIP_STRENGTH)) labelTwo = text_styles.main(i18n.makeString(FORTIFICATIONS.BUILDINGS_BUILDINGTOOLTIP_STORE)) fstLine = labelOne + text_styles.neutral(self.__toFormattedStr(hpVal)) + ' / ' + text_styles.standard(self.__toFormattedStr(maxHpValue)) + nutIcon secLine = labelTwo + text_styles.neutral(self.__toFormattedStr(defResVal)) + ' / ' + text_styles.standard(self.__toFormattedStr(maxDefResValue)) + nutIcon toolTipData = fstLine + secLine defResCompensationValue = defResVal - maxDefResValue if defResCompensationValue > 0: toolTipData += text_styles.standard(i18n.makeString(FORTIFICATIONS.BUILDINGS_BUILDINGTOOLTIP_COMPENSATION)) + text_styles.neutral(self.__toFormattedStr(defResCompensationValue)) + nutIcon return toolTipData
def _createTableHeader(self): return [ self._createTableBtnInfo( FORTIFICATIONS.CLANLISTWINDOW_TABLE_MEMBERNAME, 'userName', 140, 0, TOOLTIPS.FORTIFICATION_FIXEDPLAYERS_NIC, TEXT_ALIGN.LEFT, 'string'), self._createTableBtnInfo( FORTIFICATIONS.CLANLISTWINDOW_TABLE_ROLE, 'playerRoleID', 199, 1, TOOLTIPS.FORTIFICATION_FIXEDPLAYERS_FORTROLE, TEXT_ALIGN.LEFT), self._createTableBtnInfo( i18n.makeString( FORTIFICATIONS.FIXEDPLAYERS_LISTHEADER_FIELDWEEK, icon=icons.nut()), 'intWeekMining', 103, 2, TOOLTIPS.FORTIFICATION_FIXEDPLAYERS_WEEK, TEXT_ALIGN.RIGHT), self._createTableBtnInfo( i18n.makeString( FORTIFICATIONS.FIXEDPLAYERS_LISTHEADER_FIELDALLTIME, icon=icons.nut()), 'intTotalMining', 103, 2, TOOLTIPS.FORTIFICATION_FIXEDPLAYERS_ALLTIME, TEXT_ALIGN.RIGHT) ]
def getBuildingTooltipBody(self, hpVal, maxHpValue, defResVal, maxDefResValue): nutIcon = ' ' + icons.nut() labelOne = i18n.makeString( FORTIFICATIONS.BUILDINGS_BUILDINGTOOLTIP_STRENGTH) labelTwo = i18n.makeString( FORTIFICATIONS.BUILDINGS_BUILDINGTOOLTIP_STORE) fstLine = labelOne + self.__toFormattedStr( hpVal) + '/' + self.__toFormattedStr(maxHpValue) + nutIcon secLine = labelTwo + self.__toFormattedStr( defResVal) + '/' + self.__toFormattedStr(maxDefResValue) + nutIcon toolTipData = fstLine + secLine return toolTipData
def __makeData(self): sourceCount = text_styles.defRes( str(fortified_regions.g_cache.startResource)) sourceCount += ' ' + icons.nut() sourceCount = text_styles.standard( i18n.makeString(FORTIFICATIONS.CONGRATULATIONWINDOW_TEXTBODY, sourceCount=sourceCount)) self.as_setTextS(sourceCount) self.as_setTitleS( i18n.makeString(FORTIFICATIONS.CONGRATULATIONWINDOW_TEXTTITLE)) self.as_setButtonLblS( i18n.makeString(FORTIFICATIONS.CONGRATULATIONWINDOW_BUTTONLBL)) self.as_setWindowTitleS( i18n.makeString(FORTIFICATIONS.CONGRATULATIONWINDOW_TITLELBL))
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 __updateSortieData(self): ms = i18n.makeString dossier = self.fortCtrl.getFort().getFortDossier() sortiesStats = dossier.getSortiesStats() totalRes = sortiesStats.getLoot() defresValueStr = str(BigWorld.wg_getIntegralFormat(totalRes)) + ' ' formattedDefresValue = ''.join((text_styles.defRes(defresValueStr), icons.nut())) middleBattlesCount = BigWorld.wg_getIntegralFormat(sortiesStats.getMiddleBattlesCount()) championshipBattlesCount = BigWorld.wg_getIntegralFormat(sortiesStats.getChampionBattlesCount()) absoluteBattlesCount = BigWorld.wg_getIntegralFormat(sortiesStats.getAbsoluteBattlesCount()) self.__data.update({'clanName': g_clanCache.clanTag, 'sortieBattlesCount': ProfileUtils.getTotalBattlesHeaderParam(sortiesStats, FORTIFICATIONS.CLANSTATS_PARAMS_SORTIE_BATTLESCOUNT_LABEL, FORTIFICATIONS.CLANSTATS_PARAMS_SORTIE_BATTLESCOUNT_TOOLTIP), 'sortieWins': ProfileUtils.packLditItemData(ProfileUtils.getFormattedWinsEfficiency(sortiesStats), FORTIFICATIONS.CLANSTATS_PARAMS_SORTIE_WINS_LABEL, FORTIFICATIONS.CLANSTATS_PARAMS_SORTIE_WINS_TOOLTIP, 'wins40x32.png'), 'sortieAvgDefres': ProfileUtils.packLditItemData(ProfileUtils.formatEfficiency(sortiesStats.getBattlesCount(), sortiesStats.getAvgLoot), FORTIFICATIONS.CLANSTATS_PARAMS_SORTIE_AVGDEFRES_LABEL, FORTIFICATIONS.CLANSTATS_PARAMS_SORTIE_AVGDEFRES_TOOLTIP, 'avgDefes40x32.png'), 'sortieBattlesStats': [{'value': self.__getMiddleTitleText(middleBattlesCount), 'label': ms(FORTIFICATIONS.CLANSTATS_PARAMS_SORTIE_BATTLES_MIDDLEBATTLESCOUNT_LABEL)}, {'value': self.__getMiddleTitleText(championshipBattlesCount), 'label': ms(FORTIFICATIONS.CLANSTATS_PARAMS_SORTIE_BATTLES_CHAMPIONBATTLESCOUNT_LABEL)}, {'value': self.__getMiddleTitleText(absoluteBattlesCount), 'label': ms(FORTIFICATIONS.CLANSTATS_PARAMS_SORTIE_BATTLES_ABSOLUTEBATTLESCOUNT_LABEL)}], 'sortieDefresStats': [{'value': formattedDefresValue, 'label': ms(FORTIFICATIONS.CLANSTATS_PARAMS_SORTIE_DEFRES_LOOTINSORTIES_LABEL)}]})
def _packBlocks(self, compensationValue): title = TOOLTIPS.FORTIFICATION_POPOVER_DEFRESPROGRESS_HEADER items = super(FortPopoverDefResTooltipData, self)._packBlocks() items.append( formatters.packTitleDescBlock(text_styles.highTitle(title), desc=text_styles.main(self._descr))) if compensationValue is not None: blocksGap = 12 compensationHeader = text_styles.main( TOOLTIPS. FORTIFICATION_POPOVER_DEFRESPROGRESS_COMPENSATION_HEADER ) + text_styles.alert('+' + compensationValue) + icons.nut() compensationBody = text_styles.standard( TOOLTIPS.FORTIFICATION_POPOVER_DEFRESPROGRESS_COMPENSATION_BODY ) items.append( formatters.packBuildUpBlockData( [ formatters.packTextBlockData( text_styles.concatStylesToMultiLine( compensationHeader, compensationBody)) ], blocksGap, BLOCKS_TOOLTIP_TYPES. TOOLTIP_BUILDUP_BLOCK_WHITE_BG_LINKAGE)) return items
def _update(self): initData = {'windowTitle': i18n.makeString(FORTIFICATIONS.FORTCLANLISTWINDOW_TITLE, clanName=g_clanCache.clanTag), 'members': self._getClanMembers(), 'tableHeader': [self._createHeader(FORTIFICATIONS.CLANLISTWINDOW_TABLE_MEMBERNAME, 'userName', 181, 0, TOOLTIPS.FORTIFICATION_FIXEDPLAYERS_NIC, TEXT_ALIGN.LEFT, sortType='string'), self._createHeader(FORTIFICATIONS.CLANLISTWINDOW_TABLE_ROLE, 'playerRoleID', 203, 1, TOOLTIPS.FORTIFICATION_FIXEDPLAYERS_FORTROLE, TEXT_ALIGN.LEFT), self._createHeader(i18n.makeString(FORTIFICATIONS.FIXEDPLAYERS_LISTHEADER_FIELDWEEK, icon=icons.nut()), 'intWeekMining', 137, 2, TOOLTIPS.FORTIFICATION_FIXEDPLAYERS_WEEK, TEXT_ALIGN.RIGHT), self._createHeader(i18n.makeString(FORTIFICATIONS.FIXEDPLAYERS_LISTHEADER_FIELDALLTIME, icon=icons.nut()), 'intTotalMining', 147, 3, TOOLTIPS.FORTIFICATION_FIXEDPLAYERS_ALLTIME, TEXT_ALIGN.CENTER)]} self.as_setDataS(initData)
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 __getFormattedDefresValue(self, value): return ''.join((text_styles.defRes(ProfileUtils.getAvailableValueStr(value) + ' '), icons.nut()))
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 _createTableHeader(self): return [ self._createTableBtnInfo( FORTIFICATIONS.CLANLISTWINDOW_TABLE_MEMBERNAME, "userName", 140, 0, TOOLTIPS.FORTIFICATION_FIXEDPLAYERS_NIC, TEXT_ALIGN.LEFT, "string", ), self._createTableBtnInfo( FORTIFICATIONS.CLANLISTWINDOW_TABLE_ROLE, "playerRoleID", 199, 1, TOOLTIPS.FORTIFICATION_FIXEDPLAYERS_FORTROLE, TEXT_ALIGN.LEFT, ), self._createTableBtnInfo( i18n.makeString(FORTIFICATIONS.FIXEDPLAYERS_LISTHEADER_FIELDWEEK, icon=icons.nut()), "intWeekMining", 103, 2, TOOLTIPS.FORTIFICATION_FIXEDPLAYERS_WEEK, TEXT_ALIGN.RIGHT, ), self._createTableBtnInfo( i18n.makeString(FORTIFICATIONS.FIXEDPLAYERS_LISTHEADER_FIELDALLTIME, icon=icons.nut()), "intTotalMining", 103, 2, TOOLTIPS.FORTIFICATION_FIXEDPLAYERS_ALLTIME, TEXT_ALIGN.RIGHT, ), ]
def __prepareIndicatorData(self, isCanModernization, increment=False, resLeft=0): if increment: hpTotalVal = self.nextLevel.levelRef.hp hpVal = self.nextLevel.hp defResVal = self.__defResVal - self.__cost + resLeft maxDefResVal = self.nextLevel.levelRef.storage else: hpTotalVal = self.__hpTotalVal hpVal = self.__hpVal defResVal = self.__defResVal maxDefResVal = self.__maxDerResVal formatter = text_styles.defRes if self.__progress == FORTIFICATION_ALIASES.STATE_FOUNDATION_DEF or self.__progress == FORTIFICATION_ALIASES.STATE_FOUNDATION: formatter = text_styles.alert if not isCanModernization and increment: currentHpLabel = text_styles.main('--') currentHpValue = 0 else: currentHpLabel = str(BigWorld.wg_getIntegralFormat(hpVal)) currentHpValue = hpVal FORMAT_PATTERN = '###' formattedHpValue = formatter(FORMAT_PATTERN) formatter = text_styles.standard if increment: formatter = text_styles.neutral formattedHpTotal = formatter( str(BigWorld.wg_getIntegralFormat(hpTotalVal))) formattedHpTotal += ' ' + icons.nut() if not isCanModernization and increment: currentDefResLabel = text_styles.main('--') currentDefResValue = 0 else: currentDefResLabel = str(BigWorld.wg_getIntegralFormat(defResVal)) currentDefResValue = defResVal defResValueFormatter = text_styles.alert( FORMAT_PATTERN ) if defResVal > maxDefResVal else text_styles.defRes(FORMAT_PATTERN) formattedDefResTotal = formatter( str(BigWorld.wg_getIntegralFormat(maxDefResVal))) formattedDefResTotal += ' ' + icons.nut() result = {} result['hpLabel'] = i18n.makeString( FORTIFICATIONS.BUILDINGPOPOVER_INDICATORS_HPLBL) result['defResLabel'] = i18n.makeString( FORTIFICATIONS.BUILDINGPOPOVER_INDICATORS_DEFRESLBL) result['hpCurrentValue'] = currentHpValue result['hpTotalValue'] = hpTotalVal result['defResCurrentValue'] = currentDefResValue result['defResTotalValue'] = maxDefResVal result['defResTotalValue'] = maxDefResVal result['defResCompensationValue'] = max(0, defResVal - maxDefResVal) hpProgressLabels = {} hpProgressLabels['currentValue'] = currentHpLabel hpProgressLabels['currentValueFormatter'] = formattedHpValue hpProgressLabels['totalValue'] = formattedHpTotal hpProgressLabels['separator'] = '/' storeProgressLabels = {} storeProgressLabels['currentValue'] = currentDefResLabel storeProgressLabels['currentValueFormatter'] = defResValueFormatter storeProgressLabels['totalValue'] = formattedDefResTotal storeProgressLabels['separator'] = '/' result['hpProgressLabels'] = hpProgressLabels result['defResProgressLabels'] = storeProgressLabels return result
def _packBlocks(self, compensationValue): title = TOOLTIPS.FORTIFICATION_POPOVER_DEFRESPROGRESS_HEADER items = super(FortPopoverDefResTooltipData, self)._packBlocks() items.append(formatters.packTitleDescBlock(text_styles.highTitle(title), desc=text_styles.main(self._descr))) if compensationValue is not None: blocksGap = 12 compensationHeader = text_styles.main(TOOLTIPS.FORTIFICATION_POPOVER_DEFRESPROGRESS_COMPENSATION_HEADER) + text_styles.alert('+' + compensationValue) + icons.nut() compensationBody = text_styles.standard(TOOLTIPS.FORTIFICATION_POPOVER_DEFRESPROGRESS_COMPENSATION_BODY) items.append(formatters.packBuildUpBlockData([formatters.packTextBlockData(text_styles.concatStylesToMultiLine(compensationHeader, compensationBody))], blocksGap, BLOCKS_TOOLTIP_TYPES.TOOLTIP_BUILDUP_BLOCK_WHITE_BG_LINKAGE)) return items