Exemplo n.º 1
0
 def __checkAvailability(self):
     if not g_eventsCache.getHistoricalBattles():
         LOG_DEBUG('No historical battles available.')
         self.leave(pre_queue_ctx.LeavePreQueueCtx(waitingID='prebattle/leave'))
         return 
     historicalBattle = g_eventsCache.getHistoricalBattles().get(self._settings[PREQUEUE_SETTING_NAME.BATTLE_ID])
     if historicalBattle is None:
         LOG_DEBUG('Currently selected historical battle is no longer available.')
         self.leave(pre_queue_ctx.LeavePreQueueCtx(waitingID='prebattle/leave'))
     else:
         g_currentVehicle.setHistoricalBattle(historicalBattle)
Exemplo n.º 2
0
 def __checkAvailability(self):
     if not g_eventsCache.getHistoricalBattles():
         LOG_DEBUG('No historical battles available.')
         self.leave(
             pre_queue_ctx.LeavePreQueueCtx(waitingID='prebattle/leave'))
         return
     historicalBattle = g_eventsCache.getHistoricalBattles().get(
         self._settings[PREQUEUE_SETTING_NAME.BATTLE_ID])
     if historicalBattle is None:
         LOG_DEBUG(
             'Currently selected historical battle is no longer available.')
         self.leave(
             pre_queue_ctx.LeavePreQueueCtx(waitingID='prebattle/leave'))
     else:
         g_currentVehicle.setHistoricalBattle(historicalBattle)
 def updateFightButton(self):
     battle = g_eventsCache.getHistoricalBattles().get(self.selectedBattleID)
     enabled = False
     tooltip = ''
     if battle.isFuture():
         tooltip = i18n.makeString(TOOLTIPS.HISTORICALBATTLES_FIGHTBUTTON_DISABLED_FUTURE)
     elif self.selectedVehicleID == -1 or not battle.canParticipateWith(self.selectedVehicleID):
         tooltip = i18n.makeString(TOOLTIPS.HISTORICALBATTLES_FIGHTBUTTON_DISABLED_NOVEHICLE)
     else:
         vehicle = g_itemsCache.items.getItemByCD(self.selectedVehicleID)
         price = battle.getShellsLayoutPrice(self.selectedVehicleID)
         selected = self._getSelectedPriceIndex(price)
         enoughGold, enoughCredits = battle.getShellsLayoutPriceStatus(self.selectedVehicleID)[selected]
         if vehicle.isReadyToFight:
             if enoughGold and enoughCredits:
                 tooltip = i18n.makeString(TOOLTIPS.HISTORICALBATTLES_FIGHTBUTTON_ENABLED_DESCRIPTION)
                 enabled = True
             else:
                 tooltip = i18n.makeString(TOOLTIPS.HISTORICALBATTLES_FIGHTBUTTON_DISABLED_MONEY)
         elif not vehicle.isCrewFull:
             tooltip = i18n.makeString(TOOLTIPS.HISTORICALBATTLES_FIGHTBUTTON_DISABLED_CREW)
         elif vehicle.isInBattle:
             tooltip = i18n.makeString(TOOLTIPS.HISTORICALBATTLES_FIGHTBUTTON_DISABLED_INBATTLE)
         elif vehicle.isBroken:
             tooltip = i18n.makeString(TOOLTIPS.HISTORICALBATTLES_FIGHTBUTTON_DISABLED_BROKEN)
     if enabled:
         tooltipHeader = i18n.makeString(TOOLTIPS.HISTORICALBATTLES_FIGHTBUTTON_ENABLED)
     else:
         tooltipHeader = i18n.makeString(TOOLTIPS.HISTORICALBATTLES_FIGHTBUTTON_DISABLED)
     self.as_updateFightButtonS(enabled, tooltipHeader, tooltip, False)
Exemplo n.º 4
0
 def attachStickers(self, model, parentNode, isDamaged):
     self.detachStickers()
     self.__model = model
     self.__parentNode = parentNode
     self.__isDamaged = isDamaged
     self.__parentNode.attach(self.__stickerModel)
     isHBParticipatingVehicle = False
     if self.preQueueFunctional is not None and self.preQueueFunctional.getQueueType() == constants.QUEUE_TYPE.HISTORICAL:
         battleId = self.preQueueFunctional.getSetting(PREQUEUE_SETTING_NAME.BATTLE_ID)
         battle = g_eventsCache.getHistoricalBattles().get(battleId)
         if battle is not None and battle.canParticipateWith(self.__vehicleDescriptor.type.compactDescr):
             isHBParticipatingVehicle = True
     replayCtrl = BattleReplay.g_replayCtrl
     for (slotType, slots,) in self.__slotsByType.iteritems():
         if slotType != SlotTypes.CLAN or self.__clanID == 0 or replayCtrl.isPlaying and replayCtrl.isOffline:
             self.__doAttachStickers(slotType)
         elif slotType == SlotTypes.CLAN:
             arenaBonusType = None
             if hasattr(BigWorld.player(), 'arena'):
                 arenaBonusType = BigWorld.player().arena.bonusType
             if game_control.g_instance.roaming.isInRoaming() or arenaBonusType == constants.ARENA_BONUS_TYPE.HISTORICAL or isHBParticipatingVehicle or self.__isLoadingClanEmblems:
                 continue
             self.__isLoadingClanEmblems = True
             fileCache = Account.g_accountRepository.customFilesCache
             fileServerSettings = Account.g_accountRepository.fileServerSettings
             clan_emblems = fileServerSettings.get('clan_emblems')
             if clan_emblems is None:
                 continue
             url = None
             try:
                 url = clan_emblems['url_template'] % self.__clanID
             except:
                 LOG_ERROR('Failed to attach stickers to the vehicle - server returned incorrect url format: %s' % clan_emblems['url_template'])
                 continue
             fileCache.get(url, self.__onClanEmblemLoaded)
Exemplo n.º 5
0
    def _getHistoricalBattleData(self):
        historicalBattleData = None
        if self.preQueueFunctional.getQueueType() == QUEUE_TYPE.HISTORICAL:
            battleId = self.preQueueFunctional.getSetting(
                PREQUEUE_SETTING_NAME.BATTLE_ID)
            battle = g_eventsCache.getHistoricalBattles().get(battleId)
            if battle is not None:
                vehicle = g_currentVehicle.item
                if battle.canParticipateWith(vehicle.intCD):
                    shellsItems = battle.getShellsLayout(vehicle.intCD)
                    priceString = battle.getShellsLayoutFormatedPrice(
                        vehicle.intCD, self.app.colorManager, True, True)
                    historicalBattleData = {
                        'price': priceString,
                        'shells': [],
                        'battleID': battleId
                    }
                    shells = historicalBattleData['shells']
                    for shell, count in shellsItems:
                        shells.append({
                            'id':
                            str(shell.intCD),
                            'type':
                            shell.type,
                            'label':
                            ITEM_TYPES.shell_kindsabbreviation(shell.type),
                            'icon':
                            '../maps/icons/ammopanel/ammo/%s' %
                            shell.descriptor['icon'][0],
                            'count':
                            count
                        })

        return historicalBattleData
