Ejemplo n.º 1
0
    def __validateCustomization(self):
        for intCD, dossier in self.itemsCache.items.getVehicleDossiersIterator(
        ):
            _, nationID, _ = parseIntCompactDescr(intCD)
            customization = vehicles.g_cache.customization(nationID)
            camouflages = customization['camouflages']
            inscriptions = customization['inscriptions']
            emblems = vehicles.g_cache.playerEmblems()[1]
            for camoID in list(dossier['camouflages']):
                if camoID not in camouflages:
                    raise ValidateException(
                        'Invalid camounflage for vehicle %s' % intCD,
                        self.CODES.DOSSIER_CAMOUFLAGES_ERROR,
                        ('camouflage', camoID))

            for insID in list(dossier['inscriptions']):
                if insID not in inscriptions:
                    raise ValidateException(
                        'Invalid insription for vehicle %s' % intCD,
                        self.CODES.DOSSIER_INSCRIPTIONS_ERROR,
                        ('inscription', insID))

            for emblemID in list(dossier['emblems']):
                if emblemID not in emblems:
                    raise ValidateException(
                        'Invalid emblem for vehicle %s' % intCD,
                        self.CODES.DOSSIER_EMBLEMS_ERROR, ('emblem', emblemID))
Ejemplo n.º 2
0
def splitIntDescr(intDescr):
    itemType, customizationType, id = items.parseIntCompactDescr(intDescr)
    if itemType != 12 or customizationType not in CustomizationType.RANGE:
        raise SoftException(
            'intDescr is not correct customization item int descriptor',
            intDescr)
    return (customizationType, id)
Ejemplo n.º 3
0
    def __getLeaguesData(self):
        leaguesRewardsData = self.__rankedController.getLeagueRewards()
        result = []
        formatter = getRankedAwardsFormatter()

        def findAndPreformatBonus(awards, bonusName):
            bonus = findFirst(lambda x: x.getName() == bonusName, awards)
            if bonus is not None:
                bonus = first(formatter.getPreformattedBonuses([bonus]))
            return bonus

        for data in leaguesRewardsData:
            leagueID = data['league']
            awards = data['awards']
            badgeBonus = findAndPreformatBonus(awards, 'dossier')
            styleBonus = findAndPreformatBonus(awards, 'customizations')
            if leagueID and styleBonus and badgeBonus:
                isCurrent = self.__rankedController.getWebSeasonProvider(
                ).seasonInfo.league == leagueID
                styleCD = styleBonus.specialArgs[0]
                style = self.__itemsCache.items.getItemByCD(styleCD)
                _, _, styleID = parseIntCompactDescr(styleCD)
                self.__styleDescriptions[styleID] = backport.text(
                    R.strings.ranked_battles.rewardsView.tabs.leagues.
                    description.dyn('league%s' % leagueID)())
                badgeID = badgeBonus.specialArgs[0]
                result.append(
                    rewards_vos.getLeagueRewardVO(leagueID, styleBonus,
                                                  styleID, style.userName,
                                                  badgeID, isCurrent))
            _logger.error('Invalid awards or leagueID in quests')

        return result
Ejemplo n.º 4
0
 def __getCustomizationsData(self, intCD):
     _, cType, idx = parseIntCompactDescr(intCD)
     customizationInvData = self.getCacheValue(GUI_ITEM_TYPE.CUSTOMIZATION,
                                               {})
     itemsInvData = customizationInvData.get(CustomizationInvData.ITEMS, {})
     typeInvData = itemsInvData.get(cType, {})
     return typeInvData.get(idx, {})
Ejemplo n.º 5
0
 def getC11nItemAppliedVehicles(self, itemCD):
     _, itemType, itemId = parseIntCompactDescr(itemCD)
     path = (GUI_ITEM_TYPE.CUSTOMIZATION,
      CustomizationInvData.DRESSED,
      itemType,
      itemId)
     vehs = self.getCacheValueByPath(path, defaultValue={})
     return vehs.keys()
Ejemplo n.º 6
0
def _getItemByCompactDescr(compactDescr):
    itemTypeID, nationID, compTypeID = parseIntCompactDescr(compactDescr)
    items = None
    if itemTypeID == ITEM_TYPES.crewSkin:
        items = g_cache.crewSkins().skins
    elif itemTypeID == ITEM_TYPES.crewBook:
        items = g_cache.crewBooks().books
    return items[compTypeID]
