def _generateOptions(self, ctx=None):
     options = []
     vehicle = self.__getVehicle(self.vehCD)
     self._manageStartOptions(options, vehicle)
     if vehicle.isPurchased:
         options.append(
             self._makeItem(VEHICLE.SELL, MENU.contextmenu(VEHICLE.SELL),
                            {'enabled': vehicle.canSell}))
     elif vehicle.isUnlocked:
         items = self.itemsCache.items
         if vehicle.isRestoreAvailable():
             label = MENU.CONTEXTMENU_RESTORE
         elif vehicle.canTradeIn:
             label = MENU.CONTEXTMENU_BUYORTRADEIN
         else:
             label = MENU.CONTEXTMENU_BUY
         if canBuyGoldForVehicleThroughWeb(vehicle):
             btnEnabled = True
         else:
             btnEnabled = vehicle.mayObtainWithMoneyExchange(
                 items.stats.money, items.shop.exchangeRate)
         options.append(
             self._makeItem(VEHICLE.BUY, label, {'enabled': btnEnabled}))
     else:
         isAvailableToUnlock, _, _ = g_techTreeDP.isVehicleAvailableToUnlock(
             self.vehCD)
         options.append(
             self._makeItem(VEHICLE.RESEARCH,
                            MENU.contextmenu(VEHICLE.RESEARCH),
                            {'enabled': isAvailableToUnlock}))
     self._manageEndOptions(options, vehicle)
     return options
 def buyVehicle(self):
     vehicle = self.itemsCache.items.getItemByCD(self.vehCD)
     if canBuyGoldForVehicleThroughWeb(vehicle):
         shared_events.showVehicleBuyDialog(vehicle)
     else:
         ItemsActionsFactory.doAction(ItemsActionsFactory.BUY_VEHICLE,
                                      self.vehCD)
Exemplo n.º 3
0
 def request4Buy(self, itemCD):
     itemCD = int(itemCD)
     vehicle = self.itemsCache.items.getItemByCD(itemCD)
     if canBuyGoldForVehicleThroughWeb(vehicle):
         shared_events.showVehicleBuyDialog(vehicle)
     else:
         ItemsActionsFactory.doAction(ItemsActionsFactory.BUY_VEHICLE, itemCD)
 def onBuyOrResearchClick(self):
     vehicle = g_currentPreviewVehicle.item
     if self.__packItems is not None:
         requestConfirmed = yield self.__requestConfirmation()
         if requestConfirmed:
             goldPrice = self.__packPrice.get(Currency.GOLD, 0)
             if goldPrice > self.itemsCache.items.stats.gold:
                 showBuyGoldForBundle(goldPrice, self.__buyParams)
             else:
                 showBuyVehicleOverlay(self.__buyParams)
     elif canBuyGoldForVehicleThroughWeb(vehicle):
         event_dispatcher.showVehicleBuyDialog(vehicle)
     elif self.__isHeroTank:
         url = self.heroTanks.getCurrentRelatedURL()
         self.fireEvent(
             events.OpenLinkEvent(events.OpenLinkEvent.SPECIFIED, url=url))
     elif self._actionType == factory.UNLOCK_ITEM:
         unlockProps = g_techTreeDP.getUnlockProps(self._vehicleCD)
         factory.doAction(factory.UNLOCK_ITEM,
                          self._vehicleCD,
                          unlockProps.parentID,
                          unlockProps.unlockIdx,
                          unlockProps.xpCost,
                          skipConfirm=self._skipConfirm)
     else:
         factory.doAction(factory.BUY_VEHICLE,
                          self._vehicleCD,
                          False,
                          VIEW_ALIAS.VEHICLE_PREVIEW_20,
                          skipConfirm=self._skipConfirm)
     return
 def onBuyOrResearchClick(self):
     if self.__isHeroTank:
         url = self.heroTanks.getCurrentRelatedURL()
         self.fireEvent(
             events.OpenLinkEvent(events.OpenLinkEvent.SPECIFIED, url=url))
     else:
         vehicle = g_currentPreviewVehicle.item
         if canBuyGoldForVehicleThroughWeb(vehicle):
             event_dispatcher.showVehicleBuyDialog(
                 vehicle, previousAlias=VIEW_ALIAS.VEHICLE_PREVIEW)
         else:
             self.__previewDP.buyAction(self._actionType, self._vehicleCD,
                                        self._skipConfirm)
 def request4Buy(self, itemCD):
     itemCD = int(itemCD)
     if getTypeOfCompactDescr(itemCD) == GUI_ITEM_TYPE.VEHICLE:
         vehicle = self.itemsCache.items.getItemByCD(itemCD)
         if canBuyGoldForVehicleThroughWeb(vehicle):
             shared_events.showVehicleBuyDialog(vehicle)
         else:
             ItemsActionsFactory.doAction(ItemsActionsFactory.BUY_VEHICLE,
                                          itemCD,
                                          skipConfirm=self._skipConfirm)
     else:
         ItemsActionsFactory.doAction(
             ItemsActionsFactory.BUY_AND_INSTALL_ITEM,
             itemCD,
             self._data.getRootCD(),
             skipConfirm=self._skipConfirm)
 def buyVehicle(self):
     vehicle = self.itemsCache.items.getItemByCD(self._nodeCD)
     if canBuyGoldForVehicleThroughWeb(vehicle):
         shared_events.showVehicleBuyDialog(vehicle)
     else:
         super(ResearchVehicleContextMenuHandler, self).buyVehicle()