コード例 #1
0
    def CreateFittingData(self, items, putModuleAmmoInHangar = True):
        fitData = []
        dronesByType = defaultdict(int)
        chargesByType = defaultdict(int)
        iceByType = defaultdict(int)
        fightersByType = defaultdict(int)
        for item in items:
            typeID = item.typeID
            flagID = item.flagID
            if IsShipFittingFlag(flagID) and IsShipFittable(item.categoryID):
                fitData.append((int(typeID), int(flagID), 1))
            elif item.categoryID == const.categoryDrone and flagID == const.flagDroneBay:
                dronesByType[typeID] += item.stacksize
            elif item.categoryID == const.categoryFighter and flagID == const.flagFighterBay:
                fightersByType[typeID] += item.stacksize
            elif item.categoryID == const.categoryCharge and flagID == const.flagCargo:
                chargesByType[typeID] += item.stacksize
            elif hasattr(item, 'groupID') and item.groupID == const.groupIceProduct and flagID == const.flagCargo:
                iceByType[typeID] += item.stacksize
            elif putModuleAmmoInHangar and item.categoryID == const.categoryCharge and flagID in const.moduleSlotFlags:
                chargesByType[typeID] += getattr(item, 'stacksize', 1)

        fitData += self.GetDataToAddToFitData(const.flagDroneBay, dronesByType)
        fitData += self.GetDataToAddToFitData(const.flagFighterBay, fightersByType)
        fitData += self.GetDataToAddToFitData(const.flagCargo, chargesByType)
        fitData += self.GetDataToAddToFitData(const.flagCargo, iceByType)
        return fitData
コード例 #2
0
    def CreateFittingData(self, items):
        fitData = []
        dronesByType = defaultdict(int)
        chargesByType = defaultdict(int)
        iceByType = defaultdict(int)
        for item in items:
            if IsShipFittingFlag(item.flagID) and item.categoryID in (
                    const.categoryModule, const.categorySubSystem):
                fitData.append((int(item.typeID), int(item.flagID), 1))
            elif item.categoryID == const.categoryDrone and item.flagID == const.flagDroneBay:
                typeID = item.typeID
                dronesByType[typeID] += item.stacksize
            elif item.categoryID == const.categoryCharge and item.flagID == const.flagCargo:
                typeID = item.typeID
                chargesByType[typeID] += item.stacksize
            elif hasattr(
                    item, 'groupID'
            ) and item.groupID == const.groupIceProduct and item.flagID == const.flagCargo:
                typeID = item.typeID
                iceByType[typeID] += item.stacksize

        flag = const.flagDroneBay
        for drone, quantity in dronesByType.iteritems():
            fitData.append((int(drone), int(flag), int(quantity)))

        flag = const.flagCargo
        for charge, quantity in chargesByType.iteritems():
            fitData.append((int(charge), int(flag), int(quantity)))

        flag = const.flagCargo
        for ice, quantity in iceByType.iteritems():
            fitData.append((int(ice), int(flag), int(quantity)))

        return fitData
コード例 #3
0
    def VerifyFitting(self, fitting):
        if fitting.name.find('@@') != -1 or fitting.description.find('@@') != -1:
            raise UserError('InvalidFittingInvalidCharacter')
        if fitting.shipTypeID is None:
            raise UserError('InvalidFittingDataTypeID', {'typeName': fitting.shipTypeID})
        shipTypeName = evetypes.GetNameOrNone(fitting.shipTypeID)
        if shipTypeName is None:
            raise UserError('InvalidFittingDataTypeID', {'typeName': fitting.shipTypeID})
        if evetypes.GetCategoryID(fitting.shipTypeID) not in (const.categoryShip, const.categoryStructure):
            raise UserError('InvalidFittingDataShipNotShip', {'typeName': shipTypeName})
        if len(fitting.fitData) == 0:
            raise UserError('ParseFittingFittingDataEmpty')
        for typeID, flag, qty in fitting.fitData:
            if not evetypes.Exists(typeID):
                raise UserError('InvalidFittingDataTypeID', {'typeID': typeID})
            try:
                int(flag)
            except TypeError:
                raise UserError('InvalidFittingDataInvalidFlag', {'type': typeID})

            if not (IsShipFittingFlag(flag) or flag in (const.flagDroneBay, const.flagCargo, const.flagFighterBay)):
                raise UserError('InvalidFittingDataInvalidFlag', {'type': typeID})
            try:
                int(qty)
            except TypeError:
                raise UserError('InvalidFittingDataInvalidQuantity', {'type': typeID})

            if qty == 0:
                raise UserError('InvalidFittingDataInvalidQuantity', {'type': typeID})

        return True
コード例 #4
0
 def OnDogmaItemChange(self, item, change):
     if item.locationID == change.get(const.ixLocationID,
                                      None) and item.flagID == change.get(
                                          const.ixFlag):
         return
     activeShipID = util.GetActiveShip()
     if item.locationID == activeShipID and IsShipFittingFlag(
             item.flagID) and item.categoryID == const.categorySubSystem:
         self.ShowShip(activeShipID)
