Пример #1
0
 def _setTableData(self, f, nation, tabType, actionsSelected, itemCD):
     nation = int(nation) if nation >= 0 else None
     if nation is not None:
         nation = getNationIndex(nation)
     self.__clearTableData()
     cls = self._getTabClass(tabType)
     self._currentTab = cls(nation, f, actionsSelected, itemCD)
     self._table.setItemWrapper(self._currentTab.itemWrapper)
     dataProviderValues = self._currentTab.buildItems(self.__invVehicles)
     self._table.setDataProviderValues(dataProviderValues)
     showNoItemsInfo = len(dataProviderValues) == 0
     noItemsInfo = None
     if showNoItemsInfo:
         noItemsInfo = {
             'message': text_styles.main(MENU.STORE_MENU_NOITEMS)
         }
     self._table.as_setDataS({
         'type': self._currentTab.getTableType(),
         'showNoItemsInfo': showNoItemsInfo,
         'noItemsInfo': noItemsInfo
     })
     self.as_setActionAvailableS(self._currentTab.hasDiscounts())
     if self._currentTab.getScrollIdx():
         self.as_scrollPositionS(self._currentTab.getScrollIdx())
     return
Пример #2
0
 def _setTableData(self, filter, nation, type, actionsSelected, itemCD):
     """
     Prepare and set data for selected tab, set dataProvider itemWrapper and values
     set account credits and gold into Flash
     :param type: <str> tab ID
     :param nation: <int> gui nation
     :param actionsSelected: <bool> discount's checkbox value
     :param filter: <obj> filter data
     """
     nation = int(nation) if nation >= 0 else None
     if nation is not None:
         nation = getNationIndex(nation)
     self.__clearTableData()
     cls = self._getTabClass(type)
     self._currentTab = cls(nation, filter, actionsSelected, itemCD)
     self._table.setItemWrapper(self._currentTab.itemWrapper)
     dataProviderValues = self._currentTab.buildItems(self.__invVehicles)
     self._table.setDataProviderValues(dataProviderValues)
     showNoItemsInfo = len(dataProviderValues) == 0
     noItemsInfo = None
     if showNoItemsInfo:
         noItemsInfo = {'message': text_styles.main(MENU.STORE_MENU_NOITEMS)}
     self._table.as_setDataS({'type': self._currentTab.getTableType(),
      'showNoItemsInfo': showNoItemsInfo,
      'noItemsInfo': noItemsInfo})
     self.as_setActionAvailableS(self._currentTab.hasDiscounts())
     if self._currentTab.getScrollIdx():
         self.as_scrollPositionS(self._currentTab.getScrollIdx())
     return
Пример #3
0
 def _setTableData(self, filter, nation, type):
     """
     Prepare and set data for selected tab, set dataProvider itemWrapper and values
     set account credits and gold into Flash
     :param type: <str> tab ID
     :param nation: <int> gui nation
     :param filter: <obj> filter data
     """
     nation = int(nation) if nation >= 0 else None
     if nation is not None:
         nation = getNationIndex(nation)
     self.__clearTableData()
     cls = self._getTabClass(type)
     self._currentTab = cls(nation, filter)
     self._table.setItemWrapper(self._currentTab.itemWrapper)
     dataProviderValues = self._currentTab.buildItems(self.__invVehicles)
     self._table.setDataProviderValues(dataProviderValues)
     showNoItemsInfo = len(dataProviderValues) == 0
     noItemsInfo = None
     if showNoItemsInfo:
         noItemsInfo = {
             'message': text_styles.main(MENU.STORE_MENU_NOITEMS)
         }
     self._table.as_setDataS({
         'gold': g_itemsCache.items.stats.gold,
         'credits': g_itemsCache.items.stats.credits,
         'type': self._currentTab.getTableType(),
         'showNoItemsInfo': showNoItemsInfo,
         'noItemsInfo': noItemsInfo
     })
     return
Пример #4
0
def _getBattleChartsStatistics(battlesStats, levelDisabledTooltip):
    outcome = []
    tDict = battlesStats[0]
    typesRes = []
    for vehType in VEHICLE_TYPES_ORDER:
        typesRes.append({
            'xField':
            i18n.makeString(DIALOGS.vehicleselldialog_vehicletype(vehType)),
            'icon':
            '../maps/icons/filters/tanks/{0}.png'.format(vehType),
            'yField':
            tDict[vehType],
            'tooltip':
            PROFILE.SECTION_STATISTICS_CHART_TYPE_TOOLTIP
        })

    _setChartDataPercentages(typesRes)
    outcome.append(typesRes)
    tDict = battlesStats[1]
    nationRes = []
    for guiNationIdx, _ in enumerate(GUI_NATIONS):
        nationIdx = getNationIndex(guiNationIdx)
        nationName = nations.NAMES[nationIdx]
        nationRes.append({
            'xField':
            i18n.makeString(MENU.nations(nationName)),
            'icon':
            '../maps/icons/filters/nations/{0}.png'.format(nationName),
            'yField':
            tDict[nationIdx],
            'tooltip':
            PROFILE.SECTION_STATISTICS_CHART_NATION_TOOLTIP
        })

    _setChartDataPercentages(nationRes)
    outcome.append(nationRes)
    tDict = battlesStats[2]
    lvlRes = len(tDict) * [None]
    for level, value in tDict.iteritems():
        tooltip = PROFILE.SECTION_STATISTICS_CHART_LEVEL_TOOLTIP
        if value is None:
            value = -1
            if levelDisabledTooltip is not None:
                tooltip = levelDisabledTooltip
        lvlRes[level - 1] = {
            'xField': str(level),
            'icon': '../maps/icons/levels/tank_level_{0}.png'.format(level),
            'yField': value,
            'tooltip': tooltip
        }

    _setChartDataPercentages(lvlRes)
    outcome.append(lvlRes)
    return {'data': outcome}
def _getVehStatsByNation(battlesStats):
    tDict = battlesStats[1]
    nationRes = []
    for guiNationIdx, _ in enumerate(GUI_NATIONS):
        nationIdx = getNationIndex(guiNationIdx)
        nationName = nations.NAMES[nationIdx]
        nationRes.append({'xField': i18n.makeString(MENU.nations(nationName)),
         'icon': '../maps/icons/filters/nations/{0}.png'.format(nationName),
         'yField': tDict[nationIdx],
         'tooltip': PROFILE.SECTION_STATISTICS_CHART_NATION_TOOLTIP})

    _setChartDataPercentages(nationRes)
    return nationRes
Пример #6
0
 def _setTableData(self, filter, nation, type):
     nation = int(nation) if nation >= 0 else None
     if nation is not None:
         nation = getNationIndex(nation)
     filter = list(filter)
     self._clearTableData()
     self._tableType = type
     self._currentTab = self._getTab(self._tableType, nation, filter)
     self._table.setItemWrapper(self._currentTab.itemWrapper)
     self._table.setDataProviderValues(self._currentTab.buildItems(self.__invVehicles))
     self._table.as_setGoldS(g_itemsCache.items.stats.gold)
     self._table.as_setCreditsS(g_itemsCache.items.stats.credits)
     self._table.as_setTableTypeS(self._tableType)
     return
