示例#1
0
 def updateOutfitByVehicleSlots(self, fromOutfit, toOutfit):
     for item, component in fromOutfit.itemsFull():
         if isinstance(component, EmptyComponent):
             for regionIdx in getAppliedRegionsForCurrentHangarVehicle(Area.MISC, item.itemTypeID):
                 toOutfit.getContainer(Area.MISC).slotFor(item.itemTypeID).set(item, regionIdx, component)
             continue
         for areaId, slotType, regionIdx in slotsIdsFromAppliedTo(component.appliedTo, item.itemTypeID):
             regionsIndexes = getAppliedRegionsForCurrentHangarVehicle(areaId, slotType)
             if regionIdx in regionsIndexes:
                 toOutfit.getContainer(areaId).slotFor(slotType).set(item, regionIdx, component)
     toOutfit.invalidate()
示例#2
0
 def removeItemFromAllTankAreas(self, season, slotType):
     for areaId in Area.TANK_PARTS:
         regionsIndexes = getAppliedRegionsForCurrentHangarVehicle(
             areaId, slotType)
         for regionIdx in regionsIndexes:
             slotId = C11nId(areaId=areaId,
                             slotType=slotType,
                             regionIdx=regionIdx)
             self.removeItemFromSlot(season, slotId)
示例#3
0
    def getEmptyRegions(self):
        emptyRegions = []
        slotType = TABS_ITEM_MAPPING[self._tabIndex]
        for areaId in Area.ALL:
            regionsIndexes = getAppliedRegionsForCurrentHangarVehicle(
                areaId, slotType)
            for regionIdx in regionsIndexes:
                outfit = self.getModifiedOutfit(self._currentSeason)
                item = outfit.getContainer(areaId).slotFor(slotType).getItem(
                    regionIdx)
                if item is None:
                    emptyRegions.append((areaId, slotType, regionIdx))

        mask = appliedToFromSlotsIds(emptyRegions)
        return mask
示例#4
0
    def checkSlotsFilling(self, slotType, season):
        allSlotsFilled = True
        for areaId in Area.ALL:
            regionsIndexes = getAppliedRegionsForCurrentHangarVehicle(
                areaId, slotType)
            for regionIdx in regionsIndexes:
                item = self.getModifiedOutfit(season).getContainer(
                    areaId).slotFor(slotType).getItem(regionIdx)
                if item is None:
                    break
            else:
                continue

            allSlotsFilled = False
            break

        return allSlotsFilled
示例#5
0
    def installItemToAllTankAreas(self, season, slotType, currentSlotData):
        currentSeasonIdx = SEASON_TYPE_TO_IDX[season]
        additionalyApplyedItems = 0
        for areaId in Area.TANK_PARTS:
            regionsIndexes = getAppliedRegionsForCurrentHangarVehicle(
                areaId, slotType)
            multiSlot = self.currentOutfit.getContainer(areaId).slotFor(
                slotType)
            for regionIdx in regionsIndexes:
                slotData = multiSlot.getSlotData(regionIdx)
                df = currentSlotData.weakDiff(slotData)
                if slotData.item is None or df.item is not None:
                    self.installItem(currentSlotData.item.intCD, areaId,
                                     slotType, regionIdx, currentSeasonIdx,
                                     currentSlotData.component)
                    additionalyApplyedItems += 1

        return additionalyApplyedItems