コード例 #5
0
 def _IsSubsystemBeingLoaded(self, change, item):
     locationOrFlagIsInChange = const.ixLocationID in change or const.ixFlag in change
     if not locationOrFlagIsInChange:
         return False
     if item.locationID != self.GetItemID():
         return False
     if not IsShipFittingFlag(item.flagID):
         return False
     if item.categoryID != const.categorySubSystem:
         return False
     return True
コード例 #6
0
def _add_item(self, itemID, sourceLocation, quantity, dividing=False):
    try:
        dropLocation = self._GetInvCacheContainer().GetItem().itemID
        dogmaLocation = sm.GetService('clientDogmaIM').GetDogmaLocation()
        stateMgr = sm.StartService('godma').GetStateManager()
        item = dogmaLocation.dogmaItems.get(itemID)
        if dropLocation == sourceLocation and not dividing:
            if getattr(item, 'flagID', None):
                if item.flagID == self.locationFlag:
                    return
        if not dividing and not self.CheckAndConfirmOneWayMove():
            return
        if self.locationFlag:
            item = stateMgr.GetItem(itemID)
            if item and self.locationFlag == const.flagCargo and IsShipFittingFlag(item.flagID):
                containerArgs = self._GetContainerArgs()
                if item.categoryID == const.categoryCharge:
                    return dogmaLocation.UnloadChargeToContainer(item.locationID, item.itemID, containerArgs,
                                                                 self.locationFlag, quantity)
                if item.categoryID == const.categoryModule:
                    return stateMgr.UnloadModuleToContainer(item.locationID, item.itemID, containerArgs,
                                                            self.locationFlag)
            else:
                return self._GetInvCacheContainer().Add(itemID, sourceLocation, qty=quantity, flag=self.locationFlag)
        else:
            lockFlag = None
            typeID = self.GetTypeID()
            if typeID and evetypes.GetGroupID(typeID) == const.groupAuditLogSecureContainer:
                thisContainer = sm.GetService('invCache').GetInventoryFromId(self.itemID)
                thisContainerItem = thisContainer.GetItem()
                rolesAreNeeded = thisContainerItem is None or not util.IsStation(thisContainerItem.locationID) and \
                                                              thisContainerItem.locationID != session.shipid
                if rolesAreNeeded:
                    config = thisContainer.ALSCConfigGet()
                    lockFlag = const.flagLocked if bool(config & const.ALSCLockAddedItems) else const.flagUnlocked
                    if lockFlag == const.flagLocked and charsession.corprole & const.corpRoleEquipmentConfig == 0:
                        bot.log.warn('Какая-то проблема с переносом из конта в конт, требуется подтверждение')
                        
                        if eve.Message('ConfirmAddLockedItemToAuditContainer', {}, uiconst.OKCANCEL) != uiconst.ID_OK:
                            return
            return self._GetInvCacheContainer().Add(itemID, sourceLocation, qty=quantity, flag=self.locationFlag)
    except:
        return
コード例 #7
0
    def VerifyFitting(self, fitting):
        if fitting.name.find('@@') != -1 or fitting.description.find(
                '@@') != -1:
            raise UserError('InvalidFittingInvalidCharacter')
        if fitting.shipTypeID is None:
            raise UserError('InvalidFittingDataTypeID',
                            {'typeName': fitting.shipTypeID})
        shipType = cfg.invtypes.Get(fitting.shipTypeID, None)
        if shipType is None:
            raise UserError('InvalidFittingDataTypeID',
                            {'typeName': fitting.shipTypeID})
        if cfg.invtypes.Get(
                fitting.shipTypeID).categoryID != const.categoryShip:
            raise UserError('InvalidFittingDataShipNotShip',
                            {'typeName': shipType.typeName})
        if len(fitting.fitData) == 0:
            raise UserError('ParseFittingFittingDataEmpty')
        for typeID, flag, qty in fitting.fitData:
            type = cfg.invtypes.GetIfExists(typeID)
            if type is None:
                raise UserError('InvalidFittingDataTypeID', {'typeID': typeID})
            try:
                int(flag)
            except TypeError:
                raise UserError('InvalidFittingDataInvalidFlag',
                                {'type': type.typeID})

            if not (IsShipFittingFlag(flag)
                    or flag in (const.flagDroneBay, const.flagCargo)):
                raise UserError('InvalidFittingDataInvalidFlag',
                                {'type': type.typeID})
            try:
                int(qty)
            except TypeError:
                raise UserError('InvalidFittingDataInvalidQuantity',
                                {'type': type.typeID})

            if qty == 0:
                raise UserError('InvalidFittingDataInvalidQuantity',
                                {'type': type.typeID})

        return True
コード例 #8
0
ファイル: minihangar.py プロジェクト: connoryang/1v1dec
 def OnDropData(self, dragObj, nodes):
     self.Hilite(0)
     if len(nodes) == 1:
         item = nodes[0].item
         if IsShipFittingFlag(item.flagID):
             dogmaLocation = sm.GetService(
                 'clientDogmaIM').GetDogmaLocation()
             shipID = util.GetActiveShip()
             if IsShipFittable(item.categoryID):
                 dogmaLocation.UnloadModuleToContainer(shipID,
                                                       item.itemID,
                                                       (shipID, ),
                                                       flag=const.flagCargo)
                 return
             if item.categoryID == const.categoryCharge:
                 dogmaLocation.UnloadChargeToContainer(
                     shipID, item.itemID, (shipID, ), const.flagCargo)
                 return
     invCtrl.ShipCargo(util.GetActiveShip()).OnDropData(nodes)
     CargoSlots.OnDropData(self, dragObj, nodes)
