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._actionType == ItemsActionsFactory.UNLOCK_ITEM:
         unlockProps = g_techTreeDP.getUnlockProps(self.__vehicleCD)
         ItemsActionsFactory.doAction(ItemsActionsFactory.UNLOCK_ITEM,
                                      self.__vehicleCD,
                                      unlockProps.parentID,
                                      unlockProps.unlockIdx,
                                      unlockProps.xpCost)
     else:
         ItemsActionsFactory.doAction(ItemsActionsFactory.BUY_VEHICLE,
                                      self.__vehicleCD)
 def buyAction(self, actionType, vehicleCD, skipConfirm):
     if actionType == factory.UNLOCK_ITEM:
         unlockProps = g_techTreeDP.getUnlockProps(vehicleCD)
         factory.doAction(factory.UNLOCK_ITEM,
                          vehicleCD,
                          unlockProps.parentID,
                          unlockProps.unlockIdx,
                          unlockProps.xpCost,
                          skipConfirm=skipConfirm)
     else:
         factory.doAction(factory.BUY_VEHICLE,
                          vehicleCD,
                          skipConfirm=skipConfirm)
 def buyAction(self, actionType, vehicleCD, skipConfirm, level=-1):
     if actionType == factory.BC_UNLOCK_ITEM:
         unlockProps = g_techTreeDP.getUnlockProps(vehicleCD, level)
         factory.doAction(factory.BC_UNLOCK_ITEM,
                          vehicleCD,
                          unlockProps,
                          skipConfirm=skipConfirm)
     else:
         factory.doAction(factory.BUY_VEHICLE,
                          vehicleCD,
                          False,
                          None,
                          VIEW_ALIAS.VEHICLE_PREVIEW,
                          skipConfirm=skipConfirm)
     return
 def __research(self):
     if self._actionType == factory.UNLOCK_ITEM:
         unlockProps = g_techTreeDP.getUnlockProps(self._vehicleCD,
                                                   self._vehicleLevel)
         factory.doAction(factory.UNLOCK_ITEM,
                          self._vehicleCD,
                          unlockProps,
                          skipConfirm=self._skipConfirm)
     else:
         factory.doAction(factory.BUY_VEHICLE,
                          self._vehicleCD,
                          False,
                          None,
                          VIEW_ALIAS.VEHICLE_PREVIEW,
                          skipConfirm=self._skipConfirm)
     return
Esempio n. 6
0
 def researchVehicle(self):
     unlockProp = g_techTreeDP.getUnlockProps(self.vehCD)
     ItemsActionsFactory.doAction(ItemsActionsFactory.UNLOCK_ITEM,
                                  self.vehCD, unlockProp.parentID,
                                  unlockProp.unlockIdx, unlockProp.xpCost)
 def unlockVehicle(self):
     unlockProps = g_techTreeDP.getUnlockProps(self._nodeCD)
     ItemsActionsFactory.doAction(ItemsActionsFactory.UNLOCK_ITEM,
                                  self._nodeCD, unlockProps.parentID,
                                  unlockProps.unlockIdx, unlockProps.xpCost)
