Beispiel #1
0
 def fortPrepareOrder(self):
     currentOrderID = self.fortCtrl.getFort().getBuildingOrder(
         FortViewHelper.getBuildingIDbyUID(self.buildingID))
     from gui import DialogsInterface
     DialogsInterface.showDialog(
         BuyOrderDialogMeta(FortViewHelper.getOrderUIDbyID(currentOrderID)),
         None)
Beispiel #2
0
 def description(self):
     from gui.Scaleform.daapi.view.lobby.fortifications.fort_utils.FortViewHelper import FortViewHelper
     if self.isSpecialMission:
         awardText = i18n.makeString(FORTIFICATIONS.ORDERS_SPECIALMISSION_POSSIBLEAWARD) + ' '
         bonusDescr = i18n.makeString(FORTIFICATIONS.orders_specialmission_possibleaward_description_level(self.level))
         return ''.join((text_styles.neutral(awardText), text_styles.main(bonusDescr)))
     elif self.isConsumable:
         return fort_formatters.getBonusText('', FortViewHelper.getBuildingUIDbyID(self.buildingID), ctx=dict(self.getParams()))
     else:
         effectValueStr = '+' + str(abs(self.effectValue))
         return fort_formatters.getBonusText('%s%%' % effectValueStr, FortViewHelper.getBuildingUIDbyID(self.buildingID))
Beispiel #3
0
 def description(self):
     from gui.Scaleform.daapi.view.lobby.fortifications.fort_utils.FortViewHelper import FortViewHelper
     if self.isSpecialMission:
         awardText = i18n.makeString(FORTIFICATIONS.ORDERS_SPECIALMISSION_POSSIBLEAWARD) + ' '
         bonusDescr = i18n.makeString(FORTIFICATIONS.orders_specialmission_possibleaward_description_level(self.level))
         return self.app.utilsManager.textManager.concatStyles(((TEXT_MANAGER_STYLES.NEUTRAL_TEXT, awardText), (TEXT_MANAGER_STYLES.MAIN_TEXT, bonusDescr)))
     elif self.isConsumable:
         return fort_formatters.getBonusText('', FortViewHelper.getBuildingUIDbyID(self.buildingID), ctx=dict(self.getParams()))
     else:
         effectValueStr = '+' + str(abs(self.effectValue))
         return fort_formatters.getBonusText('%s%%' % effectValueStr, FortViewHelper.getBuildingUIDbyID(self.buildingID))
Beispiel #4
0
 def description(self):
     from gui.Scaleform.daapi.view.lobby.fortifications.fort_utils.FortViewHelper import FortViewHelper
     if self.isSpecialMission:
         awardText = i18n.makeString(FORTIFICATIONS.ORDERS_SPECIALMISSION_POSSIBLEAWARD) + ' '
         bonusDescr = i18n.makeString(FORTIFICATIONS.orders_specialmission_possibleaward_description_level(self.level))
         return ''.join((text_styles.neutral(awardText), text_styles.main(bonusDescr)))
     elif self.isConsumable:
         return fort_formatters.getBonusText('', FortViewHelper.getBuildingUIDbyID(self.buildingID), ctx=dict(self.getParams()))
     else:
         effectValueStr = '+' + str(abs(self.effectValue))
         return fort_formatters.getBonusText('%s%%' % effectValueStr, FortViewHelper.getBuildingUIDbyID(self.buildingID))
    def updateList(self):
        directions = []
        openedDirectionsCount = len(self.fortCtrl.getFort().getOpenedDirections())
        fightsForDirections = self.fortCtrl.getFort().getDirectionsInBattle()
        for direction in range(1, g_fortCache.maxDirections + 1):
            buildings = self.fortCtrl.getFort().getBuildingsByDirections().get(direction)
            isOpened = buildings is not None
            inBattle = direction in fightsForDirections
            canBeClosed = isOpened and not inBattle and findFirst(lambda b: b is not None, buildings) is None
            buildingsData = []
            if isOpened:
                for building in buildings:
                    data = None
                    if building is not None:
                        uid = self.getBuildingUIDbyID(building.typeID)
                        data = {'uid': uid,
                         'progress': self._getProgress(building.typeID, building.level),
                         'toolTipData': [i18n.makeString('#fortifications:Buildings/buildingName/%s' % uid), self.getCommonBuildTooltipData(building)],
                         'iconSource': FortViewHelper.getSmallIconSource(uid, building.level)}
                    buildingsData.append(data)

            directions.append({'uid': direction,
             'fullName': i18n.makeString('#fortifications:General/direction', value=i18n.makeString('#fortifications:General/directionName%d' % direction)),
             'isOpened': isOpened,
             'canBeClosed': canBeClosed,
             'closeButtonVisible': isOpened and openedDirectionsCount > 1,
             'buildings': buildingsData})

        self.as_setDirectionsS(directions)
        return
 def __listFields(self, id, name, shortDescr, status, buildingStatus, isNewItem):
     return {'buildingID': id,
      'buildingName': name,
      'shortDescr': shortDescr,
      'statusLbl': status,
      'buildingStatus': buildingStatus,
      'isNewItem': isNewItem,
      'buildingIcon': FortViewHelper.getSmallIconSource(id, FORT_BATTLE_DIVISIONS.ABSOLUTE.maxFortLevel)}
 def __listFields(self, id, name, shortDescr, status, buildingStatus, isNewItem):
     return {'buildingID': id,
      'buildingName': name,
      'shortDescr': shortDescr,
      'statusLbl': status,
      'buildingStatus': buildingStatus,
      'isNewItem': isNewItem,
      'buildingIcon': FortViewHelper.getSmallIconSource(id, FORT_BATTLE_DIVISIONS.ABSOLUTE.maxFortLevel)}
 def requestBuildingInfo(self, uid):
     infoData = {}
     id = self.getBuildingIDbyUID(uid)
     self.__markAsVisited(id)
     buildingStatus = self.__getBuildingStatus(id)
     infoData['buildingName'] = text_styles.highTitle(
         i18n.makeString(FORTIFICATIONS.buildings_buildingname(uid)))
     infoData['buildingID'] = uid
     infoData['longDescr'] = text_styles.standard(
         i18n.makeString(FORTIFICATIONS.buildingsprocess_longdescr(uid)))
     buttonLbl = FORTIFICATIONS.BUILDINGSPROCESS_BUTTONLBL
     if buildingStatus == self.BUILDING_STATUS.BUILT:
         buttonLbl = text_styles.standard(
             i18n.makeString(
                 FORTIFICATIONS.BUILDINGSPROCESS_BUTTONLBLBUILT))
     infoData['buttonLabel'] = i18n.makeString(buttonLbl)
     infoData['orderInfo'] = self.__makeOrderInfoData(uid)
     isVisibleBtn = True
     isEnableBtn = True
     statusMsg = ''
     statusIconTooltip = None
     if buildingStatus == self.BUILDING_STATUS.BUILT:
         statusMsg = ''.join(
             (icons.checkmark(),
              text_styles.success(
                  i18n.makeString(
                      FORTIFICATIONS.BUILDINGSPROCESS_STATUSMSG_BUILT))))
         isEnableBtn = False
         isVisibleBtn = False
         statusIconTooltip = self.__makeStatusTooltip(True)
         buttonTooltip = self.__makeButtonTooltip(
             self.BUILDING_STATUS.BUILT, None)
     elif buildingStatus == self.BUILDING_STATUS.NOT_AVAILABLE:
         isEnableBtn = False
         isVisibleBtn = True
         statusMsg = text_styles.error(
             i18n.makeString(FORTIFICATIONS.
                             BUILDINGSPROCESS_BUILDINGINFO_STATUSMESSAGE))
         imageSource = icons.makeImageTag(
             RES_ICONS.MAPS_ICONS_LIBRARY_REDNOTAVAILABLE, 12, 12, 0, 0)
         statusMsg = imageSource + ' ' + statusMsg
         statusIconTooltip = self.__makeStatusTooltip(False)
         buttonTooltip = self.__makeButtonTooltip(
             self.BUILDING_STATUS.NOT_AVAILABLE, None)
     else:
         buttonTooltip = self.__makeButtonTooltip(
             self.BUILDING_STATUS.AVAILABLE,
             i18n.makeString(FORTIFICATIONS.buildings_buildingname(uid)))
     infoData['isVisibleBtn'] = isVisibleBtn
     infoData['isEnableBtn'] = isEnableBtn
     infoData['statusMsg'] = statusMsg
     infoData['statusIconTooltip'] = statusIconTooltip
     infoData['buttonTooltip'] = buttonTooltip
     buildingIcon = FortViewHelper.getPopoverIconSource(
         uid, FORT_BATTLE_DIVISIONS.ABSOLUTE.maxFortLevel)
     infoData['buildingIcon'] = buildingIcon
     self.as_responseBuildingInfoS(infoData)
     return