Exemplo n.º 6
0
    def _getVehiclesDescrsList(self):
        vehsList = []
        try:
            from gui.server_events import g_eventsCache
            for qIDs in self.__getQuestByDossierRecord(
                    self._name).getChildren().itervalues():
                for qID in qIDs:
                    counterQuest = g_eventsCache.getQuests().get(qID)
                    histBattleCond = counterQuest.preBattleCond.getConditions(
                    ).find('historicalBattleIDs')
                    allVehsCompDescrs = set()
                    for hID in histBattleCond._battlesIDs:
                        hb = g_eventsCache.getHistoricalBattles().get(hID)
                        if hb is not None:
                            allVehsCompDescrs.update(
                                hb.getVehiclesData().keys())

                    vehsList = filter(
                        lambda intCD: not counterQuest.isCompletedByGroup(
                            intCD), allVehsCompDescrs)
                    break

        except Exception:
            pass

        return vehsList
Exemplo n.º 7
0
    def _getGlobalData(self, data):
        try:
            nation = nations.NAMES[data.getNationID()]
        except IndexError:
            LOG_ERROR('Nation not found', data.getNationID())
            nation = None

        globalData = self._cache['global']
        item = data.getRootItem()
        historicalBattleID = -1
        warningMessage = None
        if data.preQueueFunctional.getQueueType() == QUEUE_TYPE.HISTORICAL:
            selectedVehicleID = data.preQueueFunctional.getSetting(PREQUEUE_SETTING_NAME.SELECTED_VEHICLE_ID)
            if item.intCD == selectedVehicleID:
                battleID = data.preQueueFunctional.getSetting(PREQUEUE_SETTING_NAME.BATTLE_ID)
                historicalBattle = g_eventsCache.getHistoricalBattles().get(battleID)
                if historicalBattle is not None and historicalBattle.canParticipateWith(item.intCD):
                    historicalBattleID = battleID
                    warnText = i18n.makeString(MENU.RESEARCH_STATUS_HISTORICALMODULES)
                    warningMessage = gui.makeHtmlString('html_templates:lobby/research', 'warningMessage', {'text': warnText})
        globalData.update({'enableInstallItems': data.isInstallItemsEnabled(),
         'statusString': data.getRootStatusString(),
         'extraInfo': self._getExtraInfo(data),
         'freeXP': data.getUnlockStats().freeXP,
         'hasNationTree': nation in techtree_dp.g_techTreeDP.getAvailableNations(),
         'warningMessage': warningMessage,
         'historicalBattleID': historicalBattleID})
 def updateStatusMessage(self):
     battle = g_eventsCache.getHistoricalBattles().get(self.selectedBattleID)
     message = ''
     templateName = 'notValid'
     if battle.isFuture():
         templateName = 'notReady'
         message = ''
     elif self.selectedVehicleID == -1:
         templateName = 'notSelected'
         message = i18n.makeString(HISTORICAL_BATTLES.TANKSTATUS_NOTSELECTED)
     elif not battle.canParticipateWith(self.selectedVehicleID):
         message = i18n.makeString(HISTORICAL_BATTLES.TANKSTATUS_NOTVALID)
     else:
         vehicle = g_itemsCache.items.getItemByCD(self.selectedVehicleID)
         if vehicle.isReadyToFight or vehicle.lock == LOCK_REASON.IN_QUEUE:
             templateName = 'ready'
             message = i18n.makeString(HISTORICAL_BATTLES.TANKSTATUS_READY, tankName=vehicle.userName)
         else:
             templateName = 'notReady'
             if not vehicle.isCrewFull:
                 message = i18n.makeString(HISTORICAL_BATTLES.TANKSTATUS_NOTREADY_CREW, tankName=vehicle.userName)
             elif vehicle.isInBattle:
                 message = i18n.makeString(HISTORICAL_BATTLES.TANKSTATUS_NOTREADY_INBATTLE, tankName=vehicle.userName)
             elif vehicle.isBroken:
                 message = i18n.makeString(HISTORICAL_BATTLES.TANKSTATUS_NOTREADY_BROKEN, tankName=vehicle.userName)
     status = makeHtmlString('html_templates:lobby/historicalBattles/tankStatus', templateName, {'message': message})
     self.as_setStatusMessageS(status)
 def updateFightButton(self):
     battle = g_eventsCache.getHistoricalBattles().get(self.selectedBattleID)
     enabled = False
     tooltip = ''
     if battle.isFuture():
         tooltip = i18n.makeString(TOOLTIPS.HISTORICALBATTLES_FIGHTBUTTON_DISABLED_FUTURE)
     elif self.selectedVehicleID == -1 or not battle.canParticipateWith(self.selectedVehicleID):
         tooltip = i18n.makeString(TOOLTIPS.HISTORICALBATTLES_FIGHTBUTTON_DISABLED_NOVEHICLE)
     else:
         vehicle = g_itemsCache.items.getItemByCD(self.selectedVehicleID)
         price = battle.getShellsLayoutPrice(self.selectedVehicleID)
         selected = self._getSelectedPriceIndex(price)
         enoughGold, enoughCredits = battle.getShellsLayoutPriceStatus(self.selectedVehicleID)[selected]
         if vehicle.isReadyToFight:
             if enoughGold and enoughCredits:
                 tooltip = i18n.makeString(TOOLTIPS.HISTORICALBATTLES_FIGHTBUTTON_ENABLED_DESCRIPTION)
                 enabled = True
             else:
                 tooltip = i18n.makeString(TOOLTIPS.HISTORICALBATTLES_FIGHTBUTTON_DISABLED_MONEY)
         elif not vehicle.isCrewFull:
             tooltip = i18n.makeString(TOOLTIPS.HISTORICALBATTLES_FIGHTBUTTON_DISABLED_CREW)
         elif vehicle.isInBattle:
             tooltip = i18n.makeString(TOOLTIPS.HISTORICALBATTLES_FIGHTBUTTON_DISABLED_INBATTLE)
         elif vehicle.isBroken:
             tooltip = i18n.makeString(TOOLTIPS.HISTORICALBATTLES_FIGHTBUTTON_DISABLED_BROKEN)
     if enabled:
         tooltipHeader = i18n.makeString(TOOLTIPS.HISTORICALBATTLES_FIGHTBUTTON_ENABLED)
     else:
         tooltipHeader = i18n.makeString(TOOLTIPS.HISTORICALBATTLES_FIGHTBUTTON_DISABLED)
     self.as_updateFightButtonS(enabled, tooltipHeader, tooltip, False)
 def updateStatusMessage(self):
     battle = g_eventsCache.getHistoricalBattles().get(self.selectedBattleID)
     message = ''
     templateName = 'notValid'
     if battle.isFuture():
         templateName = 'notReady'
         message = ''
     elif self.selectedVehicleID == -1:
         templateName = 'notSelected'
         message = i18n.makeString(HISTORICAL_BATTLES.TANKSTATUS_NOTSELECTED)
     elif not battle.canParticipateWith(self.selectedVehicleID):
         message = i18n.makeString(HISTORICAL_BATTLES.TANKSTATUS_NOTVALID)
     else:
         vehicle = g_itemsCache.items.getItemByCD(self.selectedVehicleID)
         if vehicle.isReadyToFight or vehicle.lock == LOCK_REASON.IN_QUEUE:
             templateName = 'ready'
             message = i18n.makeString(HISTORICAL_BATTLES.TANKSTATUS_READY, tankName=vehicle.userName)
         else:
             templateName = 'notReady'
             if not vehicle.isCrewFull:
                 message = i18n.makeString(HISTORICAL_BATTLES.TANKSTATUS_NOTREADY_CREW, tankName=vehicle.userName)
             elif vehicle.isInBattle:
                 message = i18n.makeString(HISTORICAL_BATTLES.TANKSTATUS_NOTREADY_INBATTLE, tankName=vehicle.userName)
             elif vehicle.isBroken:
                 message = i18n.makeString(HISTORICAL_BATTLES.TANKSTATUS_NOTREADY_BROKEN, tankName=vehicle.userName)
     status = makeHtmlString('html_templates:lobby/historicalBattles/tankStatus', templateName, {'message': message})
     self.as_setStatusMessageS(status)