Пример #7
0
 def _setTableData(self, filter, nation, type):
     nation = int(nation) if nation >= 0 else None
     if nation is not None:
         nation = getNationIndex(nation)
     filter = list(filter)
     self._clearTableData()
     self._tableType = type
     self._currentTab = self._getTab(self._tableType, nation, filter)
     self._table.setItemWrapper(self._currentTab.itemWrapper)
     self._table.setDataProviderValues(
         self._currentTab.buildItems(self.__invVehicles))
     self._table.as_setGoldS(g_itemsCache.items.stats.gold)
     self._table.as_setCreditsS(g_itemsCache.items.stats.credits)
     self._table.as_setTableTypeS(self._tableType)
     return
Пример #8
0
def _getBattleChartsStatistics(battlesStats, levelDisabledTooltip):
    outcome = []
    tDict = battlesStats[0]
    typesRes = []
    for vehType in VEHICLE_TYPES_ORDER:
        typesRes.append({'xField': i18n.makeString(DIALOGS.vehicleselldialog_vehicletype(vehType)),
         'icon': '../maps/icons/filters/tanks/{0}.png'.format(vehType),
         'yField': tDict[vehType],
         'tooltip': PROFILE.SECTION_STATISTICS_CHART_TYPE_TOOLTIP})

    _setChartDataPercentages(typesRes)
    outcome.append(typesRes)
    tDict = battlesStats[1]
    nationRes = []
    for guiNationIdx, _ in enumerate(GUI_NATIONS):
        nationIdx = getNationIndex(guiNationIdx)
        nationName = nations.NAMES[nationIdx]
        nationRes.append({'xField': i18n.makeString(MENU.nations(nationName)),
         'icon': '../maps/icons/filters/nations/{0}.png'.format(nationName),
         'yField': tDict[nationIdx],
         'tooltip': PROFILE.SECTION_STATISTICS_CHART_NATION_TOOLTIP})

    _setChartDataPercentages(nationRes)
    outcome.append(nationRes)
    tDict = battlesStats[2]
    lvlRes = len(tDict) * [None]
    for level, value in tDict.iteritems():
        tooltip = PROFILE.SECTION_STATISTICS_CHART_LEVEL_TOOLTIP
        if value is None:
            value = -1
            if levelDisabledTooltip != None:
                tooltip = levelDisabledTooltip
        lvlRes[level - 1] = {'xField': str(level),
         'icon': '../maps/icons/levels/tank_level_{0}.png'.format(level),
         'yField': value,
         'tooltip': tooltip}

    _setChartDataPercentages(lvlRes)
    outcome.append(lvlRes)
    return {'data': outcome}
Пример #9
0
def sortVehTable(tableID,
                 btnID,
                 direction,
                 nation=None,
                 vehType=None,
                 level=None,
                 cbSelected=None,
                 isAction=None):
    result = []
    vehData = getVehiclesData(tableID)
    if vehData is None:
        return result
    else:
        vehList, props = vehData
        updateVehiclesDataProps(tableID,
                                nationIdx=nation,
                                vehTypeIdx=vehType,
                                levelIdx=level,
                                selectedBtn=btnID,
                                sortDirect=direction,
                                checkbox=cbSelected)
        for v, data in vehList:
            if nation != -1 and getNationIndex(nation) != v.nationID:
                continue
            if vehType != -1 and vehType != VEHICLE_TYPES_ORDER_INDICES[
                    v.type]:
                continue
            if level != -1 and level != v.level:
                continue
            if isAction and cbSelected and v.isInInventory:
                continue
            if not isAction and cbSelected and not v.isInInventory:
                continue
            result.append((v, data))

        if btnID in _SORTINGS:
            result.sort(cmp=_SORTINGS[btnID],
                        reverse=direction == 'descending')
        return (result, props.disableChecker)
Пример #10
0
def sortVehTable(tableID, btnID, direction, nation = None, vehType = None, level = None, cbSelected = None, isAction = None):
    result = []
    vehData = getVehiclesData(tableID)
    if vehData is None:
        return result
    vehList, props = vehData
    updateVehiclesDataProps(tableID, nationIdx=nation, vehTypeIdx=vehType, levelIdx=level, selectedBtn=btnID, sortDirect=direction, checkbox=cbSelected)
    for v, data in vehList:
        if nation != -1 and getNationIndex(nation) != v.nationID:
            continue
        if vehType != -1 and vehType != VEHICLE_TYPES_ORDER_INDICES[v.type]:
            continue
        if level != -1 and level != v.level:
            continue
        if isAction and cbSelected and v.isInInventory:
            continue
        if not isAction and cbSelected and not v.isInInventory:
            continue
        result.append((v, data))

    if btnID in _SORTINGS:
        result.sort(cmp=_SORTINGS[btnID], reverse=direction == 'descending')
    return (result, props.disableChecker)
Пример #11
0
def _getBattleChartsStatistics(battlesStats):
    outcome = []
    tDict = battlesStats[0]
    typesRes = []
    for value in VEHICLE_TYPES_ORDER:
        typesRes.append({value: tDict[value]})

    outcome.append(typesRes)
    tDict = battlesStats[1]
    nationRes = []
    for guiNationIdx, _ in enumerate(GUI_NATIONS):
        nationIdx = getNationIndex(guiNationIdx)
        nationRes.append({str(nationIdx): tDict[nationIdx]})

    outcome.append(nationRes)
    tDict = battlesStats[2]
    lvlRes = len(tDict) * [None]
    for level, value in tDict.iteritems():
        if value is None:
            value = -1
        lvlRes[level - 1] = {str(level): value}

    outcome.append(lvlRes)
    return {'data': outcome}
Пример #12
0
    def getData(self, battlesStats):
        outcome = []
        tDict = battlesStats[0]
        typesRes = []
        for value in VEHICLE_TYPES_ORDER:
            typesRes.append({value: tDict[value]})

        outcome.append(typesRes)
        tDict = battlesStats[1]
        nationRes = []
        for guiNationIdx, _ in enumerate(GUI_NATIONS):
            nationIdx = getNationIndex(guiNationIdx)
            nationRes.append({str(nationIdx): tDict[nationIdx]})

        outcome.append(nationRes)
        tDict = battlesStats[2]
        lvlRes = len(tDict) * [None]
        for level, value in tDict.iteritems():
            if value is None:
                value = -1
            lvlRes[level - 1] = {str(level): value}

        outcome.append(lvlRes)
        return {'data': outcome}