Beispiel #9
0
    def updateList(self):
        directions = []
        openedDirectionsCount = len(
            self.fortCtrl.getFort().getOpenedDirections())
        fightsForDirections = self.fortCtrl.getFort().getDirectionsInBattle()
        for direction in range(1, g_fortCache.maxDirections + 1):
            buildings = self.fortCtrl.getFort().getBuildingsByDirections().get(
                direction)
            isOpened = buildings is not None
            inBattle = direction in fightsForDirections
            canBeClosed = isOpened and not inBattle and findFirst(
                lambda b: b is not None, buildings) is None
            buildingsData = []
            if isOpened:
                for building in buildings:
                    data = None
                    if building is not None:
                        uid = self.getBuildingUIDbyID(building.typeID)
                        data = {
                            'uid':
                            uid,
                            'progress':
                            self._getProgress(building.typeID, building.level),
                            'toolTipData': [
                                i18n.makeString(
                                    '#fortifications:Buildings/buildingName/%s'
                                    % uid),
                                self.getCommonBuildTooltipData(building)
                            ],
                            'iconSource':
                            FortViewHelper.getSmallIconSource(
                                uid, building.level)
                        }
                    buildingsData.append(data)

            directions.append({
                'uid':
                direction,
                'fullName':
                i18n.makeString('#fortifications:General/direction',
                                value=i18n.makeString(
                                    '#fortifications:General/directionName%d' %
                                    direction)),
                'isOpened':
                isOpened,
                'canBeClosed':
                canBeClosed,
                'closeButtonVisible':
                isOpened and openedDirectionsCount > 1,
                'buildings':
                buildingsData
            })

        self.as_setDirectionsS(directions)
        return
Beispiel #10
0
 def __makeBuildingData(self, buildingID, isAttack, level, isLooted, isAvailable):
     (curBuildingId, _, _), curBuildingIsAttack = self.__currentBuilding
     fort = self.fortCtrl.getFort()
     inProcess, _ = fort.getDefenceHourProcessing()
     isDefenceOn = fort.isDefenceHourEnabled() or inProcess
     uid = self.getBuildingUIDbyID(buildingID)
     return {'uid': uid,
      'progress': self._getProgress(buildingID, level),
      'buildingLevel': level,
      'underAttack': curBuildingId == buildingID and curBuildingIsAttack == isAttack,
      'looted': isLooted,
      'isAvailable': isAvailable,
      'iconSource': FortViewHelper.getSmallIconSource(uid, level, isDefenceOn)}
Beispiel #11
0
    def __getDirectionBuildings(self, direction):
        buildings = [None, None]
        for buildingID, buildingData in self.__item.getDictBuildingsBrief().iteritems():
            dir = getDirectionFromDirPos(buildingData['dirPosByte'])
            if direction == dir:
                pos = getPositionFromDirPos(buildingData['dirPosByte'])
                level = buildingData['level']
                uid = self.getBuildingUIDbyID(buildingID)
                buildings[pos] = {'uid': uid,
                 'progress': self._getProgress(buildingID, level),
                 'buildingLevel': level,
                 'iconSource': FortViewHelper.getSmallIconSource(uid, level)}

        return buildings
