def isVehicleCanBeCustomized(vehicle, itemTypeID, itemsFilter=None):
    if itemTypeID not in C11N_ITEM_TYPE_MAP:
        _logger.error(
            'Failed to get customization item from cache. Wrong itemTypeID: %s',
            itemTypeID)
        return False
    else:
        cType = C11N_ITEM_TYPE_MAP[itemTypeID]
        customizationCache = g_cache.customization20().itemTypes
        if cType not in customizationCache:
            _logger.error(
                'Failed to get customization item from cache. Wrong cType: %s',
                cType)
            return False
        for areaId in Area.ALL:
            if any(vehicle.getAnchors(itemTypeID, areaId)):
                break
        else:
            return False

        customizationService = dependency.instance(ICustomizationService)
        eventsCache = dependency.instance(IEventsCache)
        requirement = createCustomizationBaseRequestCriteria(
            vehicle, eventsCache.questsProgress, set(), itemTypeID=itemTypeID)
        if itemsFilter is not None:
            requirement |= REQ_CRITERIA.CUSTOM(itemsFilter)
        for itemID in customizationCache[cType]:
            item = customizationService.getItemByID(itemTypeID, itemID)
            if requirement(item):
                return True

        return False
Пример #2
0
    def __init__(self, strCompactDescr=None, component=None, vehicleCD='', vehicleType=None):
        super(Outfit, self).__init__(strCompactDescr)
        self._containers = {}
        self._vehicleCD = vehicleCD
        if strCompactDescr is not None and component is not None:
            raise SoftException("'strCompactDescr' and 'component' arguments are mutually exclusive!")
        if strCompactDescr:
            component = parseOutfitDescr(strCompactDescr)
        elif component is None:
            component = CustomizationOutfit()
        self._id = component.styleId
        self.__styleProgressionLevel = component.styleProgressionLevel
        self.__styleSerialNumber = component.serial_number
        self._styleDescr = None
        if self._id:
            intCD = makeIntCompactDescrByID('customizationItem', CustomizationType.STYLE, self._id)
            if not IS_EDITOR:
                self._styleDescr = getItemByCompactDescr(intCD)
            else:
                from items.vehicles import g_cache
                if g_cache.customization20(createNew=False):
                    self._styleDescr = getItemByCompactDescr(intCD)
        self._construct(vehicleType=vehicleType)
        for container in self._containers.itervalues():
            container.unpack(component)

        self.__itemsCounter = None
        self.invalidate()
        return
Пример #3
0
def new_applyVehicleOutfit(base, self, *a, **kw):
    outfit = self._CompoundAppearance__outfit
    vID = self._CompoundAppearance__vID
    vDesc = self._CompoundAppearance__typeDesc
    if not vDesc:
        return base(self, *a, **kw)
    fashions = self._CompoundAppearance__fashions
    paintItems = {}
    paints = g_cache.customization20().paints
    for paintID in g_config.data['scale'].itervalues():
        paintItem = Paint(paints[paintID].compactDescr)
        if not paintItem.descriptor.matchVehicleType(vDesc.type):
            return base(self, *a, **kw)
        paintItems[paintID] = paintItem
    accountID = str(BigWorld.player().arena.vehicles[vID]['accountDBID'])
    if accountID not in g_config.dossier:
        if accountID not in g_config.pending:
            g_config.thread([accountID])
        return base(self, *a, **kw)
    paintID = None
    rating = g_config.dossier[accountID]['wgr']
    for value in sorted(int(x) for x in g_config.data['scale']):
        if rating < value:
            paintID = g_config.data['scale'][str(value)]
            break
    for fashionIdx, descId in enumerate(TankPartNames.ALL):
        if not g_config.data['paint_%s' % descId]:
            continue
        removeCamo = False
        container = outfit.getContainer(fashionIdx)
        paintSlot = container.slotFor(GUI_ITEM_TYPE.PAINT)
        camoSlot = container.slotFor(GUI_ITEM_TYPE.CAMOUFLAGE)
        if paintSlot is not None:
            for idx in xrange(paintSlot.capacity()):
                if g_config.data['ignorePresentPaints'] or paintSlot.getItem(
                        idx) is None:
                    paintSlot.set(paintItems[paintID], idx)
                    removeCamo = True
        if camoSlot is not None:
            if g_config.data['removeCamouflages'] and removeCamo:
                camoSlot.clear()
                fashion = fashions[fashionIdx]
                if fashion is None:
                    continue
                fashion.removeCamouflage()
    self._CompoundAppearance__outfit = outfit
    base(self, *a, **kw)