def researchVehicle(intCD, successorCD=0, callback=lambda: None):
    vehItem = getItem(intCD)
    unlockingSequence = []
    if not vehItem.isUnlocked:
        unlockTuple = g_techTreeDP.getUnlockProps(intCD)
        unlockingSequence.extend(researchVehicle(unlockTuple[0], intCD))
        MYLOG("Research {} ({}) for {} XP".format(vehItem.shortUserName,
                                                  str(intCD), unlockTuple[2]))
    else:
        MYLOG("{} is already researched".format(vehItem.shortUserName))

    researchRequirementsArr = [data for data in vehItem.getUnlocksDescrs()]
    researchRequirements = {}
    for data in researchRequirementsArr:
        researchRequirements[data[2]] = data[3]

    if successorCD != 0:
        for unlockIdx, _, nodeCD, required in researchRequirementsArr:
            if nodeCD == successorCD:
                researched = set(vehItem.getAutoUnlockedItems())
                while len(required) > 0:
                    requiredCopy = set(required)
                    for itemCD in required:
                        item = getItem(itemCD)
                        if item.isUnlocked or itemCD in researched:
                            requiredCopy.remove(itemCD)
                            researched.add(itemCD)
                            continue

                        requiredForItem = researchRequirements[itemCD]
                        if requiredForItem.issubset(researched):
                            MYLOG(" - research {}".format(item.shortUserName))
                            itemData = [
                                data for data in researchRequirementsArr
                                if data[2] == itemCD
                            ][0]
                            unlockingSequence.append([intCD, itemData[0]])
                            requiredCopy.remove(itemCD)
                            researched.add(itemCD)
                    required = requiredCopy

                itemData = [
                    data for data in researchRequirementsArr
                    if data[2] == successorCD
                ][0]
                unlockingSequence.append([intCD, itemData[0]])
    else:
        researched = set(vehItem.getAutoUnlockedItems())
        itemsToBeResearched = len(researchRequirementsArr) + len(researched)

        for unlockIdx, xpCost, nodeCD, required in researchRequirementsArr:
            item = getItem(nodeCD)
            if item.isUnlocked:
                researched.add(nodeCD)

        itemsToBeResearched -= len(researched)

        while itemsToBeResearched > 0:
            for unlockIdx, xpCost, nodeCD, required in researchRequirementsArr:
                if required.issubset(researched):
                    item = getItem(nodeCD)
                    MYLOG(" - research {}".format(item.shortUserName))
                    arr = [intCD, unlockIdx]
                    if not nodeCD in researched:
                        unlockingSequence.append(arr)
                        researched.add(nodeCD)
                        itemsToBeResearched -= 1

        MYLOG(unlockingSequence)
        combinedCallback = lambda: (pushInfoMessage("Fully unlocked {}".format(
            vehItem.shortUserName)), callback())
        processQueue(unlockingSequence, lambda
                     (parent, id): unlockItem(parent, id), 1, combinedCallback)

    return unlockingSequence
 def unlockVehicle(self):
     unlockProps = g_techTreeDP.getUnlockProps(self._nodeCD)
     ItemsActionsFactory.doAction(ItemsActionsFactory.UNLOCK_ITEM, self._nodeCD, unlockProps.parentID, unlockProps.unlockIdx, unlockProps.xpCost)
Esempio n. 10
0
 def researchVehicle(self):
     vehicle = self.itemsCache.items.getItemByCD(self.vehCD)
     unlockProps = g_techTreeDP.getUnlockProps(vehicle.intCD, vehicle.level)
     ItemsActionsFactory.doAction(ItemsActionsFactory.UNLOCK_ITEM, self.vehCD, unlockProps)
 def onBuyOrResearchClick(self):
     if self._actionType == ItemsActionsFactory.UNLOCK_ITEM:
         unlockProps = g_techTreeDP.getUnlockProps(self.__vehicleCD)
         ItemsActionsFactory.doAction(ItemsActionsFactory.UNLOCK_ITEM, self.__vehicleCD, unlockProps.parentID, unlockProps.unlockIdx, unlockProps.xpCost)
     else:
         ItemsActionsFactory.doAction(ItemsActionsFactory.BUY_VEHICLE, self.__vehicleCD)
 def researchVehicle(self):
     unlockProp = g_techTreeDP.getUnlockProps(self.vehCD)
     ItemsActionsFactory.doAction(ItemsActionsFactory.UNLOCK_ITEM, self.vehCD, unlockProp.parentID, unlockProp.unlockIdx, unlockProp.xpCost)
Esempio n. 13
0
 def unlockVehicle(self):
     level = self.itemsCache.items.getItemByCD(self._nodeCD).level
     unlockProps = g_techTreeDP.getUnlockProps(self._nodeCD, level)
     ItemsActionsFactory.doAction(ItemsActionsFactory.UNLOCK_ITEM,
                                  self._nodeCD, unlockProps)