Beispiel #12
0
 def __makeBuildingData(self, buildingID, isAttack, level, isLooted, isAvailable):
     (curBuildingId, _, _), curBuildingIsAttack = self.__currentBuilding
     fort = self.fortCtrl.getFort()
     inProcess, _ = fort.getDefenceHourProcessing()
     isDefenceOn = fort.isDefenceHourEnabled() or inProcess
     uid = self.getBuildingUIDbyID(buildingID)
     return {
         "uid": uid,
         "progress": self._getProgress(buildingID, level),
         "buildingLevel": level,
         "underAttack": curBuildingId == buildingID and curBuildingIsAttack == isAttack,
         "looted": isLooted,
         "isAvailable": isAvailable,
         "iconSource": FortViewHelper.getSmallIconSource(uid, level, isDefenceOn),
     }
 def __makeSettingsBlockVO(self, isTopBlock):
     if isTopBlock:
         minFortLevel = FORT_BATTLE_DIVISIONS.CHAMPION.minFortLevel
         maxFortLevel = FORT_BATTLE_DIVISIONS.CHAMPION.maxFortLevel
         defenceTankIcon = attackTankIconTop = self.__makeTankIconVO(
             False, FORT_BATTLE_DIVISIONS.CHAMPION.maxCombatants,
             RES_ICONS.MAPS_ICONS_LIBRARY_USA_A12_T32,
             fort_formatters.getIconLevel(
                 FORT_BATTLE_DIVISIONS.CHAMPION.iconLevel),
             FORT_BATTLE_DIVISIONS.CHAMPION.divisionID)
         attackTankIconBottom = self.__makeTankIconVO(
             True, FORT_BATTLE_DIVISIONS.ABSOLUTE.maxCombatants,
             RES_ICONS.MAPS_ICONS_LIBRARY_FORTIFICATION_USSR_T62A,
             fort_formatters.getIconLevel(
                 FORT_BATTLE_DIVISIONS.ABSOLUTE.iconLevel),
             FORT_BATTLE_DIVISIONS.ABSOLUTE.divisionID)
     else:
         minFortLevel = FORT_BATTLE_DIVISIONS.ABSOLUTE.minFortLevel
         maxFortLevel = FORT_BATTLE_DIVISIONS.ABSOLUTE.maxFortLevel
         defenceTankIcon = attackTankIconTop = self.__makeTankIconVO(
             False, FORT_BATTLE_DIVISIONS.ABSOLUTE.maxCombatants,
             RES_ICONS.MAPS_ICONS_LIBRARY_FORTIFICATION_USSR_T62A,
             fort_formatters.getIconLevel(
                 FORT_BATTLE_DIVISIONS.ABSOLUTE.iconLevel),
             FORT_BATTLE_DIVISIONS.ABSOLUTE.divisionID)
         attackTankIconBottom = self.__makeTankIconVO(
             True, FORT_BATTLE_DIVISIONS.CHAMPION.maxCombatants,
             RES_ICONS.MAPS_ICONS_LIBRARY_USA_A12_T32,
             fort_formatters.getIconLevel(
                 FORT_BATTLE_DIVISIONS.CHAMPION.iconLevel),
             FORT_BATTLE_DIVISIONS.CHAMPION.divisionID)
     return {
         'startLvlSrc':
         fort_formatters.getIconLevel(minFortLevel),
         'endLvlSrc':
         fort_formatters.getIconLevel(maxFortLevel),
         'buildingIcon':
         FortViewHelper.getSmallIconSource(
             FORTIFICATION_ALIASES.FORT_BASE_BUILDING, maxFortLevel),
         'lvlDashTF':
         text_styles.stats('-'),
         'defenceTankIcon':
         defenceTankIcon,
         'attackTankIconTop':
         attackTankIconTop,
         'attackTankIconBottom':
         attackTankIconBottom
     }
