コード例 #1
0
 def __initData(self):
     fort = self.fortCtrl.getFort()
     self.__battleID = getBattleID()
     self.__battle = fort.getBattle(self.__battleID)
     self.__allBuildings = self.__battle.getAllBuildList()
     if self.__allBuildings:
         self.__prevBuilding = self.__allBuildings[self.__battle.getPrevBuildNum()]
         self.__currentBuilding = self.__allBuildings[self.__battle.getCurrentBuildNum()]
コード例 #2
0
ファイル: fortclanbattleroom.py プロジェクト: webiumsk/WoT
 def __initData(self):
     fort = self.fortCtrl.getFort()
     self.__battleID = getBattleID()
     self.__battle = fort.getBattle(self.__battleID)
     self.__allBuildings = self.__battle.getAllBuildList()
     if self.__allBuildings:
         self.__prevBuilding = self.__allBuildings[self.__battle.getPrevBuildNum()]
         self.__currentBuilding = self.__allBuildings[self.__battle.getCurrentBuildNum()]
コード例 #3
0
 def requestToJoin(self, battleID):
     currentBattleID = getBattleID()
     if currentBattleID == battleID:
         fort_events.showFortBattleRoomWindow()
     else:
         battle = self.fortCtrl.getFort().getBattle(battleID)
         if battle is not None:
             fort_helpers.tryToConnectFortBattle(battleID, battle.getPeripheryID())
         else:
             SystemMessages.pushI18nMessage(SYSTEM_MESSAGES.FORTIFICATION_ERRORS_BATTLE_DOES_NOT_EXIST, type=SystemMessages.SM_TYPE.Error)
     return
コード例 #4
0
 def requestToJoin(self, battleID):
     currentBattleID = getBattleID()
     if currentBattleID == battleID:
         fort_events.showFortBattleRoomWindow()
     else:
         battle = self.fortCtrl.getFort().getBattle(battleID)
         if battle is not None:
             fort_helpers.tryToConnectFortBattle(battleID,
                                                 battle.getPeripheryID())
         else:
             SystemMessages.pushI18nMessage(
                 SYSTEM_MESSAGES.FORTIFICATION_ERRORS_BATTLE_DOES_NOT_EXIST,
                 type=SystemMessages.SM_TYPE.Error)
     self.destroy()
