Example #1
0
    def Load(self):
        with bluepy.Timer('LoadAttributes'):
            self.LoadAttributes()
        with bluepy.Timer('LoadTypeAttributes'):
            self.LoadTypeAttributes()
        with bluepy.Timer('LoadEffects'):
            self.LoadEffects()
        with bluepy.Timer('LoadTypeEffects'):
            self.LoadTypeEffects(run=True)
        self.crystalGroupIDs = cfg.GetCrystalGroups()
        self.controlBunkersByFactionID = {}
        for typeID in evetypes.GetTypeIDsByGroup(const.groupControlBunker):
            factionID = int(self.GetTypeAttribute2(typeID, const.attributeFactionID))
            self.controlBunkersByFactionID[factionID] = typeID

        import re
        cgre = re.compile('chargeGroup\\d{1,2}')
        cgattrs = tuple([ a.attributeID for a in cfg.dgmattribs if cgre.match(a.attributeName) is not None ])
        self.chargeGroupAttributes = cgattrs
        self.crystalModuleGroupIDs = {}
        for categoryID in (const.categoryModule, const.categoryStructureModule, const.categoryStarbase):
            for groupID in evetypes.GetGroupIDsByCategory(categoryID):
                typeIDs = evetypes.GetTypeIDsByGroup(groupID)
                if len(typeIDs) > 0:
                    typeID = typeIDs.pop()
                    for attributeID in cgattrs:
                        v = self.GetTypeAttribute(typeID, attributeID)
                        if v is not None and v in self.crystalGroupIDs:
                            self.crystalModuleGroupIDs[groupID] = True
                            break
Example #2
0
    def GetSubSystemsByGroup(self):
        godma = sm.StartService('godma')
        if self.isPreview:
            subSystemsByGroupID = {}
            for groupID in evetypes.GetGroupIDsByCategory(
                    const.categorySubSystem):
                if groupID not in subSystemsByGroupID:
                    subSystemsByGroupID[groupID] = []
                for typeID in evetypes.GetTypeIDsByGroup(groupID):
                    if evetypes.IsPublished(typeID) and godma.GetTypeAttribute(
                            typeID,
                            const.attributeFitsToShipType) == self.ship.typeID:
                        subSystemsByGroupID[groupID].append((typeID, typeID))

        else:
            if not util.IsDocked():
                return
            inv = sm.GetService('invCache').GetInventory(const.containerHangar)
            subSystemsByGroupID = {}
            for item in inv.List(const.flagHangar):
                if item.categoryID != const.categorySubSystem:
                    continue
                if godma.GetTypeAttribute(
                        item.typeID,
                        const.attributeFitsToShipType) != self.ship.typeID:
                    continue
                if item.groupID not in subSystemsByGroupID:
                    subSystemsByGroupID[item.groupID] = []
                subSystemsByGroupID[item.groupID].append(
                    (item.typeID, item.itemID))

        return subSystemsByGroupID
Example #3
0
    def CreateUpgradeCache(self):
        upgradeGroups = {}
        sovSvc = sm.GetService('sov')
        itemData = sovSvc.GetInfrastructureHubItemData(self.hubID)
        self.billingCost = self.GetBillingCost(itemData)
        potentialGroupIDs = evetypes.GetGroupIDsByCategory(
            categoryInfrastructureUpgrade)
        groupIDsToAdd = set()
        for groupID in potentialGroupIDs:
            if evetypes.IsGroupPublishedByGroup(groupID):
                groupIDsToAdd.add(groupID)

        for eachGroupID in groupIDsToAdd:
            groupName = evetypes.GetGroupNameByGroup(eachGroupID)
            potentialTypeIDs = evetypes.GetTypeIDsByGroup(eachGroupID)
            typesForGroup = []
            for eachTypeID in potentialTypeIDs:
                if evetypes.IsPublished(eachTypeID):
                    typeInfo = self.GetTypeInfo(eachTypeID, itemData, sovSvc)
                    typesForGroup.append(typeInfo)

            upgradeGroups[eachGroupID] = util.KeyVal(groupID=eachGroupID,
                                                     groupName=groupName,
                                                     types=typesForGroup)

        self.upgradeGroups = upgradeGroups.values()
        self.upgradeGroups.sort(key=lambda g: g.groupName)
        for groupInfo in self.upgradeGroups:
            groupInfo.types.sort(key=lambda t: t.typeName)