Пример #13
0
    def requestTableData(self, nation, type, filter):
        Waiting.show('updateShop')
        AccountSettings.setFilter('shop_current', (nation, type))
        AccountSettings.setFilter('shop_' + type, filter)
        nation = int(nation) if nation >= 0 else None
        if nation is not None:
            nation = getNationIndex(nation)
        filter = list(filter)
        itemTypeID, requestCriteria, inventoryVehicles, checkExtra, extra = self._getRequestParameters(nation, type, filter)
        modulesAll = g_itemsCache.items.getItems(itemTypeID, requestCriteria, nation)
        shopRqs = g_itemsCache.items.shop
        isEnabledBuyingGoldShellsForCredits = shopRqs.isEnabledBuyingGoldShellsForCredits
        isEnabledBuyingGoldEqsForCredits = shopRqs.isEnabledBuyingGoldEqsForCredits
        self._clearTableData()
        self.__tableType = type
        dataProviderValues = []
        for module in sorted(modulesAll.itervalues()):
            extraModuleInfo = None
            if module.itemTypeID == GUI_ITEM_TYPE.GUN and module.isClipGun():
                extraModuleInfo = CLIP_ICON_PATH
            inventoryCount = 0
            vehicleCount = 0
            if module.isInInventory:
                inventoryCount = 1
                if type != self._VEHICLE:
                    inventoryCount = module.inventoryCount
            if type in (self._MODULE, self._OPTIONAL_DEVICE, self._EQUIPMENT):
                installedVehicles = module.getInstalledVehicles(inventoryVehicles)
                vehicleCount = len(installedVehicles)
            if checkExtra:
                if 'locked' not in extra and type not in (self._OPTIONAL_DEVICE, self._EQUIPMENT):
                    if not module.isUnlocked:
                        continue
                if 'inHangar' not in extra and type not in (self._OPTIONAL_DEVICE, self._EQUIPMENT):
                    if inventoryCount > 0 and not module.isRented:
                        continue
                if type == self._VEHICLE and 'rentals' not in extra:
                    if module.isRented:
                        continue
                if 'onVehicle' not in extra:
                    if vehicleCount > 0:
                        continue
            disabled = False
            statusMessage = ''
            money = g_itemsCache.items.stats.money
            if type == self._VEHICLE:
                if module.getState()[0] == Vehicle.VEHICLE_STATE.RENTAL_IS_ORVER:
                    statusMessage = '#menu:store/vehicleStates/%s' % module.getState()[0]
                    disabled = not self._isPurchaseEnabled(module, money)
                elif BigWorld.player().isLongDisconnectedFromCenter:
                    statusMessage = MENU.SHOP_ERRORS_CENTERISDOWN
                    disabled = True
                elif inventoryCount > 0:
                    statusMessage = MENU.SHOP_ERRORS_INHANGAR
                    disabled = True
                    if module.isRentable:
                        disabled = not self._isPurchaseEnabled(module, money)
                elif not module.isUnlocked:
                    statusMessage = MENU.SHOP_ERRORS_UNLOCKNEEDED
                    disabled = True
                else:
                    disabled = not self._isPurchaseEnabled(module, money)
            elif type not in (self._SHELL, self._OPTIONAL_DEVICE, self._EQUIPMENT) and not module.isUnlocked:
                statusMessage = MENU.SHOP_ERRORS_UNLOCKNEEDED
                disabled = True
            else:
                disabled = not self._isPurchaseEnabled(module, money)
            dataProviderValues.append((module,
             inventoryCount,
             vehicleCount,
             disabled,
             statusMessage,
             isEnabledBuyingGoldShellsForCredits,
             isEnabledBuyingGoldEqsForCredits,
             extraModuleInfo))

        self._table.setDataProviderValues(dataProviderValues)
        self._table.as_setGoldS(g_itemsCache.items.stats.gold)
        self._table.as_setCreditsS(g_itemsCache.items.stats.credits)
        self._table.as_setTableTypeS(self.__tableType)
        Waiting.hide('updateShop')
        return