コード例 #5
0
    def __updateData(self):
        fort = self.fortCtrl.getFort()
        battle = fort.getBattle(getBattleID())
        _getText = self.app.utilsManager.textManager.getText
        result = []
        if battle is not None:
            activeConsumes = dict(((otID, slotIdx) for slotIdx, (otID, level) in battle.getActiveConsumables().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 = _getText(TextType.MAIN_TEXT, _ms(FORTIFICATIONS.ORDERSELECTPOPOVER_ORDERLEVEL, orderLevel=orderItem.level))
                if not isBuildingReady:
                    icon = self.app.utilsManager.getHtmlIconText(ImageUrlProperties(RES_ICONS.MAPS_ICONS_LIBRARY_REDNOTAVAILABLE, 16, 16, -2, 0))
                    description = '%s %s' % (icon, _getText(TextType.ERROR_TEXT, _ms(FORTIFICATIONS.ORDERSELECTPOPOVER_NOTAVAILABLE)))
                    orderCountText = ''
                elif not isSelected:
                    description = orderLevelLabel
                    if orderItem.count:
                        orderCountText = _getText(TextType.STANDARD_TEXT, _ms(FORTIFICATIONS.ORDERSELECTPOPOVER_ORDERCOUNT, orderNumber=_getText(TextType.STATS_TEXT, str(orderItem.count))))
                    else:
                        orderCountText = _getText(TextType.STANDARD_TEXT, _ms(FORTIFICATIONS.ORDERSELECTPOPOVER_ORDERCOUNT, orderNumber=orderItem.count))
                else:
                    if isSelectedInThisSlot:
                        description = ''
                    else:
                        description = orderLevelLabel
                    icon = self.app.utilsManager.textManager.getIcon(TextIcons.CHECKMARK_ICON)
                    orderCountText = icon + _getText(TextType.SUCCESS_TEXT, _ms(FORTIFICATIONS.ORDERSELECTPOPOVER_SELECTED))
                result.append({'orderID': orderTypeID,
                 'orderIconSrc': orderItem.icon,
                 'headerText': _getText(TextType.MIDDLE_TITLE, _ms(orderItem.userName)),
                 'descriptionText': description,
                 'orderCountText': orderCountText,
                 'isEnabled': isConsumableEnabled,
                 'isSelected': isSelectedInThisSlot,
                 'showArsenalIcon': showArsenalIcon,
                 'returnBtnLabel': returnBtnLabel})

        self.as_setDataS({'orders': result})
        return
コード例 #6
0
 def handleAction(self, model, entityID, action):
     super(AcceptPrbFortInviteHandler, self).handleAction(model, entityID, action)
     notification = model.collection.getItem(NOTIFICATION_TYPE.MESSAGE, entityID)
     if not notification:
         LOG_ERROR('Notification not found', NOTIFICATION_TYPE.MESSAGE, entityID)
         return
     customData = notification.getSavedData()
     battleID = customData.get('battleID')
     peripheryID = customData.get('peripheryID')
     if battleID is not None and peripheryID is not None:
         if battleID == getBattleID():
             fort_events.showFortBattleRoomWindow()
         else:
             fort_helpers.tryToConnectFortBattle(battleID, peripheryID)
     else:
         LOG_ERROR('Invalid fort battle data', battleID, peripheryID)
コード例 #7
0
    def __updateSlots(self):
        fort = self.fortCtrl.getFort()
        canActivateConsumables = self.fortCtrl.getPermissions().canActivateConsumable() and self.unitFunctional.getPermissions().canChangeConsumables()
        self.__battleID = getBattleID()
        self.__battle = fort.getBattle(self.__battleID)
        result = []
        if self.__battle is not None:
            activeConsumes = self.__battle.getActiveConsumables()
            for slotIdx in xrange(fortified_regions.g_cache.consumablesSlotCount):
                if slotIdx in activeConsumes:
                    orderTypeID, level = activeConsumes[slotIdx]
                    orderItem = fort.getOrder(orderTypeID)
                    result.append(_makeSlotVO(self.getOrderUIDbyID(orderTypeID), slotIdx, fort.getBuilding(orderItem.buildingID).userName, level, orderItem.icon, orderTypeID, not canActivateConsumables))
                elif canActivateConsumables:
                    result.append(_makeEmptySlotVO(slotIdx))

        self.as_setPanelPropsS(dict(self._SLOTS_PROPS))
        self.as_setOrdersS(result)
        return
コード例 #8
0
ファイル: common.py プロジェクト: webiumsk/WoT
 def getDisplayableData(self, buildingUID, isMine):
     ms = i18n.makeString
     fort = self.fortCtrl.getFort()
     battleID = getBattleID()
     battle = fort.getBattle(battleID)
     buildingTypeID = self.getBuildingIDbyUID(buildingUID)
     if battle.isDefence():
         isAttack = not isMine
     else:
         isAttack = isMine
     if isAttack:
         buildingsList = battle.getAttackerBuildList()
         buildingsFullList = battle.getAttackerFullBuildList()
     else:
         buildingsList = battle.getDefenderBuildList()
         buildingsFullList = battle.getDefenderFullBuildList()
     buildingFullData = findFirst(lambda x: x[0] == buildingTypeID, buildingsFullList)
     _, status, buildingLevel, hpVal, defResVal = buildingFullData
     isReadyForBattle = status == constants.FORT_BUILDING_STATUS.READY_FOR_BATTLE
     buildingData = None
     resCount, arenaTypeID = (None, None)
     if isReadyForBattle:
         buildingData = findFirst(lambda x: x[0] == buildingTypeID, buildingsList)
         _, resCount, arenaTypeID = buildingData
     _, status, buildingLevel, hpVal, defResVal = buildingFullData
     progress = self._getProgress(buildingTypeID, buildingLevel)
     normLevel = max(buildingLevel, 1)
     buildingLevelData = fortified_regions.g_cache.buildings[buildingTypeID].levels[normLevel]
     hpTotalVal = buildingLevelData.hp
     maxDefResVal = buildingLevelData.storage
     buildingName = self.app.utilsManager.textManager.getText(TextType.HIGH_TITLE, ms(FORT.buildings_buildingname(buildingUID)))
     currentMapTxt = None
     buildingLevelTxt = self.app.utilsManager.textManager.getText(TextType.MAIN_TEXT, ms(FORT.FORTMAINVIEW_HEADER_LEVELSLBL, buildLevel=str(fort_formatters.getTextLevel(buildingLevel))))
     descrActionTxt = None
     statusTxt = None
     statusLevel = None
     indicatorsModel = None
     infoMessage = None
     if status == constants.FORT_BUILDING_STATUS.LOW_LEVEL:
         minBuildingLevel = fortified_regions.g_cache.defenceConditions.minRegionLevel
         minLevel = fort_formatters.getTextLevel(1)
         maxLevel = fort_formatters.getTextLevel(minBuildingLevel - 1)
         infoMessage = ms(FORT.TOOLTIPBUILDINGINFO_LOWLEVELMESSAGE, minLevel=minLevel, maxLevel=maxLevel)
     else:
         indicatorsModel = makeBuildingIndicatorsVO(buildingLevel, progress, hpVal, hpTotalVal, defResVal, maxDefResVal)
         if isReadyForBattle:
             lootedBuildings = battle.getLootedBuildList()
             battleStatus = self.BATTLE_STATUSES.NO_BATTLE
             if (buildingData, isAttack) in lootedBuildings:
                 battleStatus = self.BATTLE_STATUSES.LOST
                 if battle.isDefence() and isAttack or not battle.isDefence() and not isAttack:
                     battleStatus = self.BATTLE_STATUSES.WON
             arenaType = ArenaType.g_cache.get(arenaTypeID)
             prefix = self.app.utilsManager.textManager.getText(TextType.STANDARD_TEXT, ms(FORT.TOOLTIPBUILDINGINFO_MEP_MAPPREFIX))
             mapName = self.app.utilsManager.textManager.getText(TextType.NEUTRAL_TEXT, arenaType.name)
             currentMapTxt = prefix + mapName
             statusLevel = battleStatus.level
             statusTxt = ms(battleStatus.msg)
             defResStatusTxt = self.app.utilsManager.textManager.concatStyles(((battleStatus.color, '%s %s' % (battleStatus.prefix, BigWorld.wg_getIntegralFormat(resCount))), (TextIcons.NUT_ICON,)))
             descrActionTxt = self.app.utilsManager.textManager.getText(TextType.MAIN_TEXT, ms(FORT.TOOLTIPBUILDINGINFO_DESCRACTION))
             descrActionTxt = descrActionTxt % {'value': defResStatusTxt}
         else:
             minResCount = hpTotalVal * 0.2
             minResStatusTxt = self.app.utilsManager.textManager.concatStyles(((TextType.NEUTRAL_TEXT, BigWorld.wg_getIntegralFormat(minResCount)), (TextIcons.NUT_ICON,)))
             infoMessage = self.app.utilsManager.textManager.getText(TextType.MAIN_TEXT, ms(FORT.TOOLTIPBUILDINGINFO_DESTROYEDMESSAGE))
             infoMessage = infoMessage % {'value': minResStatusTxt}
     result = {'buildingUID': buildingUID,
      'buildingName': buildingName,
      'currentMap': currentMapTxt,
      'buildingLevel': buildingLevelTxt,
      'descrAction': descrActionTxt,
      'statusMsg': statusTxt,
      'statusLevel': statusLevel,
      'indicatorModel': indicatorsModel,
      'isAvailable': isReadyForBattle,
      'infoMessage': infoMessage}
     return result
コード例 #9
0
ファイル: unit_ext.py プロジェクト: webiumsk/WOT0.9.10
 def _getFortBattleTimer(self):
     if self.fortState.getStateID() == CLIENT_FORT_STATE.HAS_FORT:
         fortBattle = self.fortCtrl.getFort().getBattle(getBattleID())
         if fortBattle is not None:
             return fortBattle.getRoundStartTimeLeft()
     return 0
コード例 #10
0
ファイル: unit_ext.py プロジェクト: webiumsk/WOT0.9.10
 def onFortBattleChanged(self, cache, item, battleItem):
     if getBattleID() == battleItem.getID():
         self.startNotification()
コード例 #11
0
ファイル: unit_ext.py プロジェクト: jamesxia4/wot_client
 def _getFortBattleTimer(self):
     if self.fortState.getStateID() == CLIENT_FORT_STATE.HAS_FORT:
         fortBattle = self.fortCtrl.getFort().getBattle(getBattleID())
         if fortBattle is not None:
             return fortBattle.getRoundStartTimeLeft()
     return 0
コード例 #12
0
ファイル: unit_ext.py プロジェクト: jamesxia4/wot_client
 def onFortBattleChanged(self, cache, item, battleItem):
     if getBattleID() == battleItem.getID():
         self.startNotification()