Example #4
0
def GetBlueprintsByProductGroup(groupID):
    blueprints = set()
    for typeIDInGroup in evetypes.GetTypeIDsByGroup(groupID):
        for typeID in cfg.blueprints.filter_keys('productTypeID',
                                                 typeIDInGroup):
            blueprints.add(typeID)

    blueprints.discard(None)
    return blueprints
Example #5
0
def GetDecryptors(job):
    if job.activityID == industry.INVENTION:
        if boot.role == 'client':
            dogma = sm.GetService('godma')
        else:
            dogma = sm.GetService('dogmaStaticMgr')
        options = [industry.Material(mutable=True)]
        for typeID in evetypes.GetTypeIDsByGroup(const.groupDecryptors):
            options.append(
                industry.Material(
                    mutable=True,
                    typeID=typeID,
                    quantity=1,
                    modifiers=[
                        industry.MaxRunsModifier(
                            dogma.GetTypeAttribute(
                                typeID,
                                const.attributeInventionMaxRunModifier),
                            output=True,
                            activity=industry.INVENTION,
                            reference=industry.Reference.DECRYPTOR),
                        industry.MaterialModifier(
                            dogma.GetTypeAttribute(
                                typeID, const.attributeInventionMEModifier) /
                            100.0,
                            output=True,
                            activity=industry.INVENTION,
                            reference=industry.Reference.DECRYPTOR),
                        industry.TimeModifier(
                            dogma.GetTypeAttribute(
                                typeID, const.attributeInventionPEModifier) /
                            100.0,
                            output=True,
                            activity=industry.INVENTION,
                            reference=industry.Reference.DECRYPTOR),
                        industry.ProbabilityModifier(
                            dogma.GetTypeAttribute(
                                typeID,
                                const.attributeInventionPropabilityMultiplier),
                            activity=industry.INVENTION,
                            reference=industry.Reference.DECRYPTOR)
                    ]))

        decryptor = industry.Material(mutable=True, options=options)
        if job.request:
            allTypes = decryptor.all_types()
            for typeID in job.request['materials']:
                if typeID in allTypes:
                    decryptor.select(typeID)

        if getattr(job, 'optionalTypeID', None) in decryptor.all_types():
            decryptor.select(job.optionalTypeID)
        if getattr(job, 'optionalTypeID2', None) in decryptor.all_types():
            decryptor.select(job.optionalTypeID2)
        return [decryptor]
    return []
Example #6
0
    def PreviewType(self, typeID, subsystems=None):
        evetypes.RaiseIFNotExists(typeID)
        godma = sm.GetService('godma')
        if IsModularShip(typeID):
            if subsystems is None:
                subsystems = {}
                subSystemsForType = {}
                for groupID in evetypes.GetGroupIDsByCategory(
                        const.categorySubSystem):
                    if groupID not in subSystemsForType:
                        subSystemsForType[groupID] = []
                    for typeID in evetypes.GetTypeIDsByGroup(groupID):
                        if evetypes.IsPublished(
                                typeID) and godma.GetTypeAttribute(
                                    typeID,
                                    const.attributeFitsToShipType) == typeID:
                            subSystemsForType[groupID].append(typeID)

                for k, v in subSystemsForType.iteritems():
                    subsystems[k] = random.choice(v)

            model = sm.StartService('t3ShipSvc').GetTech3ShipFromDict(
                typeID, subsystems)
        else:
            dna = gfxutils.BuildSOFDNAFromTypeID(typeID)
            if dna is not None:
                spaceObjectFactory = sm.GetService(
                    'sofService').spaceObjectFactory
                model = spaceObjectFactory.BuildFromDNA(dna)
            else:
                fileName = inventorycommon.typeHelpers.GetGraphicFile(typeID)
                if fileName == '':
                    log.LogWarn('type', typeID, 'has no graphicFile')
                    return
                model = trinity.Load(fileName)
            if model is None:
                self.sceneContainer.ClearScene()
                raise UserError('PreviewNoModel')
            if getattr(model, 'boosters', None) is not None:
                model.boosters = None
            if getattr(model, 'modelRotationCurve', None) is not None:
                model.modelRotationCurve = None
            if getattr(model, 'modelTranslationCurve', None) is not None:
                model.modelTranslationCurve = None
        if hasattr(model, 'ChainAnimationEx'):
            model.ChainAnimationEx('NormalLoop', 0, 0, 1.0)
        self._CreateRotationCurve(model)
        self.sceneContainer.AddToScene(model)
        camera = self.sceneContainer.camera
        if camera is not None:
            rad = model.GetBoundingSphereRadius()
            minZoom = rad + camera.frontClip
            camera.translationFromParent = minZoom * 2
            self.sceneContainer.UpdateViewPort()
    def GetStructuresForGroup(self, groupID):
        planetTypeID = sm.GetService('planetUI').typeID
        godma = sm.GetService('godma')
        structureIDs = set()
        for typeID in evetypes.GetTypeIDsByGroup(groupID):
            typeRestriction = godma.GetTypeAttribute(
                typeID, const.attributePlanetRestriction)
            if typeRestriction and int(typeRestriction) != planetTypeID:
                continue
            structureIDs.add(typeID)

        return structureIDs
