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 __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