コード例 #9
0
ファイル: __init__.py プロジェクト: connoryang/1v1dec
def CanRepackageLocation(locationID, flagID):
    if IsShipFittingFlag(flagID):
        return False
    if IsJunkLocation(locationID):
        return False
    return True
コード例 #10
0
ファイル: eveCommonUtils.py プロジェクト: connoryang/1v1dec
def CombatLog_CopyText(mail, *args):
    kwargs = {
        'system': mail.solarSystemID,
        'target': mail.victimShipTypeID,
        'damage': mail.victimDamageTaken
    }
    if boot.role == 'client':
        kwargs['security'] = sm.GetService('map').GetSecurityStatus(
            mail.solarSystemID)
    else:
        kwargs['security'] = cfg.mapSystemCache[
            mail.solarSystemID].pseudoSecurity
    if mail.moonID is not None:
        kwargs['moon'] = cfg.evelocations.Get(mail.moonID).name
    else:
        kwargs['moon'] = localization.GetByLabel('UI/Common/Unknown')
    if mail.victimAllianceID is not None:
        kwargs['alliance'] = cfg.eveowners.Get(mail.victimAllianceID).name
    else:
        kwargs['alliance'] = localization.GetByLabel('UI/Common/Unknown')
    if mail.victimFactionID is not None:
        kwargs['faction'] = cfg.eveowners.Get(mail.victimFactionID).name
    else:
        kwargs['faction'] = localization.GetByLabel('UI/Common/Unknown')
    if mail.victimCharacterID is not None:
        if mail.victimCorporationID is None:
            return
        kwargs['victim'] = mail.victimCharacterID
        kwargs['corporation'] = cfg.eveowners.Get(
            mail.victimCorporationID).name
        headerLabel = 'UI/Util/CommonUtils/KillMailHeaderWithShip'
    elif mail.victimCorporationID is not None:
        kwargs['corporation'] = cfg.eveowners.Get(
            mail.victimCorporationID).name
        headerLabel = 'UI/Util/CommonUtils/KillMailHeaderWithStructure'
    else:
        return
    header = localization.GetByLabel(headerLabel, **kwargs)
    attackers, items = GetAttackersAndItemsFromKillMail(mail)
    attackerList = []
    for row in attackers:
        attacker = row[1]
        data = {'damage': attacker.damageDone}
        attackerLabel = None
        if attacker.characterID is not None:
            data['attacker'] = cfg.eveowners.Get(attacker.characterID).name
            data['security'] = attacker.secStatusText
            data['corporation'] = cfg.eveowners.Get(
                attacker.corporationID).name
            if attacker.allianceID is not None:
                data['alliance'] = cfg.eveowners.Get(attacker.allianceID).name
            else:
                data['alliance'] = localization.GetByLabel('UI/Common/None')
            if attacker.factionID is not None:
                data['faction'] = cfg.eveowners.Get(attacker.factionID).name
            else:
                data['faction'] = localization.GetByLabel('UI/Common/None')
            if attacker.shipTypeID is not None:
                data['ship'] = evetypes.GetName(attacker.shipTypeID)
            else:
                data['ship'] = localization.GetByLabel('UI/Common/Unknown')
            if attacker.weaponTypeID is not None:
                data['weapon'] = evetypes.GetName(attacker.weaponTypeID)
            else:
                data['weapon'] = localization.GetByLabel('UI/Common/Unknown')
            if attacker.finalBlow:
                attackerLabel = 'UI/Util/CommonUtils/KillMailPlayerAttackerWithFinalBlow'
            else:
                attackerLabel = 'UI/Util/CommonUtils/KillMailPlayerAttacker'
        elif attacker.corporationID is not None:
            if attacker.shipTypeID is not None:
                data['attacker'] = evetypes.GetName(attacker.shipTypeID)
            else:
                data['attacker'] = localization.GetByLabel('UI/Common/Unknown')
            data['owner'] = cfg.eveowners.Get(attacker.corporationID).name
            if attacker.finalBlow:
                attackerLabel = 'UI/Util/CommonUtils/KillMailMPCAttackerWithFinalBlow'
            else:
                attackerLabel = 'UI/Util/CommonUtils/KillMailNPCAttacker'
        if attackerLabel is not None:
            attackerList.append(localization.GetByLabel(attackerLabel, **data))

    droppedItemList = []
    destroyedItemList = []
    textDropped = textDestroyed = ''
    for item in items:
        qty = None
        if item.qtyDropped > 0:
            qty = item.qtyDropped
            wasDropped = True
        else:
            qty = item.qtyDestroyed
            wasDropped = False
        if item.flag == const.flagCargo:
            itemLocation = localization.GetByLabel(
                'UI/Util/CommonUtils/KillMailItemLocation',
                itemLocation=localization.GetByLabel('UI/Generic/Cargo'))
        elif item.flag == const.flagDroneBay:
            itemLocation = localization.GetByLabel(
                'UI/Util/CommonUtils/KillMailItemLocation',
                itemLocation=localization.GetByLabel('UI/Common/DroneBay'))
        elif item.flag == const.flagImplant:
            itemLocation = localization.GetByLabel(
                'UI/Util/CommonUtils/KillMailItemLocation',
                itemLocation=localization.GetByLabel('UI/Common/Implant'))
        elif IsShipFittingFlag(item.flag):
            itemLocation = ''
        else:
            itemLocation = localization.GetByLabel(
                'UI/Util/CommonUtils/KillMailItemLocation',
                itemLocation=localization.GetByLabel('UI/Common/Other'))
        itemText = GetItemText(item, qty, itemLocation)
        if wasDropped:
            droppedItemList.append(itemText)
        else:
            destroyedItemList.append(itemText)
        if len(item.contents) > 0:
            for subitem in item.contents:
                itemLocation = localization.GetByLabel(
                    'UI/Util/CommonUtils/KillMailItemLocation',
                    itemLocation=localization.GetByLabel(
                        'UI/Util/CommonUtils/InContainer'))
                if subitem.qtyDropped > 0:
                    qty = subitem.qtyDropped
                else:
                    qty = subitem.qtyDestroyed
                itemText = '<t>' + GetItemText(subitem, qty, itemLocation)
                if wasDropped:
                    droppedItemList.append(itemText)
                else:
                    destroyedItemList.append(itemText)

    if len(droppedItemList) > 0:
        textDropped = localization.GetByLabel(
            'UI/Util/CommonUtils/KillMailDroppedItems',
            droppedItems=''.join(droppedItemList))
    if len(destroyedItemList) > 0:
        textDestroyed = localization.GetByLabel(
            'UI/Util/CommonUtils/KillMailDestroyedItems',
            destroyedItems=''.join(destroyedItemList))
    killmail = localization.GetByLabel('UI/Util/CommonUtils/KillMail',
                                       timestamp=util.FmtDate(mail.killTime,
                                                              fmt='ll'),
                                       header=header,
                                       attackers=''.join(attackerList),
                                       droppedItems=textDropped,
                                       destroyedItems=textDestroyed)
    return killmail.replace('\n', '')