Beispiel #14
0
 def _generateOptions(self):
     result = []
     buildingDescr = self.fortCtrl.getFort().getBuilding(FortViewHelper.getBuildingIDbyUID(self.buildingID))
     if buildingDescr is not None and self.fortCtrl.getPermissions().canViewContext():
         canModernization = self._canModernization(buildingDescr)
         enableModernizationBtn = self._isEnableModernizationBtnByProgress(buildingDescr) and self._isEnableModernizationBtnByDamaged(buildingDescr)
         if self._isMilitaryBase(buildingDescr.typeID):
             if self._isVisibleDirectionCtrlBtn(buildingDescr):
                 result.append(self._makeItem(FORTIFICATION_ALIASES.CTX_ACTION_DIRECTION_CONTROL, MENU.FORTIFICATIONCTX_DIRECTIONCONTROL, {'enabled': self._isEnableDirectionControl()}))
         elif self._isVisibleActionBtn(buildingDescr):
             result.append(self._makeItem(FORTIFICATION_ALIASES.CTX_ACTION_PREPARE_ORDER, MENU.FORTIFICATIONCTX_PREPAREORDER, {'enabled': self._isEnableActionBtn(buildingDescr)}))
         result.append(self._makeItem(FORTIFICATION_ALIASES.CTX_ACTION_ASSIGN_PLAYERS, MENU.FORTIFICATIONCTX_ASSIGNEDPLAYERS))
         if canModernization:
             result.append(self._makeItem(FORTIFICATION_ALIASES.CTX_ACTION_MODERNIZATION, MENU.FORTIFICATIONCTX_MODERNIZATION, {'enabled': enableModernizationBtn}))
         if not self._isMilitaryBase(buildingDescr.typeID) and self._isVisibleDemountBtn(buildingDescr):
             result.append(self._makeItem(FORTIFICATION_ALIASES.CTX_ACTION_DESTROY, MENU.FORTIFICATIONCTX_DESTROY, {'enabled': self._isEnableDemountBtn(buildingDescr)}))
     return result
 def __makeSettingsBlockVO(self, isTopBlock):
     if isTopBlock:
         minFortLevel = FORT_BATTLE_DIVISIONS.CHAMPION.minFortLevel
         maxFortLevel = FORT_BATTLE_DIVISIONS.CHAMPION.maxFortLevel
         defenceTankIcon = attackTankIconTop = self.__makeTankIconVO(False, FORT_BATTLE_DIVISIONS.CHAMPION.maxCombatants, RES_ICONS.MAPS_ICONS_LIBRARY_USA_A12_T32, fort_formatters.getIconLevel(FORT_BATTLE_DIVISIONS.CHAMPION.iconLevel), FORT_BATTLE_DIVISIONS.CHAMPION.divisionID)
         attackTankIconBottom = self.__makeTankIconVO(True, FORT_BATTLE_DIVISIONS.ABSOLUTE.maxCombatants, RES_ICONS.MAPS_ICONS_LIBRARY_FORTIFICATION_USSR_T62A, fort_formatters.getIconLevel(FORT_BATTLE_DIVISIONS.ABSOLUTE.iconLevel), FORT_BATTLE_DIVISIONS.ABSOLUTE.divisionID)
     else:
         minFortLevel = FORT_BATTLE_DIVISIONS.ABSOLUTE.minFortLevel
         maxFortLevel = FORT_BATTLE_DIVISIONS.ABSOLUTE.maxFortLevel
         defenceTankIcon = attackTankIconTop = self.__makeTankIconVO(False, FORT_BATTLE_DIVISIONS.ABSOLUTE.maxCombatants, RES_ICONS.MAPS_ICONS_LIBRARY_FORTIFICATION_USSR_T62A, fort_formatters.getIconLevel(FORT_BATTLE_DIVISIONS.ABSOLUTE.iconLevel), FORT_BATTLE_DIVISIONS.ABSOLUTE.divisionID)
         attackTankIconBottom = self.__makeTankIconVO(True, FORT_BATTLE_DIVISIONS.CHAMPION.maxCombatants, RES_ICONS.MAPS_ICONS_LIBRARY_USA_A12_T32, fort_formatters.getIconLevel(FORT_BATTLE_DIVISIONS.CHAMPION.iconLevel), FORT_BATTLE_DIVISIONS.CHAMPION.divisionID)
     return {'startLvlSrc': fort_formatters.getIconLevel(minFortLevel),
      'endLvlSrc': fort_formatters.getIconLevel(maxFortLevel),
      'buildingIcon': FortViewHelper.getSmallIconSource(FORTIFICATION_ALIASES.FORT_BASE_BUILDING, maxFortLevel),
      'lvlDashTF': text_styles.stats('-'),
      'defenceTankIcon': defenceTankIcon,
      'attackTankIconTop': attackTankIconTop,
      'attackTankIconBottom': attackTankIconBottom}
 def requestBuildingInfo(self, uid):
     infoData = {}
     id = self.getBuildingIDbyUID(uid)
     self.__markAsVisited(id)
     buildingStatus = self.__getBuildingStatus(id)
     infoData['buildingName'] = text_styles.highTitle(i18n.makeString(FORTIFICATIONS.buildings_buildingname(uid)))
     infoData['buildingID'] = uid
     infoData['longDescr'] = text_styles.standard(i18n.makeString(FORTIFICATIONS.buildingsprocess_longdescr(uid)))
     buttonLbl = FORTIFICATIONS.BUILDINGSPROCESS_BUTTONLBL
     if buildingStatus == self.BUILDING_STATUS.BUILT:
         buttonLbl = text_styles.standard(i18n.makeString(FORTIFICATIONS.BUILDINGSPROCESS_BUTTONLBLBUILT))
     infoData['buttonLabel'] = i18n.makeString(buttonLbl)
     infoData['orderInfo'] = self.__makeOrderInfoData(uid)
     isVisibleBtn = True
     isEnableBtn = True
     statusMsg = ''
     statusIconTooltip = None
     if buildingStatus == self.BUILDING_STATUS.BUILT:
         statusMsg = ''.join((icons.checkmark(), text_styles.success(i18n.makeString(FORTIFICATIONS.BUILDINGSPROCESS_STATUSMSG_BUILT))))
         isEnableBtn = False
         isVisibleBtn = False
         statusIconTooltip = self.__makeStatusTooltip(True)
         buttonTooltip = self.__makeButtonTooltip(self.BUILDING_STATUS.BUILT, None)
     elif buildingStatus == self.BUILDING_STATUS.NOT_AVAILABLE:
         isEnableBtn = False
         isVisibleBtn = True
         statusMsg = text_styles.error(i18n.makeString(FORTIFICATIONS.BUILDINGSPROCESS_BUILDINGINFO_STATUSMESSAGE))
         imageSource = icons.makeImageTag(RES_ICONS.MAPS_ICONS_LIBRARY_REDNOTAVAILABLE, 12, 12, 0, 0)
         statusMsg = imageSource + ' ' + statusMsg
         statusIconTooltip = self.__makeStatusTooltip(False)
         buttonTooltip = self.__makeButtonTooltip(self.BUILDING_STATUS.NOT_AVAILABLE, None)
     else:
         buttonTooltip = self.__makeButtonTooltip(self.BUILDING_STATUS.AVAILABLE, i18n.makeString(FORTIFICATIONS.buildings_buildingname(uid)))
     infoData['isVisibleBtn'] = isVisibleBtn
     infoData['isEnableBtn'] = isEnableBtn
     infoData['statusMsg'] = statusMsg
     infoData['statusIconTooltip'] = statusIconTooltip
     infoData['buttonTooltip'] = buttonTooltip
     buildingIcon = FortViewHelper.getPopoverIconSource(uid, FORT_BATTLE_DIVISIONS.ABSOLUTE.maxFortLevel)
     infoData['buildingIcon'] = buildingIcon
     self.as_responseBuildingInfoS(infoData)
     return
