Пример #1
0
 def sell(self, vehicleCD, shells, eqs, optDevs, inventory, isDismissCrew):
     """
     Make server request to sell given @vehicle. Called from flash.
     
     @param vehicle: <dict> vehicle packed data to sell
     @param shells: <list> list of shells items to sell
     @param eqs: <list> list of equipment items to sell
     @param optDevs: <list> list of optional devices to sell
     @param inventory: <list> list of inventory items to sell
     @param isDismissCrew: <bool> is dismiss crew
     """
     getItem = lambda data: g_itemsCache.items.getItemByCD(
         int(data['intCD']))
     getShellItem = lambda data: Shell(
         int(data['intCD']), int(data['count']), proxy=g_itemsCache.items)
     try:
         vehicle = g_itemsCache.items.getItemByCD(int(vehicleCD))
         shells = [
             getShellItem(flashObject2Dict(shell)) for shell in shells
         ]
         eqs = [getItem(flashObject2Dict(eq)) for eq in eqs]
         optDevs = [getItem(flashObject2Dict(dev)) for dev in optDevs]
         inventory = [
             getItem(flashObject2Dict(module)) for module in inventory
         ]
         self.__doSellVehicle(vehicle, shells, eqs, optDevs, inventory,
                              isDismissCrew)
     except Exception:
         LOG_ERROR('There is error while selling vehicle')
         LOG_CURRENT_EXCEPTION()
Пример #2
0
 def createShell(self,
                 intCompactDescr,
                 count=0,
                 defaultCount=0,
                 proxy=None,
                 isBoughtForCredits=False):
     return Shell(intCompactDescr, count, defaultCount, proxy,
                  isBoughtForCredits)
Пример #3
0
    def _parseShells(self, layoutList, defaultLayoutsList, proxy):
        result = list()
        for i in xrange(0, len(layoutList), 2):
            intCD = abs(layoutList[i])
            shellsVehCount = layoutList[i + 1]
            shellsDefCount = defaultLayoutsList[i + 1] if i + 1 < len(defaultLayoutsList) else 0
            isBoughtForCredits = defaultLayoutsList[i] < 0 if i < len(defaultLayoutsList) else False
            result.append(Shell(intCD, shellsVehCount, shellsDefCount, proxy, isBoughtForCredits))

        return result
Пример #4
0
 def createShell(self, intCompactDescr, count = 0, defaultCount = 0, proxy = None, isBoughtForCredits = False):
     """
     Creates Shell item by the given arguments.
     
     :param intCompactDescr: item int compact descriptor
     :param count: count of shells in ammo bay
     :param defaultCount: count default shells in ammo bay
     :param proxy:  instance of ItemsRequester
     :param isBoughtForCredits: is item has been bought for credits
     :return: an instance of Shell class.
     """
     return Shell(intCompactDescr, count, defaultCount, proxy, isBoughtForCredits)
Пример #5
0
    def _parseShells(self, layoutList, defaultLayoutList, proxy):
        shellsDict = dict(((cd, count) for cd, count, _ in LayoutIterator(layoutList)))
        defaultsDict = dict(((cd, (count, isBoughtForCredits)) for cd, count, isBoughtForCredits in LayoutIterator(defaultLayoutList)))
        layoutList = list(layoutList)
        for shot in self.descriptor.gun['shots']:
            cd = shot['shell']['compactDescr']
            if cd not in shellsDict:
                layoutList.extend([cd, 0])

        result = list()
        for idx, (intCD, count, _) in enumerate(LayoutIterator(layoutList)):
            defaultCount, isBoughtForCredits = defaultsDict.get(intCD, (0, False))
            result.append(Shell(intCD, count, defaultCount, proxy, isBoughtForCredits))

        return result
Пример #6
0
 def getShellItem(data):
     return Shell(int(data['intCD']),
                  int(data['count']),
                  proxy=self.itemsCache.items)