Пример #14
0
    def requestTableData(self, nation, type, filter):
        Waiting.show('updateShop')
        AccountSettings.setFilter('shop_current', (nation, type))
        AccountSettings.setFilter('shop_' + type, filter)
        nation = int(nation) if nation >= 0 else None
        if nation is not None:
            nation = getNationIndex(nation)
        filter = list(filter)
        requestType = [type]
        checkFits = None
        checkFitsArtefacts = None
        checkExtra = False
        modulesFits = {}
        vehicleFits = []
        extra = []
        modulesAllVehicle = []
        if type == self._MODULE:
            typeSize = int(filter.pop(0))
            requestType = filter[0:typeSize]
            filter = filter[typeSize:]
            fitsType = filter.pop(0)
            compact = filter.pop(0)
            if compact == '0':
                LOG_ERROR('compact value has invalid value: ', compact)
                Waiting.hide('updateShop')
                return
            fitsVehicle = getItemByCompact(compact)
            checkExtra = True
            extra = filter[:]
            checkFits = True if fitsType != 'otherVehicles' else None
            myVehicles = yield Requester(self._VEHICLE).getFromInventory()
            modulesAllVehicle = VehicleItemsRequester(myVehicles).getItems(requestType)
            if fitsType == 'myVehicle':
                for rType in requestType:
                    modulesFits.update(_getComponentsByType(fitsVehicle, ITEM_TYPE_INDICES[rType]))

            elif fitsType != 'otherVehicles':
                for vehicle in myVehicles:
                    for rType in requestType:
                        modulesFits.update(_getComponentsByType(vehicle, ITEM_TYPE_INDICES[rType]))

            filter = requestType
        elif type == self._SHELL:
            filterSize = int(filter.pop(0))
            fitsType = filter.pop(filterSize)
            compact = filter.pop(filterSize)
            if compact == '0':
                LOG_ERROR('compact value has invalid value: ', compact)
                Waiting.hide('updateShop')
                return
            fitsVehicle = getItemByCompact(compact)
            checkFits = True if fitsType != 'otherGuns' else None
            if fitsType == 'myVehicleGun':
                for shoot in fitsVehicle.descriptor.gun['shots']:
                    modulesFits[shoot[self._SHELL]['compactDescr']] = True

            elif fitsType == 'myInventoryGuns':
                myGuns = yield Requester('vehicleGun').getFromInventory()
                for gun in myGuns:
                    for shoot in gun.descriptor['shots']:
                        modulesFits[shoot[self._SHELL]['compactDescr']] = True

            elif fitsType != 'otherGuns':
                myGuns = yield Requester('vehicleGun').getFromInventory()
                for gun in myGuns:
                    for shoot in gun.descriptor['shots']:
                        modulesFits[shoot[self._SHELL]['compactDescr']] = True

                myVehicles = yield Requester(self._VEHICLE).getFromInventory()
                for vehicle in myVehicles:
                    for shoot in vehicle.descriptor.gun['shots']:
                        modulesFits[shoot[self._SHELL]['compactDescr']] = True

        elif type == self._VEHICLE:
            filterSize = int(filter.pop(0))
            extra = filter[filterSize:]
            checkExtra = True
            filter = filter[0:filterSize]
        else:
            fitsType = filter.pop(0)
            compact = filter.pop(0)
            if compact == '0':
                LOG_ERROR('compact value has invalid value: ', compact)
                Waiting.hide('updateShop')
                return
            fitsVehicle = getItemByCompact(compact)
            extra = filter
            checkExtra = type in (self._OPTIONAL_DEVICE, self._EQUIPMENT)
            checkFitsArtefacts = True if fitsType != 'otherVehicles' else None
            myVehicles = yield Requester(self._VEHICLE).getFromInventory()
            modulesAllVehicle = VehicleItemsRequester(myVehicles).getItems(requestType)
            if fitsType == 'myVehicle':
                vehicleFits = [fitsVehicle]
            elif fitsType != 'otherVehicles':
                vehicleFits = [ v for v in myVehicles if v.nation == nation ] if nation != None else myVehicles
            filter = requestType
        filter = map(lambda w: w.lower(), filter)
        modulesAll = list()
        modulesAllInventory = list()
        for rType in requestType:
            inv = yield Requester(rType).getFromInventory()
            modulesAllInventory.extend(inv)
            shp = yield Requester(rType).getFromShop(nation=nation)
            modulesAll.extend(shp)

        unlocks = yield StatsRequester().getUnlocks()
        shopRqs = yield ShopRequester().request()
        self.__clearTableData()
        self.__tableData = [type]
        modulesAll.sort()
        for module in modulesAll:
            extraModuleInfo = None
            if module.hidden:
                continue
            if module.type.lower() not in filter:
                continue
            if checkFits is not None:
                if (module.compactDescr in modulesFits.keys()) != checkFits:
                    continue
            if checkFitsArtefacts is not None:
                for veh in vehicleFits:
                    if module.descriptor.checkCompatibilityWithVehicle(veh.descriptor)[0] == checkFitsArtefacts:
                        break
                else:
                    continue

            if module.isClipGun():
                extraModuleInfo = CLIP_ICON_PATH
            inventoryCount = 0
            vehicleCount = 0
            installedIn = ''
            if module in modulesAllInventory:
                inventoryCount = 1
                if type != self._VEHICLE:
                    inventoryModule = modulesAllInventory[modulesAllInventory.index(module)]
                    inventoryCount = inventoryModule.count
            if type in (self._MODULE, self._OPTIONAL_DEVICE, self._EQUIPMENT) and module in modulesAllVehicle:
                vehModule = modulesAllVehicle[modulesAllVehicle.index(module)]
                vehicleCount = vehModule.count
                installedIn = ', '.join([ v.shortName for v in vehModule.vehicles ])
            if checkExtra:
                if 'locked' not in extra:
                    if type == self._VEHICLE:
                        compdecs = module.descriptor.type.compactDescr
                        if compdecs not in unlocks:
                            continue
                    elif type not in (self._SHELL, self._OPTIONAL_DEVICE, self._EQUIPMENT) and module.compactDescr not in unlocks:
                        continue
                if 'inHangar' not in extra and type not in (self._OPTIONAL_DEVICE, self._EQUIPMENT):
                    if inventoryCount > 0:
                        continue
                if 'onVehicle' not in extra:
                    if vehicleCount > 0:
                        continue
            disabled = ''
            if type == self._VEHICLE:
                if BigWorld.player().isLongDisconnectedFromCenter:
                    disabled = MENU.SHOP_ERRORS_CENTERISDOWN
                if inventoryCount > 0:
                    disabled = MENU.SHOP_ERRORS_INHANGAR
                else:
                    compdecs = module.descriptor.type.compactDescr
                    if compdecs not in unlocks:
                        disabled = MENU.SHOP_ERRORS_UNLOCKNEEDED
            elif type not in (self._SHELL, self._OPTIONAL_DEVICE, self._EQUIPMENT) and module.compactDescr not in unlocks:
                disabled = MENU.SHOP_ERRORS_UNLOCKNEEDED
            if not (shopRqs.isEnabledBuyingGoldShellsForCredits and module.itemTypeName == 'shell'):
                goldAmmoForCredits = shopRqs.isEnabledBuyingGoldEqsForCredits and module.itemTypeName == 'equipment'
                module.priceOrder = goldAmmoForCredits and (module.priceOrder[0] + module.priceOrder[1] * shopRqs.exchangeRateForShellsAndEqs, module.priceOrder[1])
            valueElement = {'id': compactItem(module),
             'name': module.name if type in (self._OPTIONAL_DEVICE, self._EQUIPMENT) else module.longName,
             'desc': getShortDescr(module.tableName),
             'inventoryId': None,
             'inventoryCount': inventoryCount,
             'vehicleCount': vehicleCount,
             'credits': module.priceOrder[0],
             'gold': module.priceOrder[1],
             'price': module.priceOrder,
             'currency': 'credits' if module.priceOrder[1] == 0 else 'gold',
             'level': module.level,
             'nation': module.nation,
             'type': module.itemTypeName if type not in (self._VEHICLE,
                      self._OPTIONAL_DEVICE,
                      self._SHELL,
                      self._EQUIPMENT) else module.icon,
             'disabled': disabled,
             'statusLevel': InventoryVehicle.STATE_LEVEL.WARNING,
             'removable': module.descriptor['removable'] if type == self._OPTIONAL_DEVICE else True,
             'tankType': module.type if type == self._VEHICLE else type,
             'isPremium': module.isPremium if type == self._VEHICLE else False,
             'isElite': self.app.tooltipManager.isVehicleElite(module) if type == self._VEHICLE else False,
             'itemTypeName': module.itemTypeName,
             'goldShellsForCredits': shopRqs.isEnabledBuyingGoldShellsForCredits,
             'goldEqsForCredits': shopRqs.isEnabledBuyingGoldEqsForCredits,
             EXTRA_MODULE_INFO: extraModuleInfo}
            self.__tableData.append(valueElement)

        requester = yield StatsRequesterr().request()
        self._table.as_setGoldS(requester.gold)
        self._table.as_setCreditsS(requester.credits)
        self._table.as_setTableS(self.__tableData)
        Waiting.hide('updateShop')
        return