コード例 #11
0
    def OnDropData(self, dragObj, nodes):
        if self.blinkBG:
            uicore.animations.FadeOut(self.blinkBG, duration=0.2)
        if len(nodes) and getattr(nodes[0], 'scroll', None):
            nodes[0].scroll.ClearSelection()
            if not nodes[0].rec:
                return
            if not hasattr(nodes[0].rec, 'locationID'):
                return
            locationID = nodes[0].rec.locationID
            if locationID != self.rec.locationID:
                if not sm.GetService('crimewatchSvc').CheckCanTakeItems(
                        locationID):
                    sm.GetService('crimewatchSvc').SafetyActivated(
                        const.shipSafetyLevelPartial)
                    return
        if self.isShip:
            if invCtrl.ShipCargo(self.rec.itemID).OnDropData(nodes):
                self.Blink()
            return
        if self.isContainer:
            if invCtrl.StationContainer(self.rec.itemID).OnDropData(nodes):
                self.Blink()
            return
        mergeToMe = []
        notUsed = []
        sourceID = None
        for node in nodes:
            if getattr(node, '__guid__',
                       None) not in ('xtriui.ShipUIModule', 'xtriui.InvItem',
                                     'listentry.InvItem'):
                notUsed.append(node)
                continue
            if node.item.itemID == self.sr.node.item.itemID:
                notUsed.append(node)
                continue
            if node.item.typeID == self.sr.node.item.typeID and not isinstance(
                    self.sr.node.item.itemID, tuple) and not getattr(
                        node.item, 'singleton',
                        False) and not self.sr.node.item.singleton:
                mergeToMe.append(node.item)
            else:
                notUsed.append(node)
            if sourceID is None:
                sourceID = node.rec.locationID

        if sourceID is None:
            log.LogInfo('OnDropData: Moot operation with ', nodes)
            return
        if mergeToMe:
            containerItem = sm.GetService('invCache').GetInventoryFromId(
                self.rec.locationID).GetItem()
            if session.solarsystemid and containerItem.itemID == mergeToMe[
                    0].locationID and containerItem.ownerID not in (
                        session.charid, session.corpid, session.allianceid):
                return
        shift = uicore.uilib.Key(uiconst.VK_SHIFT)
        mergeData = []
        stateMgr = sm.StartService('godma').GetStateManager()
        dogmaLocation = sm.GetService('clientDogmaIM').GetDogmaLocation()
        singletons = []
        for invItem in mergeToMe:
            if invItem.stacksize == 1:
                quantity = 1
            elif shift:
                ret = uix.QtyPopup(
                    invItem.stacksize, 1, 1, None,
                    localization.GetByLabel(
                        'UI/Inventory/ItemActions/StackItems'))
                if ret is not None:
                    quantity = ret['qty']
                else:
                    quantity = None
            else:
                quantity = invItem.stacksize
            if not quantity:
                continue
            if invItem.categoryID == const.categoryCharge and IsShipFittingFlag(
                    invItem.flagID):
                if type(invItem.itemID) is tuple:
                    flag = invItem.itemID[1]
                    chargeIDs = dogmaLocation.GetSubLocationsInBank(
                        invItem.locationID, invItem.itemID)
                    if chargeIDs:
                        for chargeID in chargeIDs:
                            charge = dogmaLocation.dogmaItems[chargeID]
                            mergeData.append(
                                (charge.itemID, self.rec.itemID,
                                 dogmaLocation.GetAttributeValue(
                                     chargeID,
                                     const.attributeQuantity), charge))

                    else:
                        mergeData.append((invItem.itemID, self.rec.itemID,
                                          quantity, invItem))
                else:
                    crystalIDs = dogmaLocation.GetCrystalsInBank(
                        invItem.locationID, invItem.itemID)
                    if crystalIDs:
                        for crystalID in crystalIDs:
                            crystal = dogmaLocation.GetItem(crystalID)
                            if crystal.singleton:
                                singletons.append(crystalID)
                            else:
                                mergeData.append(
                                    (crystal.itemID, self.rec.itemID,
                                     crystal.stacksize, crystal))

                    else:
                        mergeData.append((invItem.itemID, self.rec.itemID,
                                          quantity, invItem))
            else:
                mergeData.append(
                    (invItem.itemID, self.rec.itemID, quantity, invItem))

        if singletons and util.GetAttrs(self, 'sr', 'node', 'rec', 'flagID'):
            flag = self.sr.node.rec.flagID
            inv = sm.GetService('invCache').GetInventoryFromId(
                self.rec.locationID)
            if inv:
                inv.MultiAdd(singletons,
                             sourceID,
                             flag=flag,
                             fromManyFlags=True)
        if mergeData and util.GetAttrs(self, 'sr', 'node', 'container',
                                       'invController', 'MultiMerge'):
            invController = self.sr.node.container.invController
            sm.ScatterEvent('OnInvContDragExit', invController.GetInvID(), [])
            if invController.MultiMerge(mergeData, sourceID):
                sm.GetService('audio').SendUIEvent('ui_state_stack')
                self.Blink()
        if notUsed and util.GetAttrs(self, 'sr', 'node', 'container',
                                     'OnDropData'):
            self.sr.node.container.OnDropData(dragObj, notUsed)
