Exemplo n.º 1
0
def add_item(self, item, forceQuantity=0, sourceLocation=None):
    locationID = session.locationid
    for i in xrange(2):
        try:
            if locationID != session.locationid:
                return
            itemQuantity = item.stacksize
            if itemQuantity == 1:
                quantity = 1
            elif forceQuantity > 0:
                quantity = forceQuantity
            else:
                quantity = itemQuantity
            if not item.itemID or not quantity:
                return
            if locationID != session.locationid:
                return
            if sourceLocation is None:
                sourceLocation = item.locationID
            return _add_item(self, item.itemID, sourceLocation, quantity)
        except UserError as what:
            if what.args[0] in ('NotEnoughCargoSpace', 'NotEnoughCargoSpaceOverload', 'NotEnoughDroneBaySpace',
                                'NotEnoughDroneBaySpaceOverload', 'NoSpaceForThat', 'NoSpaceForThatOverload',
                                'NotEnoughChargeSpace', 'NotEnoughSpecialBaySpace', 'NotEnoughSpecialBaySpaceOverload',
                                'NotEnoughSpace'):
                try:
                    cap = self.GetCapacity()
                except UserError:
                    raise what
                
                free = cap.capacity - cap.used
                if free < 0:
                    raise
                if item.typeID == const.typePlasticWrap:
                    volume = sm.GetService('invCache').GetInventoryFromId(item.itemID).GetCapacity().used
                else:
                    volume = GetItemVolume(item, 1)
                maxQty = min(item.stacksize, int(free / (volume or 1)))
                if maxQty <= 0:
                    if volume < 0.1:
                        req = 0.01
                    else:
                        req = volume
                    eve.Message('NotEnoughCargoSpaceFor1Unit', {'type': item.typeID,
                                                                'free': free,
                                                                'required': req})
                    
                    bot.log.warn('Недостаточно места в контейнере')
                    
                    return
                if self._DBLessLimitationsCheck(what.args[0], item):
                    return
                forceQuantity = 1
            else:
                raise
            sys.exc_clear()
Exemplo n.º 2
0
    def SetSecondaryVolume(self, items = []):
        volume = 0
        for item in items:
            volume += GetItemVolume(item)

        self.secondaryVolume = volume
        value = self.GetVolumeProportion(volume)
        currWidth = self.capacityGaugeSec.width
        duration = 0.5 * fabs(currWidth - value) ** 0.3
        uicore.animations.MorphScalar(self.capacityGaugeSec, 'width', currWidth, value, duration=duration)
        self.UpdateLabel()
Exemplo n.º 3
0
    def UpdateLabel(self):
        if self.invCont.invController.hasCapacity:
            cap = self.invCont.invController.GetCapacity()
            volume = cap.used + self.additionalVolume
            text = localization.GetByLabel('UI/Inventory/ContainerQuantityAndCapacity', quantity=volume, capacity=cap.capacity)
        else:
            volume = 0.0
            for item in self.invCont.invController.GetItems():
                volume += GetItemVolume(item)

            text = localization.GetByLabel('UI/Inventory/ContainerCapacity', capacity=volume)
        if self.secondaryVolume:
            if text:
                text = '(%s) ' % localization.formatters.FormatNumeric(self.secondaryVolume, useGrouping=True, decimalPlaces=1) + text
        self.capacityText.text = text
Exemplo n.º 4
0
 def GetValue(self, condition, item):
     if condition == ITEM_CATEGORY:
         return item.categoryID
     if condition == ITEM_GROUP:
         return item.groupID
     if condition == ITEM_VOLUME:
         return GetItemVolume(item)
     if condition == ITEM_PRICE:
         price = util.GetAveragePrice(item)
         if price is not None:
             price = util.RoundISK(price)
         return price
     if condition == ITEM_STACKSIZE:
         return item.stacksize
     if condition == ITEM_ASSEMBLED:
         return item.singleton
     if condition == ITEM_SLOT:
         effects = cfg.dgmtypeeffects.get(item.typeID, [])
         return [effect.effectID for effect in effects]
     if condition == ITEM_NAME:
         name = uix.GetItemName(item)
         return StripTags(name)
     if condition == ITEM_METAGROUP:
         ret = int(
             sm.GetService('godma').GetTypeAttribute(
                 item.typeID, const.attributeMetaGroupID, 0))
         if not ret:
             ret = int(
                 sm.GetService('godma').GetTypeAttribute(
                     item.typeID, const.attributeTechLevel, 1))
             if ret == 3:
                 ret = 14
         return ret
     if condition == ITEM_METALEVEL:
         return int(
             sm.GetService('godma').GetTypeAttribute(
                 item.typeID, const.attributeMetaLevel, 0))
     if condition == ITEM_POWER:
         return int(
             sm.GetService('godma').GetTypeAttribute(
                 item.typeID, const.attributePower, 0))
     if condition == ITEM_CPU:
         return int(
             sm.GetService('godma').GetTypeAttribute(
                 item.typeID, const.attributeCpu, 0))
     if condition == ITEM_BLUEPRINT_COPY:
         return item.singleton == const.singletonBlueprintCopy