Exemplo n.º 11
0
 def _getValue(self):
     result = list()
     shell = self._tooltip.item
     configuration = self._tooltip.context.getParamsConfiguration(shell)
     vehicle = configuration.vehicle
     params = configuration.params
     historicalBattleID = configuration.historicalBattleID
     battle = g_eventsCache.getHistoricalBattles().get(historicalBattleID)
     vDescr = vehicle.descriptor if vehicle is not None else None
     vCompDescr = vehicle.intCD if vehicle is not None else None
     if vehicle is not None and battle is not None and battle.canParticipateWith(vCompDescr):
         vDescr = battle.getVehicleModifiedDescr(vehicle)
     result.append([])
     if params:
         result = [ItemsParameters.g_instance.getParameters(shell.descriptor, vDescr)]
     result.append([])
     if vehicle is not None:
         gun = VehicleItem(vDescr.gun)
         vehicleShell = findFirst(lambda s: s.intCD == shell.intCD, vehicle.shells)
         shellCount = vehicleShell.count if vehicleShell else getattr(shell, 'count', 0)
         if battle is not None and battle.canParticipateWith(vCompDescr):
             _, shellCount = findFirst(lambda x: x[0].intCD == shell.intCD, battle.getShellsLayout(vCompDescr), (None, 0))
         result[-1].append({'label': 'ammo',
          'current': shellCount,
          'total': gun.descriptor['maxAmmo']})
     return result
Exemplo n.º 12
0
 def _update(self, state):
     if g_eventsCache.getHistoricalBattles():
         self._isSelected = state.isInPreQueue(QUEUE_TYPE.HISTORICAL)
         self._isDisabled = state.hasLockedState
     else:
         self._isSelected = False
         self._isDisabled = True
     self._isVisible = not self._isDisabled
Exemplo n.º 13
0
 def _update(self, state):
     if g_eventsCache.getHistoricalBattles():
         self._isSelected = state.isInPreQueue(QUEUE_TYPE.HISTORICAL)
         self._isDisabled = state.hasLockedState
     else:
         self._isSelected = False
         self._isDisabled = True
     self._isVisible = not self._isDisabled
Exemplo n.º 14
0
 def _getHistoricalBattleData(self):
     vDescr = None
     if self.preQueueFunctional.getQueueType() == QUEUE_TYPE.HISTORICAL:
         battleId = self.preQueueFunctional.getSetting(PREQUEUE_SETTING_NAME.BATTLE_ID)
         battle = g_eventsCache.getHistoricalBattles().get(battleId)
         if battle is not None:
             vDescr = battle.getVehicleModifiedDescr(g_currentVehicle.item)
     return vDescr
Exemplo n.º 15
0
def packHistoricalBattleElement(battleID):
    from gui.server_events import g_eventsCache
    battles = g_eventsCache.getHistoricalBattles()
    if battleID in battles:
        battleName = battles[battleID].getUserName()
    else:
        battleName = str(battleID)
    return _packIconTextElement(label=battleName)
Exemplo n.º 16
0
def packHistoricalBattleElement(battleID):
    from gui.server_events import g_eventsCache
    battles = g_eventsCache.getHistoricalBattles()
    if battleID in battles:
        battleName = battles[battleID].getUserName()
    else:
        battleName = str(battleID)
    return _packIconTextElement(label=battleName)
Exemplo n.º 17
0
 def _getHistoricalBattleData(self):
     vDescr = None
     if self.preQueueFunctional.getQueueType() == QUEUE_TYPE.HISTORICAL:
         battleId = self.preQueueFunctional.getSetting(
             PREQUEUE_SETTING_NAME.BATTLE_ID)
         battle = g_eventsCache.getHistoricalBattles().get(battleId)
         if battle is not None:
             vDescr = battle.getVehicleModifiedDescr(g_currentVehicle.item)
     return vDescr
Exemplo n.º 18
0
    def onQueueInfoReceived(self, randomsQueueInfo, companiesQueueInfo, historicalQueueInfo):
        if prb_control.isCompany():
            data = {'title': '#menu:prebattle/typesCompaniesTitle',
             'data': list()}
            self.flashObject.as_setPlayers(makeHtmlString('html_templates:lobby/queue/playersLabel', 'teams', {'count': sum(companiesQueueInfo['divisions'])}))
            vDivisions = companiesQueueInfo['divisions']
            if vDivisions is not None:
                vClassesLen = len(vDivisions)
                for vDivision in BattleQueue.DIVISIONS_ORDERED:
                    data['data'].append(('#menu:prebattle/CompaniesTitle/%s' % constants.PREBATTLE_COMPANY_DIVISION_NAMES[vDivision], vDivisions[vDivision] if vDivision < vClassesLen else 0))

                self.as_setListByTypeS(data)
            self.as_showStartS(constants.IS_DEVELOPMENT)
        elif prb_control.isInHistoricalQueue():
            battleID = self.preQueueFunctional.getSetting(PREQUEUE_SETTING_NAME.BATTLE_ID)
            battleData = historicalQueueInfo[battleID]
            battle = g_eventsCache.getHistoricalBattles(False)[battleID]
            teamA = battleData.get(HistoricalBattle.SIDES.A, {})
            teamB = battleData.get(HistoricalBattle.SIDES.B, {})
            countA = sum(teamA.get('by_class', {}).values())
            countB = sum(teamB.get('by_class', {}).values())
            self.flashObject.as_setPlayers(makeHtmlString('html_templates:lobby/queue/playersLabel', 'twoSides', {'sideA': battle.getSideUserName(HistoricalBattle.SIDES.A),
             'countA': countA,
             'sideB': battle.getSideUserName(HistoricalBattle.SIDES.B),
             'countB': countB}))
            data = {'title': '#menu:prebattle/typesTitle',
             'data': []}
            vClassesData = data['data']
            for vClass, message in BattleQueue.TYPES_ORDERED:
                byClassA = teamA.get('by_class', {}).get(vClass, 0)
                byClassB = teamB.get('by_class', {}).get(vClass, 0)
                vClassesData.append((message, byClassA + byClassB))

            self.as_setListByTypeS(data)
        else:
            info = dict(randomsQueueInfo)
            if 'classes' in info:
                vClasses = info['classes']
                vClassesLen = len(vClasses)
            else:
                vClasses = []
                vClassesLen = 0
            self.flashObject.as_setPlayers(makeHtmlString('html_templates:lobby/queue/playersLabel', 'players', {'count': sum(vClasses)}))
            if vClassesLen:
                data = {'title': '#menu:prebattle/typesTitle',
                 'data': []}
                vClassesData = data['data']
                for vClass, message in BattleQueue.TYPES_ORDERED:
                    idx = constants.VEHICLE_CLASS_INDICES[vClass]
                    vClassesData.append((message, vClasses[idx] if idx < vClassesLen else 0))

                self.as_setListByTypeS(data)
            self.as_showStartS(constants.IS_DEVELOPMENT and sum(vClasses) > 1)
        if not self.__inited:
            self.__inited = True
        return
 def onPriceSelected(self, priceIndex):
     battle = g_eventsCache.getHistoricalBattles().get(self.selectedBattleID)
     if battle.canParticipateWith(self.selectedVehicleID):
         self.priceIndex = int(priceIndex)
         price = battle.getShellsLayoutPrice(self.selectedVehicleID)
         isCreditsAmmo = price[self.priceIndex][1] == 0
         storedSetting = self.preQueueFunctional.getSetting(PREQUEUE_SETTING_NAME.PRICE_INDEX, defaultdict(dict))
         storedSetting[self.selectedBattleID][self.selectedVehicleID] = (self.priceIndex, isCreditsAmmo)
         self.preQueueFunctional.changeSetting(PREQUEUE_SETTING_NAME.PRICE_INDEX, storedSetting)
         self.updatePriceStatus()
         self.updateFightButton()
