예제 #1
0
    def _request(self, callback):
        _logger.debug('Make server request to put on outfit on vehicle %s, outfitData %s', self.vehicle.invID, self.outfitData)
        requestData = []
        c11nService = dependency.instance(ICustomizationService)
        for outfit, season in self.outfitData:
            component = None
            if outfit.style:
                intCD = makeIntCompactDescrByID('customizationItem', CustomizationType.STYLE, outfit.style.id)
                style = self.itemsCache.items.getItemByCD(intCD)
                if style and style.isProgressive:
                    outfit = c11nService.removeAdditionalProgressionData(outfit=outfit, style=style, vehCD=self.vehicle.descriptor.makeCompactDescr(), season=season)
                    component = outfit.pack()
            if component is None:
                component = outfit.pack()
            if component.styleId and isEditedStyle(component):
                intCD = makeIntCompactDescrByID('customizationItem', CustomizationType.STYLE, component.styleId)
                style = self.itemsCache.items.getItemByCD(intCD)
                baseOutfit = style.getOutfit(season, self.vehicle.descriptor.makeCompactDescr())
                baseComponent = baseOutfit.pack()
                component = component.getDiff(baseComponent)
            self.__validateOutfitComponent(component)
            requestData.append((component.makeCompDescr(), season))

        BigWorld.player().shop.buyAndEquipOutfit(self.vehicle.invID, requestData, lambda code: self._response(code, callback))
        return
예제 #2
0
def getOfflineInventory(itemsCache=None):
    data = {i: {} for i in GUI_ITEM_TYPE.ALL()}

    compDescr = {}
    for value in g_list._VehicleList__ids.values():
        vehicle = vehicles.VehicleDescr(typeID=value)
        intCompDescr = vehicles.makeIntCompactDescrByID('vehicle', *value)
        item = Vehicle(typeCompDescr=intCompDescr, proxy=itemsCache.items)

        vDesc = vehicle
        vType = vDesc.type
        turretv = vType.turrets[-1][-1]
        gunv = turretv.guns[-1]

        gunIDv = makeIntCompactDescrByID('vehicleGun', gunv.id[0], gunv.id[1])
        turretIDv = makeIntCompactDescrByID('vehicleTurret', turretv.id[0],
                                            turretv.id[1])
        engineIDv = makeIntCompactDescrByID('vehicleEngine',
                                            vType.engines[-1].id[0],
                                            vType.engines[-1].id[1])
        radioIDv = makeIntCompactDescrByID('vehicleRadio',
                                           vType.radios[-1].id[0],
                                           vType.radios[-1].id[1])
        chassisIDv = makeIntCompactDescrByID('vehicleChassis',
                                             vType.chassis[-1].id[0],
                                             vType.chassis[-1].id[1])

        vDesc.installComponent(chassisIDv)
        vDesc.installComponent(engineIDv)
        vDesc.installTurret(turretIDv, gunIDv)
        vDesc.installComponent(radioIDv)

        if not item.isOnlyForEventBattles and not item.isPremiumIGR:
            compDescr[len(compDescr)] = vDesc.makeCompactDescr()

    data[GUI_ITEM_TYPE.VEHICLE] = {
        'repair': {},
        'lastCrew': {},
        'settings': {},
        'compDescr': compDescr,
        'eqs': {},
        'shells': {},
        'customizationExpiryTime': {},
        'lock': {},
        'shellsLayout': {},
        'vehicle': {}
    }
    data['customizations'] = {False: {}, True: {}}

    return {
        'inventory': data,
    }
 def activateEquipment(self, equipmentID, preferredPos=None):
     equipment = vehs_core.g_cache.equipments()[equipmentID]
     if equipment.clientSelector:
         strikeSelectorConstructor = importClass(equipment.clientSelector, 'AvatarInputHandler.MapCaseMode')
     else:
         typeEq = type(equipment)
         if typeEq in _STRIKE_SELECTORS:
             strikeSelectorConstructor = _STRIKE_SELECTORS.get(type(equipment))
         else:
             cd = makeIntCompactDescrByID('equipment', NONE_INDEX, equipmentID)
             eq = self.guiSessionProvider.shared.equipments.getEquipment(cd)
             if eq is None:
                 return
             strikeSelectorConstructor = eq.getStrikeSelector()
     if strikeSelectorConstructor is None:
         LOG_ERROR('Cannot use equipment with id', equipmentID)
         return
     else:
         self.__activeSelector.destroy()
         pos = preferredPos or self.__getDesiredShotPoint()
         self.__activeSelector = strikeSelectorConstructor(pos, equipment)
         self.camera.aimingSystem.setAimingLimits(self.__activeSelector.aimLimits)
         self.__equipmentID = equipmentID
         replayCtrl = BattleReplay.g_replayCtrl
         if replayCtrl.isRecording:
             replayCtrl.setEquipmentID(equipmentID)
         isVisible = isinstance(BigWorld.player().inputHandler.ctrl, MapCaseControlModeBase)
         self.setGUIVisible(isVisible)
         return