Example #8
0
 def _InitShipTypeIDDict(self):
     self.shipTypeIDsByFactionIDAndGroupID = defaultdict(list)
     for groupID in evetypes.GetGroupIDsByCategory(const.categoryShip):
         if not evetypes.IsGroupPublishedByGroup(groupID):
             continue
         for typeID in evetypes.GetTypeIDsByGroup(groupID):
             try:
                 key = (evetypes.GetFactionID(typeID),
                        evetypes.GetIsisGroupID(typeID))
                 self.shipTypeIDsByFactionIDAndGroupID[key].append(typeID)
             except (KeyError, AttributeError):
                 pass
Example #9
0
    def Menu(self, node, *args):
        ids = []
        if node.sublevel == 0:
            categoryID = node.id[1]
            for typeID in evetypes.GetTypeIDsByCategory(categoryID):
                ids.append(typeID)

        else:
            groupID = node.id[1]
            for typeID in evetypes.GetTypeIDsByGroup(groupID):
                ids.append(typeID)

        def _crea(listOftypeIDs,
                  what='/createitem',
                  qty=1,
                  maxValue=2147483647):
            if uicore.uilib.Key(uiconst.VK_SHIFT):
                result = uix.QtyPopup(maxvalue=maxValue,
                                      minvalue=1,
                                      caption=what,
                                      label=u'Quantity',
                                      hint='')
                if result:
                    qty = result['qty']
                else:
                    return
            for typeID in listOftypeIDs:
                sm.StartService('slash').SlashCmd('/createitem %d %d' %
                                                  (typeID, qty))

        def _load(listOftypeIDs, what='/load', qty=1, maxValue=2147483647):
            if uicore.uilib.Key(uiconst.VK_SHIFT):
                result = uix.QtyPopup(maxvalue=maxValue,
                                      minvalue=1,
                                      caption=what,
                                      label=u'Quantity',
                                      hint='')
                if result:
                    qty = result['qty']
                else:
                    return
            for typeID in listOftypeIDs:
                sm.StartService('slash').SlashCmd('/load me %d %d' %
                                                  (typeID, qty))

        l = [
            None, ('WM: create all of these', lambda *x: _crea(ids)),
            ('GM: load me all of these', lambda *x: _load(ids))
        ]
        return l
Example #10
0
    def GetContent(self, node, newitems=0):
        rows = []
        if node is None:
            for categoryID in evetypes.IterateCategories():
                rows.append((categoryID,
                             evetypes.GetCategoryNameByCategory(categoryID)))

            level = 0
        elif node.sublevel == 0:
            for groupID in evetypes.GetGroupIDsByCategory(node.id[1]):
                rows.append((groupID, evetypes.GetGroupNameByGroup(groupID)))

            level = 1
        else:
            for typeID in evetypes.GetTypeIDsByGroup(node.id[1]):
                rows.append((typeID, evetypes.GetName(typeID)))

            level = 2
        stuff = []
        if level != 2:
            rows = sorted(rows, key=lambda row: row[1])
            for row in rows:
                data = {
                    'GetSubContent': self.GetContent,
                    'MenuFunction': self.Menu,
                    'label': row[1],
                    'id': (row[1], row[0]),
                    'groupItems': [],
                    'showlen': False,
                    'sublevel': level,
                    'state': 'locked',
                    'selected': 0,
                    'hideExpander': True,
                    'BlockOpenWindow': 1,
                    'hideFill': True
                }
                stuff.append(listentry.Get('Group', data))

        else:
            for row in rows:
                data = util.KeyVal()
                data.sublevel = 2
                data.label = '%s<t>%d' % (row[1], row[0])
                data.invtype = row
                data.showinfo = 1
                data.typeID = row[0]
                stuff.append(listentry.Get('TypeDBEntry', data=data))

        return stuff