Exemplo n.º 20
0
 def showModuleInfo(self, moduleId):
     if moduleId is None:
         return LOG_ERROR('There is error while attempting to show module info window: ', str(moduleId))
     vehicle = g_currentVehicle.item
     vDescr = vehicle.descriptor
     _, _, battleID = self._getHistoricalBattleData()
     battle = g_eventsCache.getHistoricalBattles().get(battleID)
     if battle is not None and battle.canParticipateWith(vehicle.intCD):
         vDescr = battle.getVehicleModifiedDescr(vehicle)
     self.fireEvent(events.LoadViewEvent(VIEW_ALIAS.MODULE_INFO_WINDOW, getViewName(VIEW_ALIAS.MODULE_INFO_WINDOW, moduleId), {'moduleCompactDescr': str(moduleId),
      'vehicleDescr': vDescr}))
 def onPriceSelected(self, priceIndex):
     battle = g_eventsCache.getHistoricalBattles().get(self.selectedBattleID)
     if battle.canParticipateWith(self.selectedVehicleID):
         self.priceIndex = int(priceIndex)
         price = battle.getShellsLayoutPrice(self.selectedVehicleID)
         isCreditsAmmo = price[self.priceIndex][1] == 0
         storedSetting = self.preQueueFunctional.getSetting(PREQUEUE_SETTING_NAME.PRICE_INDEX, defaultdict(dict))
         storedSetting[self.selectedBattleID][self.selectedVehicleID] = (self.priceIndex, isCreditsAmmo)
         self.preQueueFunctional.changeSetting(PREQUEUE_SETTING_NAME.PRICE_INDEX, storedSetting)
         self.updatePriceStatus()
         self.updateFightButton()
 def updateRemainimgTime(self):
     battle = g_eventsCache.getHistoricalBattles().get(self.selectedBattleID)
     if battle.isFuture():
         timeRemaining = battle.getStartTimeLeft()
     else:
         timeRemaining = battle.getFinishTimeLeft()
     headerTimerText = ''
     footerTimerText = ''
     if battle.isFuture() or timeRemaining <= self.COOLDOWN_TRESHOLD:
         remainingText = time_utils.getTillTimeString(timeRemaining, MENU.TIME_TIMEVALUE)
         headerTimerText = i18n.makeString(HISTORICAL_BATTLES.TIMER_TOSTART if battle.isFuture() else HISTORICAL_BATTLES.TIMER_TOFINISH, time=remainingText)
         footerTimerText = i18n.makeString(HISTORICAL_BATTLES.BATTLESTATUS_REMAININGTIME, time=remainingText)
     self.as_updateTimerS(headerTimerText, footerTimerText)
    def updateCarouselData(self):
        LOG_DEBUG('Historical battles list updated.')
        items = []
        for battle in sorted(g_eventsCache.getHistoricalBattles().itervalues()):
            items.append({'id': battle.getID(),
             'name': battle.getUserName(),
             'image': battle.getIcon(),
             'tooltipHeader': battle.getUserName(),
             'tooltipDescription': battle.getDescription(),
             'isFuture': battle.isFuture()})

        if items:
            self.as_setCarouselDataS(items)
 def updatePriceBlock(self):
     battle = g_eventsCache.getHistoricalBattles().get(self.selectedBattleID)
     if self.selectedVehicleID == -1 or not battle.canParticipateWith(self.selectedVehicleID):
         params = {'value': 0,
          'color': self.app.colorManager.getColorScheme('textColorError').get('rgb'),
          'icon': getAbsoluteUrl(RES_ICONS.MAPS_ICONS_LIBRARY_CREDITSICON_2)}
         data = (makeHtmlString('html_templates:lobby/historicalBattles/ammoStatus', 'priceLabel', params),)
         selected = 0
     else:
         data = battle.getShellsLayoutFormatedPrice(self.selectedVehicleID, self.app.colorManager)
         price = battle.getShellsLayoutPrice(self.selectedVehicleID)
         selected = self._getSelectedPriceIndex(price)
     self.as_setPricesS(data, selected)
 def updatePriceBlock(self):
     battle = g_eventsCache.getHistoricalBattles().get(self.selectedBattleID)
     if self.selectedVehicleID == -1 or not battle.canParticipateWith(self.selectedVehicleID):
         params = {'value': 0,
          'color': self.app.colorManager.getColorScheme('textColorError').get('rgb'),
          'icon': getAbsoluteUrl(RES_ICONS.MAPS_ICONS_LIBRARY_CREDITSICON_2)}
         data = (makeHtmlString('html_templates:lobby/historicalBattles/ammoStatus', 'priceLabel', params),)
         selected = 0
     else:
         data = battle.getShellsLayoutFormatedPrice(self.selectedVehicleID, self.app.colorManager)
         price = battle.getShellsLayoutPrice(self.selectedVehicleID)
         selected = self._getSelectedPriceIndex(price)
     self.as_setPricesS(data, selected)
    def updateCarouselData(self):
        LOG_DEBUG('Historical battles list updated.')
        items = []
        for battle in sorted(g_eventsCache.getHistoricalBattles().itervalues()):
            items.append({'id': battle.getID(),
             'name': battle.getUserName(),
             'image': battle.getIcon(),
             'tooltipHeader': battle.getUserName(),
             'tooltipDescription': battle.getDescription(),
             'isFuture': battle.isFuture()})

        if items:
            self.as_setCarouselDataS(items)
 def updateRemainimgTime(self):
     battle = g_eventsCache.getHistoricalBattles().get(self.selectedBattleID)
     if battle.isFuture():
         timeRemaining = battle.getStartTimeLeft()
     else:
         timeRemaining = battle.getFinishTimeLeft()
     headerTimerText = ''
     footerTimerText = ''
     if battle.isFuture() or timeRemaining <= self.COOLDOWN_TRESHOLD:
         remainingText = time_utils.getTillTimeString(timeRemaining, MENU.TIME_TIMEVALUE)
         headerTimerText = i18n.makeString(HISTORICAL_BATTLES.TIMER_TOSTART if battle.isFuture() else HISTORICAL_BATTLES.TIMER_TOFINISH, time=remainingText)
         footerTimerText = i18n.makeString(HISTORICAL_BATTLES.BATTLESTATUS_REMAININGTIME, time=remainingText)
     self.as_updateTimerS(headerTimerText, footerTimerText)