示例#6
0
    def __updateItemAppliedToAllFlag(self):
        self._isItemAppliedToAll = False
        if self.__ctx.currentTab in (C11nTabs.PAINT, C11nTabs.CAMOUFLAGE):
            self._isItemAppliedToAll = True
            for areaId in Area.TANK_PARTS:
                regionsIndexes = getAppliedRegionsForCurrentHangarVehicle(
                    areaId, self._slotID)
                multiSlot = self.__ctx.currentOutfit.getContainer(
                    areaId).slotFor(self._slotID)
                for regionIdx in regionsIndexes:
                    slotData = multiSlot.getSlotData(regionIdx)
                    df = self._currentSlotData.weakDiff(slotData)
                    if slotData.item is None or df.item is not None:
                        break
                else:
                    continue

                self._isItemAppliedToAll = False
                break

        elif self.__ctx.currentTab in (C11nTabs.EFFECT, C11nTabs.EMBLEM,
                                       C11nTabs.INSCRIPTION):
            self._isItemAppliedToAll = True
            firstSeason = SeasonType.COMMON_SEASONS[0]
            fistSlotData = self.__ctx.getModifiedOutfit(
                firstSeason).getContainer(self._areaID).slotFor(
                    self._slotID).getSlotData(self._regionID)
            if fistSlotData.item is not None:
                for season in SeasonType.COMMON_SEASONS[1:]:
                    slotData = self.__ctx.getModifiedOutfit(
                        season).getContainer(self._areaID).slotFor(
                            self._slotID).getSlotData(self._regionID)
                    df = fistSlotData.weakDiff(slotData)
                    if slotData.item is None or df.item is not None:
                        self._isItemAppliedToAll = False
                        break

            else:
                self._isItemAppliedToAll = False
        return
    def _getUpdatedAnchorsData(self):
        tabIndex = self.__ctx.currentTab
        cType = TABS_ITEM_MAPPING[tabIndex]
        slotIds = []
        if tabIndex == C11nTabs.STYLE:
            slotId = CustomizationSlotIdVO(Area.MISC, GUI_ITEM_TYPE.STYLE, 0)
            slotIds.append(slotId)
        else:
            for areaId in Area.ALL:
                regionsIndexes = getAppliedRegionsForCurrentHangarVehicle(
                    areaId, cType)
                for regionsIndex in regionsIndexes:
                    slotId = CustomizationSlotIdVO(areaId, cType, regionsIndex)
                    slotIds.append(slotId)

        anchorVOs = []
        for zIdx, slotId in enumerate(slotIds):
            anchorVOs.append(
                CustomizationAnchorPositionVO(zIdx,
                                              slotId._asdict())._asdict())

        return CustomizationAnchorsSetVO(anchorVOs)._asdict()
    def __setAnchorsInitData(self, update=False):
        def customizationSlotIdToUid(customizationSlotIdVO):
            s = struct.pack('bbh', customizationSlotIdVO.areaId,
                            customizationSlotIdVO.slotId,
                            customizationSlotIdVO.regionId)
            return struct.unpack('I', s)[0]

        tabIndex = self.__ctx.currentTab
        anchorVOs = []
        cType = TABS_ITEM_MAPPING[tabIndex]
        if tabIndex == C11nTabs.STYLE:
            slotId = CustomizationSlotIdVO(0, GUI_ITEM_TYPE.STYLE, 0)
            uid = customizationSlotIdToUid(slotId)
            anchorVOs.append(
                CustomizationSlotUpdateVO(slotId._asdict(), -1, uid)._asdict())
        else:
            for areaId in Area.ALL:
                regionsIndexes = getAppliedRegionsForCurrentHangarVehicle(
                    areaId, cType)
                slot = self.__ctx.currentOutfit.getContainer(areaId).slotFor(
                    cType)
                for regionsIndex in regionsIndexes:
                    slotId = CustomizationSlotIdVO(areaId, cType, regionsIndex)
                    item = slot.getItem(regionsIndex)
                    itemIntCD = item.intCD if item is not None else 0
                    uid = customizationSlotIdToUid(slotId)
                    anchorVOs.append(
                        CustomizationSlotUpdateVO(slotId._asdict(), itemIntCD,
                                                  uid)._asdict())

        doRegions = tabIndex in C11nTabs.REGIONS
        if update:
            self.as_updateAnchorDataS(
                CustomizationAnchorInitVO(anchorVOs, doRegions)._asdict())
        else:
            self.as_setAnchorInitS(
                CustomizationAnchorInitVO(anchorVOs, doRegions)._asdict())
        return
    def __setAnchorsInitData(self, update=False):
        def customizationSlotIdToUid(customizationSlotIdVO):
            s = struct.pack('bbh', customizationSlotIdVO.areaId,
                            customizationSlotIdVO.slotId,
                            customizationSlotIdVO.regionId)
            return struct.unpack('I', s)[0]

        tabIndex = self.__ctx.currentTab
        anchorVOs = []
        cType = TABS_ITEM_MAPPING[tabIndex]
        maxItemsReached = False
        if tabIndex == C11nTabs.STYLE:
            anchorId = CustomizationSlotIdVO(Area.MISC, GUI_ITEM_TYPE.STYLE, 0)
            uid = customizationSlotIdToUid(anchorId)
            anchorVOs.append(
                CustomizationSlotUpdateVO(
                    anchorId._asdict(), self.__ctx.modifiedStyle.intCD
                    if self.__ctx.modifiedStyle is not None else 0, uid,
                    None)._asdict())
        else:
            potentialPlaceTooltip = None
            if cType in QUANTITY_LIMITED_CUSTOMIZATION_TYPES:
                outfit = self.__ctx.getModifiedOutfit(self.__ctx.currentSeason)
                if self.__ctx.isC11nItemsQuantityLimitReached(outfit, cType):
                    maxItemsReached = True
                    potentialPlaceTooltip = makeTooltip(
                        VEHICLE_CUSTOMIZATION.
                        CUSTOMIZATION_TOOLTIP_POTENTIALPROJDECALPLACE_TITLE,
                        VEHICLE_CUSTOMIZATION.
                        CUSTOMIZATION_TOOLTIP_POTENTIALPROJDECALPLACE_TEXT)
            for areaId in Area.ALL:
                regionsIndexes = getAppliedRegionsForCurrentHangarVehicle(
                    areaId, cType)
                slot = self.__ctx.currentOutfit.getContainer(areaId).slotFor(
                    cType)
                for regionsIndex in regionsIndexes:
                    anchorId = CustomizationSlotIdVO(areaId, cType,
                                                     regionsIndex)
                    slotId = self.__ctx.getSlotIdByAnchorId(
                        C11nId(areaId=areaId,
                               slotType=cType,
                               regionIdx=regionsIndex))
                    itemIntCD = 0
                    if slotId is not None:
                        item = slot.getItem(slotId.regionIdx)
                        itemIntCD = item.intCD if item is not None else 0
                    tooltip = None
                    if not itemIntCD:
                        tooltip = potentialPlaceTooltip
                    uid = customizationSlotIdToUid(anchorId)
                    anchorVOs.append(
                        CustomizationSlotUpdateVO(anchorId._asdict(),
                                                  itemIntCD, uid,
                                                  tooltip)._asdict())

        if tabIndex in C11nTabs.REGIONS:
            typeRegions = CUSTOMIZATION_ALIASES.ANCHOR_TYPE_REGION
        elif tabIndex == C11nTabs.PROJECTION_DECAL:
            typeRegions = CUSTOMIZATION_ALIASES.ANCHOR_TYPE_PROJECTION_DECAL
        else:
            typeRegions = CUSTOMIZATION_ALIASES.ANCHOR_TYPE_DECAL
        if update:
            self.as_updateAnchorDataS(
                CustomizationAnchorInitVO(anchorVOs, typeRegions,
                                          maxItemsReached)._asdict())
        else:
            self.as_setAnchorInitS(
                CustomizationAnchorInitVO(anchorVOs, typeRegions,
                                          maxItemsReached)._asdict())
        return