Esempio n. 1
0
    def getItemInventoryCount(self, item, excludeBase=False):
        baseCount = 0
        appliedCount = 0
        for season in SeasonType.COMMON_SEASONS:
            baseOutfit = self.__baseOutfits[season]
            modifiedOutfit = self._modifiedOutfits[season]
            bCount = baseOutfit.itemsCounter[item.intCD]
            aCount = modifiedOutfit.itemsCounter[item.intCD]
            if item.itemTypeID in EDITABLE_STYLE_APPLY_TO_ALL_AREAS_TYPES:
                bCount = min(1, bCount)
                aCount = min(1, aCount)
            baseCount += bCount
            appliedCount += aCount

        if baseCount:
            inventoryCount = getItemInventoryCount(item)
        else:
            inventoryCount = super(EditableStyleMode, self).getItemInventoryCount(item, excludeBase)
        if excludeBase:
            return inventoryCount
        if item.isStyleOnly:
            slotType = ITEM_TYPE_TO_SLOT_TYPE[item.itemTypeID]
            if slotType in EDITABLE_STYLE_APPLY_TO_ALL_AREAS_TYPES:
                availableCount = any((getAvailableRegions(areaId, slotType) for areaId in Area.ALL))
            else:
                availableCount = sum((len(getAvailableRegions(areaId, slotType)) for areaId in Area.ALL))
            if slotType == GUI_ITEM_TYPE.PROJECTION_DECAL:
                availableCount = min(availableCount, MAX_USERS_PROJECTION_DECALS)
            suitableSeasons = tuple((season for season in SeasonType.COMMON_SEASONS if item.season & season))
            availableCount *= len(suitableSeasons)
            actualInventoryCount = availableCount - appliedCount + inventoryCount
        else:
            actualInventoryCount = max(baseCount - appliedCount, 0) + inventoryCount
        return max(actualInventoryCount, 0)
Esempio n. 2
0
    def removeItemFromAllTankAreas(self, season, slotType):
        for areaId in Area.TANK_PARTS:
            regionsIndexes = getAvailableRegions(areaId, slotType)
            for regionIdx in regionsIndexes:
                slotId = C11nId(areaId=areaId, slotType=slotType, regionIdx=regionIdx)
                self.removeItem(slotId, season, refresh=False)

        self._ctx.refreshOutfit(season)
        self._events.onItemsRemoved()
def getCurrentVehicleAvailableRegionsMap():
    availableRegionsMap = {}
    for areaId in Area.ALL:
        availableRegionsMap[areaId] = {}
        for slotType in CustomizationTabs.SLOT_TYPES.itervalues():
            regions = getAvailableRegions(areaId, slotType)
            availableRegionsMap[areaId][slotType] = regions

    return availableRegionsMap
def getEmptyRegions(outfit, slotType):
    emptyRegions = []
    for areaId in Area.ALL:
        regionsIndexes = getAvailableRegions(areaId, slotType)
        for regionIdx in regionsIndexes:
            intCD = outfit.getContainer(areaId).slotFor(slotType).getItemCD(regionIdx)
            if not intCD:
                emptyRegions.append((areaId, slotType, regionIdx))

    mask = appliedToFromSlotsIds(emptyRegions)
    return mask
def checkSlotsFilling(outfit, slotType):
    availableCount = 0
    filledCount = 0
    for areaId in Area.ALL:
        regionsIndexes = getAvailableRegions(areaId, slotType)
        availableCount += len(regionsIndexes)
        for regionIdx in regionsIndexes:
            intCD = outfit.getContainer(areaId).slotFor(slotType).getItemCD(regionIdx)
            if intCD:
                filledCount += 1

    if slotType in QUANTITY_LIMITED_CUSTOMIZATION_TYPES:
        availableCount = min(availableCount, QUANTITY_LIMITED_CUSTOMIZATION_TYPES[slotType])
    return (availableCount, filledCount)
Esempio n. 6
0
    def installItemToAllTankAreas(self, season, slotType, slotData):
        additionallyAppliedItems = 0
        for areaId in Area.TANK_PARTS:
            regionsIndexes = getAvailableRegions(areaId, slotType)
            multiSlot = self._modifiedOutfits[season].getContainer(areaId).slotFor(slotType)
            for regionIdx in regionsIndexes:
                otherSlotData = multiSlot.getSlotData(regionIdx)
                df = slotData.weakDiff(otherSlotData)
                if not otherSlotData.intCD or df.intCD:
                    slotId = C11nId(areaId=areaId, slotType=slotType, regionIdx=regionIdx)
                    res = self.installItem(intCD=slotData.intCD, slotId=slotId, season=season, component=slotData.component)
                    if res:
                        additionallyAppliedItems += 1

        return additionallyAppliedItems
Esempio n. 7
0
    def isPossibleToInstallToAllTankAreas(self, intCD, slotType):
        item = self._service.getItemByCD(intCD)
        if not item.isLimited and not item.isHidden or item.isStyleOnly:
            return True
        needed = 0
        for areaId in Area.TANK_PARTS:
            regionsIndexes = getAvailableRegions(areaId, slotType)
            multiSlot = self.currentOutfit.getContainer(areaId).slotFor(slotType)
            for regionIdx in regionsIndexes:
                otehrIntCD = multiSlot.getItemCD(regionIdx)
                if intCD != otehrIntCD:
                    needed += 1

        inventoryCount = self.getItemInventoryCount(item)
        toBye = needed - inventoryCount
        return toBye <= item.buyCount
def __removeItemFromEditableStyleAllAreas(outfit, baseOutfit, slotType):
    for areaId in Area.TANK_PARTS:
        regionsIndexes = getAvailableRegions(areaId, slotType)
        for regionIdx in regionsIndexes:
            slotId = C11nId(areaId=areaId, slotType=slotType, regionIdx=regionIdx)
            __removeItemFromEditableStyleOutfit(outfit, baseOutfit, slotId)