Exemplo n.º 28
0
 def _getHistoricalBattleData(self):
     modulesData, shellsData = (None, None)
     historicalBattleID = -1
     if self.preQueueFunctional.getQueueType() == QUEUE_TYPE.HISTORICAL:
         battleId = self.preQueueFunctional.getSetting(PREQUEUE_SETTING_NAME.BATTLE_ID)
         battle = g_eventsCache.getHistoricalBattles().get(battleId)
         if battle is not None and g_currentVehicle.isPresent():
             vehicleData = battle.getVehicleData(g_currentVehicle.item.intCD)
             if vehicleData is not None:
                 historicalBattleID = battleId
                 modulesData = battle.getModules(g_currentVehicle.item)
                 shellsData = battle.getShellsLayout(g_currentVehicle.item.intCD)
     return (modulesData, shellsData, historicalBattleID)
Exemplo n.º 29
0
    def attachStickers(self, model, parentNode, isDamaged):
        self.detachStickers()
        self.__model = model
        self.__parentNode = parentNode
        self.__isDamaged = isDamaged
        self.__parentNode.attach(self.__stickerModel)
        isHBParticipatingVehicle = False
        if self.preQueueFunctional is not None and self.preQueueFunctional.getQueueType(
        ) == constants.QUEUE_TYPE.HISTORICAL:
            battleId = self.preQueueFunctional.getSetting(
                PREQUEUE_SETTING_NAME.BATTLE_ID)
            battle = g_eventsCache.getHistoricalBattles().get(battleId)
            if battle is not None and battle.canParticipateWith(
                    self.__vehicleDescriptor.type.compactDescr):
                isHBParticipatingVehicle = True
        replayCtrl = BattleReplay.g_replayCtrl
        for slotType, slots in self.__slotsByType.iteritems():
            if slotType != SlotTypes.CLAN or self.__clanID == 0 or replayCtrl.isPlaying and replayCtrl.isOffline:
                if slotType != SlotTypes.CLAN:
                    self.__doAttachStickers(slotType)
            elif slotType == SlotTypes.CLAN:
                arenaBonusType = None
                if hasattr(BigWorld.player(), 'arena'):
                    arenaBonusType = BigWorld.player().arena.bonusType
                serverSettings = g_lobbyContext.getServerSettings()
                if serverSettings is not None and serverSettings.roaming.isInRoaming(
                ) or arenaBonusType == constants.ARENA_BONUS_TYPE.HISTORICAL or isHBParticipatingVehicle or self.__isLoadingClanEmblems:
                    continue
                self.__isLoadingClanEmblems = True
                accountRep = Account.g_accountRepository
                if accountRep is None:
                    LOG_ERROR(
                        'Failed to attach stickers to the vehicle - account repository is not initialized'
                    )
                    continue
                fileCache = accountRep.customFilesCache
                fileServerSettings = accountRep.fileServerSettings
                clan_emblems = fileServerSettings.get('clan_emblems')
                if clan_emblems is None:
                    continue
                url = None
                try:
                    url = clan_emblems['url_template'] % self.__clanID
                except:
                    LOG_ERROR(
                        'Failed to attach stickers to the vehicle - server returned incorrect url format: %s'
                        % clan_emblems['url_template'])
                    continue

                fileCache.get(url, self.__onClanEmblemLoaded)
 def updateBattleInfo(self):
     battle = g_eventsCache.getHistoricalBattles().get(self.selectedBattleID)
     self.as_setBattleDataS({'id': self.selectedBattleID,
      'name': battle.getUserName(),
      'isFuture': battle.isFuture(),
      'datesInfo': battle.getDatesInfo(),
      'descriptionText': battle.getLongDescription(),
      'mapName': battle.getMapName(),
      'mapImage': battle.getMapIcon(),
      'mapInfo': battle.getMapInfo(),
      'arenaID': battle.getArenaTypeID(),
      'descriptionURL': battle.getDescriptionUrl(),
      'sideA': battle.getSideUserName(HistoricalBattle.SIDES.A),
      'sideB': battle.getSideUserName(HistoricalBattle.SIDES.B)})
     self.initBattleTimer()
Exemplo n.º 31
0
    def getDisplayableData(self, battleID, vehicleID):
        battle = g_eventsCache.getHistoricalBattles().get(battleID)
        shellsItems = battle.getShellsLayout(int(vehicleID))
        priceString = battle.getShellsLayoutFormatedPrice(int(vehicleID), self.app.colorManager, True, True)
        data = {'price': priceString,
         'shells': []}
        shells = data['shells']
        for shell, count in shellsItems:
            shells.append({'id': str(shell.intCD),
             'type': shell.type,
             'label': ITEM_TYPES.shell_kindsabbreviation(shell.type),
             'icon': '../maps/icons/ammopanel/ammo/%s' % shell.descriptor['icon'][0],
             'count': count})

        return data
 def updateBattleInfo(self):
     battle = g_eventsCache.getHistoricalBattles().get(self.selectedBattleID)
     self.as_setBattleDataS({'id': self.selectedBattleID,
      'name': battle.getUserName(),
      'isFuture': battle.isFuture(),
      'datesInfo': battle.getDatesInfo(),
      'descriptionText': battle.getLongDescription(),
      'mapName': battle.getMapName(),
      'mapImage': battle.getMapIcon(),
      'mapInfo': battle.getMapInfo(),
      'arenaID': battle.getArenaTypeID(),
      'descriptionURL': battle.getDescriptionUrl(),
      'sideA': battle.getSideUserName(HistoricalBattle.SIDES.A),
      'sideB': battle.getSideUserName(HistoricalBattle.SIDES.B)})
     self.initBattleTimer()
Exemplo n.º 33
0
 def _getHistoricalBattleData(self):
     modulesData, shellsData = (None, None)
     historicalBattleID = -1
     if self.preQueueFunctional.getQueueType() == QUEUE_TYPE.HISTORICAL:
         battleId = self.preQueueFunctional.getSetting(
             PREQUEUE_SETTING_NAME.BATTLE_ID)
         battle = g_eventsCache.getHistoricalBattles().get(battleId)
         if battle is not None and g_currentVehicle.isPresent():
             vehicleData = battle.getVehicleData(
                 g_currentVehicle.item.intCD)
             if vehicleData is not None:
                 historicalBattleID = battleId
                 modulesData = battle.getModules(g_currentVehicle.item)
                 shellsData = battle.getShellsLayout(
                     g_currentVehicle.item.intCD)
     return (modulesData, shellsData, historicalBattleID)