Пример #15
0
    def requestTableData(self, nation, type, filter):
        Waiting.show('updateInventory')
        AccountSettings.setFilter('inventory_current', (nation, type))
        AccountSettings.setFilter('inventory_' + type, filter)
        nation = int(nation) if nation >= 0 else None
        if nation is not None:
            nation = getNationIndex(nation)
        filter = list(filter)
        itemTypeID, requestCriteria, inventoryVehicles, checkExtra, extra = self._getRequestParameters(nation, type, filter)
        modulesAll = g_itemsCache.items.getItems(itemTypeID, requestCriteria, nation)
        shopRqs = g_itemsCache.items.shop
        isEnabledBuyingGoldShellsForCredits = shopRqs.isEnabledBuyingGoldShellsForCredits
        isEnabledBuyingGoldEqsForCredits = shopRqs.isEnabledBuyingGoldEqsForCredits
        self._clearTableData()
        self.__tableType = type
        dataProviderValues = []
        for module in sorted(modulesAll.itervalues()):
            extraModuleInfo = None
            if module.itemTypeID == GUI_ITEM_TYPE.GUN and module.isClipGun():
                extraModuleInfo = CLIP_ICON_PATH
            inventoryCount = 0
            vehicleCount = 0
            if module.isInInventory:
                inventoryCount = 1
                if type != self._VEHICLE:
                    inventoryCount = module.inventoryCount
            if type in (self._MODULE, self._OPTIONAL_DEVICE, self._EQUIPMENT):
                installedVehicles = module.getInstalledVehicles(inventoryVehicles)
                vehicleCount = len(installedVehicles)
            if checkExtra:
                if type == self._VEHICLE and 'brocken' not in extra:
                    if module.repairCost > 0:
                        continue
                if type == self._VEHICLE and 'locked' not in extra:
                    if module.isLocked:
                        continue
                if type == self._VEHICLE and 'premiumIGR' not in extra:
                    if module.isPremiumIGR:
                        continue
                if type == self._VEHICLE and IS_RENTALS_ENABLED and 'rentals' not in extra:
                    if module.isRented and not module.isPremiumIGR:
                        continue
                if 'onVehicle' in extra:
                    if vehicleCount == 0 and inventoryCount == 0:
                        continue
            disable = False
            statusMessage = ''
            if type == self._VEHICLE:
                state = module.getState()[0]
                isStateSuitable = state in (Vehicle.VEHICLE_STATE.RENTAL_IS_ORVER, Vehicle.VEHICLE_STATE.IGR_RENTAL_IS_ORVER)
                isExcludedState = state in (Vehicle.VEHICLE_STATE.UNSUITABLE_TO_UNIT,)
                if isStateSuitable or not isExcludedState and not module.canSell:
                    statusMessage = makeString('#menu:store/vehicleStates/%s' % state)
                    disable = not module.canSell
            elif type in (self._MODULE, self._OPTIONAL_DEVICE, self._EQUIPMENT) and not module.isInInventory:
                if type == self._OPTIONAL_DEVICE:
                    if not module.descriptor['removable']:
                        statusMessage = makeString(MENU.INVENTORY_DEVICE_ERRORS_NOT_REMOVABLE)
                        disable = True
                    else:
                        statusMessage = makeString(MENU.INVENTORY_DEVICE_ERRORS_RESERVED)
                        disable = True
                else:
                    statusMessage = makeString(MENU.INVENTORY_ERRORS_RESERVED)
                    disable = True
            dataProviderValues.append((module,
             inventoryCount,
             vehicleCount,
             disable,
             statusMessage,
             isEnabledBuyingGoldShellsForCredits,
             isEnabledBuyingGoldEqsForCredits,
             extraModuleInfo))

        self._table.setDataProviderValues(dataProviderValues)
        self._table.as_setGoldS(g_itemsCache.items.stats.gold)
        self._table.as_setCreditsS(g_itemsCache.items.stats.credits)
        self._table.as_setTableTypeS(self.__tableType)
        Waiting.hide('updateInventory')
        return
Пример #16
0
    def requestTableData(self, nation, type, filter):
        Waiting.show('updateShop')
        AccountSettings.setFilter('shop_current', (nation, type))
        AccountSettings.setFilter('shop_' + type, filter)
        nation = int(nation) if nation >= 0 else None
        if nation is not None:
            nation = getNationIndex(nation)
        filter = list(filter)
        itemTypeID, requestCriteria, inventoryVehicles, checkExtra, extra = self._getRequestParameters(nation, type, filter)
        modulesAll = g_itemsCache.items.getItems(itemTypeID, requestCriteria, nation)
        shopRqs = g_itemsCache.items.shop
        isEnabledBuyingGoldShellsForCredits = shopRqs.isEnabledBuyingGoldShellsForCredits
        isEnabledBuyingGoldEqsForCredits = shopRqs.isEnabledBuyingGoldEqsForCredits
        self._clearTableData()
        self.__tableType = type
        dataProviderValues = []
        for module in sorted(modulesAll.itervalues()):
            extraModuleInfo = None
            if module.itemTypeID == GUI_ITEM_TYPE.GUN and module.isClipGun():
                extraModuleInfo = CLIP_ICON_PATH
            inventoryCount = 0
            vehicleCount = 0
            if module.isInInventory:
                inventoryCount = 1
                if type != self._VEHICLE:
                    inventoryCount = module.inventoryCount
            if type in (self._MODULE, self._OPTIONAL_DEVICE, self._EQUIPMENT):
                installedVehicles = module.getInstalledVehicles(inventoryVehicles)
                vehicleCount = len(installedVehicles)
            if checkExtra:
                if 'locked' not in extra and type not in (self._OPTIONAL_DEVICE, self._EQUIPMENT):
                    if not module.isUnlocked:
                        continue
                if 'inHangar' not in extra and type not in (self._OPTIONAL_DEVICE, self._EQUIPMENT):
                    if inventoryCount > 0 and not module.isRented:
                        continue
                if type == self._VEHICLE and 'rentals' not in extra:
                    if module.isRented:
                        continue
                if 'onVehicle' not in extra:
                    if vehicleCount > 0:
                        continue
            disabled = False
            statusMessage = ''
            money = g_itemsCache.items.stats.money
            if type == self._VEHICLE:
                if module.getState()[0] == Vehicle.VEHICLE_STATE.RENTAL_IS_ORVER:
                    statusMessage = '#menu:store/vehicleStates/%s' % module.getState()[0]
                    disabled = not self._isPurchaseEnabled(module, money)
                elif BigWorld.player().isLongDisconnectedFromCenter:
                    statusMessage = MENU.SHOP_ERRORS_CENTERISDOWN
                    disabled = True
                elif inventoryCount > 0:
                    statusMessage = MENU.SHOP_ERRORS_INHANGAR
                    disabled = True
                    if module.isRentable:
                        disabled = not self._isPurchaseEnabled(module, money)
                elif not module.isUnlocked:
                    statusMessage = MENU.SHOP_ERRORS_UNLOCKNEEDED
                    disabled = True
                else:
                    disabled = not self._isPurchaseEnabled(module, money)
            elif type not in (self._SHELL, self._OPTIONAL_DEVICE, self._EQUIPMENT) and not module.isUnlocked:
                statusMessage = MENU.SHOP_ERRORS_UNLOCKNEEDED
                disabled = True
            else:
                disabled = not self._isPurchaseEnabled(module, money)
            dataProviderValues.append((module,
             inventoryCount,
             vehicleCount,
             disabled,
             statusMessage,
             isEnabledBuyingGoldShellsForCredits,
             isEnabledBuyingGoldEqsForCredits,
             extraModuleInfo))

        self._table.setDataProviderValues(dataProviderValues)
        self._table.as_setGoldS(g_itemsCache.items.stats.gold)
        self._table.as_setCreditsS(g_itemsCache.items.stats.credits)
        self._table.as_setTableTypeS(self.__tableType)
        Waiting.hide('updateShop')