Ejemplo n.º 7
0
 def __getVehicleDescr(self, vehicleCD=None, vehicleName=None):
     if vehicleCD is not None:
         itemTypeId, nationId, innationId = parseIntCompactDescr(vehicleCD)
     elif vehicleName is not None:
         nationId, innationId = vehicles.g_list.getIDsByName(vehicleName)
     else:
         _logger.error('Do not specified correct vehicle int cd or vehicle name!')
         return
     return vehicles.VehicleDescr(typeID=(nationId, innationId))
Ejemplo n.º 8
0
 def getC11nItemAppliedOnVehicleCount(self, itemCD, vehicleIntCD):
     _, itemType, itemId = parseIntCompactDescr(itemCD)
     path = (GUI_ITEM_TYPE.CUSTOMIZATION,
      CustomizationInvData.DRESSED,
      itemType,
      itemId,
      vehicleIntCD)
     count = self.getCacheValueByPath(path, defaultValue=0)
     return count
Ejemplo n.º 9
0
 def buildItem(self, *args, **kwargs):
     intCD = args[0]
     itemTypeID, _, _ = parseIntCompactDescr(intCD)
     if itemTypeID == GUI_ITEM_TYPE.VEHICLE:
         vehicle = self.getVehicle()
         return (vehicle, vehicle)
     module = self.__getProgressionCtrl().getModule(intCD)
     currentModule = self.__getProgressionCtrl(
     ).getInstalledOnVehicleAnalogByIntCD(intCD)
     return (module, currentModule)
Ejemplo n.º 10
0
 def __getModuleInfoPanel(self, intCD):
     itemTypeID, _, _ = parseIntCompactDescr(intCD)
     if itemTypeID != GUI_ITEM_TYPE.VEHICLE:
         module = self.__getModuleItem(intCD)
         if module is not None:
             return {'header': getTreeModuleHeader(module),
              'parameters': getShortListParameters(module, self.__getProgressionVehicle(), self.__getInstalledOnVehicleAnalogByIntCD(intCD)),
              'module': {'icon': getTreeModuleIcon(module),
                         'available': True}}
     return
Ejemplo n.º 11
0
    def itemsFilter(items):
        filtered = {}
        for itemCD, count in items.items():
            itemTypeID, _, _ = parseIntCompactDescr(itemCD)
            if any(
                (condition(itemTypeID, itemCD) for condition in conditions)):
                filtered[itemCD] = count
                del items[itemCD]

        return filtered
Ejemplo n.º 12
0
    def sellAll(self):
        itemSellSpecs = []
        for item in self._dataProvider.collection:
            if item['selected']:
                intCD = item['id']
                count = item['count']
                typeIdx, _, _ = parseIntCompactDescr(intCD)
                itemSellSpecs.append(ItemSellSpec(typeIdx, intCD, count))

        ItemsActionsFactory.doAction(ItemsActionsFactory.SELL_MULTIPLE,
                                     itemSellSpecs)
Ejemplo n.º 13
0
def removeItemFromEditableStyle(outfit, baseOutfit, slotId):
    slotType = slotId.slotType
    if slotType in EDITABLE_STYLE_APPLY_TO_ALL_AREAS_TYPES:
        __removeItemFromEditableStyleAllAreas(outfit, baseOutfit, slotType)
        if slotType == GUI_ITEM_TYPE.CAMOUFLAGE:
            slotData = getSlotDataFromSlot(outfit, slotId)
            parsedData = parseIntCompactDescr(compactDescr=slotData.intCD)
            for _, uSlotId in getUnsuitableDependentData(outfit, parsedData[2], outfit.style.dependencies):
                __doItemRemoveFromEditableStyleOutfit(outfit, baseOutfit, uSlotId, True)

    else:
        __removeItemFromEditableStyleOutfit(outfit, baseOutfit, slotId)
 def checkSlotCompatibility(self, compDescr=None, descr=None):
     if compDescr is None and descr is None:
         raise SoftException(
             "One of 'compDescr' or 'descr' arguments must be specified.")
     if compDescr is None:
         compDescr = descr.compactDescr
     itemTypeID, nationID, itemID = parseIntCompactDescr(compDescr)
     return (
         False,
         'Item type of slot ({}) does not match type of item ({})'.format(
             self.itemType, itemTypeID)
     ) if itemTypeID != self.itemType else self._checkSlotCompatibility(
         (itemTypeID, nationID, itemID), descr)