Exemplo n.º 34
0
 def canPlayerDoAction(self):
     histBattleID = self.getSetting(PREQUEUE_SETTING_NAME.BATTLE_ID)
     vehicleID = g_currentVehicle.item.intCD if g_currentVehicle.isPresent() else None
     historicalBattle = g_eventsCache.getHistoricalBattles().get(histBattleID)
     (priceIndex, _,) = self.getSelectedPrice(histBattleID, vehicleID)
     if historicalBattle is not None and vehicleID is not None:
         if historicalBattle.isFuture():
             return (False, '')
         if not historicalBattle.canParticipateWith(vehicleID):
             return (False, '')
         prices = historicalBattle.getShellsLayoutPrice(vehicleID)
         selected = priceIndex if priceIndex is not None else len(prices) - 1
         (enoughGold, enoughCredits,) = historicalBattle.getShellsLayoutPriceStatus(vehicleID)[selected]
         if not enoughGold or not enoughCredits:
             return (False, '')
         return super(HistoricalQueueFunctional, self).canPlayerDoAction()
     return (False, '')
Exemplo n.º 35
0
    def getDisplayableData(self, battleID):
        templatePath = 'html_templates:lobby/historicalBattles/tooltips'
        template = 'moduleLabel'
        vehicle = g_currentVehicle.item
        battle = g_eventsCache.getHistoricalBattles().get(battleID)
        modules = battle.getModules(vehicle)
        data = {}
        if modules is not None:
            modulesData = []
            for item in modules.itervalues():
                modulesData.append({'type': item.itemTypeName,
                 'label': makeHtmlString(templatePath, template, {'type': item.userType,
                           'name': item.userName})})

            data = {'tankName': vehicle.userName,
             'modules': modulesData}
        return data
Exemplo n.º 36
0
 def showModuleInfo(self, moduleId):
     if moduleId is None:
         return LOG_ERROR(
             'There is error while attempting to show module info window: ',
             str(moduleId))
     vehicle = g_currentVehicle.item
     vDescr = vehicle.descriptor
     _, _, battleID = self._getHistoricalBattleData()
     battle = g_eventsCache.getHistoricalBattles().get(battleID)
     if battle is not None and battle.canParticipateWith(vehicle.intCD):
         vDescr = battle.getVehicleModifiedDescr(vehicle)
     self.fireEvent(
         events.LoadViewEvent(
             VIEW_ALIAS.MODULE_INFO_WINDOW,
             getViewName(VIEW_ALIAS.MODULE_INFO_WINDOW, moduleId), {
                 'moduleCompactDescr': str(moduleId),
                 'vehicleDescr': vDescr
             }))
 def updatePriceStatus(self):
     battle = g_eventsCache.getHistoricalBattles().get(self.selectedBattleID)
     message = ''
     templateName = 'notValid'
     if self.selectedVehicleID == -1:
         message = i18n.makeString(HISTORICAL_BATTLES.AMMOSTATUS_VEHICLENOTSELECTED)
     elif not battle.canParticipateWith(self.selectedVehicleID):
         message = i18n.makeString(HISTORICAL_BATTLES.AMMOSTATUS_VEHICLENOTVALID)
     else:
         vehicle = g_itemsCache.items.getItemByCD(self.selectedVehicleID)
         price = battle.getShellsLayoutPrice(self.selectedVehicleID)
         selected = self._getSelectedPriceIndex(price)
         enoughGold, enoughCredits = battle.getShellsLayoutPriceStatus(self.selectedVehicleID)[selected]
         if enoughGold and enoughCredits:
             templateName = 'valid'
             message = i18n.makeString(HISTORICAL_BATTLES.AMMOSTATUS_NORMAL, tankName=vehicle.userName)
         else:
             message = i18n.makeString(HISTORICAL_BATTLES.AMMOSTATUS_NOTENOUGH, tankName=vehicle.userName)
     status = makeHtmlString('html_templates:lobby/historicalBattles/ammoStatus', templateName, {'message': message})
     self.as_setPriceInfoS(status)
 def updatePriceStatus(self):
     battle = g_eventsCache.getHistoricalBattles().get(self.selectedBattleID)
     message = ''
     templateName = 'notValid'
     if self.selectedVehicleID == -1:
         message = i18n.makeString(HISTORICAL_BATTLES.AMMOSTATUS_VEHICLENOTSELECTED)
     elif not battle.canParticipateWith(self.selectedVehicleID):
         message = i18n.makeString(HISTORICAL_BATTLES.AMMOSTATUS_VEHICLENOTVALID)
     else:
         vehicle = g_itemsCache.items.getItemByCD(self.selectedVehicleID)
         price = battle.getShellsLayoutPrice(self.selectedVehicleID)
         selected = self._getSelectedPriceIndex(price)
         enoughGold, enoughCredits = battle.getShellsLayoutPriceStatus(self.selectedVehicleID)[selected]
         if enoughGold and enoughCredits:
             templateName = 'valid'
             message = i18n.makeString(HISTORICAL_BATTLES.AMMOSTATUS_NORMAL, tankName=vehicle.userName)
         else:
             message = i18n.makeString(HISTORICAL_BATTLES.AMMOSTATUS_NOTENOUGH, tankName=vehicle.userName)
     status = makeHtmlString('html_templates:lobby/historicalBattles/ammoStatus', templateName, {'message': message})
     self.as_setPriceInfoS(status)
Exemplo n.º 39
0
    def _getVehiclesDescrsList(self):
        vehsList = []
        try:
            from gui.server_events import g_eventsCache
            for qIDs in self.__getQuestByDossierRecord(self._name).getChildren().itervalues():
                for qID in qIDs:
                    counterQuest = g_eventsCache.getQuests().get(qID)
                    histBattleCond = counterQuest.preBattleCond.getConditions().find('historicalBattleIDs')
                    allVehsCompDescrs = set()
                    for hID in histBattleCond._battlesIDs:
                        hb = g_eventsCache.getHistoricalBattles().get(hID)
                        if hb is not None:
                            allVehsCompDescrs.update(hb.getVehiclesData().keys())

                    vehsList = filter(lambda intCD: not counterQuest.isCompletedByGroup(intCD), allVehsCompDescrs)
                    break

        except Exception:
            pass

        return vehsList