예제 #4
0
 def __onVehicleControlling(self, vehicle):
     if not self.isActive():
         return
     else:
         vTypeDesc = vehicle.typeDescriptor
         vehicleType = vTypeDesc.type.id
         self.__vehicleId = makeIntCompactDescrByID('vehicle',
                                                    vehicleType[0],
                                                    vehicleType[1])
         self.__haveReqLevel = vTypeDesc.level >= _HINT_MIN_VEHICLE_LEVEL
         if vTypeDesc.isWheeledVehicle or vTypeDesc.type.isDualgunVehicleType or vTypeDesc.hasTurboshaftEngine:
             self.__updateHintCounterOnStart(self.__vehicleId, vehicle,
                                             self.__helpHintSettings)
         if self.__canDisplayHelpHint(vTypeDesc):
             self.__displayHint(CommandMapping.CMD_SHOW_HELP)
             return
         if self.__canDisplayBattleCommunicationHint():
             isDisplayed = self.__displayHint(
                 CommandMapping.CMD_CHAT_SHORTCUT_CONTEXT_COMMAND)
             if isDisplayed:
                 self.__battleComHintSettings = self._updateBattleCounterOnUsed(
                     self.__battleComHintSettings)
             return
         if self.__canDisplayQuestHint():
             self.__displayHint(CommandMapping.CMD_QUEST_PROGRESS_SHOW)
             return
         if self.__hintInQueue is not None:
             self._parentObj.removeBtnHint(CommandMapping.CMD_SHOW_HELP)
             self._parentObj.removeBtnHint(
                 CommandMapping.CMD_QUEST_PROGRESS_SHOW)
             self._parentObj.removeBtnHint(
                 CommandMapping.CMD_CHAT_SHORTCUT_CONTEXT_COMMAND)
             self.__callbackDelayer.destroy()
         return
예제 #5
0
    def __getSuitableIntCD(self, unsuitableItem, dependentByType):
        suitableItemIntCD = None
        posUnsuitType = unsuitableItem.descriptor.itemType
        if posUnsuitType == CustomizationType.DECAL:
            originalDecalType = unsuitableItem.descriptor.type
            getItemByCD = self._service.getItemByCD
            for suitableID in dependentByType:
                posiblySuitableIntCD = makeIntCompactDescrByID('customizationItem', posUnsuitType, suitableID)
                suitableItem = getItemByCD(posiblySuitableIntCD)
                if suitableItem.descriptor.type == originalDecalType:
                    suitableItemIntCD = posiblySuitableIntCD
                    break

        else:
            suitableItemIntCD = makeIntCompactDescrByID('customizationItem', posUnsuitType, dependentByType[0])
        return suitableItemIntCD
 def create(cls, component, cType, proxy=None):
     if isComponentComplex(component):
         componentID = component.id
     else:
         componentID = component
     intCD = makeIntCompactDescrByID('customizationItem', cType,
                                     componentID)
     return cls.itemsFactory.createCustomization(intCD, proxy)