Beispiel #17
0
 def _generateOptions(self, ctx=None):
     result = []
     buildingDescr = self.fortCtrl.getFort().getBuilding(
         FortViewHelper.getBuildingIDbyUID(self.buildingID))
     if buildingDescr is not None and self.fortCtrl.getPermissions(
     ).canViewContext():
         canModernization = self._canModernization(buildingDescr)
         enableModernizationBtn = self._isEnableModernizationBtnByProgress(
             buildingDescr) and self._isEnableModernizationBtnByDamaged(
                 buildingDescr)
         if self._isMilitaryBase(buildingDescr.typeID):
             if self._isVisibleDirectionCtrlBtn(buildingDescr):
                 result.append(
                     self._makeItem(
                         FORTIFICATION_ALIASES.CTX_ACTION_DIRECTION_CONTROL,
                         MENU.FORTIFICATIONCTX_DIRECTIONCONTROL,
                         {'enabled': self._isEnableDirectionControl()}))
         elif self._isVisibleActionBtn(buildingDescr):
             result.append(
                 self._makeItem(
                     FORTIFICATION_ALIASES.CTX_ACTION_PREPARE_ORDER,
                     MENU.FORTIFICATIONCTX_PREPAREORDER,
                     {'enabled': self._isEnableActionBtn(buildingDescr)}))
         result.append(
             self._makeItem(FORTIFICATION_ALIASES.CTX_ACTION_ASSIGN_PLAYERS,
                            MENU.FORTIFICATIONCTX_ASSIGNEDPLAYERS))
         if canModernization:
             result.append(
                 self._makeItem(
                     FORTIFICATION_ALIASES.CTX_ACTION_MODERNIZATION,
                     MENU.FORTIFICATIONCTX_MODERNIZATION,
                     {'enabled': enableModernizationBtn}))
         if not self._isMilitaryBase(
                 buildingDescr.typeID) and self._isVisibleDemountBtn(
                     buildingDescr):
             result.append(
                 self._makeItem(
                     FORTIFICATION_ALIASES.CTX_ACTION_DESTROY,
                     MENU.FORTIFICATIONCTX_DESTROY,
                     {'enabled': self._isEnableDemountBtn(buildingDescr)}))
     return result
 def __prepareHeaderData(self):
     fort = self.fortCtrl.getFort()
     isDefencePeriodActivated = fort.isDefenceHourEnabled()
     inProcess, _ = fort.getDefenceHourProcessing()
     isDefenceOn = isDefencePeriodActivated or inProcess
     buildingIcon = FortViewHelper.getPopoverIconSource(self._buildingUID, self.__buildingLevel, isDefenceOn=isDefenceOn)
     result = {'buildingName': i18n.makeString(FORT.buildings_buildingname(self._buildingUID)),
      'buildingIcon': buildingIcon}
     buildLevel = self.__convertBuildLevel(self.__buildingLevel)
     result['buildLevel'] = i18n.makeString(FORT.BUILDINGPOPOVER_HEADER_LEVELSLBL, buildLevel=buildLevel)
     upgradeBtnVisible = False
     upgradeBtnEnable = False
     localTooltip = ''
     if self._canModernization(self.__buildingDescr):
         upgradeBtnVisible = upgradeBtnEnable = True
         localTooltip = TOOLTIPS.FORTIFICATION_POPOVER_UPGRADEFOUNDATIONBTN
     if upgradeBtnVisible:
         if not self._isEnableModernizationBtnByDamaged(self.__buildingDescr):
             upgradeBtnEnable = False
             localTooltip = TOOLTIPS.FORTIFICATION_POPOVER_UPGRADEBTN_DISABLEDBYDESTROY
         elif not self._isEnableModernizationBtnByProgress(self.__buildingDescr):
             upgradeBtnEnable = False
             localTooltip = TOOLTIPS.FORTIFICATION_POPOVER_UPGRADEFOUNDATIONBTN_DISABLED
     result['upgradeButtonToolTip'] = localTooltip
     result['showUpgradeButton'] = upgradeBtnVisible
     result['enableUpgradeBtn'] = upgradeBtnEnable
     isVisibleDemountBtn = self._isVisibleDemountBtn(self.__buildingDescr)
     result['isVisibleDemountBtn'] = isVisibleDemountBtn
     if isVisibleDemountBtn:
         result['enableDemountBtn'] = self._isEnableDemountBtn(self.__buildingDescr)
         result['demountBtnTooltip'] = TOOLTIPS.FORTIFICATION_POPOVER_DEMOUNTBTN
     header, body, filterColor = self.__makeHeaderStatusMessage()
     result['titleStatus'] = header
     result['bodyStatus'] = body
     result['glowColor'] = int(filterColor, 16)
     result['isModernization'] = self.__canUpgrade
     result['canDeleteBuilding'] = self.fortCtrl.getPermissions().canDeleteBuilding()
     if self.__progress is ALIAS.STATE_BUILDING and isDefencePeriodActivated:
         nextMapTimestamp, nextMapID, curMapID = self.fortCtrl.getFort().getBuildingMaps(self._buildingID)
         isMapsInfoEnabled = nextMapTimestamp > 0
         if self.__buildingLevel < fortified_regions.g_cache.defenceConditions.minRegionLevel:
             mapIcon = icons.alert()
             mapMsg = text_styles.alert(i18n.makeString(FORT.BUILDINGPOPOVER_MAPINFO_NOBATTLE))
             header = i18n.makeString(TOOLTIPS.FORTIFICATION_FORTBUILDINGCARDPOPOVER_MAPINFO_NOBATTLE_HEADER)
             body = i18n.makeString(TOOLTIPS.FORTIFICATION_FORTBUILDINGCARDPOPOVER_MAPINFO_NOBATTLE_BODY)
             isToolTipSpecial = False
         elif isMapsInfoEnabled:
             currentMapUserName = self.__getMapUserName(curMapID)
             mapIcon = icons.info()
             mapMsg = text_styles.main(currentMapUserName)
             header = i18n.makeString(TOOLTIPS.FORTIFICATION_FORTBUILDINGCARDPOPOVER_MAPINFO_HEADER, currentMap=currentMapUserName)
             body = i18n.makeString(TOOLTIPS.FORTIFICATION_FORTBUILDINGCARDPOPOVER_MAPINFO_BODY, nextMap=self.__getMapUserName(nextMapID), changeDate=BigWorld.wg_getLongDateFormat(nextMapTimestamp), changeTime=BigWorld.wg_getShortTimeFormat(nextMapTimestamp))
             isToolTipSpecial = True
         else:
             mapIcon = mapMsg = ''
             isToolTipSpecial = False
         mapInfo = i18n.makeString(mapIcon + ' ' + mapMsg)
         result['mapInfo'] = mapInfo
         result['isToolTipSpecial'] = isToolTipSpecial
         result['tooltipData'] = {'mapName': header,
          'description': body,
          'imageURL': self.__getMapImage(curMapID)}
     return result