Пример #17
0
    def requestTableData(self, nation, type, filter):
        Waiting.show('updateInventory')
        AccountSettings.setFilter('inventory_current', (nation, type))
        AccountSettings.setFilter('inventory_' + type, filter)
        nation = int(nation) if nation >= 0 else None
        if nation is not None:
            nation = getNationIndex(nation)
        filter = list(filter)
        requestType = [type]
        checkFits = None
        checkFitsArtefacts = None
        checkExtra = False
        modulesFits = {}
        vehicleFits = []
        extra = []
        modulesAllVehicle = []
        if type == self._MODULE:
            typeSize = int(filter.pop(0))
            requestType = filter[0:typeSize]
            filter = filter[typeSize:]
            fitsType = filter.pop(0)
            fitsVehicle = getItemByCompact(filter.pop(0))
            checkExtra = True
            extra = filter[:]
            checkFits = True if fitsType != 'otherVehicles' else False
            myVehicles = yield Requester(self._VEHICLE).getFromInventory()
            modulesAllVehicle = VehicleItemsRequester(myVehicles).getItems(requestType)
            if fitsType == 'myVehicle':
                if fitsVehicle:
                    for rType in requestType:
                        modulesFits.update(_getComponentsByType(fitsVehicle, ITEM_TYPE_INDICES[rType]))

            else:
                for vehicle in myVehicles:
                    for rType in requestType:
                        modulesFits.update(_getComponentsByType(vehicle, ITEM_TYPE_INDICES[rType]))

            filter = requestType
        elif type == self._SHELL:
            filterSize = int(filter.pop(0))
            fitsType = filter.pop(filterSize)
            fitsVehicle = getItemByCompact(filter.pop(filterSize))
            checkFits = True if fitsType != 'otherGuns' else False
            if fitsType == 'myVehicleGun':
                for shoot in fitsVehicle.descriptor.gun['shots']:
                    modulesFits[shoot[self._SHELL]['compactDescr']] = True

            elif fitsType == 'myInventoryGuns':
                myGuns = yield Requester('vehicleGun').getFromInventory()
                for gun in myGuns:
                    for shoot in gun.descriptor['shots']:
                        modulesFits[shoot[self._SHELL]['compactDescr']] = True

            else:
                myGuns = yield Requester('vehicleGun').getFromInventory()
                for gun in myGuns:
                    for shoot in gun.descriptor['shots']:
                        modulesFits[shoot[self._SHELL]['compactDescr']] = True

                myVehicles = yield Requester(self._VEHICLE).getFromInventory()
                for vehicle in myVehicles:
                    for shoot in vehicle.descriptor.gun['shots']:
                        modulesFits[shoot[self._SHELL]['compactDescr']] = True

        elif type == self._VEHICLE:
            filterSize = int(filter.pop(0))
            extra = filter[filterSize:]
            checkExtra = True
            filter = filter[0:filterSize]
        else:
            fitsType = filter.pop(0)
            compact = filter.pop(0)
            fitsVehicle = getItemByCompact(compact)
            extra = filter
            checkExtra = type in (self._OPTIONAL_DEVICE, self._EQUIPMENT)
            checkFitsArtefacts = True if fitsType != 'otherVehicles' else False
            myVehicles = yield Requester(self._VEHICLE).getFromInventory()
            modulesAllVehicle = VehicleItemsRequester(myVehicles).getItems(requestType)
            if fitsType == 'myVehicle':
                vehicleFits = [fitsVehicle]
            else:
                vehicleFits = myVehicles
            filter = requestType
        filter = map(lambda w: w.lower(), filter)
        modulesAll = list()
        modulesShop = list()
        for rType in requestType:
            inv = yield Requester(rType).getFromInventory()
            shp = yield Requester(rType).getFromShop()
            modulesShop.extend(shp)
            modulesAll.extend(inv)

        vehPrices = {}
        if type == self._VEHICLE:
            compactDescrs = [ v.compactDescr for v in modulesAll ]
            vehPrices = yield StatsRequester().getVehiclesPrices(compactDescrs)
            vehPrices = dict(zip(compactDescrs, vehPrices))
        if type in (self._MODULE, self._OPTIONAL_DEVICE, self._EQUIPMENT):
            for vehModule in modulesAllVehicle:
                if vehModule not in modulesAll:
                    if modulesShop.count(vehModule) != 0:
                        modulesAll.append(vehModule)

        self.__clearTableData()
        self.__tableData = [type]
        excludeModules = []
        for module in modulesAll:
            if modulesShop.count(module) != 0:
                module.priceOrder = modulesShop[modulesShop.index(module)].priceOrder
            elif constants.IS_DEVELOPMENT:
                excludeModules.append(module)
                LOG_ERROR("Not found module %s '%s' (%r) in shop." % (module.type, module.unicName, module.compactDescr))

        modulesAll.sort()
        shopRqs = yield ShopRequester().request()
        for module in modulesAll:
            extraModuleInfo = None
            if module in excludeModules:
                continue
            if nation is not None:
                if module.nation != nation and module.nation != nations.NONE_INDEX:
                    continue
                if module.type.lower() not in filter:
                    continue
                if checkFits is not None:
                    if (module.compactDescr in modulesFits.keys()) != checkFits:
                        continue
                if module.isClipGun():
                    extraModuleInfo = CLIP_ICON_PATH
                if checkFitsArtefacts is not None:
                    compatible = False
                    for veh in vehicleFits:
                        if nation is not None and veh.nation != nation:
                            continue
                        compatible |= module.descriptor.checkCompatibilityWithVehicle(veh.descriptor)[0]

                    if compatible != checkFitsArtefacts:
                        continue
                inventoryCount = 0
                vehicleCount = 0
                if isinstance(module, VehicleItem):
                    vehicleCount = module.count
                else:
                    inventoryCount = module.count
                    if type in (self._MODULE, self._OPTIONAL_DEVICE, self._EQUIPMENT) and module in modulesAllVehicle:
                        vehModule = modulesAllVehicle[modulesAllVehicle.index(module)]
                        vehicleCount = vehModule.count
                if checkExtra:
                    if type == self._VEHICLE and 'brocken' not in extra:
                        if module.repairCost > 0:
                            continue
                    if type == self._VEHICLE and 'locked' not in extra:
                        if module.lock != 0:
                            continue
                    if 'onVehicle' not in extra:
                        if vehicleCount > 0 and inventoryCount == 0:
                            continue
                disable = ''
                if type == self._VEHICLE and not module.canSell:
                    disable = makeString(MENU.tankcarousel_vehiclestates(module.getState()))
                elif type in (self._MODULE, self._OPTIONAL_DEVICE, self._EQUIPMENT) and isinstance(module, VehicleItem):
                    if type == self._OPTIONAL_DEVICE:
                        if not module.descriptor['removable']:
                            disable = makeString(MENU.INVENTORY_DEVICE_ERRORS_NOT_REMOVABLE)
                        else:
                            disable = makeString(MENU.INVENTORY_DEVICE_ERRORS_RESERVED)
                    else:
                        disable = makeString(MENU.INVENTORY_ERRORS_RESERVED)
                sellPrice = isinstance(module, InventoryVehicle) and vehPrices.get(module.compactDescr, (0, 0))
            else:
                sellPrice = (0, 0)
                item = g_itemsCache.items.getItemByCD(module.compactDescr)
                if item is not None:
                    sellPrice = item.sellPrice
            valueElement = {'id': compactItem(module),
             'name': module.name if type in (self._OPTIONAL_DEVICE, self._EQUIPMENT) else module.longName,
             'desc': getShortDescr(module.tableName),
             'inventoryId': module.inventoryId if isinstance(module, InventoryVehicle) else None,
             'inventoryCount': inventoryCount,
             'vehicleCount': vehicleCount,
             'credits': sellPrice[0],
             'gold': sellPrice[1],
             'price': sellPrice,
             'currency': 'credits' if sellPrice[1] == 0 else 'gold',
             'level': module.level,
             'nation': module.nation,
             'type': module.itemTypeName if type not in (self._VEHICLE,
                      self._OPTIONAL_DEVICE,
                      self._SHELL,
                      self._EQUIPMENT) else module.icon,
             'disabled': disable,
             'statusLevel': module.getStateLevel() if isinstance(module, InventoryVehicle) else InventoryVehicle.STATE_LEVEL.INFO,
             'removable': module.descriptor['removable'] if type == self._OPTIONAL_DEVICE else True,
             'tankType': module.type if type == self._VEHICLE else type,
             'isPremium': module.isPremium if type == self._VEHICLE else False,
             'isElite': self.app.tooltipManager.isVehicleElite(module) if type == self._VEHICLE else False,
             'itemTypeName': module.itemTypeName,
             'goldShellsForCredits': shopRqs.isEnabledBuyingGoldShellsForCredits,
             'goldEqsForCredits': shopRqs.isEnabledBuyingGoldEqsForCredits,
             EXTRA_MODULE_INFO: extraModuleInfo}
            self.__tableData.append(valueElement)

        requester = yield StatsRequesterr().request()
        self._table.as_setGoldS(requester.gold)
        self._table.as_setCreditsS(requester.credits)
        self._table.as_setTableS(self.__tableData)
        Waiting.hide('updateInventory')
        return
