def __precachEquipments(self): self.__cache.setdefault(nations.NONE_INDEX, {})[vehicles._EQUIPMENT] = {} equipments = self.__getItems(vehicles._EQUIPMENT, nations.NONE_INDEX) for eqpDescr in equipments: equipmentNations, params = set(), {} for vDescr in self.__getItems(vehicles._VEHICLE): if not eqpDescr.checkCompatibilityWithVehicle(vDescr)[0]: continue nation, id = vDescr.type.id equipmentNations.add(nation) eqDescrType = type(eqpDescr) if eqDescrType is artefacts.Artillery: shellDescr = vehicles.getDictDescr(eqpDescr.shellCompactDescr) shellParams = self.getShellParameters(shellDescr) params.update({'damage': (shellDescr['damage'][0], shellDescr['damage'][0]), 'piercingPower': eqpDescr.piercingPower, 'caliber': shellParams['caliber'], 'shotsNumberRange': eqpDescr.shotsNumber, 'explosionRadius': shellDescr['explosionRadius'], 'areaRadius': eqpDescr.areaRadius, 'artDelayRange': eqpDescr.delay}) elif eqDescrType is artefacts.Bomber: shellDescr = vehicles.getDictDescr(eqpDescr.shellCompactDescr) params.update({'bombDamage': (shellDescr['damage'][0], shellDescr['damage'][0]), 'piercingPower': eqpDescr.piercingPower, 'bombsNumberRange': eqpDescr.bombsNumber, 'areaSquare': eqpDescr.areaLength * eqpDescr.areaWidth, 'flyDelayRange': eqpDescr.delay}) self.__cache[nations.NONE_INDEX][vehicles._EQUIPMENT][eqpDescr.compactDescr] = {'nations': equipmentNations, 'avgParams': params}
def __precachEquipments(self): self.__cache.setdefault(nations.NONE_INDEX, {})[vehicles._EQUIPMENT] = {} equipments = self.__getItems(vehicles._EQUIPMENT, nations.NONE_INDEX) for eqpDescr in equipments: equipmentNations, params = set(), {} for vDescr in self.__getItems(vehicles._VEHICLE): if not eqpDescr.checkCompatibilityWithVehicle(vDescr)[0]: continue nation, id = vDescr.type.id equipmentNations.add(nation) eqDescrType = type(eqpDescr) if eqDescrType is artefacts.Artillery: shellDescr = vehicles.getDictDescr(eqpDescr.shellCompactDescr) shellParams = self.getShellParameters(shellDescr) params.update({'damage': (shellDescr['damage'][0], shellDescr['damage'][0]), 'piercingPower': eqpDescr.piercingPower, 'caliber': shellParams['caliber'], 'shotsNumberRange': eqpDescr.shotsNumberRange, 'areaRadius': eqpDescr.areaRadius, 'artDelayRange': eqpDescr.delayRange}) elif eqDescrType is artefacts.Bomber: shellDescr = vehicles.getDictDescr(eqpDescr.shellCompactDescr) params.update({'bombDamage': (shellDescr['damage'][0], shellDescr['damage'][0]), 'piercingPower': eqpDescr.piercingPower, 'bombsNumberRange': eqpDescr.bombsNumberRange, 'areaSquare': eqpDescr.areaLength * eqpDescr.areaWidth, 'flyDelayRange': eqpDescr.delayRange}) self.__cache[nations.NONE_INDEX][vehicles._EQUIPMENT][eqpDescr.compactDescr] = {'nations': equipmentNations, 'avgParams': params}
def __validateInvItem(self, itemTypeID, errorCode): for intCompactDescr, itemData in g_itemsCache.items.inventory.getItemsData( itemTypeID).iteritems(): try: vehicles.getDictDescr(abs(intCompactDescr)) except Exception as e: raise ValidateException( e.message, errorCode, self.__packItemData(itemTypeID, itemData))
def descriptor(self): if self.__descriptor is None: if self.itemTypeName == _VEHICLE_TYPE_NAME: self.__descriptor = vehicles.VehicleDescr(typeID=(self.nationID, self.compTypeID)) else: self.__descriptor = vehicles.getDictDescr(self.compactDescr) return self.__descriptor
def __getCommonParameters(self, itemTypeCompDescr, paramsDict, excluded=tuple()): result = list() if GUI_SETTINGS.technicalInfo: compDescrType = getTypeOfCompactDescr(itemTypeCompDescr) params = self.__itemCommonParamsList.get(compDescrType, {}) if compDescrType == vehicles._EQUIPMENT: eqDescr = vehicles.getDictDescr(itemTypeCompDescr) params = params.get(type(eqDescr), []) else: params = self.__itemCommonParamsList.get(compDescrType, []) for param in params: if type(param) == str: if param not in excluded: result.append([param, paramsDict.get(param)]) else: paramName = param[0] paramValue = paramsDict.get(param[0]) formatFunc = param[1] formattedValue = formatFunc(paramValue) if formattedValue is not None and paramName not in excluded: result.append([paramName, formattedValue]) return result
def _showMessage4Item(self, scope, msg, itemCD, msgType = SystemMessages.SM_TYPE.Error, **kwargs): itemTypeID, nationID, itemID = vehicles.parseIntCompactDescr(itemCD) raise itemTypeID != _VEHICLE or AssertionError key = scope('item', msg) kwargs.update({'typeString': getTypeInfoByIndex(itemTypeID)['userString'], 'userString': vehicles.getDictDescr(itemCD)['userString']}) SystemMessages.pushMessage(i18n.makeString(key, **kwargs), type=msgType)
def descriptor(self): if self.__descriptor is None: if self.itemTypeName == _VEHICLE_TYPE_NAME: self.__descriptor = vehicles.VehicleDescr( typeID=(self.nationID, self.compTypeID)) else: self.__descriptor = vehicles.getDictDescr(self.compactDescr) return self.__descriptor
def getOrderedShellsLayout(self): result = [] for intCD in self._order: descriptor = vehicles.getDictDescr(intCD) quantity, quantityInClip = self.__ammo[intCD] result.append((intCD, descriptor, quantity, quantityInClip, self.__gunSettings)) return result
def __getItemsDescriptors(self, itemType, idx): iterator = CACHE_ITERATORS[itemType](idx) if itemType == ITEM_TYPES.vehicle: return [vehicles.VehicleDescr(typeID=(idx, cd)) for cd in iterator] else: return [ vehicles.getDictDescr(data['compactDescr']) for data in iterator ]
def getEquipmentParameters(eqpDescr): params = dict() eqDescrType = type(eqpDescr) if eqDescrType is artefacts.Artillery: shellDescr = vehicles.getDictDescr(eqpDescr.shellCompactDescr) params.update({'damage': (shellDescr['damage'][0],) * 2, 'piercingPower': eqpDescr.piercingPower, 'caliber': shellDescr['caliber'], 'shotsNumberRange': eqpDescr.shotsNumber, 'areaRadius': eqpDescr.areaRadius, 'artDelayRange': eqpDescr.delay}) elif eqDescrType is artefacts.Bomber: shellDescr = vehicles.getDictDescr(eqpDescr.shellCompactDescr) params.update({'bombDamage': (shellDescr['damage'][0],) * 2, 'piercingPower': eqpDescr.piercingPower, 'bombsNumberRange': eqpDescr.bombsNumber, 'areaSquare': eqpDescr.areaLength * eqpDescr.areaWidth, 'flyDelayRange': eqpDescr.delay}) return params
def _showMessage(self, scope, msg, itemCD, msgType = SystemMessages.SM_TYPE.Error, **kwargs): itemTypeID, nationID, itemID = vehicles.parseIntCompactDescr(itemCD) if itemTypeID == _VEHICLE: key = scope('vehicle', msg) kwargs['userString'] = vehicles.getVehicleType(itemCD).userString else: key = scope('item', msg) kwargs.update({'typeString': getTypeInfoByIndex(itemTypeID)['userString'], 'userString': vehicles.getDictDescr(itemCD)['userString']}) SystemMessages.pushMessage(i18n.makeString(key, **kwargs), type=msgType)
def __validateInventoryItem(self, type, errorCode): """ Method validates inventory items' data. @param type: <int> type index of item @param errorCode: <CODES> code to return in error case @return: <CODES> eror code """ for intCompactDescr in self.__inventory.getItems(type).iterkeys(): try: vehicles.getDictDescr(intCompactDescr) except Exception: item_type_id, nationIdx, innation_id = vehicles.parseIntCompactDescr(intCompactDescr) LOG_ERROR('There is exception while validation item (%s)' % ITEM_TYPE_NAMES[type], intCompactDescr, (item_type_id, nationIdx, innation_id)) LOG_CURRENT_EXCEPTION() return errorCode return self.CODES.OK
def __makeSimpleItem(self, typeCompDescr): itemTypeID = getTypeOfCompactDescr(typeCompDescr) cache = self.__itemsCache[itemTypeID] if typeCompDescr in cache: return cache[typeCompDescr] itemsInvData = self.getCacheValue(itemTypeID, {}) if typeCompDescr not in itemsInvData: return None data = self.ITEM_DATA(typeCompDescr, vehicles.getDictDescr(typeCompDescr), itemsInvData[typeCompDescr]) item = cache[typeCompDescr] = data return item
def _getBuyConfirmMeta(self, itemCD, price, conflictedEqs): itemTypeID, nationID, itemID = vehicles.parseIntCompactDescr(itemCD) conflictedEqs = self._getConflictedEqsMeta(conflictedEqs).getMessage() ctx = {'credits': BigWorld.wg_getIntegralFormat(price[0]), 'typeString': getTypeInfoByIndex(itemTypeID)['userString'], 'conflictedEqs': conflictedEqs if conflictedEqs else ''} if itemTypeID == _VEHICLE: ctx['userString'] = vehicles.getVehicleType(itemCD).userString else: ctx['userString'] = vehicles.getDictDescr(itemCD)['userString'] return HtmlMessageDialogMeta('html_templates:lobby/dialogs', 'confirmBuyAndInstall', ctx=ctx)
def _getUnlockConfirmMeta(self, itemCD, costCtx): itemTypeID, nationID, itemID = vehicles.parseIntCompactDescr(itemCD) ctx = {'xpCost': BigWorld.wg_getIntegralFormat(costCtx['xpCost']), 'freeXP': BigWorld.wg_getIntegralFormat(costCtx['freeXP']), 'typeString': getTypeInfoByIndex(itemTypeID)['userString']} if itemTypeID == _VEHICLE: key = 'confirmUnlockVehicle' ctx['userString'] = vehicles.getVehicleType(itemCD).userString else: key = 'confirmUnlockItem' ctx['userString'] = vehicles.getDictDescr(itemCD)['userString'] return HtmlMessageLocalDialogMeta('html_templates:lobby/dialogs', key, ctx=ctx)
def __readBonus_item(self, bonus, _name, section, _gFinishTime): compDescr = section.asInt try: descr = vehicles.getDictDescr(compDescr) if descr['itemTypeName'] not in items.SIMPLE_ITEM_TYPE_NAMES: raise Exception, 'Wrong compact descriptor (%d). Not simple item.' % compDescr except: raise Exception, 'Wrong compact descriptor (%d)' % compDescr count = 1 if section.has_key('count'): count = section['count'].asInt bonus.setdefault('items', {})[compDescr] = count
def __readBonus_item(bonus, _name, section): compDescr = section.asInt try: descr = vehicles.getDictDescr(compDescr) if descr['itemTypeName'] not in items.SIMPLE_ITEM_TYPE_NAMES: raise Exception('Wrong compact descriptor (%d). Not simple item.' % compDescr) except: raise Exception('Wrong compact descriptor (%d)' % compDescr) count = 1 if section.has_key('count'): count = section['count'].asInt bonus.setdefault('items', {})[compDescr] = count
def __readBonus_item(bonus, _name, section): compDescr = section.asInt try: descr = vehicles.getDictDescr(compDescr) if descr["itemTypeName"] not in items.SIMPLE_ITEM_TYPE_NAMES: raise Exception, "Wrong compact descriptor (%d). Not simple item." % compDescr except: raise Exception, "Wrong compact descriptor (%d)" % compDescr count = 1 if section.has_key("count"): count = section["count"].asInt bonus.setdefault("items", {})[compDescr] = count
def setEquipment(self, intCD, quantity, stage, timeRemaining): if not intCD: self.onEquipmentAdded(intCD, None) return if intCD in self.__equipments: item = self.__equipments[intCD] item.update(quantity, stage, timeRemaining) self.onEquipmentUpdated(intCD, item) else: descriptor = vehicles.getDictDescr(intCD) item = self.createItem(descriptor, quantity, stage, timeRemaining) self.__equipments[intCD] = item self.onEquipmentAdded(intCD, item)
def __validateInventoryItem(self, type, errorCode): """ Method validates inventory items' data. @param type: <int> type index of item @param errorCode: <CODES> code to return in error case @return: <CODES> eror code """ for intCompactDescr in self.__inventory.getItems(type).iterkeys(): try: vehicles.getDictDescr(intCompactDescr) except Exception: item_type_id, nationIdx, innation_id = vehicles.parseIntCompactDescr( intCompactDescr) LOG_ERROR( 'There is exception while validation item (%s)' % ITEM_TYPE_NAMES[type], intCompactDescr, (item_type_id, nationIdx, innation_id)) LOG_CURRENT_EXCEPTION() return errorCode return self.CODES.OK
def findConflictedEquipments(itemCompactDescr, itemTypeID, vehicle): conflictEqs = [] if itemTypeID != ITEM_TYPE_INDICES['vehicleEngine']: return conflictEqs oldModule, = vehicle.descriptor.installComponent(itemCompactDescr) for equipmentDescr in vehicle.equipments: if equipmentDescr: equipment = vehicles.getDictDescr(equipmentDescr) installPossible, reason = equipment.checkCompatibilityWithVehicle(vehicle.descriptor) if not installPossible: conflictEqs.append(equipment) vehicle.descriptor.installComponent(oldModule) return conflictEqs
def _getBuyConfirmMeta(self, itemCD, price, conflictedEqs): itemTypeID, nationID, itemID = vehicles.parseIntCompactDescr(itemCD) conflictedEqs = self._getConflictedEqsMeta(conflictedEqs).getMessage() ctx = { 'credits': BigWorld.wg_getIntegralFormat(price[0]), 'typeString': getTypeInfoByIndex(itemTypeID)['userString'], 'conflictedEqs': conflictedEqs if conflictedEqs else '' } if itemTypeID == _VEHICLE: ctx['userString'] = vehicles.getVehicleType(itemCD).userString else: ctx['userString'] = vehicles.getDictDescr(itemCD)['userString'] return HtmlMessageDialogMeta('html_templates:lobby/dialogs', 'confirmBuyAndInstall', ctx=ctx)
def _getUnlockConfirmMeta(self, itemCD, costCtx): itemTypeID, nationID, itemID = vehicles.parseIntCompactDescr(itemCD) ctx = { 'xpCost': BigWorld.wg_getIntegralFormat(costCtx['xpCost']), 'freeXP': BigWorld.wg_getIntegralFormat(costCtx['freeXP']), 'typeString': getTypeInfoByIndex(itemTypeID)['userString'] } if itemTypeID == _VEHICLE: key = 'confirmUnlockVehicle' ctx['userString'] = vehicles.getVehicleType(itemCD).userString else: key = 'confirmUnlockItem' ctx['userString'] = vehicles.getDictDescr(itemCD)['userString'] return HtmlMessageLocalDialogMeta('html_templates:lobby/dialogs', key, ctx=ctx)
def setEquipment(self, intCD, quantity, stage, timeRemaining): if not intCD: self.onEquipmentAdded(intCD, None, False) return else: if intCD in self.__equipments: item = self.__equipments[intCD] isDeployed = item.getStage() == EQUIPMENT_STAGES.DEPLOYING and stage == EQUIPMENT_STAGES.READY item.update(quantity, stage, timeRemaining) self.onEquipmentUpdated(intCD, item, isinstance(item, _OrderItem), isDeployed) else: descriptor = vehicles.getDictDescr(intCD) item = self.createItem(descriptor, quantity, stage, timeRemaining) self.__equipments[intCD] = item self.onEquipmentAdded(intCD, item, isinstance(item, _OrderItem)) return
def _showMessage4Item(self, scope, msg, itemCD, msgType=SystemMessages.SM_TYPE.Error, **kwargs): itemTypeID, nationID, itemID = vehicles.parseIntCompactDescr(itemCD) raise itemTypeID != _VEHICLE or AssertionError key = scope('item', msg) kwargs.update({ 'typeString': getTypeInfoByIndex(itemTypeID)['userString'], 'userString': vehicles.getDictDescr(itemCD)['userString'] }) SystemMessages.pushMessage(i18n.makeString(key, **kwargs), type=msgType)
def setEquipment(self, intCD, quantity, stage, timeRemaining): if not intCD: self.onEquipmentAdded(intCD, None) return else: if intCD in self._equipments: item = self._equipments[intCD] item.update(quantity, stage, timeRemaining) self.onEquipmentUpdated(intCD, item) if item.getPrevStage() in (EQUIPMENT_STAGES.DEPLOYING, EQUIPMENT_STAGES.UNAVAILABLE, EQUIPMENT_STAGES.COOLDOWN) and item.getStage() == EQUIPMENT_STAGES.READY: SoundGroups.g_instance.playSound2D(self.__readySndName) else: descriptor = vehicles.getDictDescr(intCD) item = self.createItem(descriptor, quantity, stage, timeRemaining) self._equipments[intCD] = item self.onEquipmentAdded(intCD, item) return
def setShells(self, intCD, quantity, quantityInClip): result = SHELL_SET_RESULT.UNDEFINED if intCD in self.__ammo: prevAmmo = self.__ammo[intCD] self.__ammo[intCD] = (quantity, quantityInClip) result |= SHELL_SET_RESULT.UPDATED if intCD == self.__currShellCD: result |= SHELL_SET_RESULT.CURRENT if quantityInClip > 0 and prevAmmo[1] == 0 and quantity == prevAmmo[0]: result |= SHELL_SET_RESULT.CASSETTE_RELOAD self.onShellsUpdated(intCD, quantity, quantityInClip, result) else: self.__ammo[intCD] = (quantity, quantityInClip) self._order.append(intCD) result |= SHELL_SET_RESULT.ADDED descriptor = vehicles.getDictDescr(intCD) self.onShellsAdded(intCD, descriptor, quantity, quantityInClip, self.__gunSettings) return result
def getFormattedParamsList(descriptor, parameters, excludeRelative = False): compactDescr = descriptor.type.compactDescr if isinstance(descriptor, vehicles.VehicleDescr) else descriptor['compactDescr'] itemTypeIdx = getTypeOfCompactDescr(compactDescr) if itemTypeIdx == ITEM_TYPES.equipment: eqDescr = vehicles.getDictDescr(compactDescr) paramsList = ITEMS_PARAMS_LIST[itemTypeIdx].get(type(eqDescr), []) else: paramsList = ITEMS_PARAMS_LIST[itemTypeIdx] params = [] for paramName in paramsList: if excludeRelative and isRelativeParameter(paramName): continue paramValue = parameters.get(paramName) fmtValue = paramValue if paramValue is None else baseFormatParameter(paramName, paramValue) if fmtValue: params.append((paramName, fmtValue)) return params
def __loadAutoUnlockItems(self, rootCD, autoUnlocks, hasFakeTurrets = False): autoUnlocked = dict(map(lambda nodeCD: (vehicles.getDictDescr(nodeCD).get('itemTypeName'), nodeCD), autoUnlocks)) self._autoGunCD = -1 self._autoTurretCD = -1 for itemType in _RESEARCH_ITEMS: if itemType > len(ITEM_TYPE_NAMES) - 1: continue nodeCD = autoUnlocked[ITEM_TYPE_NAMES[itemType]] if itemType == _TURRET: self._autoTurretCD = nodeCD if hasFakeTurrets: continue elif itemType == _GUN: self._autoGunCD = nodeCD node = self._getNodeData(nodeCD, 0, makeDefUnlockProps(), set([rootCD])) node['state'] |= NODE_STATE.AUTO_UNLOCKED self._nodesIdx[nodeCD] = len(self._nodes) self._nodes.append(node)
def setShells(self, intCD, quantity, quantityInClip): result = SHELL_SET_RESULT.UNDEFINED if intCD in self.__ammo: prevAmmo = self.__ammo[intCD] self.__ammo[intCD] = (quantity, quantityInClip) result |= SHELL_SET_RESULT.UPDATED if intCD == self.__currShellCD: result |= SHELL_SET_RESULT.CURRENT if quantityInClip > 0 and prevAmmo[ 1] == 0 and quantity == prevAmmo[0]: result |= SHELL_SET_RESULT.CASSETTE_RELOAD self.onShellsUpdated(intCD, quantity, quantityInClip, result) else: self.__ammo[intCD] = (quantity, quantityInClip) self._order.append(intCD) result |= SHELL_SET_RESULT.ADDED descriptor = vehicles.getDictDescr(intCD) self.onShellsAdded(intCD, descriptor, quantity, quantityInClip, self.__gunSettings) return result
def _showMessage(self, scope, msg, itemCD, msgType=SystemMessages.SM_TYPE.Error, **kwargs): itemTypeID, nationID, itemID = vehicles.parseIntCompactDescr(itemCD) if itemTypeID == _VEHICLE: key = scope('vehicle', msg) kwargs['userString'] = vehicles.getVehicleType(itemCD).userString else: key = scope('item', msg) kwargs.update({ 'typeString': getTypeInfoByIndex(itemTypeID)['userString'], 'userString': vehicles.getDictDescr(itemCD)['userString'] }) SystemMessages.pushMessage(i18n.makeString(key, **kwargs), type=msgType)
def getFormattedParamsList(descriptor, parameters, excludeRelative=False): compactDescr = descriptor.type.compactDescr if isinstance( descriptor, vehicles.VehicleDescr) else descriptor['compactDescr'] itemTypeIdx = getTypeOfCompactDescr(compactDescr) if itemTypeIdx == ITEM_TYPES.equipment: eqDescr = vehicles.getDictDescr(compactDescr) paramsList = ITEMS_PARAMS_LIST[itemTypeIdx].get(type(eqDescr), []) else: paramsList = ITEMS_PARAMS_LIST[itemTypeIdx] params = [] for paramName in paramsList: if excludeRelative and isRelativeParameter(paramName): continue paramValue = parameters.get(paramName) fmtValue = paramValue if paramValue is None else baseFormatParameter( paramName, paramValue) if fmtValue: params.append((paramName, fmtValue)) return params
def __loadAutoUnlockItems(self, rootCD, autoUnlocks, hasFakeTurrets=False): autoUnlocked = dict( map( lambda nodeCD: (vehicles.getDictDescr(nodeCD).get('itemTypeName'), nodeCD), autoUnlocks)) self._autoGunCD = -1 self._autoTurretCD = -1 for itemType in _RESEARCH_ITEMS: if itemType > len(ITEM_TYPE_NAMES) - 1: continue nodeCD = autoUnlocked[ITEM_TYPE_NAMES[itemType]] if itemType == _TURRET: self._autoTurretCD = nodeCD if hasFakeTurrets: continue elif itemType == _GUN: self._autoGunCD = nodeCD node = self._getNodeData(nodeCD, 0, makeDefUnlockProps(), set([rootCD])) node['state'] |= NODE_STATE.AUTO_UNLOCKED self._nodesIdx[nodeCD] = len(self._nodes) self._nodes.append(node)
def __getCommonParameters(self, itemTypeCompDescr, paramsDict, excluded = tuple()): result = list() if GUI_SETTINGS.technicalInfo: compDescrType = getTypeOfCompactDescr(itemTypeCompDescr) params = self.__itemCommonParamsList.get(compDescrType, {}) if compDescrType == vehicles._EQUIPMENT: eqDescr = vehicles.getDictDescr(itemTypeCompDescr) params = params.get(type(eqDescr), []) else: params = self.__itemCommonParamsList.get(compDescrType, []) for param in params: if type(param) == str: if param not in excluded: result.append([param, paramsDict.get(param)]) else: paramName = param[0] paramValue = paramsDict.get(param[0]) formatFunc = param[1] formattedValue = formatFunc(paramValue) if formattedValue is not None and paramName not in excluded: result.append([paramName, formattedValue]) return result
def setEquipment(self, intCD, quantity, stage, timeRemaining): if not intCD: self.onEquipmentAdded(intCD, None) return else: if intCD in self._equipments: item = self._equipments[intCD] item.update(quantity, stage, timeRemaining) self.onEquipmentUpdated(intCD, item) if item.getPrevStage() in ( EQUIPMENT_STAGES.DEPLOYING, EQUIPMENT_STAGES.UNAVAILABLE, EQUIPMENT_STAGES.COOLDOWN ) and item.getStage() == EQUIPMENT_STAGES.READY: avatar_getter.getSoundNotifications().play( self.__readySndName) else: descriptor = vehicles.getDictDescr(intCD) item = self.createItem(descriptor, quantity, stage, timeRemaining) self._equipments[intCD] = item self._order.append(intCD) self.onEquipmentAdded(intCD, item) return
def getAutoUnlockedItemsMap(self): return dict( map( lambda nodeCD: (vehicles.getDictDescr(nodeCD).get('itemTypeName'), nodeCD), self.descriptor.type.autounlockedItems))
def __getItemDescriptor(self, typeIdx, nationIdx, itemID): if typeIdx == vehicles._VEHICLE: return vehicles.VehicleDescr(typeID=(nationIdx, itemID)) return vehicles.getDictDescr(itemID)
def getAutoUnlockedItemsMap(self): return dict(map(lambda nodeCD: (vehicles.getDictDescr(nodeCD).get('itemTypeName'), nodeCD), self.descriptor.type.autounlockedItems))
def descriptor(self): return vehicles.getDictDescr(self.intCompactDescr)
def __validateInvItem(self, itemTypeID, errorCode): for intCompactDescr, itemData in g_itemsCache.items.inventory.getItemsData(itemTypeID).iteritems(): try: vehicles.getDictDescr(abs(intCompactDescr)) except Exception as e: raise ValidateException(e.message, errorCode, self.__packItemData(itemTypeID, itemData))
def __getItemsDescriptors(self, itemType, idx): iterator = CACHE_ITERATORS[itemType](idx) if itemType == ITEM_TYPES.vehicle: return [ vehicles.VehicleDescr(typeID=(idx, cd)) for cd in iterator ] else: return [ vehicles.getDictDescr(data['compactDescr']) for data in iterator ]