예제 #7
0
 def updateC11nProgressionData(self):
     self.__c11nProgressionData = {}
     customizationInvData = self.getCacheValue(GUI_ITEM_TYPE.CUSTOMIZATION, {})
     itemsInvData = customizationInvData.get(CustomizationInvData.PROGRESSION, {})
     for cType, typeInvData in itemsInvData.iteritems():
         for idx, itemData in typeInvData.iteritems():
             itemIntCD = makeIntCompactDescrByID('customizationItem', cType, idx)
             self.__updateC11nProgressionDataForItem(itemIntCD, itemData)
예제 #8
0
 def __init__(self, nationID, vehTypeID, role, tokenName, tokenData):
     vehicle = self.itemsCache.items.getItemByCD(makeIntCompactDescrByID('vehicle', nationID, vehTypeID))
     super(TankmanTokenRecruit, self).__init__([plugins.VehicleCrewLockedValidator(vehicle), plugins.IsLongDisconnectedFromCenter()])
     self.nationID = nationID
     self.vehTypeID = vehTypeID
     self.role = role
     self.tokenName = tokenName
     self.recruitInfo = tokenData
     self.vehicleName = vehicle.shortUserName
예제 #9
0
def createShell(nationID, componentID, name):
    """Creates vehicle's shell.
    :param nationID: integer containing ID of nation.
    :param componentID: integer containing ID of shell in nation scope.
    :param name: string containing name of shell.
    :return: instance of Shell.
    """
    return Shell(ITEM_TYPES.shell, (nationID, componentID), name,
                 makeIntCompactDescrByID('shell', nationID, componentID))
    def alternateItems(self):
        items = []
        for itemType, ids in self.descriptor.alternateItems.iteritems():
            for itemId in ids:
                compactDescr = makeIntCompactDescrByID('customizationItem',
                                                       itemType, itemId)
                items.append(self._service.getItemByCD(compactDescr))

        return items
예제 #11
0
 def showItemTooltip(self, cmd):
     itemType = cmd.type
     if itemType == ItemPackType.CREW_BOOK:
         itemId = makeIntCompactDescrByID('crewBook', CrewBookCacheType.CREW_BOOK, cmd.id)
     else:
         itemId = getCDFromId(itemType=cmd.type, itemId=cmd.id)
     rawItem = ItemPackEntry(type=itemType, id=itemId, count=cmd.count or 1, extra=cmd.extra or {})
     item = lookupItem(rawItem, self.itemsCache, self.goodiesCache)
     showItemTooltip(self.__getTooltipMgr(), rawItem, item)
def createInstallableItem(itemTypeID, nationID, itemID, name):
    if itemTypeID in _TYPE_ID_TO_CLASS:
        clazz = _TYPE_ID_TO_CLASS[itemTypeID]
        return clazz(
            itemTypeID, (nationID, itemID), name,
            makeIntCompactDescrByID(ITEM_TYPE_NAMES[itemTypeID], nationID,
                                    itemID))
    raise SoftException(
        'Item can not be created by type {}'.format(itemTypeID))
def getCustomizationItemData(itemId, customizationName):
    itemsCache = dependency.instance(IItemsCache)
    customizationType = CustomizationNamesToTypes.get(
        customizationName.upper())
    if customizationType is None:
        _logger.warning('Wrong customization name: %s', customizationName)
    compactDescr = makeIntCompactDescrByID('customizationItem',
                                           customizationType, itemId)
    item = itemsCache.items.getItemByCD(compactDescr)
    itemName = item.userName
    itemTypeName = item.itemFullTypeName
    return _CustomizationItemData(itemTypeName, itemName)