コード例 #12
0
def move_items(self, items, count=0):
    if not isinstance(items, list):
        items = [items]
    if len(items) > 1:
        items = filter(self.DoesAcceptItem, items)
    if not items:
        return
    else:
        sourceLocation = items[0].locationID
        if self.itemID != sourceLocation and not sm.GetService('crimewatchSvc').CheckCanTakeItems(sourceLocation):
            sm.GetService('crimewatchSvc').SafetyActivated(const.shipSafetyLevelPartial)
            return
        if session.shipid and self.itemID == session.shipid:
            if self.itemID != sourceLocation and not sm.GetService('consider').ConfirmTakeIllicitGoods(items):
                return
        if len(items) == 1:
            item = items[0]
            if hasattr(item, 'flagID') and IsShipFittingFlag(item.flagID):
                if item.locationID == util.GetActiveShip():
                    if not self.CheckAndConfirmOneWayMove():
                        return
                    itemKey = item.itemID
                    locationID = item.locationID
                    dogmaLocation = sm.GetService('clientDogmaIM').GetDogmaLocation()
                    containerArgs = self._GetContainerArgs()
                    if item.categoryID == const.categoryCharge:
                        return dogmaLocation.UnloadChargeToContainer(locationID, itemKey, containerArgs,
                                                                     self.locationFlag)
                    if item.categoryID == const.categoryModule:
                        return dogmaLocation.UnloadModuleToContainer(locationID, itemKey, containerArgs,
                                                                     self.locationFlag)
            ret = add_item(self, item, sourceLocation=sourceLocation, forceQuantity=int(count))
            if ret:
                sm.ScatterEvent('OnClientEvent_MoveFromCargoToHangar', sourceLocation, self.itemID, self.locationFlag)
            return ret
        elif not self.CheckAndConfirmOneWayMove():
            return
        items.sort(key=lambda item: evetypes.GetVolume(item.typeID) * item.stacksize)
        itemIDs = [node.itemID for node in items]
        dogmaLocation = sm.GetService('clientDogmaIM').GetDogmaLocation()
        masters = dogmaLocation.GetAllSlaveModulesByMasterModule(sourceLocation)
        if masters:
            inBank = 0
            for itemID in itemIDs:
                if dogmaLocation.IsInWeaponBank(sourceLocation, itemID):
                    inBank = 1
                    break
            
            if inBank:
                ret = eve.Message('CustomQuestion', {'header': localization.GetByLabel('UI/Common/Confirm'),
                                                     'question': localization.GetByLabel(
                                                         'UI/Inventory/WeaponLinkUnfitMany')}, uiconst.YESNO)
                
                bot.log.warn('Какая-то проблема с переносом из конта в конт')
                
                if ret != uiconst.ID_YES:
                    return
        for item in items:
            if item.categoryID == const.categoryCharge and IsShipFittingFlag(item.flagID):
                log.LogInfo('A module with a db item charge dropped from ship fitting into some container. '
                            'Cannot use multimove, must remove charge first.')
                ret = [add_item(self, item, forceQuantity=int(count))]
                items.remove(item)
                for _item in items:
                    ret.append(add_item(self, _item, forceQuantity=int(count)))
                
                return ret
        
        invCacheCont = self._GetInvCacheContainer()
        if self.locationFlag:
            ret = invCacheCont.MultiAdd(itemIDs, sourceLocation, flag=self.locationFlag)
        else:
            ret = invCacheCont.MultiAdd(itemIDs, sourceLocation, flag=const.flagNone)
        
        if ret:
            sm.ScatterEvent('OnClientEvent_MoveFromCargoToHangar', sourceLocation, self.itemID, self.locationFlag)
        return ret