Ejemplo n.º 15
0
 def openBarracks(self, cmd):
     location = intCD = cmd.location
     if isinstance(location, int):
         nationID, location = parseIntCompactDescr(location)[1:]
         tankType = first(
             self.__itemsCache.items.getVehicles(
                 _makeCriteria(intCD)).values()).type
         role = cmd.role or _ALL
     else:
         nationID, location = None, _LOCATION.get(location)
         tankType = cmd.tank_type
         role = cmd.role
     shared_events.showBarracks(location, nationID, tankType, role)
     return
Ejemplo n.º 16
0
 def updateC11nProgressionDataForItem(self, itemIntCD):
     if not self.__c11nProgressionData:
         self.updateC11nProgressionData()
         return
     if itemIntCD in self.__c11nProgressionData:
         del self.__c11nProgressionData[itemIntCD]
     customizationInvData = self.getCacheValue(GUI_ITEM_TYPE.CUSTOMIZATION, {})
     itemsInvData = customizationInvData.get(CustomizationInvData.PROGRESSION, {})
     _, cType, idx = parseIntCompactDescr(itemIntCD)
     if cType in itemsInvData:
         typeInvData = itemsInvData[cType]
         if idx in typeInvData:
             itemData = typeInvData[idx]
             self.__updateC11nProgressionDataForItem(itemIntCD, itemData)
Ejemplo n.º 17
0
 def __init__(self, intCompactDescr, proxy=None):
     super(CrewSkin, self).__init__(intCompactDescr, proxy)
     self.__freeCount = 0
     self.__tankmenIDs = set()
     _, _, self.__id = parseIntCompactDescr(intCompactDescr)
     if proxy is not None and proxy.inventory.isSynced():
         self.__freeCount = proxy.inventory.getItems(
             GUI_ITEM_TYPE.CREW_SKINS, self.__id)
         allTankmen = proxy.getTankmen()
         self.__tankmenIDs = {
             invID
             for invID, tankman in allTankmen.iteritems()
             if tankman.skinID != NO_CREW_SKIN_ID
             and tankman.skinID == self.__id
         }
     return
Ejemplo n.º 18
0
def _isValidTankmanLocation(_, data, itemsCache=None):
    loc = data.get('location')
    if loc in _LOCATION:
        return True
    if isinstance(loc, int):
        intCD = loc
        itemTypeID = first(parseIntCompactDescr(intCD))
        if itemTypeID != ITEM_TYPES.vehicle:
            raise WebCommandException(
                'intCD: %d is not valid value for "location",vehicle with this descriptor are not exists',
                intCD)
        vehicles = itemsCache.items.getVehicles(_makeCriteria(intCD))
        if not vehicles:
            raise WebCommandException(
                'intCD: %d is not valid value for "location",vehicle with this descriptor are not in the inventory',
                intCD)
        return True
    raise WebCommandException('"%s" is not valid value for "location"', loc)
 def parseCompactDescr(compDescr):
     itemTypeId, _, idxWithinItemType = parseIntCompactDescr(compDescr)
     return (itemTypeId, idxWithinItemType)
Ejemplo n.º 20
0
 def getTankName(vehCompactDesc):
     itemTypeID, nationId, vehId = parseIntCompactDescr(vehCompactDesc)
     tank = g_cache.vehicle(nationId, vehId)
     return tank.name
Ejemplo n.º 21
0
def getVehicleLevel(vehTypeCompDescr):
    _, nationID, innationID = parseIntCompactDescr(vehTypeCompDescr)
    return vehicles.g_list.getList(nationID)[innationID].level
Ejemplo n.º 22
0
def splitIntDescr(intDescr):
    """Split int item descriptor to (customizationType, itemId) tuple."""
    itemType, customizationType, id = items.parseIntCompactDescr(intDescr)
    if itemType != 12 or customizationType not in CustomizationType.RANGE:
        raise ValueError('intDescr is not correct customization item int descriptor', intDescr)
    return (customizationType, id)
Ejemplo n.º 23
0
 def __doesVehicleExist(self, vehIntCD):
     itemTypeID, _, _ = parseIntCompactDescr(vehIntCD)
     return True if itemTypeID == GUI_ITEM_TYPE.VEHICLE else False
 def getC11nSerialNumber(self, itemCD):
     _, itemType, itemID = parseIntCompactDescr(itemCD)
     path = (GUI_ITEM_TYPE.CUSTOMIZATION,
             CustomizationInvData.SERIAL_NUMBERS, itemType, itemID,
             'serial_number')
     return self.getCacheValueByPath(path)