예제 #14
0
    def initC11nItemsNoveltyData(self):
        self.__newC11nItems.clear()
        self.__newC11nItemsByVehicleCache.clear()
        customizationInvData = self.getCacheValue(GUI_ITEM_TYPE.CUSTOMIZATION, {})
        newItemsInvData = customizationInvData.get(CustomizationInvData.NOVELTY_DATA, {})
        for cType, itemsData in newItemsInvData.iteritems():
            for itemId, itemData in itemsData.iteritems():
                if itemData is not None:
                    intCD = makeIntCompactDescrByID('customizationItem', cType, itemId)
                    self.__newC11nItems[intCD] = itemData

        return
 def __init__(self, nationID, vehTypeID, role, tmanCostTypeIdx):
     super(TankmanRecruit, self).__init__([
         plugins.VehicleCrewLockedValidator(
             self.itemsCache.items.getItemByCD(
                 makeIntCompactDescrByID('vehicle', nationID, vehTypeID))),
         plugins.MoneyValidator(self.__getRecruitPrice(tmanCostTypeIdx)),
         plugins.FreeTankmanValidator(isEnabled=tmanCostTypeIdx == 0),
         plugins.BarracksSlotsValidator(),
         plugins.IsLongDisconnectedFromCenter()
     ])
     self.nationID = nationID
     self.vehTypeID = vehTypeID
     self.role = role
     self.tmanCostTypeIdx = tmanCostTypeIdx
예제 #16
0
def createInstallableItem(itemTypeID, nationID, itemID, name):
    """ Creates vehicle's item by ID of type.
    :param itemTypeID: integer containing index of ITEM_TYPE.
    :param nationID: integer containing ID of nation.
    :param itemID: integer containing unique ID of item in nation scope.
    :param name: string containing name of component.
    :return: instance of item.
    """
    if itemTypeID in _TYPE_ID_TO_CLASS:
        clazz = _TYPE_ID_TO_CLASS[itemTypeID]
        return clazz(
            itemTypeID, (nationID, itemID), name,
            makeIntCompactDescrByID(ITEM_TYPE_NAMES[itemTypeID], nationID,
                                    itemID))
    raise ValueError('Item can not be created by type {}'.format(itemTypeID))
예제 #17
0
 def create(cls, component, cType, proxy=None):
     """ Create a customization item from the given component.
     
     :param component: an instance of SerializableComponent or int.
     :param cType: type of customization (one of CustomizationType).
     :param proxy: an instance of ItemRequester.
     :return: an instance of Customization.
     """
     if isComponentComplex(component):
         componentID = component.id
     else:
         componentID = component
     intCD = makeIntCompactDescrByID('customizationItem', cType,
                                     componentID)
     return cls.itemsFactory.createCustomization(intCD, proxy)
예제 #18
0
 def _request(self, callback):
     _logger.debug(
         'Make server request to put on outfit on vehicle %s, season %s',
         self.vehicle.invID, self.season)
     component = self.outfit.pack()
     if self.season == SeasonType.ALL:
         component = CustomizationOutfit()
         component.styleId = self.outfit.id
     elif component.styleId and isEditedStyle(component):
         intCD = makeIntCompactDescrByID('customizationItem',
                                         CustomizationType.STYLE,
                                         component.styleId)
         style = self.itemsCache.items.getItemByCD(intCD)
         baseComponent = style.getOutfit(
             self.season, self.vehicle.descriptor.makeCompactDescr())
         component = component.getDiff(baseComponent.pack())
     BigWorld.player().shop.buyAndEquipOutfit(
         self.vehicle.invID, self.season, component.makeCompDescr(),
         lambda code: self._response(code, callback))
예제 #19
0
 def compactDescr(self):
     return items.makeIntCompactDescrByID('crewSkin', self.itemType,
                                          self.id)
예제 #20
0
 def makeIntDescr(cls, itemId):
     return items.makeIntCompactDescrByID('customizationItem', cls.itemType, itemId)
예제 #21
0
 def compactDescr(self):
     return items.makeIntCompactDescrByID('customizationItem', self.itemType, self.id)
def createShell(nationID, componentID, name):
    return Shell(ITEM_TYPES.shell, (nationID, componentID), name,
                 makeIntCompactDescrByID('shell', nationID, componentID))
 def makeCompactDescr(itemTypeID, idxWithinItemType):
     return makeIntCompactDescrByID(itemTypeID, NONE_INDEX,
                                    idxWithinItemType)