コード例 #13
0
def RepackageItemsInStation(invItems, invCacheSvc):
    if eve.Message('ConfirmRepackageItem', {},
                   uiconst.YESNO) != uiconst.ID_YES:
        return
    validIDsByStationID = defaultdict(list)
    insuranceQ_OK = 0
    insuranceContracts = None
    checksToSkip = set()
    godma = sm.GetService('godma')
    for invItem in invItems:
        skipThis = False
        itemState = godma.GetItem(invItem.itemID)
        if itemState and (itemState.damage or invItem.categoryID in
                          (const.categoryShip, const.categoryDrone)
                          and itemState.armorDamage):
            eve.Message('CantRepackageDamagedItem')
            continue
        if invItem.categoryID == const.categoryShip:
            if insuranceContracts is None:
                insuranceContracts = sm.StartService(
                    'insurance').GetContracts()
            if not insuranceQ_OK and invItem.itemID in insuranceContracts:
                if eve.Message('RepairUnassembleVoidsContract', {},
                               uiconst.YESNO) != uiconst.ID_YES:
                    continue
                insuranceQ_OK = 1
            if invCacheSvc.IsInventoryPrimedAndListed(invItem.itemID):
                inv = invCacheSvc.GetInventoryFromId(invItem.itemID)
                dogmaStaticMgr = sm.GetService('clientDogmaStaticSvc')
                for item in [
                        i for i in inv.List() if IsShipFittingFlag(i.flagID)
                ]:
                    if dogmaStaticMgr.TypeHasEffect(item.typeID,
                                                    const.effectRigSlot):
                        if eve.Message(
                                'ConfirmRepackageSomethingWithUpgrades',
                            {'what': (const.UE_LOCID, invItem.itemID)},
                                uiconst.YESNO,
                                suppress=uiconst.ID_YES) == uiconst.ID_YES:
                            checksToSkip.add(
                                'ConfirmRepackageSomethingWithUpgrades')
                        else:
                            skipThis = True
                            break

                if skipThis:
                    continue
        stationID = invCacheSvc.GetStationIDOfItem(invItem)
        if stationID is not None:
            validIDsByStationID[stationID].append(
                (invItem.itemID, invItem.locationID))

    if len(validIDsByStationID) == 0:
        return
    try:
        sm.RemoteSvc('repairSvc').DisassembleItems(dict(validIDsByStationID),
                                                   list(checksToSkip))
    except UserError as e:
        if cfg.messages[e.msg].dialogType == 'question' and eve.Message(
                e.msg, e.dict, uiconst.YESNO,
                suppress=uiconst.ID_YES) == uiconst.ID_YES:
            checksToSkip.add(e.msg)
            return sm.RemoteSvc('repairSvc').DisassembleItems(
                dict(validIDsByStationID), list(checksToSkip))
        raise
コード例 #14
0
    def LoadFitting(self, ownerID, fittingID):
        """
            Loads a fitting specified with modules from hangar
        """
        if session.stationid is None:
            raise UserError('CannotLoadFittingInSpace')
        fitting = self.fittings.get(ownerID, {}).get(fittingID, None)
        if fitting is None:
            raise UserError('FittingDoesNotExist')
        itemTypes = defaultdict(lambda: 0)
        modulesByFlag = {}
        dronesByType = {}
        chargesByType = {}
        iceByType = {}
        shipInv = self.invCache.GetInventoryFromId(
            util.GetActiveShip(), locationID=session.stationid2)
        rigsToFit = False
        fitRigs = False
        dogmaLocation = sm.GetService('clientDogmaIM').GetDogmaLocation()
        for typeID, flag, qty in fitting.fitData:
            if IsShipFittingFlag(flag):
                modulesByFlag[flag] = typeID
                if const.flagRigSlot0 <= flag <= const.flagRigSlot7:
                    rigsToFit = True
            elif flag == const.flagDroneBay:
                dronesByType[typeID] = qty
            elif flag == const.flagCargo:
                groupID = cfg.invtypes.Get(typeID).groupID
                if groupID == const.groupIceProduct:
                    iceByType[typeID] = qty
                else:
                    chargesByType[typeID] = qty
            else:
                self.LogError(
                    'LoadFitting::flag neither fitting nor drone bay', typeID,
                    flag)
            skipType = False
            for item in shipInv.List(flag):
                if item.typeID == typeID:
                    itemQty = item.stacksize
                    if itemQty == qty:
                        skipType = True
                        break
                    else:
                        qty -= itemQty

            if skipType:
                continue
            itemTypes[typeID] += qty

        if rigsToFit:
            if self.HasRigFitted():
                eve.Message(
                    'CustomNotify', {
                        'notify':
                        localization.GetByLabel(
                            'UI/Fitting/ShipHasRigsAlready')
                    })
            elif eve.Message('FitRigs', {}, uiconst.YESNO) == uiconst.ID_YES:
                fitRigs = True
        inv = self.invCache.GetInventory(const.containerHangar)
        itemsToFit = defaultdict(set)
        for item in inv.List():
            if item.typeID in itemTypes:
                qtyNeeded = itemTypes[item.typeID]
                if qtyNeeded == 0:
                    continue
                quantityToTake = min(item.stacksize, qtyNeeded)
                itemsToFit[item.typeID].add(item.itemID)
                itemTypes[item.typeID] -= quantityToTake

        failedToLoad = shipInv.FitFitting(util.GetActiveShip(), itemsToFit,
                                          session.stationid2, modulesByFlag,
                                          dronesByType, chargesByType,
                                          iceByType, fitRigs)
        for typeID, qty in failedToLoad:
            itemTypes[typeID] += qty

        text = ''
        for typeID, qty in itemTypes.iteritems():
            if qty > 0:
                text += '%sx %s<br>' % (qty, cfg.invtypes.Get(typeID).typeName)

        if text != '':
            text = localization.GetByLabel('UI/Fitting/MissingItems',
                                           types=text)
            eve.Message('CustomInfo', {'info': text})
