def interceptSetResearchButton(self, nation, data): data = self._data.dump() state = data['nodes'][0]['state'] if (state & NODE_STATE_FLAGS.LOCKED > 0): state = NODE_STATE.remove(state, NODE_STATE_FLAGS.LOCKED) state = NODE_STATE.add(state, NODE_STATE_FLAGS.NEXT_2_UNLOCK) state = NODE_STATE.add(state, NODE_STATE_FLAGS.ENOUGH_XP) data['nodes'][0]['state'] = state origSetItems(self, nation, data)
def _checkTechTreeEvents(self, state, guiItem, unlockProps): if g_techTreeDP.techTreeEventsListener.hasActiveAction( guiItem.intCD) and guiItem.itemTypeID == GUI_ITEM_TYPE.VEHICLE: state |= NODE_STATE_FLAGS.HAS_TECH_TREE_EVENT NODE_STATE.removeIfHas(state, NODE_STATE_FLAGS.ACTION) noUnlockDiscount = not unlockProps or not unlockProps.discount if noUnlockDiscount and guiItem.buyPrices.itemPrice.isActionPrice( ) and not guiItem.isRestorePossible(): NODE_STATE.add(state, NODE_STATE_FLAGS.ACTION) return state
def _addNode(self, nodeCD, node): state = node.getState() if not NODE_STATE.isAnnouncement(state): if self.__overrideResearch: if not NODE_STATE.inInventory(state) and not ( NODE_STATE.isAvailable2Unlock(state) or NODE_STATE.isAvailable2Buy(state)): state = NODE_STATE.addIfNot(state, NODE_STATE_FLAGS.NOT_CLICKABLE) if self.getRootCD() == self.__firstVehicleNode: if self.__secondVehicleResearch: if nodeCD == self.__secondVehicleNode: return -1 if not NODE_STATE.inInventory( state ) and not NODE_STATE.isInstalled( state ) and nodeCD != self.__moduleNodeCD and nodeCD != self.__secondVehicleNode: return -1 item = self._items.getItemByCD(nodeCD) if item.level in DISABLED_TANK_LEVELS and NODE_STATE.isAvailable2Buy( state): state = NODE_STATE.add(state, NODE_STATE_FLAGS.PURCHASE_DISABLED) if not NODE_STATE.isAvailable2Unlock( state) and self._isLastUnlocked(nodeCD): state |= NODE_STATE_FLAGS.LAST_2_BUY if NODE_STATE.hasBlueprints(state): state = NODE_STATE.remove(state, NODE_STATE_FLAGS.BLUEPRINT) node.setState(state) return super(BCResearchItemsData, self)._addNode(nodeCD, node)
def _addNode(self, nodeCD, node): state = node['state'] if self.__overrideResearch: if nodeCD == self.__secondVehicleNode: g_bootcampGarage.setSecondVehicleNode(node) elif nodeCD == self.__moduleNodeCD: g_bootcampGarage.setModuleNode(node) if not NODE_STATE.inInventory(state): state = NODE_STATE.addIfNot(state, NODE_STATE_FLAGS.NOT_CLICKABLE) if self.getRootCD() == self.__firstVehicleNode: if self.__secondVehicleResearch: if nodeCD == self.__secondVehicleNode: return -1 if not NODE_STATE.inInventory( state ) and not NODE_STATE.isInstalled( state ) and nodeCD != self.__moduleNodeCD and nodeCD != self.__secondVehicleNode: return -1 state = NODE_STATE.removeIfHas(state, NODE_STATE_FLAGS.ELITE) item = self._items.getItemByCD(nodeCD) if item.level in DISABLED_TANK_LEVELS and NODE_STATE.isAvailable2Buy( state): state = NODE_STATE.add(state, NODE_STATE_FLAGS.PURCHASE_DISABLED) node['state'] = state return super(BCResearchItemsData, self)._addNode(nodeCD, node)
def invalidateInstalled(self): nodes = self._getNodesToInvalidate() rootItem = self.getRootItem() result = [] for node in nodes: nodeCD = node['id'] state = node['state'] item = self.getItem(nodeCD) if rootItem.isInInventory and item.isInstalled(rootItem): state = NODE_STATE.add(state, NODE_STATE.INSTALLED) else: state = NODE_STATE.remove(state, NODE_STATE.INSTALLED) if item.itemTypeID == GUI_ITEM_TYPE.VEHICLE and item.isElite: state = NODE_STATE.add(state, NODE_STATE.ELITE) if state > -1: node['state'] = state result.append((nodeCD, state)) return result
def _change2Unlocked(self, node): state = NODE_STATE.change2Unlocked(node['state']) if state < 0: return node['state'] node['state'] = state if self._canBuy(node['id']): state = NODE_STATE.add(state, NODE_STATE.ENOUGH_MONEY) else: state = NODE_STATE.remove(state, NODE_STATE.ENOUGH_MONEY) if state < 0: return node['state'] node['state'] = state return state
def _change2Unlocked(self, node): state = NODE_STATE.change2Unlocked(node.getState()) if state < 0: return node.getState() node.setState(state) if self._mayObtainForMoney(node.getNodeCD()): state = NODE_STATE.add(state, NODE_STATE_FLAGS.ENOUGH_MONEY) else: state = NODE_STATE.remove(state, NODE_STATE_FLAGS.ENOUGH_MONEY) if state < 0: return node.getState() node.setState(state) return state
def _invalidateMoney(self, nodes): result = [] for node in nodes: state = node['state'] nodeID = node['id'] if self._canRentOrBuy(nodeID): state = NODE_STATE.add(state, NODE_STATE.ENOUGH_MONEY) else: state = NODE_STATE.remove(state, NODE_STATE.ENOUGH_MONEY) if state > -1: node['state'] = state result.append((nodeID, state)) return result
def invalidateInstalled(self): """ Finds items that were installed/uninstalled on root vehicle. :return: [(<int:item compact descriptor>, <new state>), ... ]. """ nodes = self._getNodesToInvalidate() rootItem = self.getRootItem() result = [] for node in nodes: nodeCD = node['id'] state = node['state'] item = self.getItem(nodeCD) if rootItem.isInInventory and item.isInstalled(rootItem): state = NODE_STATE.add(state, NODE_STATE_FLAGS.INSTALLED) else: state = NODE_STATE.remove(state, NODE_STATE_FLAGS.INSTALLED) if item.itemTypeID == GUI_ITEM_TYPE.VEHICLE and item.isElite: state = NODE_STATE.add(state, NODE_STATE_FLAGS.ELITE) if state > -1: node['state'] = state result.append((nodeCD, state)) return result
def _invalidateXP(self, nodes): result = [] stats = self.getUnlockStats() for node in nodes: state = node['state'] props = node['unlockProps'] if self._getAllPossibleXP(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 _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 _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 _change2Unlocked(self, node): """ Changes state of node to 'unlocked'. :param node: node data. :return: int containing new state of node. """ state = NODE_STATE.change2Unlocked(node['state']) if state < 0: return node['state'] node['state'] = state if self._mayObtainForMoney(node['id']): state = NODE_STATE.add(state, NODE_STATE_FLAGS.ENOUGH_MONEY) else: state = NODE_STATE.remove(state, NODE_STATE_FLAGS.ENOUGH_MONEY) if state < 0: return node['state'] node['state'] = state return state
def _change2Unlocked(self, node): """ Changes state of node to 'unlocked'. :param node: node data. :return: int containing new state of node. """ state = NODE_STATE.change2Unlocked(node.getState()) if state < 0: return node.getState() node.setState(state) if self._mayObtainForMoney(node.getNodeCD()): state = NODE_STATE.add(state, NODE_STATE_FLAGS.ENOUGH_MONEY) else: state = NODE_STATE.remove(state, NODE_STATE_FLAGS.ENOUGH_MONEY) if state < 0: return node.getState() node.setState(state) return state
def _change2Unlocked(self, node): state = NODE_STATE.change2Unlocked(node.getState()) if state < 0: return node.getState() node.setState(state) if canBuyGoldForItemThroughWeb( node.getNodeCD()) or self._mayObtainForMoney(node.getNodeCD()): state = NODE_STATE.add(state, NODE_STATE_FLAGS.ENOUGH_MONEY) else: state = NODE_STATE.remove(state, NODE_STATE_FLAGS.ENOUGH_MONEY) if state < 0: return node.getState() if not node.isActionPrice(): state = NODE_STATE.removeIfHas(state, NODE_STATE_FLAGS.ACTION) else: state = NODE_STATE.addIfNot(state, NODE_STATE_FLAGS.ACTION) state = NODE_STATE.addIfNot(state, NODE_STATE_FLAGS.BLUEPRINT) node.setState(state) 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 _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 invalidateHovered(self, nodeCD): result = [] if nodeCD == -1: for node in self._nodes: nodeCD = node.getNodeCD() state = node.getState() state = NODE_STATE.remove(state, NODE_STATE_FLAGS.DASHED) if state > -1: node.setState(state) result.append((nodeCD, state)) _logger.debug( '[ModuleDependencies] nodes with "dashed" state cleared: %s', result) else: conflicted = self._moduleInstaller.updateConflicted( nodeCD, self.getRootItem()) moduleDependencies = [ moduleCD for moduleTypes in conflicted for moduleCD in moduleTypes ] _logger.debug( '[ModuleDependencies] nodeCD = %s, module dependencies %s', nodeCD, moduleDependencies) for node in self._nodes: nodeCD = node.getNodeCD() if nodeCD not in moduleDependencies or getTypeOfCD( nodeCD) not in GUI_ITEM_TYPE.VEHICLE_MODULES: continue state = node.getState() state = NODE_STATE.add(state, NODE_STATE_FLAGS.DASHED) if state > -1: node.setState(state) result.append((node.getNodeCD(), state)) self._moduleInstaller.clearConflictedModules() _logger.debug( '[ModuleDependencies] nodes with "dashed" state set: %s', result) return result