def change(self, vehInvID, section, isAlreadyPurchased): if self._newItemID is None: message = i18n.makeString(SYSTEM_MESSAGES.CUSTOMIZATION_INSCRIPTION_NOT_SELECTED) self.onCustomizationChangeFailed(message) return elif self._rentalPackageDP.selectedPackage is None: message = i18n.makeString(SYSTEM_MESSAGES.CUSTOMIZATION_INSCRIPTION_DAYS_NOT_SELECTED) self.onCustomizationChangeFailed(message) return else: cost, isGold = self._itemsDP.getCost(self._newItemID) if cost < 0: message = i18n.makeString(SYSTEM_MESSAGES.CUSTOMIZATION_INSCRIPTION_COST_NOT_FOUND) self.onCustomizationChangeFailed(message) return if isAlreadyPurchased: daysToWear = 0 cost = 0 elif CustomizationHelper.isItemInHangar(CUSTOMIZATION_ITEM_TYPE.INSCRIPTION, self._newItemID, self._nationID, self._itemsDP.position): hangarItem = CustomizationHelper.getItemFromHangar(CUSTOMIZATION_ITEM_TYPE.INSCRIPTION_TYPE, self._newItemID, self._nationID, self._itemsDP.position) daysToWear = 0 if hangarItem.get('isPermanent') else 7 else: daysToWear = self._rentalPackageDP.selectedPackage.get('periodDays') newIdToSend = 0 isNewInDefaultSetup = False isCurrIgr = self._itemsDP.isIGRItem(self._currentItemID) if isCurrIgr: isNewInDefaultSetup = CustomizationHelper.isIdInDefaultSetup(CUSTOMIZATION_ITEM_TYPE.INSCRIPTION, self._newItemID) if self._currentItemID is None or not isCurrIgr or isCurrIgr and not isNewInDefaultSetup or isCurrIgr and isNewInDefaultSetup and daysToWear > 0: newIdToSend = self._newItemID BigWorld.player().inventory.changeVehicleInscription(vehInvID, self.getRealPosition(), newIdToSend, daysToWear, 1, lambda resultID: self.__onChangeVehicleInscription(resultID, (cost, isGold))) return
def change(self, vehInvID, section, isAlreadyPurchased): if self._newItemID is None: message = i18n.makeString(SYSTEM_MESSAGES.CUSTOMIZATION_INSCRIPTION_NOT_SELECTED) self.onCustomizationChangeFailed(message) return if self._rentalPackageDP.selectedPackage is None: message = i18n.makeString(SYSTEM_MESSAGES.CUSTOMIZATION_INSCRIPTION_DAYS_NOT_SELECTED) self.onCustomizationChangeFailed(message) return cost, isGold = self._itemsDP.getCost(self._newItemID) if cost < 0: message = i18n.makeString(SYSTEM_MESSAGES.CUSTOMIZATION_INSCRIPTION_COST_NOT_FOUND) self.onCustomizationChangeFailed(message) return if isAlreadyPurchased: daysToWear = 0 cost = 0 elif CustomizationHelper.isItemInHangar(CUSTOMIZATION_ITEM_TYPE.INSCRIPTION, self._newItemID, self._nationID, self._itemsDP.position): hangarItem = CustomizationHelper.getItemFromHangar(CUSTOMIZATION_ITEM_TYPE.INSCRIPTION_TYPE, self._newItemID) daysToWear = 0 if hangarItem.get('isPermanent') else 7 else: daysToWear = self._rentalPackageDP.selectedPackage.get('periodDays') newIdToSend = 0 isNewInDefaultSetup = False isCurrIgr = self._itemsDP.isIGRItem(self._currentItemID) if isCurrIgr: isNewInDefaultSetup = CustomizationHelper.isIdInDefaultSetup(CUSTOMIZATION_ITEM_TYPE.INSCRIPTION, self._newItemID) if self._currentItemID is None or not isCurrIgr or isCurrIgr and not isNewInDefaultSetup or isCurrIgr and isNewInDefaultSetup and daysToWear > 0: newIdToSend = self._newItemID BigWorld.player().inventory.changeVehicleInscription(vehInvID, self.getRealPosition(), newIdToSend, daysToWear, 1, lambda resultID: self.__onChangeVehicleInscription(resultID, (cost, isGold)))
def change(self, vehInvID, section, isAlreadyPurchased): if self._rentalPackageDP.selectedPackage is None: message = i18n.makeString(SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_DAYS_NOT_SELECTED) self.onCustomizationChangeFailed(message) return else: isNewItemFound = False for kind, item in self.currentItemsByKind.iteritems(): newItemID = item.get("newItemID", None) currItemId = item.get("id", None) if newItemID is None: continue elif not isNewItemFound: isNewItemFound = True price = self.getItemCost(newItemID, item.get("packageIdx")) cost = price.get("cost", 0) isGold = price.get("isGold", False) if cost < 0: message = i18n.makeString(SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_COST_NOT_FOUND) self.onCustomizationChangeFailed(message) return localKind = kind if CustomizationHelper.isItemInHangar(CUSTOMIZATION_ITEM_TYPE.CAMOUFLAGE, newItemID, self._nationID): hangarItem = CustomizationHelper.getItemFromHangar( CUSTOMIZATION_ITEM_TYPE.CAMOUFLAGE_TYPE, newItemID, self._nationID ) daysToWear = 0 if hangarItem.get("isPermanent") else 7 else: daysToWear = self._rentalPackageDP.pyRequestItemAt(item.get("packageIdx")).get("periodDays") newIdToSend = 0 isNewInDefaultSetup = False isCurrIgr = self._itemsDP.isIGRItem(currItemId) if isCurrIgr: isNewInDefaultSetup = CustomizationHelper.isIdInDefaultSetup( CUSTOMIZATION_ITEM_TYPE.CAMOUFLAGE, newItemID ) if ( currItemId is None or not isCurrIgr or isCurrIgr and not isNewInDefaultSetup or isCurrIgr and isNewInDefaultSetup and daysToWear > 0 ): newIdToSend = newItemID BigWorld.player().inventory.changeVehicleCamouflage( vehInvID, localKind, newIdToSend, daysToWear, functools.partial(self.__onChangeVehicleCamouflage, (cost, isGold), localKind), ) if not isNewItemFound: message = i18n.makeString(SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_NOT_SELECTED) self.onCustomizationChangeFailed(message) return
def _getPriceFactor(self, itemID): priceFactor = 0 groups, emblems, names = vehicles.g_cache.playerEmblems() emblem = emblems.get(itemID) if emblem is not None: groupName, igrType, texture, bumpFile, emblemUserString, isMirrored = emblem[0:6] if not CustomizationHelper.isItemInHangar(CUSTOMIZATION_ITEM_TYPE.EMBLEM, itemID, self.nationID, self.position): priceFactor = g_itemsCache.items.shop.getEmblemsGroupPriceFactors().get(groupName) return priceFactor
def _getPriceFactor(self, itemID): priceFactor = 0 customization = vehicles.g_cache.customization(self.nationID) if customization is not None: inscriptions = customization.get('inscriptions', {}) inscription = inscriptions.get(itemID) if inscription is not None: groupName, igrType, texture, bumpMap, inscriptionUserString, isFeatured = inscription[0:6] if not CustomizationHelper.isItemInHangar(CUSTOMIZATION_ITEM_TYPE.INSCRIPTION, itemID, self.nationID, self.position): priceFactor = g_itemsCache.items.shop.getInscriptionsGroupPriceFactors(self.nationID).get(groupName) return priceFactor
def change(self, vehInvID, section, isAlreadyPurchased): if self._rentalPackageDP.selectedPackage is None: message = i18n.makeString(SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_DAYS_NOT_SELECTED) self.onCustomizationChangeFailed(message) return else: isNewItemFound = False for kind, item in self.currentItemsByKind.iteritems(): newItemID = item.get('newItemID', None) currItemId = item.get('id', None) if newItemID is None: continue elif not isNewItemFound: isNewItemFound = True price = self.getItemCost(newItemID, item.get('packageIdx')) cost = price.get('cost', 0) isGold = price.get('isGold', False) if cost < 0: message = i18n.makeString(SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_COST_NOT_FOUND) self.onCustomizationChangeFailed(message) return localKind = kind if CustomizationHelper.isItemInHangar(CUSTOMIZATION_ITEM_TYPE.CAMOUFLAGE, newItemID, self._nationID): hangarItem = CustomizationHelper.getItemFromHangar(CUSTOMIZATION_ITEM_TYPE.CAMOUFLAGE_TYPE, newItemID, self._nationID) daysToWear = 0 if hangarItem.get('isPermanent') else 7 else: daysToWear = self._rentalPackageDP.pyRequestItemAt(item.get('packageIdx')).get('periodDays') newIdToSend = 0 isNewInDefaultSetup = False isCurrIgr = self._itemsDP.isIGRItem(currItemId) if isCurrIgr: isNewInDefaultSetup = CustomizationHelper.isIdInDefaultSetup(CUSTOMIZATION_ITEM_TYPE.CAMOUFLAGE, newItemID) if currItemId is None or not isCurrIgr or isCurrIgr and not isNewInDefaultSetup or isCurrIgr and isNewInDefaultSetup and daysToWear > 0: newIdToSend = newItemID BigWorld.player().inventory.changeVehicleCamouflage(vehInvID, localKind, newIdToSend, daysToWear, functools.partial(self.__onChangeVehicleCamouflage, (cost, isGold), localKind)) if not isNewItemFound: message = i18n.makeString(SYSTEM_MESSAGES.CUSTOMIZATION_CAMOUFLAGE_NOT_SELECTED) self.onCustomizationChangeFailed(message) return
def onRequestList(self, groupName): self.currentGroup = groupName customization = vehicles.g_cache.customization(self.nationID) result = [] if customization is not None: groups = customization.get('camouflageGroups', {}) group = groups.get(groupName, {}) camouflages = customization.get('camouflages', {}) armorColor = customization.get('armorColor', 0) ids = group.get('ids', []) currIntDescr = g_currentVehicle.item.intCD for id in ids: camouflageInfo = self._constructCamouflage(id, groups, camouflages, armorColor, isCurrent=self.currentItemID == id, isInHangar=CustomizationHelper.isItemInHangar(CUSTOMIZATION_ITEM_TYPE.CAMOUFLAGE, id, self.nationID), withoutCheck=False, currVehIntD=currIntDescr) if camouflageInfo is not None: if not self._isIGR and camouflageInfo.get('igrType') == constants.IGR_TYPE.NONE or self._isIGR and camouflageInfo.get('igrType') == constants.IGR_TYPE.PREMIUM: result.append(camouflageInfo) if gui.GUI_SETTINGS.igrEnabled: for name, group in groups.iteritems(): if name not in CAMOUFLAGE_KINDS: ids = group.get('ids', []) for cID in ids: camouflage = camouflages.get(cID, None) if camouflage.get('kind', 0) == CAMOUFLAGE_KINDS.get(groupName, 0): camouflageInfo = self._constructCamouflage(cID, groups, camouflages, armorColor, isCurrent=self.currentItemID == cID, isInHangar=CustomizationHelper.isItemInHangar(CUSTOMIZATION_ITEM_TYPE.CAMOUFLAGE, cID, self.nationID), withoutCheck=False, currVehIntD=currIntDescr) if camouflageInfo is not None and camouflageInfo: if not self._isIGR and camouflageInfo.get('igrType') == constants.IGR_TYPE.NONE or self._isIGR and camouflageInfo.get('igrType') == constants.IGR_TYPE.PREMIUM: result.append(camouflageInfo) return sorted(result, cmp=self.__comparator)
def getCostForPackagePrice(self, camouflageID, packagePrice, isGold): if CustomizationHelper.isItemInHangar(CUSTOMIZATION_ITEM_TYPE.CAMOUFLAGE, camouflageID, self.nationID): priceFactor = 0 else: priceFactor = g_itemsCache.items.shop.getCamouflagesPriceFactors(self.nationID).get(camouflageID) return (self._makeCost(packagePrice, self._vehPriceFactor, priceFactor), isGold)
def makeItem(self, camouflageID, isCurrent, lifeCycle, timeLeftString, kind): customization = vehicles.g_cache.customization(self.nationID) camouflageInfo = None if customization is not None: groups = customization.get('camouflageGroups', {}) armorColor = customization.get('armorColor', 0) camouflageInfo = self._constructCamouflage(camouflageID, groups, customization.get('camouflages', {}), armorColor, lifeCycle, isCurrent, CustomizationHelper.isItemInHangar(CUSTOMIZATION_ITEM_TYPE.CAMOUFLAGE, camouflageID, self.nationID)) if camouflageInfo is not None: camouflageInfo['timeLeft'] = timeLeftString else: camouflageInfo = {'timeLeft': timeLeftString, 'id': camouflageID, 'texturePath': None, 'description': self.getDefaultDescription(kind), 'price': {'cost': 0, 'isGold': False}, 'action': None, 'isNew': False, 'invisibilityLbl': '', 'current': False} return camouflageInfo
def onRequestList(self, groupName): if not groupName: return else: customization = vehicles.g_cache.customization(self.nationID) result = [] hiddenItems = g_itemsCache.items.shop.getInscriptionsGroupHiddens(self.nationID) if customization is not None: groups = customization.get('inscriptionGroups', {}) group = groups.get(groupName, {}) inscriptions = customization.get('inscriptions', {}) if group is not None: inscriptionIDs, groupUserString, igrType, allow, deny = group isHasNew = self._hasNewItems(CUSTOMIZATION_ITEM_TYPE.INSCRIPTION_TYPE, inscriptionIDs) isHiddenGroup = groupName in hiddenItems hasItemsInHangar = False if isHiddenGroup: hasItemsInHangar = CustomizationHelper.areItemsInHangar(CUSTOMIZATION_ITEM_TYPE.INSCRIPTION, inscriptionIDs, self.nationID) self._isIGR = igrType != constants.IGR_TYPE.NONE if isHasNew or hasItemsInHangar or not isHiddenGroup: for id in inscriptionIDs: itemInfo = self._constructInscription(id, groups, inscriptions, self.currentItemID == id, False if self.isIGRItem(id) else CustomizationHelper.isItemInHangar(CUSTOMIZATION_ITEM_TYPE.INSCRIPTION, id, self.nationID, self.position), False) if itemInfo is not None: if not self._isIGR or self._isIGR and itemInfo.get('igrType') != constants.IGR_TYPE.NONE: result.append(itemInfo) return sorted(result, cmp=self.__comparator)
def makeItem(self, itemID, isCurrent, lifeCycle, timeLeftString): customization = vehicles.g_cache.customization(self.nationID) itemInfo = None if customization is not None: groups = customization.get('inscriptionGroups', {}) inscriptions = customization.get('inscriptions', {}) if inscriptions is not None: itemInfo = self._constructInscription(itemID, groups, inscriptions, isCurrent, CustomizationHelper.isItemInHangar(CUSTOMIZATION_ITEM_TYPE.INSCRIPTION, itemID, self.nationID, self.position)) if itemInfo is not None: itemInfo['timeLeft'] = timeLeftString else: itemInfo = {'timeLeft': timeLeftString, 'id': itemID, 'texturePath': None, 'description': '', 'price': {'cost': 0, 'isGold': False}, 'action': None, 'current': isCurrent, 'position': self.position} itemInfo['type'] = CUSTOMIZATION_ITEM_TYPE.INSCRIPTION return itemInfo
def onRequestList(self, groupName): groups, emblems, names = vehicles.g_cache.playerEmblems() group = groups.get(groupName) result = [] hiddenItems = g_itemsCache.items.shop.getEmblemsGroupHiddens() if group is not None: emblemIDs, groupUserString, igrType, nations, allow, deny = group self._isIGR = igrType != constants.IGR_TYPE.NONE isHasNew = self._hasNewItems(CUSTOMIZATION_ITEM_TYPE.EMBLEM_TYPE, emblemIDs) isHiddenGroup = groupName in hiddenItems hasItemsInHangar = False if isHiddenGroup: hasItemsInHangar = CustomizationHelper.areItemsInHangar(CUSTOMIZATION_ITEM_TYPE.EMBLEM, emblemIDs, self.nationID) if isHasNew or hasItemsInHangar or not isHiddenGroup: for id in emblemIDs: itemInfo = self._constructEmblem(id, groups, emblems, self.position, self.currentItemID == id, False if self.isIGRItem(id) else CustomizationHelper.isItemInHangar(CUSTOMIZATION_ITEM_TYPE.EMBLEM, id, self.nationID, self.position), False) if itemInfo is not None: if not self._isIGR or self._isIGR and itemInfo.get('igrType') != constants.IGR_TYPE.NONE: result.append(itemInfo) return sorted(result, cmp=self.__comparator)
def makeItem(self, itemID, isCurrent, lifeCycle, timeLeftString): groups, emblems, names = vehicles.g_cache.playerEmblems() itemInfo = None if emblems is not None: itemInfo = self._constructEmblem(itemID, groups, emblems, self.position, isCurrent, CustomizationHelper.isItemInHangar(CUSTOMIZATION_ITEM_TYPE.EMBLEM, itemID, self.nationID, self.position)) if itemInfo is not None: itemInfo['timeLeft'] = timeLeftString else: itemInfo = {'id': itemID, 'texturePath': None, 'description': '', 'userString': '', 'igrType': 0, 'position': self.position, 'price': {'cost': 0, 'isGold': False}, 'action': None, 'current': isCurrent, 'isInHangar': False, 'timeLeft': timeLeftString} itemInfo['type'] = CUSTOMIZATION_ITEM_TYPE.EMBLEM return itemInfo