Beispiel #19
0
 def userName(self):
     from gui.Scaleform.daapi.view.lobby.fortifications.fort_utils.FortViewHelper import FortViewHelper
     return i18n.makeString(FORTIFICATIONS.buildings_buildingname(FortViewHelper.getBuildingUIDbyID(self.typeID)))
 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 _updateDirections(self):
        directions = []
        selectedDirection = -1
        fort = self.fortCtrl.getFort()
        inProcess, _ = fort.getDefenceHourProcessing()
        isDefenceOn = fort.isDefenceHourEnabled() or inProcess
        enemyBuildings = [None, None]
        for buildingID, buildingData in self.__item.getDictBuildingsBrief(
        ).iteritems():
            dirId = getDirectionFromDirPos(buildingData['dirPosByte'])
            if self.__direction == dirId:
                pos = getPositionFromDirPos(buildingData['dirPosByte'])
                level = buildingData['level']
                if 0 <= level < 5:
                    isAvailable = False
                else:
                    isAvailable = self.__isBuildingAvailableForAttack(
                        buildingData['hp'],
                        g_fortCache.buildings[buildingID].levels[level].hp)
                uid = self.getBuildingUIDbyID(buildingID)
                enemyBuildings[pos] = {
                    'uid':
                    uid,
                    'progress':
                    self._getProgress(buildingID, level),
                    'buildingLevel':
                    level,
                    'isAvailable':
                    isAvailable,
                    'iconSource':
                    FortViewHelper.getSmallIconSource(uid, level, isDefenceOn)
                }

        enemyDirection = {
            'name':
            _ms('#fortifications:General/directionName%d' % self.__direction),
            'isMine':
            False,
            'buildings':
            enemyBuildings
        }
        for direction in range(1, g_fortCache.maxDirections + 1):
            isOpened = fort.isDirectionOpened(direction)
            isBusy = False
            availableTime = None
            name = _ms('#fortifications:General/directionName%d' % direction)
            ttHeader = _ms(
                FORTIFICATIONS.
                FORTDECLARATIONOFWARWINDOW_ITEM_NOTOPENED_TOOLTIP_HEADER)
            ttBody = _ms(
                FORTIFICATIONS.
                FORTDECLARATIONOFWARWINDOW_ITEM_NOTOPENED_TOOLTIP_BODY)
            infoMessage = ''
            allieBuildings = []
            if isOpened:
                for building in fort.getBuildingsByDirections().get(
                        direction, ()):
                    data = None
                    if building is not None:
                        buildingTypeId = building.typeID
                        uid = self.getBuildingUIDbyID(buildingTypeId)
                        level = building.level
                        data = {
                            'uid':
                            uid,
                            'progress':
                            self._getProgress(buildingTypeId, level),
                            'buildingLevel':
                            level,
                            'isAvailable':
                            self.__isBuildingAvailableForAttack(
                                building.hp, building.levelRef.hp),
                            'iconSource':
                            FortViewHelper.getSmallIconSource(
                                uid, level, isDefenceOn)
                        }
                    allieBuildings.append(data)

                eventTypeID = FORT_EVENT_TYPE.DIR_OPEN_ATTACKS_BASE + direction
                availableTime, _, _ = fort.events.get(eventTypeID,
                                                      (None, None, None))
                if availableTime <= self.__selectedDayStart:
                    availableTime = None
                if availableTime is None:
                    attackerClanName = None
                    todayAttacks = fort.getAttacks(
                        filterFunc=lambda a: self.__selectedDayStart <= a.
                        getStartTime(
                        ) <= self.__selectedDayFinish and a.isPlanned())
                    roamingDateAttacks = fort.getAttacks(
                        filterFunc=lambda a: a.getStartTime() - time_utils.
                        ONE_DAY < self.__defHourStart < a.getStartTime(
                        ) + time_utils.ONE_DAY and a.isPlanned())
                    for attack in todayAttacks + roamingDateAttacks:
                        if direction == attack.getDirection():
                            isBusy = True
                            _, defClanAbbrev, _ = attack.getOpponentClanInfo()
                            attackerClanName = '[%s]' % defClanAbbrev

                    if isBusy:
                        ttHeader = _ms(
                            FORTIFICATIONS.
                            FORTDECLARATIONOFWARWINDOW_ITEM_BUSY_TOOLTIP_HEADER
                        )
                        ttBody = _ms(
                            FORTIFICATIONS.
                            FORTDECLARATIONOFWARWINDOW_ITEM_BUSY_TOOLTIP_BODY,
                            clanName=attackerClanName)
                    else:
                        clanForAttackTag = '[%s]' % self.__item.getClanAbbrev()
                        ttHeader = _ms(
                            FORTIFICATIONS.
                            FORTDECLARATIONOFWARWINDOW_ITEM_ATTACK_TOOLTIP_HEADER,
                            direction=name)
                        ttBody = _ms(
                            FORTIFICATIONS.
                            FORTDECLARATIONOFWARWINDOW_ITEM_ATTACK_TOOLTIP_BODY,
                            direction=name,
                            clanName=clanForAttackTag)
                else:
                    infoMessage = _ms(
                        FORTIFICATIONS.
                        FORTDECLARATIONOFWARWINDOW_DIRECTION_NOTAVAILABLE,
                        date=BigWorld.wg_getShortDateFormat(availableTime))
                    ttHeader = _ms(
                        FORTIFICATIONS.
                        FORTDECLARATIONOFWARWINDOW_ITEM_NOTAVAILABLE_TOOLTIP_HEADER
                    )
                    ttBody = _ms(
                        FORTIFICATIONS.
                        FORTDECLARATIONOFWARWINDOW_ITEM_NOTAVAILABLE_TOOLTIP_BODY,
                        date=BigWorld.wg_getShortDateFormat(availableTime))
                if not isBusy and selectedDirection == -1:
                    selectedDirection = direction
            directions.append({
                'leftDirection': {
                    'name': name,
                    'uid': direction,
                    'isOpened': isOpened,
                    'isBusy': isBusy or availableTime is not None,
                    'buildings': allieBuildings,
                    'ttHeader': ttHeader,
                    'ttBody': ttBody,
                    'infoMessage': infoMessage
                },
                'rightDirection':
                enemyDirection,
                'connectionIcon':
                RES_ICONS.MAPS_ICONS_LIBRARY_FORTIFICATION_OFFENCE
            })

        self.as_setDirectionsS(directions)
        self.as_selectDirectionS(selectedDirection)
        return
