def doAction(self): item = self.itemsCache.items.getItemByCD(self.__vehCD) if item.itemTypeID is not GUI_ITEM_TYPE.VEHICLE: LOG_ERROR('Value of int-type descriptor is not refer to vehicle', self.__vehCD) return else: if item.isInInventory and not item.isRented: showInventoryMsg('already_exists', item, msgType=SystemMessages.SM_TYPE.Warning) else: price = getGUIPrice(item, self.itemsCache.items.stats.money, self.itemsCache.items.shop.exchangeRate) if price is None: showShopMsg('not_found', item) return if not self._mayObtainForMoney(item): if self._mayObtainWithMoneyExchange(item): if item.isRestoreAvailable(): meta = RestoreExchangeCreditsMeta(self.__vehCD) else: meta = ExchangeCreditsMeta(self.__vehCD) isOk, _ = yield DialogsInterface.showDialog(meta) if not isOk: return else: showShopMsg('common_rent_or_buy_error', item) if self._mayObtainForMoney(item): shared_events.showVehicleBuyDialog(item, self.__isTradeIn) yield lambda callback=None: callback return
def __getBtnDataUnlockedVehicle(self, vehicle): money = self.itemsCache.items.stats.money money = self.tradeIn.addTradeInPriceIfNeeded(vehicle, money) tooltip = '' exchangeRate = self.itemsCache.items.shop.exchangeRate price = getGUIPrice(vehicle, money, exchangeRate) currency = price.getCurrency(byWeight=True) action = getActionPriceData(vehicle) mayObtainForMoney = self.__isHeroTank or vehicle.mayObtainWithMoneyExchange( money, exchangeRate) isBuyingAvailable = not vehicle.isHidden or vehicle.isRentable or vehicle.isRestorePossible( ) if currency == Currency.GOLD: if not mayObtainForMoney: if isBuyingAvailable: tooltip = _buildBuyButtonTooltip('notEnoughGold') if isIngameShopEnabled(): mayObtainForMoney = True elif not mayObtainForMoney and isBuyingAvailable: tooltip = _buildBuyButtonTooltip('notEnoughCredits') if self._disableBuyButton: mayObtainForMoney = False return _ButtonState( mayObtainForMoney, [currency, price.getSignValue(currency)], VEHICLE_PREVIEW.BUYINGPANEL_BUYBTN_LABEL_RESTORE if vehicle.isRestorePossible() else VEHICLE_PREVIEW.BUYINGPANEL_BUYBTN_LABEL_BUY, action, tooltip, self.__packTitle)
def _makeRealExposedNode(self, node, guiItem, unlockStats, displayInfo): nodeCD = node.nodeCD earnedXP = unlockStats.getVehXP(nodeCD) state = NODE_STATE_FLAGS.LOCKED available, unlockProps = g_techTreeDP.isNext2Unlock( nodeCD, level=guiItem.level, **unlockStats._asdict()) if guiItem.isUnlocked: state = NODE_STATE_FLAGS.UNLOCKED if guiItem.isInInventory: state |= NODE_STATE_FLAGS.IN_INVENTORY if self._canSell(nodeCD): state |= NODE_STATE_FLAGS.CAN_SELL else: if canBuyGoldForItemThroughWeb( nodeCD) or self._mayObtainForMoney(nodeCD): state |= NODE_STATE_FLAGS.ENOUGH_MONEY if self._isLastUnlocked(nodeCD): state |= NODE_STATE_FLAGS.LAST_2_BUY if nodeCD in self._wereInBattle: state |= NODE_STATE_FLAGS.WAS_IN_BATTLE if guiItem.buyPrices.itemPrice.isActionPrice( ) and not guiItem.isRestorePossible(): state |= NODE_STATE_FLAGS.ACTION else: if available: state = NODE_STATE_FLAGS.NEXT_2_UNLOCK if g_techTreeDP.getAllVehiclePossibleXP( unlockProps.parentID, unlockStats) >= unlockProps.xpCost: state |= NODE_STATE_FLAGS.ENOUGH_XP if unlockProps.discount: state |= NODE_STATE_FLAGS.ACTION if guiItem.isElite: state |= NODE_STATE_FLAGS.ELITE if guiItem.isPremium: state |= NODE_STATE_FLAGS.PREMIUM if guiItem.isRented and not guiItem.isPremiumIGR: state = self._checkExpiredRent(state, guiItem) state = self._checkMoney(state, nodeCD) if guiItem.isRentable and not guiItem.isInInventory: state = self._checkMoney(state, nodeCD) if self._isVehicleCanBeChanged(): state |= NODE_STATE_FLAGS.VEHICLE_CAN_BE_CHANGED bpfProps = self._getBlueprintsProps(node.nodeCD, guiItem.level) if bpfProps is not None and bpfProps.totalCount > 0: state |= NODE_STATE_FLAGS.BLUEPRINT state = self._checkRestoreState(state, guiItem) state = self._checkRentableState(state, guiItem) state = self._checkTradeInState(state, guiItem) state = self._checkTechTreeEvents(state, guiItem, unlockProps) price = getGUIPrice(guiItem, self._stats.money, self._items.shop.exchangeRate) return nodes.RealNode(node.nodeCD, guiItem, earnedXP, state, displayInfo, unlockProps=unlockProps, bpfProps=bpfProps, price=price)
def doAction(self): item = g_itemsCache.items.getItemByCD(self.__vehCD) if item.itemTypeID is not GUI_ITEM_TYPE.VEHICLE: LOG_ERROR('Value of int-type descriptor is not refer to vehicle', self.__vehCD) return else: if item.isInInventory and not item.isRented: showInventoryMsg('already_exists', item, msgType=SystemMessages.SM_TYPE.Warning) else: price = getGUIPrice(item, g_itemsCache.items.stats.money, g_itemsCache.items.shop.exchangeRate) if price is None: showShopMsg('not_found', item) return if not self._mayObtainForMoney(item): if self._mayObtainWithMoneyExchange(item): if item.isRestoreAvailable(): meta = RestoreExchangeCreditsMeta(self.__vehCD) else: meta = ExchangeCreditsMeta(self.__vehCD) isOk, args = yield DialogsInterface.showDialog(meta) if not isOk: return else: showShopMsg('common_rent_or_buy_error', item) if self._mayObtainForMoney(item): shared_events.showVehicleBuyDialog(item) yield lambda callback = None: callback return
def _getNodeData(self, nodeCD, rootItem, guiItem, unlockStats, unlockProps, path, level=-1, topLevel=False): itemTypeID = guiItem.itemTypeID available = False xp = 0 state = NODE_STATE_FLAGS.LOCKED if topLevel and itemTypeID == GUI_ITEM_TYPE.VEHICLE: available, unlockProps = g_techTreeDP.isNext2Unlock(nodeCD, **unlockStats._asdict()) xp = g_techTreeDP.getAllVehiclePossibleXP(unlockProps.parentID, unlockStats) if guiItem.isUnlocked: state = NODE_STATE_FLAGS.UNLOCKED if itemTypeID != GUI_ITEM_TYPE.VEHICLE and rootItem.isInInventory and guiItem.isInstalled(rootItem): state |= NODE_STATE_FLAGS.INSTALLED elif guiItem.isInInventory: if rootItem.isInInventory or itemTypeID == GUI_ITEM_TYPE.VEHICLE: state |= NODE_STATE_FLAGS.IN_INVENTORY if self._canSell(nodeCD): state |= NODE_STATE_FLAGS.CAN_SELL elif canBuyGoldForItemThroughWeb(nodeCD) or self._mayObtainForMoney(nodeCD): state |= NODE_STATE_FLAGS.ENOUGH_MONEY if nodeCD in self._wereInBattle: state |= NODE_STATE_FLAGS.WAS_IN_BATTLE if guiItem.buyPrices.itemPrice.isActionPrice(): state |= NODE_STATE_FLAGS.SHOP_ACTION else: if not topLevel: available = unlockStats.isSeqUnlocked(unlockProps.required) and unlockStats.isUnlocked(self._rootCD) xp = g_techTreeDP.getAllVehiclePossibleXP(self._rootCD, unlockStats) if available: state = NODE_STATE_FLAGS.NEXT_2_UNLOCK if xp >= unlockProps.xpCost: state |= NODE_STATE_FLAGS.ENOUGH_XP if itemTypeID == GUI_ITEM_TYPE.VEHICLE: if guiItem.isElite: state |= NODE_STATE_FLAGS.ELITE if guiItem.isPremium: state |= NODE_STATE_FLAGS.PREMIUM if guiItem.isRented and not guiItem.isPremiumIGR and not guiItem.isTelecom: state = self._checkExpiredRent(state, guiItem) state = self._checkMoney(state, nodeCD) if guiItem.isRentable and not guiItem.isInInventory and not guiItem.isTelecom: state = self._checkMoney(state, nodeCD) if self._isVehicleCanBeChanged(): state |= NODE_STATE_FLAGS.VEHICLE_CAN_BE_CHANGED if guiItem.isHidden: state |= NODE_STATE_FLAGS.PURCHASE_DISABLED state = self._checkRestoreState(state, guiItem) state = self._checkRentableState(state, guiItem) state = self._checkTradeInState(state, guiItem) renderer = 'root' if self._rootCD == nodeCD else 'vehicle' else: renderer = 'item' price = getGUIPrice(guiItem, self._stats.money, self._items.shop.exchangeRate) displayInfo = {'path': path, 'renderer': renderer, 'level': level} return nodes.RealNode(nodeCD, guiItem, unlockStats.getVehXP(nodeCD), state, displayInfo, unlockProps=unlockProps, price=price)
def _getNodeData(self, nodeCD, guiItem, unlockStats, displayInfo): """ Gets node data that stores to node list. """ earnedXP = unlockStats.getVehXP(nodeCD) state = NODE_STATE_FLAGS.LOCKED available, unlockProps = g_techTreeDP.isNext2Unlock( nodeCD, **unlockStats._asdict()) if guiItem.isUnlocked: state = NODE_STATE_FLAGS.UNLOCKED if guiItem.isInInventory: state |= NODE_STATE_FLAGS.IN_INVENTORY if self._canSell(nodeCD): state |= NODE_STATE_FLAGS.CAN_SELL elif self._mayObtainForMoney(nodeCD): state |= NODE_STATE_FLAGS.ENOUGH_MONEY if nodeCD in self._wereInBattle: state |= NODE_STATE_FLAGS.WAS_IN_BATTLE if guiItem.buyPrice != guiItem.defaultPrice: state |= NODE_STATE_FLAGS.SHOP_ACTION elif available: state = NODE_STATE_FLAGS.NEXT_2_UNLOCK if g_techTreeDP.getAllVehiclePossibleXP( unlockProps.parentID, unlockStats) >= unlockProps.xpCost: state |= NODE_STATE_FLAGS.ENOUGH_XP if guiItem.isElite: state |= NODE_STATE_FLAGS.ELITE if guiItem.isPremium: state |= NODE_STATE_FLAGS.PREMIUM if guiItem.isRented and not guiItem.isPremiumIGR: state = self._checkExpiredRent(state, guiItem) state = self._checkMoney(state, nodeCD) if guiItem.isRentable and not guiItem.isInInventory: state = self._checkMoney(state, nodeCD) if self._isVehicleCanBeChanged(): state |= NODE_STATE_FLAGS.VEHICLE_CAN_BE_CHANGED state = self._checkRestoreState(state, guiItem) state = self._checkRentableState(state, guiItem) return { 'id': nodeCD, 'earnedXP': earnedXP, 'state': state, 'unlockProps': unlockProps, 'GUIPrice': getGUIPrice(guiItem, self._stats.money, self._items.shop.exchangeRate), 'displayInfo': displayInfo }
def canBuyGoldForVehicleThroughWeb(vehicle, itemsCache=None, tradeIn=None): if vehicle.isUnlocked: money = itemsCache.items.stats.money money = tradeIn.addTradeInPriceIfNeeded(vehicle, money) exchangeRate = itemsCache.items.shop.exchangeRate price = getGUIPrice(vehicle, money, exchangeRate) currency = price.getCurrency(byWeight=True) mayObtainForMoney = vehicle.mayObtainWithMoneyExchange(money, exchangeRate) isBuyingAvailable = not vehicle.isHidden or vehicle.isRentable or vehicle.isRestorePossible() if currency == Currency.GOLD: if not mayObtainForMoney: if isBuyingAvailable: return True return False
def _makeRealExposedNode(self, node, guiItem, unlockStats, displayInfo): """ Gets node data that stores to node list. """ nodeCD = node.nodeCD earnedXP = unlockStats.getVehXP(nodeCD) state = NODE_STATE_FLAGS.LOCKED available, unlockProps = g_techTreeDP.isNext2Unlock( nodeCD, **unlockStats._asdict()) if guiItem.isUnlocked: state = NODE_STATE_FLAGS.UNLOCKED if guiItem.isInInventory: state |= NODE_STATE_FLAGS.IN_INVENTORY if self._canSell(nodeCD): state |= NODE_STATE_FLAGS.CAN_SELL elif self._mayObtainForMoney(nodeCD): state |= NODE_STATE_FLAGS.ENOUGH_MONEY if nodeCD in self._wereInBattle: state |= NODE_STATE_FLAGS.WAS_IN_BATTLE if guiItem.buyPrices.itemPrice.isActionPrice(): state |= NODE_STATE_FLAGS.SHOP_ACTION elif available: state = NODE_STATE_FLAGS.NEXT_2_UNLOCK if g_techTreeDP.getAllVehiclePossibleXP( unlockProps.parentID, unlockStats) >= unlockProps.xpCost: state |= NODE_STATE_FLAGS.ENOUGH_XP if guiItem.isElite: state |= NODE_STATE_FLAGS.ELITE if guiItem.isPremium: state |= NODE_STATE_FLAGS.PREMIUM if guiItem.isRented and not guiItem.isPremiumIGR: state = self._checkExpiredRent(state, guiItem) state = self._checkMoney(state, nodeCD) if guiItem.isRentable and not guiItem.isInInventory: state = self._checkMoney(state, nodeCD) if self._isVehicleCanBeChanged(): state |= NODE_STATE_FLAGS.VEHICLE_CAN_BE_CHANGED state = self._checkRestoreState(state, guiItem) state = self._checkRentableState(state, guiItem) state = self._checkTradeInState(state, guiItem) price = getGUIPrice(guiItem, self._stats.money, self._items.shop.exchangeRate) return nodes.RealNode(node.nodeCD, guiItem, earnedXP, state, displayInfo, unlockProps=unlockProps, price=price)
def _invalidateMoney(self, nodes_): result = [] for node in nodes_: state = node.getState() nodeID = node.getNodeCD() node.setGuiPrice(getGUIPrice(self.getItem(nodeID), self._stats.money, self._items.shop.exchangeRate)) if canBuyGoldForItemThroughWeb(nodeID) or self._mayObtainForMoney(nodeID): state = NODE_STATE.add(state, NODE_STATE_FLAGS.ENOUGH_MONEY) else: state = NODE_STATE.remove(state, NODE_STATE_FLAGS.ENOUGH_MONEY) if state > -1: node.setState(state) result.append((nodeID, state)) return result
def __getBtnData(self): vehicle = g_currentPreviewVehicle.item stats = self.itemsCache.items.stats tooltip = '' if vehicle.isUnlocked: money = stats.money money = self.tradeIn.addTradeInPriceIfNeeded(vehicle, money) exchangeRate = self.itemsCache.items.shop.exchangeRate price = getGUIPrice(vehicle, money, exchangeRate) currency = price.getCurrency(byWeight=True) action = getActionPriceData(vehicle) mayObtainForMoney = vehicle.mayObtainWithMoneyExchange(money, exchangeRate) if currency == Currency.GOLD: currencyIcon = RES_ICONS.MAPS_ICONS_LIBRARY_GOLDICONBIG if mayObtainForMoney: formatter = text_styles.goldTextBig else: formatter = text_styles.errCurrencyTextBig tooltip = _buildBuyButtonTooltip('notEnoughGold') else: currencyIcon = RES_ICONS.MAPS_ICONS_LIBRARY_CREDITSICONBIG formatter = text_styles.creditsTextBig if mayObtainForMoney else text_styles.errCurrencyTextBig if not mayObtainForMoney: tooltip = _buildBuyButtonTooltip('notEnoughCredits') if self._disableBuyButton: mayObtainForMoney = False return _ButtonState(mayObtainForMoney, formatter(BigWorld.wg_getIntegralFormat(price.getSignValue(currency))), VEHICLE_PREVIEW.BUYINGPANEL_BUYBTN_LABEL_RESTORE if vehicle.isRestorePossible() else VEHICLE_PREVIEW.BUYINGPANEL_BUYBTN_LABEL_BUY, action is not None, currencyIcon, action, tooltip) else: nodeCD = vehicle.intCD currencyIcon = RES_ICONS.MAPS_ICONS_LIBRARY_XPCOSTICONBIG isAvailableToUnlock, xpCost, possibleXp = g_techTreeDP.isVehicleAvailableToUnlock(nodeCD) formatter = text_styles.creditsTextBig if possibleXp >= xpCost else text_styles.errCurrencyTextBig if not isAvailableToUnlock: unlocks = self.itemsCache.items.stats.unlocks next2Unlock, _ = g_techTreeDP.isNext2Unlock(nodeCD, unlocked=set(unlocks), xps=stats.vehiclesXPs, freeXP=stats.freeXP) if next2Unlock: tooltip = _buildBuyButtonTooltip('notEnoughXp') elif any(map(lambda cd: cd in unlocks, g_techTreeDP.getTopLevel(nodeCD))): tooltip = _buildBuyButtonTooltip('parentModuleIsLocked') else: tooltip = _buildBuyButtonTooltip('parentVehicleIsLocked') return _ButtonState(isAvailableToUnlock, formatter(BigWorld.wg_getIntegralFormat(xpCost)), VEHICLE_PREVIEW.BUYINGPANEL_BUYBTN_LABEL_RESEARCH, False, currencyIcon, None, tooltip) return None
def _getNodeData(self, nodeCD, guiItem, unlockStats, displayInfo): """ Gets node data that stores to node list. """ earnedXP = unlockStats.getVehXP(nodeCD) state = NODE_STATE_FLAGS.LOCKED available, unlockProps = g_techTreeDP.isNext2Unlock(nodeCD, **unlockStats._asdict()) if guiItem.isUnlocked: state = NODE_STATE_FLAGS.UNLOCKED if guiItem.isInInventory: state |= NODE_STATE_FLAGS.IN_INVENTORY if self._canSell(nodeCD): state |= NODE_STATE_FLAGS.CAN_SELL elif self._mayObtainForMoney(nodeCD): state |= NODE_STATE_FLAGS.ENOUGH_MONEY if nodeCD in self._wereInBattle: state |= NODE_STATE_FLAGS.WAS_IN_BATTLE if guiItem.buyPrice != guiItem.defaultPrice: state |= NODE_STATE_FLAGS.SHOP_ACTION elif available: state = NODE_STATE_FLAGS.NEXT_2_UNLOCK if g_techTreeDP.getAllVehiclePossibleXP(unlockProps.parentID, unlockStats) >= unlockProps.xpCost: state |= NODE_STATE_FLAGS.ENOUGH_XP if guiItem.isElite: state |= NODE_STATE_FLAGS.ELITE if guiItem.isPremium: state |= NODE_STATE_FLAGS.PREMIUM if guiItem.isRented and not guiItem.isPremiumIGR: state = self._checkExpiredRent(state, guiItem) state = self._checkMoney(state, nodeCD) if guiItem.isRentable and not guiItem.isInInventory: state = self._checkMoney(state, nodeCD) if self._isVehicleCanBeChanged(): state |= NODE_STATE_FLAGS.VEHICLE_CAN_BE_CHANGED state = self._checkRestoreState(state, guiItem) state = self._checkRentableState(state, guiItem) return {'id': nodeCD, 'earnedXP': earnedXP, 'state': state, 'unlockProps': unlockProps, 'GUIPrice': getGUIPrice(guiItem, self._stats.money, self._items.shop.exchangeRate), 'displayInfo': displayInfo}
def _invalidateMoney(self, nodes): """ Updates states of nodes that have become available/unavailable for purchase. :param nodes: list of nodes where search changes. :return: list( (<node ID>, <new state>), ... ) for nodes where changed the state. """ result = [] for node in nodes: state = node['state'] nodeID = node['id'] node['GUIPrice'] = getGUIPrice(self.getItem(nodeID), self._stats.money, self._items.shop.exchangeRate) if self._mayObtainForMoney(nodeID): state = NODE_STATE.add(state, NODE_STATE_FLAGS.ENOUGH_MONEY) else: state = NODE_STATE.remove(state, NODE_STATE_FLAGS.ENOUGH_MONEY) if state > -1: node['state'] = state result.append((nodeID, state)) return result
def __getBtnState(self): vehicle = g_currentPreviewVehicle.item if vehicle.isUnlocked: money = g_itemsCache.items.stats.money exchangeRate = g_itemsCache.items.shop.exchangeRate price = getGUIPrice(vehicle, money, exchangeRate) currency = price.getCurrency(byWeight=True) action = getActionPriceData(vehicle) mayObtainForMoney = vehicle.mayObtainWithMoneyExchange(money, exchangeRate) if currency == Currency.GOLD: currencyIcon = RES_ICONS.MAPS_ICONS_LIBRARY_GOLDICONBIG formatter = text_styles.goldTextBig if mayObtainForMoney else text_styles.errCurrencyTextBig else: currencyIcon = RES_ICONS.MAPS_ICONS_LIBRARY_CREDITSICONBIG formatter = text_styles.creditsTextBig if mayObtainForMoney else text_styles.errCurrencyTextBig return _ButtonState(mayObtainForMoney, formatter(BigWorld.wg_getIntegralFormat(price.get(currency))), VEHICLE_PREVIEW.BUYINGPANEL_BUYBTN_LABEL_RESTORE if vehicle.isRestorePossible() else VEHICLE_PREVIEW.BUYINGPANEL_BUYBTN_LABEL_BUY, action is not None, currencyIcon, ItemsActionsFactory.BUY_VEHICLE, action) else: nodeCD = vehicle.intCD currencyIcon = RES_ICONS.MAPS_ICONS_LIBRARY_XPCOSTICONBIG isAvailableToUnlock, xpCost, possibleXp = g_techTreeDP.isVehicleAvailableToUnlock(nodeCD) formatter = text_styles.creditsTextBig if possibleXp >= xpCost else text_styles.errCurrencyTextBig return _ButtonState(isAvailableToUnlock, formatter(BigWorld.wg_getIntegralFormat(xpCost)), VEHICLE_PREVIEW.BUYINGPANEL_BUYBTN_LABEL_RESEARCH, False, currencyIcon, ItemsActionsFactory.UNLOCK_ITEM, None) return None
def __getBtnState(self): vehicle = g_currentPreviewVehicle.item if vehicle.isUnlocked: money = g_itemsCache.items.stats.money exchangeRate = g_itemsCache.items.shop.exchangeRate price = getGUIPrice(vehicle, money, exchangeRate) currency = price.getCurrency(byWeight=True) action = getActionPriceData(vehicle) mayObtainForMoney = vehicle.mayObtainWithMoneyExchange( money, exchangeRate) if currency == Currency.GOLD: currencyIcon = RES_ICONS.MAPS_ICONS_LIBRARY_GOLDICONBIG formatter = text_styles.goldTextBig if mayObtainForMoney else text_styles.errCurrencyTextBig else: currencyIcon = RES_ICONS.MAPS_ICONS_LIBRARY_CREDITSICONBIG formatter = text_styles.creditsTextBig if mayObtainForMoney else text_styles.errCurrencyTextBig return _ButtonState( mayObtainForMoney, formatter(BigWorld.wg_getIntegralFormat(price.get(currency))), VEHICLE_PREVIEW.BUYINGPANEL_BUYBTN_LABEL_RESTORE if vehicle.isRestorePossible() else VEHICLE_PREVIEW.BUYINGPANEL_BUYBTN_LABEL_BUY, action is not None, currencyIcon, ItemsActionsFactory.BUY_VEHICLE, action) else: nodeCD = vehicle.intCD currencyIcon = RES_ICONS.MAPS_ICONS_LIBRARY_XPCOSTICONBIG isAvailableToUnlock, xpCost, possibleXp = g_techTreeDP.isVehicleAvailableToUnlock( nodeCD) formatter = text_styles.creditsTextBig if possibleXp >= xpCost else text_styles.errCurrencyTextBig return _ButtonState( isAvailableToUnlock, formatter(BigWorld.wg_getIntegralFormat(xpCost)), VEHICLE_PREVIEW.BUYINGPANEL_BUYBTN_LABEL_RESEARCH, False, currencyIcon, ItemsActionsFactory.UNLOCK_ITEM, None) return None
def _getNodeData(self, nodeCD, rootItem, guiItem, unlockStats, unlockProps, path, level = -1, topLevel = False): """ Gets node data that stores to node list. """ itemTypeID = guiItem.itemTypeID available = False xp = 0 state = NODE_STATE_FLAGS.LOCKED if topLevel and itemTypeID == GUI_ITEM_TYPE.VEHICLE: available, unlockProps = g_techTreeDP.isNext2Unlock(nodeCD, **unlockStats._asdict()) xp = g_techTreeDP.getAllVehiclePossibleXP(unlockProps.parentID, unlockStats) if guiItem.isUnlocked: state = NODE_STATE_FLAGS.UNLOCKED if itemTypeID != GUI_ITEM_TYPE.VEHICLE and rootItem.isInInventory and guiItem.isInstalled(rootItem): state |= NODE_STATE_FLAGS.INSTALLED elif guiItem.isInInventory: if rootItem.isInInventory or itemTypeID == GUI_ITEM_TYPE.VEHICLE: state |= NODE_STATE_FLAGS.IN_INVENTORY if self._canSell(nodeCD): state |= NODE_STATE_FLAGS.CAN_SELL elif self._mayObtainForMoney(nodeCD): state |= NODE_STATE_FLAGS.ENOUGH_MONEY if nodeCD in self._wereInBattle: state |= NODE_STATE_FLAGS.WAS_IN_BATTLE if guiItem.buyPrice != guiItem.defaultPrice: state |= NODE_STATE_FLAGS.SHOP_ACTION else: if not topLevel: available = unlockStats.isSeqUnlocked(unlockProps.required) and unlockStats.isUnlocked(self._rootCD) xp = g_techTreeDP.getAllVehiclePossibleXP(self._rootCD, unlockStats) if available: state = NODE_STATE_FLAGS.NEXT_2_UNLOCK if xp >= unlockProps.xpCost: state |= NODE_STATE_FLAGS.ENOUGH_XP if itemTypeID == GUI_ITEM_TYPE.VEHICLE: if guiItem.isElite: state |= NODE_STATE_FLAGS.ELITE if guiItem.isPremium: state |= NODE_STATE_FLAGS.PREMIUM if guiItem.isRented and not guiItem.isPremiumIGR and not guiItem.isTelecom: state = self._checkExpiredRent(state, guiItem) state = self._checkMoney(state, nodeCD) if guiItem.isRentable and not guiItem.isInInventory and not guiItem.isTelecom: state = self._checkMoney(state, nodeCD) if self._isVehicleCanBeChanged(): state |= NODE_STATE_FLAGS.VEHICLE_CAN_BE_CHANGED if guiItem.isHidden: state |= NODE_STATE_FLAGS.PURCHASE_DISABLED state = self._checkRestoreState(state, guiItem) state = self._checkRentableState(state, guiItem) renderer = 'root' if self._rootCD == nodeCD else 'vehicle' else: renderer = 'item' return {'id': nodeCD, 'earnedXP': unlockStats.getVehXP(nodeCD), 'state': state, 'unlockProps': unlockProps, 'GUIPrice': getGUIPrice(guiItem, self._stats.money, self._items.shop.exchangeRate), 'displayInfo': {'path': list(path), 'renderer': renderer, 'level': level}}