Exemplo n.º 40
0
 def canPlayerDoAction(self):
     histBattleID = self.getSetting(PREQUEUE_SETTING_NAME.BATTLE_ID)
     vehicleID = g_currentVehicle.item.intCD if g_currentVehicle.isPresent(
     ) else None
     historicalBattle = g_eventsCache.getHistoricalBattles().get(
         histBattleID)
     priceIndex, _ = self.getSelectedPrice(histBattleID, vehicleID)
     if historicalBattle is not None and vehicleID is not None:
         if historicalBattle.isFuture():
             return (False, '')
         if not historicalBattle.canParticipateWith(vehicleID):
             return (False, '')
         prices = historicalBattle.getShellsLayoutPrice(vehicleID)
         selected = priceIndex if priceIndex is not None else len(
             prices) - 1
         enoughGold, enoughCredits = historicalBattle.getShellsLayoutPriceStatus(
             vehicleID)[selected]
         if not enoughGold or not enoughCredits:
             return (False, '')
         return super(HistoricalQueueFunctional, self).canPlayerDoAction()
     return (False, '')
 def initBattleTimer(self):
     battle = g_eventsCache.getHistoricalBattles().get(self.selectedBattleID)
     if battle.isFuture():
         date = battle.getStartDate()
         timeRemaining = battle.getStartTimeLeft()
         ttHeader = i18n.makeString(TOOLTIPS.HISTORICALBATTLES_DATESTATUS_STARTDATE)
         ttBody = i18n.makeString(TOOLTIPS.HISTORICALBATTLES_DATESTATUS_FUTURE, date=date)
     else:
         date = battle.getFinishDate()
         timeRemaining = battle.getFinishTimeLeft()
         ttHeader = i18n.makeString(TOOLTIPS.HISTORICALBATTLES_DATESTATUS_ENDDATE)
         ttBody = i18n.makeString(TOOLTIPS.HISTORICALBATTLES_DATESTATUS_ACTIVE, date=date)
     dateString = makeHtmlString('html_templates:lobby/historicalBattles', 'dateLabel', {'icon': getAbsoluteUrl(RES_ICONS.MAPS_ICONS_BUTTONS_CALENDAR),
      'text': date})
     self.as_setDateS(dateString, ttHeader, ttBody)
     self._clearCallbacks()
     if not battle.isFuture() and timeRemaining > self.COOLDOWN_TRESHOLD:
         self.updateRemainimgTime()
         self.startCooldownCBID = BigWorld.callback(timeRemaining + 1 - self.COOLDOWN_TRESHOLD, self.updateCooldown)
     else:
         self.updateCooldown()
 def initBattleTimer(self):
     battle = g_eventsCache.getHistoricalBattles().get(self.selectedBattleID)
     if battle.isFuture():
         date = battle.getStartDate()
         timeRemaining = battle.getStartTimeLeft()
         ttHeader = i18n.makeString(TOOLTIPS.HISTORICALBATTLES_DATESTATUS_STARTDATE)
         ttBody = i18n.makeString(TOOLTIPS.HISTORICALBATTLES_DATESTATUS_FUTURE, date=date)
     else:
         date = battle.getFinishDate()
         timeRemaining = battle.getFinishTimeLeft()
         ttHeader = i18n.makeString(TOOLTIPS.HISTORICALBATTLES_DATESTATUS_ENDDATE)
         ttBody = i18n.makeString(TOOLTIPS.HISTORICALBATTLES_DATESTATUS_ACTIVE, date=date)
     dateString = makeHtmlString('html_templates:lobby/historicalBattles', 'dateLabel', {'icon': getAbsoluteUrl(RES_ICONS.MAPS_ICONS_BUTTONS_CALENDAR),
      'text': date})
     self.as_setDateS(dateString, ttHeader, ttBody)
     self._clearCallbacks()
     if not battle.isFuture() and timeRemaining > self.COOLDOWN_TRESHOLD:
         self.updateRemainimgTime()
         self.startCooldownCBID = BigWorld.callback(timeRemaining + 1 - self.COOLDOWN_TRESHOLD, self.updateCooldown)
     else:
         self.updateCooldown()
Exemplo n.º 43
0
    def _getHistoricalBattleData(self):
        historicalBattleData = None
        if self.preQueueFunctional.getQueueType() == QUEUE_TYPE.HISTORICAL:
            battleId = self.preQueueFunctional.getSetting(PREQUEUE_SETTING_NAME.BATTLE_ID)
            battle = g_eventsCache.getHistoricalBattles().get(battleId)
            if battle is not None:
                vehicle = g_currentVehicle.item
                if battle.canParticipateWith(vehicle.intCD):
                    shellsItems = battle.getShellsLayout(vehicle.intCD)
                    priceString = battle.getShellsLayoutFormatedPrice(vehicle.intCD, self.app.colorManager, True, True)
                    historicalBattleData = {'price': priceString,
                     'shells': [],
                     'battleID': battleId}
                    shells = historicalBattleData['shells']
                    for shell, count in shellsItems:
                        shells.append({'id': str(shell.intCD),
                         'type': shell.type,
                         'label': ITEM_TYPES.shell_kindsabbreviation(shell.type),
                         'icon': '../maps/icons/ammopanel/ammo/%s' % shell.descriptor['icon'][0],
                         'count': count})

        return historicalBattleData
    def updateVehiclesList(self):
        battle = g_eventsCache.getHistoricalBattles().get(self.selectedBattleID)
        teamARoster = battle.getTeamRoster(HistoricalBattle.SIDES.A)
        teamBRoster = battle.getTeamRoster(HistoricalBattle.SIDES.B)
        teamAVehicles = g_itemsCache.items.getVehicles(REQ_CRITERIA.IN_CD_LIST(teamARoster)).itervalues()
        teamBVehicles = g_itemsCache.items.getVehicles(REQ_CRITERIA.IN_CD_LIST(teamBRoster)).itervalues()

        def sortFunction(a, b):
            if a.isInInventory and not b.isInInventory:
                return -1
            if not a.isInInventory and b.isInInventory:
                return 1
            if a.isReadyToFight and not b.isReadyToFight:
                return -1
            if not a.isReadyToFight and b.isReadyToFight:
                return 1
            return 0

        teamAVehicles = sorted(teamAVehicles, sortFunction)
        teamBVehicles = sorted(teamBVehicles, sortFunction)
        teamAData = map(self._makeVehicleListItemVO, teamAVehicles)
        teamBData = map(self._makeVehicleListItemVO, teamBVehicles)
        self.as_setTeamsDataS(teamAData, teamBData)
    def updateVehiclesList(self):
        battle = g_eventsCache.getHistoricalBattles().get(self.selectedBattleID)
        teamARoster = battle.getTeamRoster(HistoricalBattle.SIDES.A)
        teamBRoster = battle.getTeamRoster(HistoricalBattle.SIDES.B)
        teamAVehicles = g_itemsCache.items.getVehicles(REQ_CRITERIA.IN_CD_LIST(teamARoster)).itervalues()
        teamBVehicles = g_itemsCache.items.getVehicles(REQ_CRITERIA.IN_CD_LIST(teamBRoster)).itervalues()

        def sortFunction(a, b):
            if a.isInInventory and not b.isInInventory:
                return -1
            if not a.isInInventory and b.isInInventory:
                return 1
            if a.isReadyToFight and not b.isReadyToFight:
                return -1
            if not a.isReadyToFight and b.isReadyToFight:
                return 1
            return 0

        teamAVehicles = sorted(teamAVehicles, sortFunction)
        teamBVehicles = sorted(teamBVehicles, sortFunction)
        teamAData = map(self._makeVehicleListItemVO, teamAVehicles)
        teamBData = map(self._makeVehicleListItemVO, teamBVehicles)
        self.as_setTeamsDataS(teamAData, teamBData)