Пример #18
0
    def requestTableData(self, nation, type, filter):
        Waiting.show('updateShop')
        AccountSettings.setFilter('shop_current', (nation, type))
        AccountSettings.setFilter('shop_' + type, filter)
        nation = int(nation) if nation >= 0 else None
        if nation is not None:
            nation = getNationIndex(nation)
        filter = list(filter)
        requestType = [type]
        checkFits = None
        checkFitsArtefacts = None
        checkExtra = False
        modulesFits = {}
        vehicleFits = []
        extra = []
        modulesAllVehicle = []
        if type == self._MODULE:
            typeSize = int(filter.pop(0))
            requestType = filter[0:typeSize]
            filter = filter[typeSize:]
            fitsType = filter.pop(0)
            compact = filter.pop(0)
            if compact == '0':
                LOG_ERROR('compact value has invalid value: ', compact)
                Waiting.hide('updateShop')
                return
            fitsVehicle = getItemByCompact(compact)
            checkExtra = True
            extra = filter[:]
            checkFits = True if fitsType != 'otherVehicles' else None
            myVehicles = yield Requester(self._VEHICLE).getFromInventory()
            modulesAllVehicle = VehicleItemsRequester(myVehicles).getItems(
                requestType)
            if fitsType == 'myVehicle':
                for rType in requestType:
                    modulesFits.update(
                        _getComponentsByType(fitsVehicle,
                                             ITEM_TYPE_INDICES[rType]))

            elif fitsType != 'otherVehicles':
                for vehicle in myVehicles:
                    for rType in requestType:
                        modulesFits.update(
                            _getComponentsByType(vehicle,
                                                 ITEM_TYPE_INDICES[rType]))

            filter = requestType
        elif type == self._SHELL:
            filterSize = int(filter.pop(0))
            fitsType = filter.pop(filterSize)
            compact = filter.pop(filterSize)
            if compact == '0':
                LOG_ERROR('compact value has invalid value: ', compact)
                Waiting.hide('updateShop')
                return
            fitsVehicle = getItemByCompact(compact)
            checkFits = True if fitsType != 'otherGuns' else None
            if fitsType == 'myVehicleGun':
                for shoot in fitsVehicle.descriptor.gun['shots']:
                    modulesFits[shoot[self._SHELL]['compactDescr']] = True

            elif fitsType == 'myInventoryGuns':
                myGuns = yield Requester('vehicleGun').getFromInventory()
                for gun in myGuns:
                    for shoot in gun.descriptor['shots']:
                        modulesFits[shoot[self._SHELL]['compactDescr']] = True

            elif fitsType != 'otherGuns':
                myGuns = yield Requester('vehicleGun').getFromInventory()
                for gun in myGuns:
                    for shoot in gun.descriptor['shots']:
                        modulesFits[shoot[self._SHELL]['compactDescr']] = True

                myVehicles = yield Requester(self._VEHICLE).getFromInventory()
                for vehicle in myVehicles:
                    for shoot in vehicle.descriptor.gun['shots']:
                        modulesFits[shoot[self._SHELL]['compactDescr']] = True

        elif type == self._VEHICLE:
            filterSize = int(filter.pop(0))
            extra = filter[filterSize:]
            checkExtra = True
            filter = filter[0:filterSize]
        else:
            fitsType = filter.pop(0)
            compact = filter.pop(0)
            if compact == '0':
                LOG_ERROR('compact value has invalid value: ', compact)
                Waiting.hide('updateShop')
                return
            fitsVehicle = getItemByCompact(compact)
            extra = filter
            checkExtra = type in (self._OPTIONAL_DEVICE, self._EQUIPMENT)
            checkFitsArtefacts = True if fitsType != 'otherVehicles' else None
            myVehicles = yield Requester(self._VEHICLE).getFromInventory()
            modulesAllVehicle = VehicleItemsRequester(myVehicles).getItems(
                requestType)
            if fitsType == 'myVehicle':
                vehicleFits = [fitsVehicle]
            elif fitsType != 'otherVehicles':
                vehicleFits = [v for v in myVehicles if v.nation == nation
                               ] if nation != None else myVehicles
            filter = requestType
        filter = map(lambda w: w.lower(), filter)
        modulesAll = list()
        modulesAllInventory = list()
        for rType in requestType:
            inv = yield Requester(rType).getFromInventory()
            modulesAllInventory.extend(inv)
            shp = yield Requester(rType).getFromShop(nation=nation)
            modulesAll.extend(shp)

        unlocks = yield StatsRequester().getUnlocks()
        shopRqs = yield ShopRequester().request()
        self.__clearTableData()
        self.__tableData = [type]
        modulesAll.sort()
        for module in modulesAll:
            extraModuleInfo = None
            if module.hidden:
                continue
            if module.type.lower() not in filter:
                continue
            if checkFits is not None:
                if (module.compactDescr in modulesFits.keys()) != checkFits:
                    continue
            if checkFitsArtefacts is not None:
                for veh in vehicleFits:
                    if module.descriptor.checkCompatibilityWithVehicle(
                            veh.descriptor)[0] == checkFitsArtefacts:
                        break
                else:
                    continue

            if module.isClipGun():
                extraModuleInfo = CLIP_ICON_PATH
            inventoryCount = 0
            vehicleCount = 0
            installedIn = ''
            if module in modulesAllInventory:
                inventoryCount = 1
                if type != self._VEHICLE:
                    inventoryModule = modulesAllInventory[
                        modulesAllInventory.index(module)]
                    inventoryCount = inventoryModule.count
            if type in (self._MODULE, self._OPTIONAL_DEVICE,
                        self._EQUIPMENT) and module in modulesAllVehicle:
                vehModule = modulesAllVehicle[modulesAllVehicle.index(module)]
                vehicleCount = vehModule.count
                installedIn = ', '.join(
                    [v.shortName for v in vehModule.vehicles])
            if checkExtra:
                if 'locked' not in extra:
                    if type == self._VEHICLE:
                        compdecs = module.descriptor.type.compactDescr
                        if compdecs not in unlocks:
                            continue
                    elif type not in (self._SHELL, self._OPTIONAL_DEVICE,
                                      self._EQUIPMENT
                                      ) and module.compactDescr not in unlocks:
                        continue
                if 'inHangar' not in extra and type not in (
                        self._OPTIONAL_DEVICE, self._EQUIPMENT):
                    if inventoryCount > 0:
                        continue
                if 'onVehicle' not in extra:
                    if vehicleCount > 0:
                        continue
            disabled = ''
            if type == self._VEHICLE:
                if BigWorld.player().isLongDisconnectedFromCenter:
                    disabled = MENU.SHOP_ERRORS_CENTERISDOWN
                if inventoryCount > 0:
                    disabled = MENU.SHOP_ERRORS_INHANGAR
                else:
                    compdecs = module.descriptor.type.compactDescr
                    if compdecs not in unlocks:
                        disabled = MENU.SHOP_ERRORS_UNLOCKNEEDED
            elif type not in (
                    self._SHELL, self._OPTIONAL_DEVICE,
                    self._EQUIPMENT) and module.compactDescr not in unlocks:
                disabled = MENU.SHOP_ERRORS_UNLOCKNEEDED
            if not (shopRqs.isEnabledBuyingGoldShellsForCredits
                    and module.itemTypeName == 'shell'):
                goldAmmoForCredits = shopRqs.isEnabledBuyingGoldEqsForCredits and module.itemTypeName == 'equipment'
                module.priceOrder = goldAmmoForCredits and (
                    module.priceOrder[0] +
                    module.priceOrder[1] * shopRqs.exchangeRateForShellsAndEqs,
                    module.priceOrder[1])
            valueElement = {
                'id':
                compactItem(module),
                'name':
                module.name if type in (self._OPTIONAL_DEVICE,
                                        self._EQUIPMENT) else module.longName,
                'desc':
                getShortDescr(module.tableName),
                'inventoryId':
                None,
                'inventoryCount':
                inventoryCount,
                'vehicleCount':
                vehicleCount,
                'credits':
                module.priceOrder[0],
                'gold':
                module.priceOrder[1],
                'price':
                module.priceOrder,
                'currency':
                'credits' if module.priceOrder[1] == 0 else 'gold',
                'level':
                module.level,
                'nation':
                module.nation,
                'type':
                module.itemTypeName
                if type not in (self._VEHICLE, self._OPTIONAL_DEVICE,
                                self._SHELL, self._EQUIPMENT) else module.icon,
                'disabled':
                disabled,
                'statusLevel':
                InventoryVehicle.STATE_LEVEL.WARNING,
                'removable':
                module.descriptor['removable']
                if type == self._OPTIONAL_DEVICE else True,
                'tankType':
                module.type if type == self._VEHICLE else type,
                'isPremium':
                module.isPremium if type == self._VEHICLE else False,
                'isElite':
                self.app.tooltipManager.isVehicleElite(module)
                if type == self._VEHICLE else False,
                'itemTypeName':
                module.itemTypeName,
                'goldShellsForCredits':
                shopRqs.isEnabledBuyingGoldShellsForCredits,
                'goldEqsForCredits':
                shopRqs.isEnabledBuyingGoldEqsForCredits,
                EXTRA_MODULE_INFO:
                extraModuleInfo
            }
            self.__tableData.append(valueElement)

        requester = yield StatsRequesterr().request()
        self._table.as_setGoldS(requester.gold)
        self._table.as_setCreditsS(requester.credits)
        self._table.as_setTableS(self.__tableData)
        Waiting.hide('updateShop')
        return
