def _findNext2UnlockItems(self, nodes): result = [] topLevelCDs = self._topLevelCDs.keys() unlockStats = self.getUnlockStats() unlockKwargs = unlockStats._asdict() for node in nodes: nodeCD = node['id'] state = node['state'] itemTypeID, _, _ = vehicles.parseIntCompactDescr(nodeCD) if itemTypeID == GUI_ITEM_TYPE.VEHICLE and (nodeCD in topLevelCDs or nodeCD == self.getRootCD()): available, unlockProps = g_techTreeDP.isNext2Unlock(nodeCD, **unlockKwargs) xp = g_techTreeDP.getAllVehiclePossibleXP(unlockProps.parentID, unlockStats) else: unlockProps = node['unlockProps'] required = unlockProps.required available = len(required) and unlockStats.isSeqUnlocked(required) and not unlockStats.isUnlocked(nodeCD) xp = g_techTreeDP.getAllVehiclePossibleXP(self.getRootCD(), unlockStats) if available and state & NODE_STATE.LOCKED > 0: state ^= NODE_STATE.LOCKED state = NODE_STATE.addIfNot(state, NODE_STATE.NEXT_2_UNLOCK) if xp >= unlockProps.xpCost: state = NODE_STATE.addIfNot(state, NODE_STATE.ENOUGH_XP) else: state = NODE_STATE.removeIfHas(state, NODE_STATE.ENOUGH_XP) node['state'] = state result.append((node['id'], state, unlockProps._makeTuple())) return result
def _findNext2UnlockItems(self, nodes): result = [] topLevelCDs = self._topLevelCDs.keys() unlockStats = self.getUnlockStats() unlockKwargs = unlockStats._asdict() for node in nodes: nodeCD = node['id'] state = node['state'] itemTypeID, _, _ = vehicles.parseIntCompactDescr(nodeCD) if itemTypeID == GUI_ITEM_TYPE.VEHICLE and ( nodeCD in topLevelCDs or nodeCD == self.getRootCD()): available, unlockProps = g_techTreeDP.isNext2Unlock( nodeCD, **unlockKwargs) xp = g_techTreeDP.getAllVehiclePossibleXP( unlockProps.parentID, unlockStats) else: unlockProps = node['unlockProps'] required = unlockProps.required available = len(required) and unlockStats.isSeqUnlocked( required) and not unlockStats.isUnlocked(nodeCD) xp = g_techTreeDP.getAllVehiclePossibleXP( self.getRootCD(), unlockStats) if available and state & NODE_STATE.LOCKED > 0: state ^= NODE_STATE.LOCKED state = NODE_STATE.addIfNot(state, NODE_STATE.NEXT_2_UNLOCK) if xp >= unlockProps.xpCost: state = NODE_STATE.addIfNot(state, NODE_STATE.ENOUGH_XP) else: state = NODE_STATE.removeIfHas(state, NODE_STATE.ENOUGH_XP) node['state'] = state result.append((node['id'], state, unlockProps._makeTuple())) return result
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, rootItem, guiItem, unlockStats, unlockProps, path, level = -1, topLevel = False): itemTypeID = guiItem.itemTypeID available = False xp = 0 state = NODE_STATE.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.UNLOCKED if itemTypeID != GUI_ITEM_TYPE.VEHICLE and rootItem.isInInventory and guiItem.isInstalled(rootItem): state |= NODE_STATE.INSTALLED elif guiItem.isInInventory: if rootItem.isInInventory or itemTypeID == GUI_ITEM_TYPE.VEHICLE: state |= NODE_STATE.IN_INVENTORY if self._canSell(nodeCD): state |= NODE_STATE.CAN_SELL elif self._canBuy(nodeCD): state |= NODE_STATE.ENOUGH_MONEY if nodeCD in self._wereInBattle: state |= NODE_STATE.WAS_IN_BATTLE if guiItem.buyPrice != guiItem.defaultPrice: state |= NODE_STATE.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.NEXT_2_UNLOCK if xp >= unlockProps.xpCost: state |= NODE_STATE.ENOUGH_XP if itemTypeID == GUI_ITEM_TYPE.VEHICLE: if guiItem.isElite: state |= NODE_STATE.ELITE if guiItem.isPremium: state |= NODE_STATE.PREMIUM if guiItem.isRented and not guiItem.isPremiumIGR and not guiItem.isTelecom: state = self._checkExpiredRent(state, guiItem) state = self._checkMoneyForRentOrBuy(state, nodeCD) if guiItem.isRentable and not guiItem.isInInventory and not guiItem.isTelecom: state = self._checkMoneyForRentOrBuy(state, nodeCD) if self._isVehicleCanBeChanged(): state |= NODE_STATE.VEHICLE_CAN_BE_CHANGED if guiItem.isDisabledForBuy: state |= NODE_STATE.PURCHASE_DISABLED renderer = 'root' if self._rootCD == nodeCD else 'vehicle' else: renderer = 'item' return {'id': nodeCD, 'earnedXP': unlockStats.getVehXP(nodeCD), 'state': state, 'unlockProps': unlockProps, 'displayInfo': {'path': list(path), 'renderer': renderer, 'level': level}}
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 _findNext2UnlockItems(self, nodes): """ Finds nodes that statuses changed to "next to unlock". :param nodes: list of nodes data. :return: [(<int:vehicle compact descriptor>, <new state>, <new UnlockProps>), ... ]. """ result = [] topLevelCDs = self._topLevelCDs.keys() unlockStats = self.getUnlockStats() unlockKwargs = unlockStats._asdict() for node in nodes: nodeCD = node.getNodeCD() state = node.getState() itemTypeID, _, _ = vehicles_core.parseIntCompactDescr(nodeCD) if itemTypeID == GUI_ITEM_TYPE.VEHICLE and ( nodeCD in topLevelCDs or nodeCD == self.getRootCD()): available, unlockProps = g_techTreeDP.isNext2Unlock( nodeCD, **unlockKwargs) xp = g_techTreeDP.getAllVehiclePossibleXP( unlockProps.parentID, unlockStats) else: unlockProps = node.getUnlockProps() required = unlockProps.required available = len(required) and unlockStats.isSeqUnlocked( required) and not unlockStats.isUnlocked(nodeCD) xp = g_techTreeDP.getAllVehiclePossibleXP( self.getRootCD(), unlockStats) if available and state & NODE_STATE_FLAGS.LOCKED > 0: state ^= NODE_STATE_FLAGS.LOCKED state = NODE_STATE.addIfNot(state, NODE_STATE_FLAGS.NEXT_2_UNLOCK) if xp >= unlockProps.xpCost: state = NODE_STATE.addIfNot(state, NODE_STATE_FLAGS.ENOUGH_XP) else: state = NODE_STATE.removeIfHas(state, NODE_STATE_FLAGS.ENOUGH_XP) node.setState(state) result.append( (node.getNodeCD(), state, unlockProps.makeTuple())) return result
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 _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 _invalidateXP(self, nodes_): result = [] stats = self.getUnlockStats() for node in nodes_: state = node.getState() props = node.getUnlockProps() if g_techTreeDP.getAllVehiclePossibleXP(props.parentID, stats) >= props.xpCost: state = NODE_STATE.add(state, NODE_STATE_FLAGS.ENOUGH_XP) else: state = NODE_STATE.remove(state, NODE_STATE_FLAGS.ENOUGH_XP) if state > -1: node.setState(state) result.append((node.getNodeCD(), state)) return result
def _invalidateXP(self, nodes): result = [] stats = self.getUnlockStats() for node in nodes: state = node['state'] props = node['unlockProps'] if g_techTreeDP.getAllVehiclePossibleXP(props.parentID, stats) >= props.xpCost: state = NODE_STATE.add(state, NODE_STATE.ENOUGH_XP) else: state = NODE_STATE.remove(state, NODE_STATE.ENOUGH_XP) if state > -1: node['state'] = state result.append((node['id'], state)) return result
def _changeNext2Unlock(self, nodeCD, unlockProps, unlockStats): state = NODE_STATE_FLAGS.NEXT_2_UNLOCK totalXP = g_techTreeDP.getAllVehiclePossibleXP(unlockProps.parentID, unlockStats) if totalXP >= unlockProps.xpCost: state = NODE_STATE.addIfNot(state, NODE_STATE_FLAGS.ENOUGH_XP) else: state = NODE_STATE.removeIfHas(state, NODE_STATE_FLAGS.ENOUGH_XP) if self.getItem(nodeCD).isElite: state = NODE_STATE.addIfNot(state, NODE_STATE_FLAGS.ELITE) try: data = self._nodes[self._nodesIdx[nodeCD]] data.setState(state) data.setUnlockProps(unlockProps) except KeyError: LOG_CURRENT_EXCEPTION() return state
def _changeNext2Unlock(self, nodeCD, unlockProps, unlockStats): state = NODE_STATE.NEXT_2_UNLOCK totalXP = g_techTreeDP.getAllVehiclePossibleXP(unlockProps.parentID, unlockStats) if totalXP >= unlockProps.xpCost: state = NODE_STATE.addIfNot(state, NODE_STATE.ENOUGH_XP) else: state = NODE_STATE.removeIfHas(state, NODE_STATE.ENOUGH_XP) if self.getItem(nodeCD).isElite: state = NODE_STATE.addIfNot(state, NODE_STATE.ELITE) try: data = self._nodes[self._nodesIdx[nodeCD]] data['state'] = state data['unlockProps'] = unlockProps except KeyError: LOG_CURRENT_EXCEPTION() return state
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 _changeNext2Unlock(self, nodeCD, unlockProps, unlockStats): try: node = self._nodes[self._nodesIdx[nodeCD]] except KeyError as e: _logger.exception(e) return 0 state = NODE_STATE.setNext2Unlock(node.getState()) totalXP = g_techTreeDP.getAllVehiclePossibleXP(unlockProps.parentID, unlockStats) if totalXP >= unlockProps.xpCost: state = NODE_STATE.addIfNot(state, NODE_STATE_FLAGS.ENOUGH_XP) else: state = NODE_STATE.removeIfHas(state, NODE_STATE_FLAGS.ENOUGH_XP) if self.getItem(nodeCD).isElite: state = NODE_STATE.addIfNot(state, NODE_STATE_FLAGS.ELITE) state = NODE_STATE.addIfNot(state, NODE_STATE_FLAGS.BLUEPRINT) node.setState(state) node.setUnlockProps(unlockProps) return state
def _invalidateXP(self, nodes): """ Updates states of nodes that have become available/unavailable for unlock. :param nodes: list of nodes where search changes. :return: list( (<node ID>, <new state>), ... ) for nodes where changed the state. """ result = [] stats = self.getUnlockStats() for node in nodes: state = node['state'] props = node['unlockProps'] if g_techTreeDP.getAllVehiclePossibleXP(props.parentID, stats) >= props.xpCost: state = NODE_STATE.add(state, NODE_STATE_FLAGS.ENOUGH_XP) else: state = NODE_STATE.remove(state, NODE_STATE_FLAGS.ENOUGH_XP) if state > -1: node['state'] = state result.append((node['id'], state)) return result
def _getNodeData(self, nodeCD, guiItem, unlockStats, displayInfo): earnedXP = unlockStats.getVehXP(nodeCD) state = NODE_STATE.LOCKED available, unlockProps = g_techTreeDP.isNext2Unlock( nodeCD, **unlockStats._asdict()) if guiItem.isUnlocked: state = NODE_STATE.UNLOCKED if guiItem.isInInventory: state |= NODE_STATE.IN_INVENTORY if self._canSell(nodeCD): state |= NODE_STATE.CAN_SELL elif self._canBuy(nodeCD): state |= NODE_STATE.ENOUGH_MONEY if nodeCD in self._wereInBattle: state |= NODE_STATE.WAS_IN_BATTLE if guiItem.buyPrice != guiItem.defaultPrice: state |= NODE_STATE.SHOP_ACTION elif available: state = NODE_STATE.NEXT_2_UNLOCK if g_techTreeDP.getAllVehiclePossibleXP( unlockProps.parentID, unlockStats) >= unlockProps.xpCost: state |= NODE_STATE.ENOUGH_XP if guiItem.isElite: state |= NODE_STATE.ELITE if guiItem.isPremium: state |= NODE_STATE.PREMIUM if guiItem.isRented and not guiItem.isPremiumIGR: state = self._checkExpiredRent(state, guiItem) state = self._checkMoneyForRentOrBuy(state, nodeCD) if guiItem.isRentable and not guiItem.isInInventory: state = self._checkMoneyForRentOrBuy(state, nodeCD) if self._isVehicleCanBeChanged(): state |= NODE_STATE.VEHICLE_CAN_BE_CHANGED return { 'id': nodeCD, 'earnedXP': earnedXP, 'state': state, 'unlockProps': unlockProps, 'displayInfo': displayInfo }
def _getNodeData(self, nodeCD, guiItem, unlockStats, displayInfo): earnedXP = unlockStats.getVehXP(nodeCD) state = NODE_STATE.LOCKED available, unlockProps = g_techTreeDP.isNext2Unlock(nodeCD, **unlockStats._asdict()) if guiItem.isUnlocked: state = NODE_STATE.UNLOCKED if guiItem.isInInventory: state |= NODE_STATE.IN_INVENTORY if self._canSell(nodeCD): state |= NODE_STATE.CAN_SELL elif self._canBuy(nodeCD): state |= NODE_STATE.ENOUGH_MONEY if nodeCD in self._wereInBattle: state |= NODE_STATE.WAS_IN_BATTLE if guiItem.buyPrice != guiItem.defaultPrice: state |= NODE_STATE.SHOP_ACTION elif available: state = NODE_STATE.NEXT_2_UNLOCK if g_techTreeDP.getAllVehiclePossibleXP(unlockProps.parentID, unlockStats) >= unlockProps.xpCost: state |= NODE_STATE.ENOUGH_XP if guiItem.isElite: state |= NODE_STATE.ELITE if guiItem.isPremium: state |= NODE_STATE.PREMIUM if guiItem.isRented and not guiItem.isPremiumIGR: state = self._checkExpiredRent(state, guiItem) state = self._checkMoneyForRentOrBuy(state, nodeCD) if guiItem.isRentable and not guiItem.isInInventory: state = self._checkMoneyForRentOrBuy(state, nodeCD) if self._isVehicleCanBeChanged(): state |= NODE_STATE.VEHICLE_CAN_BE_CHANGED return {'id': nodeCD, 'earnedXP': earnedXP, 'state': state, 'unlockProps': unlockProps, 'displayInfo': displayInfo}
def _getNodeData(self, nodeCD, rootItem, guiItem, unlockStats, unlockProps, path, level=-1, topLevel=False): itemTypeID = guiItem.itemTypeID available = False xp = 0 state = NODE_STATE.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.UNLOCKED if itemTypeID != GUI_ITEM_TYPE.VEHICLE and rootItem.isInInventory and guiItem.isInstalled( rootItem): state |= NODE_STATE.INSTALLED elif guiItem.isInInventory: if rootItem.isInInventory or itemTypeID == GUI_ITEM_TYPE.VEHICLE: state |= NODE_STATE.IN_INVENTORY if self._canSell(nodeCD): state |= NODE_STATE.CAN_SELL elif self._canBuy(nodeCD): state |= NODE_STATE.ENOUGH_MONEY if nodeCD in self._wereInBattle: state |= NODE_STATE.WAS_IN_BATTLE if guiItem.buyPrice != guiItem.defaultPrice: state |= NODE_STATE.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.NEXT_2_UNLOCK if xp >= unlockProps.xpCost: state |= NODE_STATE.ENOUGH_XP if itemTypeID == GUI_ITEM_TYPE.VEHICLE: if guiItem.isElite: state |= NODE_STATE.ELITE if guiItem.isPremium: state |= NODE_STATE.PREMIUM if guiItem.isRented and not guiItem.isPremiumIGR and not guiItem.isTelecom: state = self._checkExpiredRent(state, guiItem) state = self._checkMoneyForRentOrBuy(state, nodeCD) if guiItem.isRentable and not guiItem.isInInventory and not guiItem.isTelecom: state = self._checkMoneyForRentOrBuy(state, nodeCD) if self._isVehicleCanBeChanged(): state |= NODE_STATE.VEHICLE_CAN_BE_CHANGED if guiItem.isDisabledForBuy: state |= NODE_STATE.PURCHASE_DISABLED renderer = 'root' if self._rootCD == nodeCD else 'vehicle' else: renderer = 'item' return { 'id': nodeCD, 'earnedXP': unlockStats.getVehXP(nodeCD), 'state': state, 'unlockProps': unlockProps, 'displayInfo': { 'path': list(path), 'renderer': renderer, 'level': level } }