コード例 #15
0
def TryFit(invItems, shipID=None):
    if not shipID:
        shipID = GetActiveShip()
        if not shipID:
            return
    godma = sm.services['godma']
    invCache = sm.GetService('invCache')
    shipInv = invCache.GetInventoryFromId(shipID,
                                          locationID=session.stationid2)
    godmaSM = godma.GetStateManager()
    useRigs = None
    charges = set()
    drones = []
    subSystemGroupIDs = set()
    for invItem in invItems[:]:
        if IsFittingModule(invItem.categoryID):
            moduleEffects = cfg.dgmtypeeffects.get(invItem.typeID, [])
            for mEff in moduleEffects:
                if mEff.effectID == const.effectRigSlot:
                    if useRigs is None:
                        useRigs = True if RigFittingCheck(invItem) else False
                    if not useRigs:
                        invItems.remove(invItem)
                        invCache.UnlockItem(invItem.itemID)
                        break

        if invItem.categoryID == const.categorySubSystem:
            if invItem.groupID in subSystemGroupIDs:
                invItems.remove(invItem)
            else:
                subSystemGroupIDs.add(invItem.groupID)
        elif invItem.categoryID == const.categoryCharge:
            charges.add(invItem)
            invItems.remove(invItem)
        elif invItem.categoryID == const.categoryDrone:
            drones.append(invItem)
            invItems.remove(invItem)

    if len(invItems) > 0:
        shipInv.moniker.MultiAdd([invItem.itemID for invItem in invItems],
                                 invItems[0].locationID,
                                 flag=const.flagAutoFit)
    if charges:
        shipStuff = shipInv.List()
        shipStuff.sort(key=lambda r: (r.flagID, isinstance(r.itemID, tuple)))
        loadedSlots = set()
    if drones:
        invCtrl.ShipDroneBay(shipID or GetActiveShip()).AddItems(drones)
    dogmaLocation = sm.GetService('clientDogmaIM').GetDogmaLocation()
    shipDogmaItem = dogmaLocation.dogmaItems.get(shipID, None)
    loadedSomething = False
    for DBRowInvItem in charges:
        invItem = KeyVal(DBRowInvItem)
        chargeDgmType = godmaSM.GetType(invItem.typeID)
        isCrystalOrScript = invItem.groupID in cfg.GetCrystalGroups()
        for row in shipStuff:
            if row in loadedSlots:
                continue
            if not IsShipFittingFlag(row.flagID):
                continue
            if dogmaLocation.IsInWeaponBank(
                    row.locationID,
                    row.itemID) and dogmaLocation.IsModuleSlave(
                        row.itemID, row.locationID):
                continue
            if row.categoryID == const.categoryCharge:
                continue
            moduleDgmType = godmaSM.GetType(row.typeID)
            desiredSize = getattr(moduleDgmType, 'chargeSize', None)
            for x in xrange(1, 5):
                chargeGroup = getattr(moduleDgmType, 'chargeGroup%d' % x,
                                      False)
                if not chargeGroup:
                    continue
                if chargeDgmType.groupID != chargeGroup:
                    continue
                if desiredSize and getattr(chargeDgmType, 'chargeSize',
                                           -1) != desiredSize:
                    continue
                for i, squatter in enumerate(
                    [i for i in shipStuff if i.flagID == row.flagID]):
                    if isCrystalOrScript and i > 0:
                        break
                    if shipDogmaItem is None:
                        continue
                    subLocation = dogmaLocation.GetSubLocation(
                        shipID, squatter.flagID)
                    if subLocation is None:
                        continue
                    chargeVolume = chargeDgmType.volume * dogmaLocation.GetAttributeValue(
                        subLocation, const.attributeQuantity)
                    if godmaSM.GetType(row.typeID).capacity <= chargeVolume:
                        break
                else:
                    moduleCapacity = godmaSM.GetType(row.typeID).capacity
                    numCharges = moduleCapacity / chargeDgmType.volume
                    subLocation = dogmaLocation.GetSubLocation(
                        shipID, row.flagID)
                    if subLocation:
                        numCharges -= dogmaLocation.GetAttributeValue(
                            subLocation, const.attributeQuantity)
                    dogmaLocation.LoadAmmoToModules(shipID, [row.itemID],
                                                    invItem.typeID,
                                                    invItem.itemID,
                                                    invItem.locationID)
                    loadedSomething = True
                    invItem.stacksize -= numCharges
                    loadedSlots.add(row)
                    blue.pyos.synchro.SleepWallclock(100)
                    break

            else:
                continue

            if invItem.stacksize <= 0:
                break
        else:
            if not loadedSomething:
                uicore.Message('NoSuitableModules')