Пример #19
0
    def requestTableData(self, nation, type, filter):
        Waiting.show('updateInventory')
        AccountSettings.setFilter('inventory_current', (nation, type))
        AccountSettings.setFilter('inventory_' + type, filter)
        nation = int(nation) if nation >= 0 else None
        if nation is not None:
            nation = getNationIndex(nation)
        filter = list(filter)
        itemTypeID, requestCriteria, inventoryVehicles, checkExtra, extra = self._getRequestParameters(nation, type, filter)
        modulesAll = g_itemsCache.items.getItems(itemTypeID, requestCriteria, nation)
        shopRqs = g_itemsCache.items.shop
        isEnabledBuyingGoldShellsForCredits = shopRqs.isEnabledBuyingGoldShellsForCredits
        isEnabledBuyingGoldEqsForCredits = shopRqs.isEnabledBuyingGoldEqsForCredits
        self._clearTableData()
        self.__tableType = type
        dataProviderValues = []
        for module in sorted(modulesAll.itervalues()):
            extraModuleInfo = None
            if module.itemTypeID == GUI_ITEM_TYPE.GUN and module.isClipGun():
                extraModuleInfo = CLIP_ICON_PATH
            inventoryCount = 0
            vehicleCount = 0
            if module.isInInventory:
                inventoryCount = 1
                if type != self._VEHICLE:
                    inventoryCount = module.inventoryCount
            if type in (self._MODULE, self._OPTIONAL_DEVICE, self._EQUIPMENT):
                installedVehicles = module.getInstalledVehicles(inventoryVehicles)
                vehicleCount = len(installedVehicles)
            if checkExtra:
                if type == self._VEHICLE and 'brocken' not in extra:
                    if module.repairCost > 0:
                        continue
                if type == self._VEHICLE and 'locked' not in extra:
                    if not module.isUnlocked:
                        continue
                if type == self._VEHICLE and 'premiumIGR' not in extra:
                    if module.isPremiumIGR:
                        continue
                if type == self._VEHICLE and IS_RENTALS_ENABLED and 'rentals' not in extra:
                    if module.isRented and not module.isPremiumIGR:
                        continue
                if 'onVehicle' in extra:
                    if vehicleCount == 0 and inventoryCount == 0:
                        continue
            disable = False
            statusMessage = ''
            if type == self._VEHICLE:
                if module.getState()[0] in (Vehicle.VEHICLE_STATE.RENTAL_IS_ORVER, Vehicle.VEHICLE_STATE.IGR_RENTAL_IS_ORVER) or not module.canSell:
                    statusMessage = makeString('#menu:store/vehicleStates/%s' % module.getState()[0])
                    disable = not module.canSell
            elif type in (self._MODULE, self._OPTIONAL_DEVICE, self._EQUIPMENT) and not module.isInInventory:
                if type == self._OPTIONAL_DEVICE:
                    if not module.descriptor['removable']:
                        statusMessage = makeString(MENU.INVENTORY_DEVICE_ERRORS_NOT_REMOVABLE)
                        disable = True
                    else:
                        statusMessage = makeString(MENU.INVENTORY_DEVICE_ERRORS_RESERVED)
                        disable = True
                else:
                    statusMessage = makeString(MENU.INVENTORY_ERRORS_RESERVED)
                    disable = True
            dataProviderValues.append((module,
             inventoryCount,
             vehicleCount,
             disable,
             statusMessage,
             isEnabledBuyingGoldShellsForCredits,
             isEnabledBuyingGoldEqsForCredits,
             extraModuleInfo))

        self._table.setDataProviderValues(dataProviderValues)
        self._table.as_setGoldS(g_itemsCache.items.stats.gold)
        self._table.as_setCreditsS(g_itemsCache.items.stats.credits)
        self._table.as_setTableTypeS(self.__tableType)
        Waiting.hide('updateInventory')