Exemplo n.º 46
0
 def _getValue(self):
     result = list()
     shell = self._tooltip.item
     configuration = self._tooltip.context.getParamsConfiguration(shell)
     vehicle = configuration.vehicle
     params = configuration.params
     historicalBattleID = configuration.historicalBattleID
     battle = g_eventsCache.getHistoricalBattles().get(historicalBattleID)
     vDescr = vehicle.descriptor if vehicle is not None else None
     vCompDescr = vehicle.intCD if vehicle is not None else None
     if vehicle is not None and battle is not None and battle.canParticipateWith(
             vCompDescr):
         vDescr = battle.getVehicleModifiedDescr(vehicle)
     result.append([])
     if params:
         result = [
             ItemsParameters.g_instance.getParameters(
                 shell.descriptor, vDescr)
         ]
     result.append([])
     if vehicle is not None:
         gun = VehicleItem(vDescr.gun)
         vehicleShell = findFirst(lambda s: s.intCD == shell.intCD,
                                  vehicle.shells)
         shellCount = vehicleShell.count if vehicleShell else getattr(
             shell, 'count', 0)
         if battle is not None and battle.canParticipateWith(vCompDescr):
             _, shellCount = findFirst(lambda x: x[0].intCD == shell.intCD,
                                       battle.getShellsLayout(vCompDescr),
                                       (None, 0))
         result[-1].append({
             'label': 'ammo',
             'current': shellCount,
             'total': gun.descriptor['maxAmmo']
         })
     return result
Exemplo n.º 47
0
    def onQueueInfoReceived(self, randomsQueueInfo, companiesQueueInfo, historicalQueueInfo, eventQueueInfo):
        if prb_control.isCompany():
            data = {'title': '#menu:prebattle/typesCompaniesTitle',
             'data': list()}
            self.flashObject.as_setPlayers(makeHtmlString('html_templates:lobby/queue/playersLabel', 'teams', {'count': sum(companiesQueueInfo['divisions'])}))
            vDivisions = companiesQueueInfo['divisions']
            if vDivisions is not None:
                vClassesLen = len(vDivisions)
                for vDivision in BattleQueue.DIVISIONS_ORDERED:
                    data['data'].append(('#menu:prebattle/CompaniesTitle/%s' % constants.PREBATTLE_COMPANY_DIVISION_NAMES[vDivision], vDivisions[vDivision] if vDivision < vClassesLen else 0))

                self.as_setListByTypeS(data)
            self.as_showStartS(constants.IS_DEVELOPMENT)
        elif prb_control.isInHistoricalQueue():
            battleID = self.preQueueFunctional.getSetting(PREQUEUE_SETTING_NAME.BATTLE_ID)
            battleData = historicalQueueInfo[battleID]
            battle = g_eventsCache.getHistoricalBattles(False)[battleID]
            teamA = battleData.get(HistoricalBattle.SIDES.A, {})
            teamB = battleData.get(HistoricalBattle.SIDES.B, {})
            countA = sum(teamA.get('by_class', {}).values())
            countB = sum(teamB.get('by_class', {}).values())
            self.flashObject.as_setPlayers(makeHtmlString('html_templates:lobby/queue/playersLabel', 'twoSides', {'sideA': battle.getSideUserName(HistoricalBattle.SIDES.A),
             'countA': countA,
             'sideB': battle.getSideUserName(HistoricalBattle.SIDES.B),
             'countB': countB}))
            data = {'title': '#menu:prebattle/typesTitle',
             'data': []}
            vClassesData = data['data']
            for vClass, message in BattleQueue.TYPES_ORDERED:
                byClassA = teamA.get('by_class', {}).get(vClass, 0)
                byClassB = teamB.get('by_class', {}).get(vClass, 0)
                vClassesData.append((message, byClassA + byClassB))

            self.as_setListByTypeS(data)
        elif prb_control.isInEventBattlesQueue():
            info = dict(eventQueueInfo)
            vClasses = info.get('classes', [])
            vClassesLen = len(vClasses)
            totalPlayers = info.get('players', 0)
            self.flashObject.as_setPlayers(makeHtmlString('html_templates:lobby/queue/playersLabel', 'players', {'count': totalPlayers}))
            if vClassesLen:
                data = {'title': '#menu:prebattle/typesTitle',
                 'data': []}
                vClassesData = data['data']
                for vClass, message in BattleQueue.TYPES_ORDERED:
                    idx = constants.VEHICLE_CLASS_INDICES[vClass]
                    vClassesData.append((message, vClasses[idx] if idx < vClassesLen else 0))

                self.as_setListByTypeS(data)
        else:
            info = dict(randomsQueueInfo)
            if 'classes' in info:
                vClasses = info['classes']
                vClassesLen = len(vClasses)
            else:
                vClasses = []
                vClassesLen = 0
            self.flashObject.as_setPlayers(makeHtmlString('html_templates:lobby/queue/playersLabel', 'players', {'count': sum(vClasses)}))
            if vClassesLen:
                data = {'title': '#menu:prebattle/typesTitle',
                 'data': []}
                vClassesData = data['data']
                for vClass, message in BattleQueue.TYPES_ORDERED:
                    idx = constants.VEHICLE_CLASS_INDICES[vClass]
                    vClassesData.append((message, vClasses[idx] if idx < vClassesLen else 0))

                self.as_setListByTypeS(data)
            self.as_showStartS(constants.IS_DEVELOPMENT and sum(vClasses) > 1)
        if not self.__inited:
            self.__inited = True
Exemplo n.º 48
0
 def getItemData(self):
     battleID = self.getSetting(PREQUEUE_SETTING_NAME.BATTLE_ID)
     return g_eventsCache.getHistoricalBattles().get(battleID)
 def showFullDescription(self):
     battle = g_eventsCache.getHistoricalBattles().get(self.selectedBattleID)
     game_control.g_instance.browser.load(battle.getDescriptionUrl(), battle.getUserName(), False)
Exemplo n.º 50
0
 def getItemData(self):
     battleID = self.getSetting(PREQUEUE_SETTING_NAME.BATTLE_ID)
     return g_eventsCache.getHistoricalBattles().get(battleID)
Exemplo n.º 51
0
 def _applySettings(self, settings):
     if PREQUEUE_SETTING_NAME.BATTLE_ID in settings:
         historicalBattle = g_eventsCache.getHistoricalBattles().get(settings[PREQUEUE_SETTING_NAME.BATTLE_ID])
         g_currentVehicle.setHistoricalBattle(historicalBattle)
Exemplo n.º 52
0
 def _applySettings(self, settings):
     if PREQUEUE_SETTING_NAME.BATTLE_ID in settings:
         historicalBattle = g_eventsCache.getHistoricalBattles().get(
             settings[PREQUEUE_SETTING_NAME.BATTLE_ID])
         g_currentVehicle.setHistoricalBattle(historicalBattle)
 def showFullDescription(self):
     battle = g_eventsCache.getHistoricalBattles().get(self.selectedBattleID)
     game_control.g_instance.browser.load(battle.getDescriptionUrl(), battle.getUserName(), False)