コード例 #16
0
ファイル: __init__.py プロジェクト: connoryang/1v1dec
def _ItemPrioritized(item):
    return item.categoryID == invconst.categoryCharge and IsShipFittingFlag(
        item.flagID)
コード例 #17
0
 def ValidFittingFlag(self, flagID):
     return IsShipFittingFlag(flagID) or flagID == const.flagDroneBay
コード例 #18
0
 def _IsModule(self, flag):
     return IsShipFittingFlag(flag) and flag != invconst.flagHiddenModifers
コード例 #19
0
ファイル: fittingStuff.py プロジェクト: connoryang/1v1dec
def GetHardwareLayoutForShip(moduleTypeID, shipTypeID, dogmaStaticMgr,
                             currentModuleList):
    typeID = moduleTypeID
    groupID = evetypes.GetGroupID(moduleTypeID)
    hardwareAttribs = {}
    typeEffects = dogmaStaticMgr.TypeGetEffects(typeID)
    GTA = dogmaStaticMgr.GetTypeAttribute2
    isTurret = isLauncher = False
    if const.effectHiPower in typeEffects:
        hardwareAttribs[const.attributeHiSlots] = int(
            GTA(shipTypeID, const.attributeHiSlots))
        if const.effectTurretFitted in typeEffects:
            hardwareAttribs[const.attributeTurretSlotsLeft] = int(
                GTA(shipTypeID, const.attributeTurretSlotsLeft))
            isTurret = True
        elif const.effectLauncherFitted in typeEffects:
            hardwareAttribs[const.attributeLauncherSlotsLeft] = int(
                GTA(shipTypeID, const.attributeLauncherSlotsLeft))
            isLauncher = True
    elif const.effectMedPower in typeEffects:
        hardwareAttribs[const.attributeMedSlots] = int(
            GTA(shipTypeID, const.attributeMedSlots))
    elif const.effectLoPower in typeEffects:
        hardwareAttribs[const.attributeLowSlots] = int(
            GTA(shipTypeID, const.attributeLowSlots))
    elif const.effectRigSlot in typeEffects:
        hardwareAttribs[const.attributeRigSlots] = int(
            GTA(shipTypeID, const.attributeRigSlots))
    elif const.effectSubSystem in typeEffects:
        hardwareAttribs[const.attributeMaxSubSystems] = int(
            GTA(shipTypeID, const.attributeMaxSubSystems))
    elif const.effectServiceSlot in typeEffects:
        hardwareAttribs[const.attributeServiceSlots] = int(
            GTA(shipTypeID, const.attributeServiceSlots))
    turretsFitted = 0
    launchersFitted = 0
    rigsFitted = 0
    calibration = 0
    shipHardwareModifierAttribs = dogmaStaticMgr.GetShipHardwareModifierAttribs(
    )
    modulesByGroup = 0
    modulesByType = 0
    for item in currentModuleList:
        if not IsShipFittingFlag(item.flagID):
            continue
        if item.groupID == groupID:
            modulesByGroup += 1
        if item.typeID == typeID:
            modulesByType += 1
        if const.flagHiSlot0 <= item.flagID <= const.flagHiSlot7:
            if isTurret:
                if dogmaStaticMgr.TypeHasEffect(item.typeID,
                                                const.effectTurretFitted):
                    turretsFitted += 1
            elif isLauncher:
                if dogmaStaticMgr.TypeHasEffect(item.typeID,
                                                const.effectLauncherFitted):
                    launchersFitted += 1
        elif const.flagRigSlot0 <= item.flagID <= const.flagRigSlot7:
            rigsFitted += 1
            calibration += GTA(item.typeID, const.attributeUpgradeCost)
        elif const.flagSubSystemSlot0 <= item.flagID <= const.flagSubSystemSlot7:
            for attributeID, modifyingAttributeID in shipHardwareModifierAttribs:
                if attributeID not in hardwareAttribs:
                    continue
                hardwareAttribs[attributeID] += GTA(item.typeID,
                                                    modifyingAttributeID)

    return (hardwareAttribs, turretsFitted, launchersFitted, rigsFitted,
            calibration, modulesByGroup, modulesByType)
コード例 #20
0
 def OnInvChange(self, item, change):
     if const.ixFlag in change:
         if IsShipFittingFlag(item.flagID) or IsShipFittingFlag(
                 change[const.ixFlag]):
             uthread.new(self.InitSlotsDelayed)