Example #11
0
    def GetRandomSubsystems(self, typeID):
        def CheckSubsystemValid(subsystemTypeID):
            fitsToType = sm.GetService('godma').GetTypeAttribute(
                subsystemTypeID, const.attributeFitsToShipType)
            return evetypes.IsPublished(typeID) and fitsToType == typeID

        subsystems = {}
        subsystemGroups = evetypes.GetGroupIDsByCategory(
            const.categorySubSystem)
        for groupID in subsystemGroups:
            subsystemsInGroup = evetypes.GetTypeIDsByGroup(groupID)
            validSubsystems = filter(CheckSubsystemValid, subsystemsInGroup)
            subsystems[groupID] = random.choice(validSubsystems)

        return subsystems
Example #12
0
    def DetermineLauncherTypeFromMissileID(self, typeID, missileTypeID):
        launcherType = self.launcherTypeCache.get(missileTypeID, None)
        if launcherType:
            return launcherType
        clientDogma = self.sm.GetService('clientDogmaStaticSvc')
        usesMissiles = clientDogma.TypeHasEffect(typeID, const.effectMissileLaunchingForEntity)
        if not usesMissiles:
            return
        godma = self.sm.GetService('godma')
        group = int(godma.GetTypeAttribute2(missileTypeID, const.attributeLauncherGroup))
        for typeID in evetypes.GetTypeIDsByGroup(group):
            if typeID in cfg.invmetatypesByParent:
                launcherType = typeID
                self.launcherTypeCache[missileTypeID] = launcherType
                break

        return launcherType
Example #13
0
    def FightersMenu(self):

        def SpawnFighterInBay(fighterTypeID):
            self.LogInfo('Spawning fighter via /fit', fighterTypeID, evetypes.GetEnglishName(fighterTypeID))
            sm.RemoteSvc('slash').SlashCmd('/fit me %d %d' % (fighterTypeID, 1))

        groupMenu = []
        for fighterGroupID in evetypes.GetGroupIDsByCategory(categoryFighter):
            groupName = evetypes.GetGroupNameByGroup(fighterGroupID)
            typeMenu = []
            for fighterTypeID in evetypes.GetTypeIDsByGroup(fighterGroupID):
                fighterName = evetypes.GetEnglishName(fighterTypeID)
                typeMenu.append((fighterName, SpawnFighterInBay, (fighterTypeID,)))

            typeMenu.sort()
            groupMenu.append((groupName, typeMenu))

        groupMenu.sort()
        return [('NEW FIGHTERS', groupMenu)]
Example #14
0
#Embedded file name: e:\jenkins\workspace\client_SERENITY\branches\release\SERENITY\packages\reprocessing\__init__.py
import itertools
import evetypes
import dogma.const as dgmconst
BASIC_ORES = {462, 460, 459, 469, 457, 458}
ADVANCED_ORES = {450, 451, 452, 453, 454, 455, 456, 461, 467, 468}
CAL_AMARR_ICE = {16262, 17978, 28434, 28436, 16265, 17976, 28441, 28444}
GAL_MIN_ICE = {16264, 17975, 28433, 28443, 16263, 17977, 28438, 28442}
SPECIAL_ICE = {16266, 28439, 16267, 28435, 16268, 28437, 16269, 28440}
TYPES_BY_REFINING_ATTRIBUTE = {
    dgmconst.attributeRefiningYieldBasicOre:
    set(
        itertools.chain(*(evetypes.GetTypeIDsByGroup(groupID)
                          for groupID in BASIC_ORES))),
    dgmconst.attributeRefiningYieldAdvancedOre:
    set(
        itertools.chain(*(evetypes.GetTypeIDsByGroup(groupID)
                          for groupID in ADVANCED_ORES))),
    dgmconst.attributeRefiningYieldCalAmarrIce:
    CAL_AMARR_ICE,
    dgmconst.attributeRefiningYieldGalMinIce:
    GAL_MIN_ICE,
    dgmconst.attributeRefiningYieldSpecialIce:
    SPECIAL_ICE
}


def GetRefiningYieldMultiplierAttributeIDForType(typeID):
    return REFINING_YIELD_ATTRIBUTE_BY_TYPE.get(
        typeID, dgmconst.attributeRefiningYieldMultiplier)