Пример #4
0
 def _cleanSettings(self):
     camouflages = g_cache.customization20().camouflages
     for key, settings in self._currentSettings.iteritems():
         for ID, conf in settings.items():
             orig = g_config.camouflages[key].get(ID, {})
             if 'season' in conf and (
                     camouflages[ID].season & ~SeasonType.EVENT == reduce(
                         operator.ior, (SEASON_NAME_TO_TYPE[x] for x in conf['season']), SeasonType.UNDEFINED)
                     if 'season' not in orig else orig['season'] == conf['season']):
                 del conf['season']
             for team in ('ally', 'enemy'):
                 if team in conf and orig.get(team, True) == conf[team]:
                     del conf[team]
             if 'random_mode' in conf and conf['random_mode'] == orig.get('random_mode', SelectionMode.RANDOM):
                 del conf['random_mode']
             if not conf:
                 del settings[ID]
Пример #5
0
def new_applyVehicleOutfit(base, self, *a, **kw):
    outfit = self.outfit
    vID = self.id
    vDesc = self.typeDescriptor
    if not vDesc or not g_config.data['enabled']:
        return base(self, *a, **kw)
    player = BigWorld.player()
    team = 'player' if vID == player.playerVehicleID else \
        'ally' if player.arena.vehicles[vID]['team'] == player.team else 'enemy'
    if not (any(g_config.data['paint_' + team + '_' + part] for part in TankPartNames.ALL)):
        return base(self, *a, **kw)
    accID = player.arena.vehicles[vID]['accountDBID']
    if not accID:
        return base(self, *a, **kw)
    strAccID = str(accID)
    if strAccID not in g_config.dossier:
        if strAccID not in g_config.pending:
            g_config.thread([strAccID])
        return base(self, *a, **kw)
    paintItem = None
    rating = g_config.dossier[strAccID]['wgr']
    for value in sorted(g_config.paintItems):
        if rating < value:
            paintItem = g_config.paintItems[value]
            break
    g_cache.customization20().paints[paintItem.id] = paintItem
    for fashionIdx, part in enumerate(TankPartNames.ALL):
        if not g_config.data['paint_' + team + '_' + part]:
            continue
        removeCamo = False
        container = outfit.getContainer(fashionIdx)
        paintSlot = container.slotFor(GUI_ITEM_TYPE.PAINT)
        camoSlot = container.slotFor(GUI_ITEM_TYPE.CAMOUFLAGE)
        if paintSlot is not None:
            for idx in xrange(paintSlot.capacity()):
                if g_config.data['ignorePresentPaints'] or paintSlot.getItem(idx) is None:
                    paintSlot.set(paintItem.compactDescr, idx)
                    removeCamo = True
        if camoSlot is not None and g_config.data['removeCamouflages'] and removeCamo:
            camoSlot.clear()
            fashion = self.fashions[fashionIdx]
            if fashion is None:
                continue
            fashion.removeCamouflage()
    self._CommonTankAppearance__outfit = outfit
    return base(self, *a, **kw)
Пример #6
0
 def _getAllItems(self, requirement):
     return {item.intCD: item for item in (self.itemsCache.items.getItemByCD(item.compactDescr) for item in sum(
         (g_cache.customization20().itemTypes[C11N_ITEM_TYPE_MAP[GUI_ITEM_TYPE_INDICES[itemTypeName]]].values() for
          itemTypeName in ('paint', 'camouflage', 'decal', 'modification')), [])) if requirement(item)}