Exemplo n.º 5
0
    def TargetHasCargoWeCanTake(self, itemID, capacityLeft):
        targetCargo = self.GetInventoryForTarget(itemID)
        targetCapacity = targetCargo.GetCapacity()
        canTake = False
        if targetCapacity.used < MIN_CARGO_THRESHOLD and len(
                targetCargo.List()) == 0:
            pass
        elif targetCapacity.used < capacityLeft:
            canTake = True
        else:
            for item in targetCargo.List():
                if GetItemVolume(
                        item) <= capacityLeft and self.IsLegalInventoryMove(
                            item):
                    canTake = True
                    break

        return canTake
Exemplo n.º 6
0
 def UpdateLabel(self, new=0):
     InvItem.UpdateLabel(self, new)
     if util.GetAttrs(self, 'sr', 'node', 'remote'):
         return
     volume = GetItemVolume(self.rec)
     self.sr.node.Set(
         'sort_%s' % localization.GetByLabel('UI/Inventory/ItemVolume'),
         volume)
     u = cfg.dgmunits.Get(const.unitVolume)
     unit = u.displayName
     label = '<t>%s %s' % (util.FmtAmt(volume), unit)
     if self.sr.node.viewMode in ('list', 'details'):
         self.sr.label.text += label
         label = self.sr.label.text
     else:
         self.sr.label.text += label
         label = self.sr.label.text
     self.sr.node.label = label
Exemplo n.º 7
0
    def LootTarget(self, targetID):
        targetCargo = self.GetInventoryForTarget(targetID)
        capacityLeft = self.GetCapacityLeft()
        itemVolumesAndIds = [(GetItemVolume(item), item.itemID)
                             for item in targetCargo.List()
                             if self.IsLegalInventoryMove(item)]
        itemVolumesAndIds.sort()
        itemIDsToTake = []
        for volume, itemID in itemVolumesAndIds:
            if capacityLeft < volume:
                break
            capacityLeft -= volume
            itemIDsToTake.append(itemID)

        with self.inventory2.LockedItems(itemIDsToTake):
            self.inventory2.MoveManyItems(itemIDsToTake, targetID, self.itemID,
                                          flagCargo, self.ownerID)
            logger.debug('%s looted items %s from %s', self.itemID,
                         itemIDsToTake, targetID)
Exemplo n.º 8
0
    def SetAdditionalVolume(self, items = []):
        if not self.invCont:
            return
        volume = 0
        for item in items:
            volume += GetItemVolume(item)

        self.additionalVolume = volume
        value = self.GetVolumeProportion(volume)
        animValue = min(value, 1.0 - self.capacityGauge.width)
        currWidth = self.capacityGaugeAdd.width
        duration = 0.5 * fabs(currWidth - animValue) ** 0.3
        uicore.animations.MorphScalar(self.capacityGaugeAdd, 'width', currWidth, animValue, duration=duration)
        color = self.COLOR_SECONDARY
        if self.invCont.invController.hasCapacity:
            cap = self.invCont.invController.GetCapacity()
            if cap.capacity and volume + cap.used > cap.capacity:
                color = (0.6, 0, 0)
        self.capacityGaugeAdd.SetGradient(colorData=[(0.0, color)])
        self.UpdateLabel()
Exemplo n.º 9
0
    def GetCapacity(self,
                    flag=None,
                    capacityItemID=None,
                    skipDistanceCheck=False):
        capacity = 0.0
        used = 0.0
        if self.broker is not None:
            try:
                contents = self.broker.inventory2.SelectItems(self.itemid,
                                                              flag=self.flagID)
            except UserError:
                contents = []

            capacity = evetypes.GetCapacity(self.invItem.typeID)
            used = 0.0
            for item in contents:
                vol = GetItemVolume(item)
                if vol > 0:
                    used = used + vol

        return Row(['capacity', 'used'], [capacity, used])
Exemplo n.º 10
0
 def GetVolume(self):
     if self.charge:
         return GetItemVolume(self.charge, 1)