Beispiel #22
0
 def userName(self):
     from gui.Scaleform.daapi.view.lobby.fortifications.fort_utils.FortViewHelper import FortViewHelper
     return i18n.makeString('#fortifications:General/orderType/%s' % FortViewHelper.getOrderUIDbyID(self.orderID))
 def __prepareHeaderData(self):
     fort = self.fortCtrl.getFort()
     isDefencePeriodActivated = fort.isDefenceHourEnabled()
     inProcess, _ = fort.getDefenceHourProcessing()
     isDefenceOn = isDefencePeriodActivated or inProcess
     buildingIcon = FortViewHelper.getPopoverIconSource(
         self._buildingUID, self.__buildingLevel, isDefenceOn=isDefenceOn)
     result = {
         'buildingName':
         i18n.makeString(FORT.buildings_buildingname(self._buildingUID)),
         'buildingIcon':
         buildingIcon
     }
     buildLevel = self.__convertBuildLevel(self.__buildingLevel)
     result['buildLevel'] = i18n.makeString(
         FORT.BUILDINGPOPOVER_HEADER_LEVELSLBL, buildLevel=buildLevel)
     upgradeBtnVisible = False
     upgradeBtnEnable = False
     localTooltip = ''
     if self._canModernization(self.__buildingDescr):
         upgradeBtnVisible = upgradeBtnEnable = True
         localTooltip = TOOLTIPS.FORTIFICATION_POPOVER_UPGRADEFOUNDATIONBTN
     if upgradeBtnVisible:
         if not self._isEnableModernizationBtnByDamaged(
                 self.__buildingDescr):
             upgradeBtnEnable = False
             localTooltip = TOOLTIPS.FORTIFICATION_POPOVER_UPGRADEBTN_DISABLEDBYDESTROY
         elif not self._isEnableModernizationBtnByProgress(
                 self.__buildingDescr):
             upgradeBtnEnable = False
             localTooltip = TOOLTIPS.FORTIFICATION_POPOVER_UPGRADEFOUNDATIONBTN_DISABLED
     result['upgradeButtonToolTip'] = localTooltip
     result['showUpgradeButton'] = upgradeBtnVisible
     result['enableUpgradeBtn'] = upgradeBtnEnable
     isVisibleDemountBtn = self._isVisibleDemountBtn(self.__buildingDescr)
     result['isVisibleDemountBtn'] = isVisibleDemountBtn
     if isVisibleDemountBtn:
         result['enableDemountBtn'] = self._isEnableDemountBtn(
             self.__buildingDescr)
         result[
             'demountBtnTooltip'] = TOOLTIPS.FORTIFICATION_POPOVER_DEMOUNTBTN
     header, body, filterColor = self.__makeHeaderStatusMessage()
     result['titleStatus'] = header
     result['bodyStatus'] = body
     result['glowColor'] = int(filterColor, 16)
     result['isModernization'] = self.__canUpgrade
     result['canDeleteBuilding'] = self.fortCtrl.getPermissions(
     ).canDeleteBuilding()
     if self.__progress is ALIAS.STATE_BUILDING and isDefencePeriodActivated:
         nextMapTimestamp, nextMapID, curMapID = self.fortCtrl.getFort(
         ).getBuildingMaps(self._buildingID)
         isMapsInfoEnabled = nextMapTimestamp > 0
         if self.__buildingLevel < fortified_regions.g_cache.defenceConditions.minRegionLevel:
             mapIcon = icons.alert()
             mapMsg = text_styles.alert(
                 i18n.makeString(FORT.BUILDINGPOPOVER_MAPINFO_NOBATTLE))
             header = i18n.makeString(
                 TOOLTIPS.
                 FORTIFICATION_FORTBUILDINGCARDPOPOVER_MAPINFO_NOBATTLE_HEADER
             )
             body = i18n.makeString(
                 TOOLTIPS.
                 FORTIFICATION_FORTBUILDINGCARDPOPOVER_MAPINFO_NOBATTLE_BODY
             )
             isToolTipSpecial = False
         elif isMapsInfoEnabled:
             currentMapUserName = self.__getMapUserName(curMapID)
             mapIcon = icons.info()
             mapMsg = text_styles.main(currentMapUserName)
             header = i18n.makeString(
                 TOOLTIPS.
                 FORTIFICATION_FORTBUILDINGCARDPOPOVER_MAPINFO_HEADER,
                 currentMap=currentMapUserName)
             body = i18n.makeString(
                 TOOLTIPS.
                 FORTIFICATION_FORTBUILDINGCARDPOPOVER_MAPINFO_BODY,
                 nextMap=self.__getMapUserName(nextMapID),
                 changeDate=BigWorld.wg_getLongDateFormat(nextMapTimestamp),
                 changeTime=BigWorld.wg_getShortTimeFormat(
                     nextMapTimestamp))
             isToolTipSpecial = True
         else:
             mapIcon = mapMsg = ''
             isToolTipSpecial = False
         mapInfo = i18n.makeString(mapIcon + ' ' + mapMsg)
         result['mapInfo'] = mapInfo
         result['isToolTipSpecial'] = isToolTipSpecial
         result['tooltipData'] = {
             'mapName': header,
             'description': body,
             'imageURL': self.__getMapImage(curMapID)
         }
     return result
    def _updateDirections(self):
        directions = []
        selectedDirection = -1
        fort = self.fortCtrl.getFort()
        inProcess, _ = fort.getDefenceHourProcessing()
        isDefenceOn = fort.isDefenceHourEnabled() or inProcess
        enemyBuildings = [None, None]
        for buildingID, buildingData in self.__item.getDictBuildingsBrief().iteritems():
            dirId = getDirectionFromDirPos(buildingData['dirPosByte'])
            if self.__direction == dirId:
                pos = getPositionFromDirPos(buildingData['dirPosByte'])
                level = buildingData['level']
                if 0 <= level < 5:
                    isAvailable = False
                else:
                    isAvailable = self.__isBuildingAvailableForAttack(buildingData['hp'], g_fortCache.buildings[buildingID].levels[level].hp)
                uid = self.getBuildingUIDbyID(buildingID)
                enemyBuildings[pos] = {'uid': uid,
                 'progress': self._getProgress(buildingID, level),
                 'buildingLevel': level,
                 'isAvailable': isAvailable,
                 'iconSource': FortViewHelper.getSmallIconSource(uid, level, isDefenceOn)}

        enemyDirection = {'name': _ms('#fortifications:General/directionName%d' % self.__direction),
         'isMine': False,
         'buildings': enemyBuildings}
        for direction in range(1, g_fortCache.maxDirections + 1):
            isOpened = fort.isDirectionOpened(direction)
            isBusy = False
            availableTime = None
            name = _ms('#fortifications:General/directionName%d' % direction)
            ttHeader = _ms(FORTIFICATIONS.FORTDECLARATIONOFWARWINDOW_ITEM_NOTOPENED_TOOLTIP_HEADER)
            ttBody = _ms(FORTIFICATIONS.FORTDECLARATIONOFWARWINDOW_ITEM_NOTOPENED_TOOLTIP_BODY)
            infoMessage = ''
            allieBuildings = []
            if isOpened:
                for building in fort.getBuildingsByDirections().get(direction, ()):
                    data = None
                    if building is not None:
                        buildingTypeId = building.typeID
                        uid = self.getBuildingUIDbyID(buildingTypeId)
                        level = building.level
                        data = {'uid': uid,
                         'progress': self._getProgress(buildingTypeId, level),
                         'buildingLevel': level,
                         'isAvailable': self.__isBuildingAvailableForAttack(building.hp, building.levelRef.hp),
                         'iconSource': FortViewHelper.getSmallIconSource(uid, level, isDefenceOn)}
                    allieBuildings.append(data)

                eventTypeID = FORT_EVENT_TYPE.DIR_OPEN_ATTACKS_BASE + direction
                availableTime, _, _ = fort.events.get(eventTypeID, (None, None, None))
                if availableTime <= self.__selectedDayStart:
                    availableTime = None
                if availableTime is None:
                    attackerClanName = None
                    todayAttacks = fort.getAttacks(filterFunc=lambda a: self.__selectedDayStart <= a.getStartTime() <= self.__selectedDayFinish and a.isPlanned())
                    roamingDateAttacks = fort.getAttacks(filterFunc=lambda a: a.getStartTime() - time_utils.ONE_DAY < self.__defHourStart < a.getStartTime() + time_utils.ONE_DAY and a.isPlanned())
                    for attack in todayAttacks + roamingDateAttacks:
                        if direction == attack.getDirection():
                            isBusy = True
                            _, defClanAbbrev, _ = attack.getOpponentClanInfo()
                            attackerClanName = '[%s]' % defClanAbbrev

                    if isBusy:
                        ttHeader = _ms(FORTIFICATIONS.FORTDECLARATIONOFWARWINDOW_ITEM_BUSY_TOOLTIP_HEADER)
                        ttBody = _ms(FORTIFICATIONS.FORTDECLARATIONOFWARWINDOW_ITEM_BUSY_TOOLTIP_BODY, clanName=attackerClanName)
                    else:
                        clanForAttackTag = '[%s]' % self.__item.getClanAbbrev()
                        ttHeader = _ms(FORTIFICATIONS.FORTDECLARATIONOFWARWINDOW_ITEM_ATTACK_TOOLTIP_HEADER, direction=name)
                        ttBody = _ms(FORTIFICATIONS.FORTDECLARATIONOFWARWINDOW_ITEM_ATTACK_TOOLTIP_BODY, direction=name, clanName=clanForAttackTag)
                else:
                    infoMessage = _ms(FORTIFICATIONS.FORTDECLARATIONOFWARWINDOW_DIRECTION_NOTAVAILABLE, date=BigWorld.wg_getShortDateFormat(availableTime))
                    ttHeader = _ms(FORTIFICATIONS.FORTDECLARATIONOFWARWINDOW_ITEM_NOTAVAILABLE_TOOLTIP_HEADER)
                    ttBody = _ms(FORTIFICATIONS.FORTDECLARATIONOFWARWINDOW_ITEM_NOTAVAILABLE_TOOLTIP_BODY, date=BigWorld.wg_getShortDateFormat(availableTime))
                if not isBusy and selectedDirection == -1:
                    selectedDirection = direction
            directions.append({'leftDirection': {'name': name,
                               'uid': direction,
                               'isOpened': isOpened,
                               'isBusy': isBusy or availableTime is not None,
                               'buildings': allieBuildings,
                               'ttHeader': ttHeader,
                               'ttBody': ttBody,
                               'infoMessage': infoMessage},
             'rightDirection': enemyDirection,
             'connectionIcon': RES_ICONS.MAPS_ICONS_LIBRARY_FORTIFICATION_OFFENCE})

        self.as_setDirectionsS(directions)
        self.as_selectDirectionS(selectedDirection)
        return
Beispiel #25
0
 def fortPrepareOrder(self):
     currentOrderID = self.fortCtrl.getFort().getBuildingOrder(FortViewHelper.getBuildingIDbyUID(self.buildingID))
     from gui import DialogsInterface
     DialogsInterface.showDialog(BuyOrderDialogMeta(FortViewHelper.getOrderUIDbyID(currentOrderID)), None)
     return
Beispiel #26
0
 def userName(self):
     from gui.Scaleform.daapi.view.lobby.fortifications.fort_utils.FortViewHelper import FortViewHelper
     return i18n.makeString('#fortifications:General/orderType/%s' %
                            FortViewHelper.getOrderUIDbyID(self.orderID))
 def userName(self):
     from gui.Scaleform.daapi.view.lobby.fortifications.fort_utils.FortViewHelper import FortViewHelper
     return i18n.makeString(
         FORTIFICATIONS.buildings_buildingname(
             FortViewHelper.getBuildingUIDbyID(self.typeID)))
 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