Esempio n. 1
0
def getMarketGroup(lookfor, eager=None):
    if isinstance(lookfor, int):
        if eager is None:
            marketGroup = gamedata_session.query(MarketGroup).get(lookfor)
        else:
            marketGroup = gamedata_session.query(MarketGroup).options(*processEager(eager)).filter(MarketGroup.ID == lookfor).first()
    else:
        raise TypeError("Need integer as argument")
    return marketGroup
Esempio n. 2
0
def getAlphaClone(lookfor, eager=None):
    if isinstance(lookfor, int):
        if eager is None:
            item = gamedata_session.query(AlphaClone).get(lookfor)
        else:
            item = gamedata_session.query(AlphaClone).options(*processEager(eager)).filter(AlphaClone.ID == lookfor).first()
    else:
        raise TypeError("Need integer as argument")
    return item
Esempio n. 3
0
def getDynamicItem(itemID, eager=None):
    try:
        if isinstance(itemID, int):
            if eager is None:
                result = gamedata_session.query(DynamicItem).filter(DynamicItem.ID == itemID).one()
            else:
                result = gamedata_session.query(DynamicItem).options(*processEager(eager)).filter(DynamicItem.ID == itemID).one()
        else:
            raise TypeError("Need integer as argument")
    except exc.NoResultFound:
        result = None
    return result
Esempio n. 4
0
def getItems(lookfor, eager=None):
    """
    Gets a list of items. Does a bit of cache hackery to get working properly -- cache
    is usually based on function calls with the parameters, needed to extract data directly.
    Works well enough. Not currently used, but it's here for possible future inclusion
    """

    toGet = []
    results = []

    for id in lookfor:
        if (id, None) in cache:
            results.append(cache.get((id, None)))
        else:
            toGet.append(id)

    if len(toGet) > 0:
        # Get items that aren't currently cached, and store them in the cache
        items = gamedata_session.query(Item).filter(Item.ID.in_(toGet)).all()
        for item in items:
            cache[(item.ID, None)] = item
        results += items

    # sort the results based on the original indexing
    results.sort(key=lambda x: lookfor.index(x.ID))
    return results
Esempio n. 5
0
def getItemsByCategory(filter, where=None, eager=None):
    if isinstance(filter, int):
        filter = Category.ID == filter
    elif isinstance(filter, basestring):
        filter = Category.name == filter
    else:
        raise TypeError("Need integer or string as argument")

    filter = processWhere(filter, where)
    return gamedata_session.query(Item).options(*processEager(eager)).join(Item.group, Group.category).filter(filter).all()
Esempio n. 6
0
def getCategory(lookfor, eager=None):
    if isinstance(lookfor, int):
        if eager is None:
            category = gamedata_session.query(Category).get(lookfor)
        else:
            category = gamedata_session.query(Category).options(*processEager(eager)).filter(Category.ID == lookfor).first()
    elif isinstance(lookfor, basestring):
        if lookfor in categoryNameMap:
            id = categoryNameMap[lookfor]
            if eager is None:
                category = gamedata_session.query(Category).get(id)
            else:
                category = gamedata_session.query(Category).options(*processEager(eager)).filter(Category.ID == id).first()
        else:
            # Category names are unique, so we can use first() instead of one()
            category = gamedata_session.query(Category).options(*processEager(eager)).filter(Category.name == lookfor).first()
            categoryNameMap[lookfor] = category.ID
    else:
        raise TypeError("Need integer or string as argument")
    return category
Esempio n. 7
0
def getGroup(lookfor, eager=None):
    if isinstance(lookfor, int):
        if eager is None:
            group = gamedata_session.query(Group).get(lookfor)
        else:
            group = gamedata_session.query(Group).options(*processEager(eager)).filter(Group.ID == lookfor).first()
    elif isinstance(lookfor, basestring):
        if lookfor in groupNameMap:
            id = groupNameMap[lookfor]
            if eager is None:
                group = gamedata_session.query(Group).get(id)
            else:
                group = gamedata_session.query(Group).options(*processEager(eager)).filter(Group.ID == id).first()
        else:
            # Group names are unique, so we can use first() instead of one()
            group = gamedata_session.query(Group).options(*processEager(eager)).filter(Group.name == lookfor).first()
            groupNameMap[lookfor] = group.ID
    else:
        raise TypeError("Need integer or string as argument")
    return group
Esempio n. 8
0
def getItem(lookfor, eager=None):
    if isinstance(lookfor, int):
        if eager is None:
            item = gamedata_session.query(Item).get(lookfor)
        else:
            item = gamedata_session.query(Item).options(*processEager(eager)).filter(Item.ID == lookfor).first()
    elif isinstance(lookfor, basestring):
        if lookfor in itemNameMap:
            id = itemNameMap[lookfor]
            if eager is None:
                item = gamedata_session.query(Item).get(id)
            else:
                item = gamedata_session.query(Item).options(*processEager(eager)).filter(Item.ID == id).first()
        else:
            # Item names are unique, so we can use first() instead of one()
            item = gamedata_session.query(Item).options(*processEager(eager)).filter(Item.name == lookfor).first()
            itemNameMap[lookfor] = item.ID
    else:
        raise TypeError("Need integer or string as argument")
    return item
Esempio n. 9
0
def getAttributeInfo(attr, eager=None):
    if isinstance(attr, basestring):
        filter = AttributeInfo.name == attr
    elif isinstance(attr, int):
        filter = AttributeInfo.ID == attr
    else:
        raise TypeError("Need integer or string as argument")
    try:
        result = gamedata_session.query(AttributeInfo).options(*processEager(eager)).filter(filter).one()
    except exc.NoResultFound:
        result = None
    return result
Esempio n. 10
0
def getVariations(itemids, where=None, eager=None):
    for itemid in itemids:
        if not isinstance(itemid, int):
            raise TypeError("All passed item IDs must be integers")
    # Get out if list of provided IDs is empty
    if len(itemids) == 0:
        return []

    itemfilter = or_(*(metatypes_table.c.parentTypeID == itemid for itemid in itemids))
    filter = processWhere(itemfilter, where)
    joinon = items_table.c.typeID == metatypes_table.c.typeID
    vars = gamedata_session.query(Item).options(*processEager(eager)).join((metatypes_table, joinon)).filter(filter).all()
    return vars
Esempio n. 11
0
def searchSkills(nameLike, where=None, eager=None):
    if not isinstance(nameLike, basestring):
        raise TypeError("Need string as argument")

    items = gamedata_session.query(Item).options(*processEager(eager)).join(Item.group, Group.category)
    for token in nameLike.split(' '):
        token_safe = u"%{0}%".format(sqlizeString(token))
        if where is not None:
            items = items.filter(and_(Item.name.like(token_safe, escape="\\"), Category.ID == 16, where))
        else:
            items = items.filter(and_(Item.name.like(token_safe, escape="\\"), Category.ID == 16))
    items = items.limit(100).all()
    return items
Esempio n. 12
0
def getGroup(lookfor, eager=None):
    if isinstance(lookfor, int):
        if eager is None:
            group = gamedata_session.query(Group).get(lookfor)
        else:
            group = gamedata_session.query(Group).options(
                *processEager(eager)).filter(Group.ID == lookfor).first()
    elif isinstance(lookfor, str):
        if lookfor in groupNameMap:
            id = groupNameMap[lookfor]
            if eager is None:
                group = gamedata_session.query(Group).get(id)
            else:
                group = gamedata_session.query(Group).options(
                    *processEager(eager)).filter(Group.ID == id).first()
        else:
            # Group names are unique, so we can use first() instead of one()
            group = gamedata_session.query(Group).options(
                *processEager(eager)).filter(Group.name == lookfor).first()
            if group is not None:
                groupNameMap[lookfor] = group.ID
    else:
        raise TypeError("Need integer or string as argument")
    return group
Esempio n. 13
0
def searchItems(nameLike, where=None, join=None, eager=None):
    if not isinstance(nameLike, basestring):
        raise TypeError("Need string as argument")
    # Prepare our string for request
    nameLike = u"%{0}%".format(sqlizeString(nameLike))

    if join is None:
        join = tuple()

    if not hasattr(join, "__iter__"):
        join = (join,)

    filter = processWhere(Item.name.like(nameLike, escape="\\"), where)
    items = gamedata_session.query(Item).options(*processEager(eager)).join(*join).filter(filter).all()
    return items
Esempio n. 14
0
def getItem(lookfor, eager=None):
    if isinstance(lookfor, int):
        if eager is None:
            item = gamedata_session.query(Item).get(lookfor)
        else:
            item = gamedata_session.query(Item).options(
                *processEager(eager)).filter(Item.ID == lookfor).first()
    elif isinstance(lookfor, str):
        if lookfor in itemNameMap:
            id = itemNameMap[lookfor]
            if eager is None:
                item = gamedata_session.query(Item).get(id)
            else:
                item = gamedata_session.query(Item).options(
                    *processEager(eager)).filter(Item.ID == id).first()
        else:
            # Item names are unique, so we can use first() instead of one()
            item = gamedata_session.query(Item).options(
                *processEager(eager)).filter(Item.name == lookfor).first()
            if item is not None:
                itemNameMap[lookfor] = item.ID
    else:
        raise TypeError("Need integer or string as argument")
    return item
Esempio n. 15
0
def getVariations(itemids, where=None, eager=None):
    for itemid in itemids:
        if not isinstance(itemid, int):
            raise TypeError("All passed item IDs must be integers")
    # Get out if list of provided IDs is empty
    if len(itemids) == 0:
        return []

    itemfilter = or_(*(metatypes_table.c.parentTypeID == itemid
                       for itemid in itemids))
    filter = processWhere(itemfilter, where)
    joinon = items_table.c.typeID == metatypes_table.c.typeID
    vars = gamedata_session.query(Item).options(*processEager(eager)).join(
        (metatypes_table, joinon)).filter(filter).all()
    return vars
Esempio n. 16
0
def getCategory(lookfor, eager=None):
    if isinstance(lookfor, int):
        if eager is None:
            category = gamedata_session.query(Category).get(lookfor)
        else:
            category = gamedata_session.query(Category).options(
                *processEager(eager)).filter(Category.ID == lookfor).first()
    elif isinstance(lookfor, str):
        if lookfor in categoryNameMap:
            id = categoryNameMap[lookfor]
            if eager is None:
                category = gamedata_session.query(Category).get(id)
            else:
                category = gamedata_session.query(Category).options(
                    *processEager(eager)).filter(Category.ID == id).first()
        else:
            # Category names are unique, so we can use first() instead of one()
            category = gamedata_session.query(Category).options(
                *processEager(eager)).filter(Category.name == lookfor).first()
            if category is not None:
                categoryNameMap[lookfor] = category.ID
    else:
        raise TypeError("Need integer or string as argument")
    return category
Esempio n. 17
0
File: efs.py Progetto: bsmr-eve/Pyfa
 def getT2ItemsWhere(additionalFilter, mustBeOffensive=False, category="Module"):
     # Used to obtain a smaller subset of items while still containing examples of each group.
     T2_META_LEVEL = 5
     metaLevelAttrID = getAttributeInfo("metaLevel").attributeID
     categoryID = getCategory(category).categoryID
     result = gamedata_session.query(Item).join(ItemEffect, Group, Attribute).\
               filter(
                   additionalFilter,
                   Attribute.attributeID == metaLevelAttrID,
                   Attribute.value == T2_META_LEVEL,
                   Group.categoryID == categoryID,
               ).all()
     if mustBeOffensive:
         result = filter(lambda t: t.offensive is True, result)
     return list(result)
Esempio n. 18
0
def searchItems(nameLike, where=None, join=None, eager=None):
    if not isinstance(nameLike, basestring):
        raise TypeError("Need string as argument")
    # Prepare our string for request
    nameLike = u"%{0}%".format(sqlizeString(nameLike))

    if join is None:
        join = tuple()

    if not hasattr(join, "__iter__"):
        join = (join, )

    filter = processWhere(Item.name.like(nameLike, escape="\\"), where)
    items = gamedata_session.query(Item).options(*processEager(eager)).join(
        *join).filter(filter).all()
    return items
Esempio n. 19
0
def searchItems(nameLike, where=None, join=None, eager=None):
    if not isinstance(nameLike, basestring):
        raise TypeError("Need string as argument")

    if join is None:
        join = tuple()

    if not hasattr(join, "__iter__"):
        join = (join,)

    items = gamedata_session.query(Item).options(*processEager(eager)).join(*join)
    for token in nameLike.split(' '):
        token_safe = u"%{0}%".format(sqlizeString(token))
        items = items.filter(and_(Item.name.like(token_safe, escape="\\"), where))
    items = items.limit(100).all()
    return items
Esempio n. 20
0
    def getT2MwdSpeed(fit, sFit):
        fitID = fit.ID
        propID = None
        shipHasMedSlots = fit.ship.getModifiedItemAttr("medSlots") > 0
        shipPower = fit.ship.getModifiedItemAttr("powerOutput")
        # Monitors have a 99% reduction to prop mod power requirements
        if fit.ship.name == "Monitor":
            shipPower *= 100
        rigSize = fit.ship.getModifiedItemAttr("rigSize")
        if not shipHasMedSlots:
            return None

        filterVal = Item.groupID == getGroup("Propulsion Module").ID
        propMods = gamedata_session.query(Item).options().filter(
            filterVal).all()
        mapPropData = lambda propName: \
                      next(map(lambda propMod: {"id": propMod.typeID, "powerReq": propMod.attributes["power"].value},
                               (filter(lambda mod: mod.name == propName, propMods))))
        mwd5mn = mapPropData("5MN Microwarpdrive II")
        mwd50mn = mapPropData("50MN Microwarpdrive II")
        mwd500mn = mapPropData("500MN Microwarpdrive II")
        mwd50000mn = mapPropData("50000MN Microwarpdrive II")
        if rigSize == RigSize.SMALL or rigSize is None:
            propID = mwd5mn["id"] if shipPower > mwd5mn["powerReq"] else None
        elif rigSize == RigSize.MEDIUM:
            propID = mwd50mn[
                "id"] if shipPower > mwd50mn["powerReq"] else mwd5mn["id"]
        elif rigSize == RigSize.LARGE:
            propID = mwd500mn[
                "id"] if shipPower > mwd500mn["powerReq"] else mwd50mn["id"]
        elif rigSize == RigSize.CAPITAL:
            propID = mwd50000mn[
                "id"] if shipPower > mwd50000mn["powerReq"] else mwd500mn["id"]

        if propID is None:
            return None
        sFit.appendModule(fitID, propID)
        sFit.recalc(fit)
        fit = eos.db.getFit(fitID)
        mwdPropSpeed = fit.maxSpeed
        mwdPosition = list(
            filter(lambda mod: mod.item and mod.item.ID == propID,
                   fit.modules))[0].position
        sFit.removeModule(fitID, mwdPosition)
        sFit.recalc(fit)
        fit = eos.db.getFit(fitID)
        return mwdPropSpeed
Esempio n. 21
0
 def getT2ItemsWhere(additionalFilter,
                     mustBeOffensive=False,
                     category="Module"):
     # Used to obtain a smaller subset of items while still containing examples of each group.
     T2_META_LEVEL = 5
     metaLevelAttrID = getAttributeInfo("metaLevel").attributeID
     categoryID = getCategory(category).categoryID
     result = gamedata_session.query(Item).join(ItemEffect, Group, Attribute).\
               filter(
                   additionalFilter,
                   Attribute.attributeID == metaLevelAttrID,
                   Attribute.value == T2_META_LEVEL,
                   Group.categoryID == categoryID,
               ).all()
     if mustBeOffensive:
         result = filter(lambda t: t.offensive is True, result)
     return list(result)
Esempio n. 22
0
def searchItemsRegex(tokens, where=None, join=None, eager=None):
    if not isinstance(tokens, (tuple, list)) or not all(isinstance(t, str) for t in tokens):
        raise TypeError("Need tuple or list of strings as argument")

    if join is None:
        join = tuple()

    if not hasattr(join, "__iter__"):
        join = (join,)

    items = gamedata_session.query(Item).options(*processEager(eager)).join(*join)
    for token in tokens:
        if where is not None:
            items = items.filter(and_(Item.nameCn.op('regexp')(token), where))
        else:
            items = items.filter(Item.nameCn.op('regexp')(token))
    items = items.limit(100).all()
    return items
Esempio n. 23
0
def searchItems(nameLike, where=None, join=None, eager=None):
    if not isinstance(nameLike, basestring):
        raise TypeError("Need string as argument")

    if join is None:
        join = tuple()

    if not hasattr(join, "__iter__"):
        join = (join, )

    items = gamedata_session.query(Item).options(*processEager(eager)).join(
        *join)
    for token in nameLike.split(' '):
        token_safe = u"%{0}%".format(sqlizeString(token))
        items = items.filter(
            processWhere(Item.name.like(token_safe, escape="\\"), where))
    items = items.limit(100).all()
    return items
Esempio n. 24
0
def searchSkills(nameLike, where=None, eager=None):
    if not isinstance(nameLike, basestring):
        raise TypeError("Need string as argument")

    items = gamedata_session.query(Item).options(*processEager(eager)).join(
        Item.group, Group.category)
    for token in nameLike.split(' '):
        token_safe = u"%{0}%".format(sqlizeString(token))
        if where is not None:
            items = items.filter(
                and_(Item.name.like(token_safe, escape="\\"),
                     Category.ID == 16, where))
        else:
            items = items.filter(
                and_(Item.name.like(token_safe, escape="\\"),
                     Category.ID == 16))
    items = items.limit(100).all()
    return items
Esempio n. 25
0
def getItemWithBaseItemAttribute(lookfor, baseItemID, eager=None):
    # A lot of this is described in more detail in #1597
    item = gamedata_session.query(Item).get(lookfor)
    base = getItem(baseItemID)

    # we have to load all attributes for this object, otherwise we'll lose access to them when we expunge.
    # todo: figure out a way to eagerly load all these via the query...
    for x in [*inspect(Item).relationships.keys(), 'description']:
        getattr(item, x)

    # Copy over the attributes from the base, but ise the items attributes when there's an overlap
    # WARNING: the attribute object still has the old typeID. I don't believe we access this typeID anywhere in the code,
    # but should keep this in mind for now.
    item._Item__attributes = {**base.attributes, **item.attributes}

    # Expunge the item form the session. This is required to have different Abyssal / Base combinations loaded in memory.
    # Without expunging it, once one Abyssal Web is created, SQLAlchmey will use it for all others. We don't want this,
    # we want to generate a completely new object to work with
    gamedata_session.expunge(item)
    return item
Esempio n. 26
0
def getItemWithBaseItemAttribute(lookfor, baseItemID, eager=None):
    # A lot of this is described in more detail in #1597
    item = gamedata_session.query(Item).get(lookfor)
    base = getItem(baseItemID)

    # we have to load all attributes for this object, otherwise we'll lose access to them when we expunge.
    # todo: figure out a way to eagerly load all these via the query...
    for x in [*inspect(Item).relationships.keys(), 'description']:
        getattr(item, x)

    # Copy over the attributes from the base, but ise the items attributes when there's an overlap
    # WARNING: the attribute object still has the old typeID. I don't believe we access this typeID anywhere in the code,
    # but should keep this in mind for now.
    item._Item__attributes = {**base.attributes, **item.attributes}

    # Expunge the item form the session. This is required to have different Abyssal / Base combinations loaded in memory.
    # Without expunging it, once one Abyssal Web is created, SQLAlchmey will use it for all others. We don't want this,
    # we want to generate a completely new object to work with
    gamedata_session.expunge(item)
    return item
Esempio n. 27
0
File: efs.py Progetto: bsmr-eve/Pyfa
    def getT2MwdSpeed(fit, sFit):
        fitID = fit.ID
        propID = None
        shipHasMedSlots = fit.ship.getModifiedItemAttr("medSlots") > 0
        shipPower = fit.ship.getModifiedItemAttr("powerOutput")
        # Monitors have a 99% reduction to prop mod power requirements
        if fit.ship.name == "Monitor":
            shipPower *= 100
        rigSize = fit.ship.getModifiedItemAttr("rigSize")
        if not shipHasMedSlots:
            return None

        filterVal = Item.groupID == getGroup("Propulsion Module").ID
        propMods = gamedata_session.query(Item).options().filter(filterVal).all()
        mapPropData = lambda propName: \
                      next(map(lambda propMod: {"id": propMod.typeID, "powerReq": propMod.attributes["power"].value},
                               (filter(lambda mod: mod.name == propName, propMods))))
        mwd5mn = mapPropData("5MN Microwarpdrive II")
        mwd50mn = mapPropData("50MN Microwarpdrive II")
        mwd500mn = mapPropData("500MN Microwarpdrive II")
        mwd50000mn = mapPropData("50000MN Microwarpdrive II")
        if rigSize == RigSize.SMALL or rigSize is None:
            propID = mwd5mn["id"] if shipPower > mwd5mn["powerReq"] else None
        elif rigSize == RigSize.MEDIUM:
            propID = mwd50mn["id"] if shipPower > mwd50mn["powerReq"] else mwd5mn["id"]
        elif rigSize == RigSize.LARGE:
            propID = mwd500mn["id"] if shipPower > mwd500mn["powerReq"] else mwd50mn["id"]
        elif rigSize == RigSize.CAPITAL:
            propID = mwd50000mn["id"] if shipPower > mwd50000mn["powerReq"] else mwd500mn["id"]

        if propID is None:
            return None
        sFit.appendModule(fitID, propID)
        sFit.recalc(fit)
        fit = eos.db.getFit(fitID)
        mwdPropSpeed = fit.maxSpeed
        mwdPosition = list(filter(lambda mod: mod.item and mod.item.ID == propID, fit.modules))[0].position
        sFit.removeModule(fitID, mwdPosition)
        sFit.recalc(fit)
        fit = eos.db.getFit(fitID)
        return mwdPropSpeed
Esempio n. 28
0
File: efs.py Progetto: bsmr-eve/Pyfa
    def getTestSet(setType):
        def getT2ItemsWhere(additionalFilter, mustBeOffensive=False, category="Module"):
            # Used to obtain a smaller subset of items while still containing examples of each group.
            T2_META_LEVEL = 5
            metaLevelAttrID = getAttributeInfo("metaLevel").attributeID
            categoryID = getCategory(category).categoryID
            result = gamedata_session.query(Item).join(ItemEffect, Group, Attribute).\
                      filter(
                          additionalFilter,
                          Attribute.attributeID == metaLevelAttrID,
                          Attribute.value == T2_META_LEVEL,
                          Group.categoryID == categoryID,
                      ).all()
            if mustBeOffensive:
                result = filter(lambda t: t.offensive is True, result)
            return list(result)

        def getChargeType(item, setType):
            if setType == "turret":
                return str(item.attributes["chargeGroup1"].value) + "-" + str(item.attributes["chargeSize"].value)
            return str(item.attributes["chargeGroup1"].value)

        if setType in EfsPort.wepTestSet.keys():
            return EfsPort.wepTestSet[setType]
        else:
            EfsPort.wepTestSet[setType] = []
        modSet = EfsPort.wepTestSet[setType]

        if setType == "drone":
            ilist = getT2ItemsWhere(True, True, "Drone")
            for item in ilist:
                drone = Drone(item)
                drone.amount = 1
                drone.amountActive = 1
                drone.itemModifiedAttributes.parent = drone
                modSet.append(drone)
            return modSet

        turretFittedEffectID = gamedata_session.query(Effect).filter(Effect.name == "turretFitted").first().effectID
        launcherFittedEffectID = gamedata_session.query(Effect).filter(Effect.name == "launcherFitted").first().effectID
        if setType == "launcher":
            effectFilter = ItemEffect.effectID == launcherFittedEffectID
            reqOff = False
        else:
            effectFilter = ItemEffect.effectID == turretFittedEffectID
            reqOff = True
        ilist = getT2ItemsWhere(effectFilter, reqOff)
        previousChargeTypes = []
        # Get modules from item list
        for item in ilist:
            chargeType = getChargeType(item, setType)
            # Only add turrets if we don"t already have one with the same size and ammo type.
            if setType == "launcher" or chargeType not in previousChargeTypes:
                previousChargeTypes.append(chargeType)
                mod = Module(item)
                modSet.append(mod)

        sMkt = Market.getInstance()
        # Due to typed missile damage bonuses we"ll need to add extra launchers to cover all four types.
        additionalLaunchers = []
        for mod in modSet:
            clist = list(gamedata_session.query(Item).options().
                    filter(Item.groupID == mod.getModifiedItemAttr("chargeGroup1")).all())
            mods = [mod]
            charges = [clist[0]]
            if setType == "launcher":
                # We don"t want variations of missiles we already have
                prevCharges = list(sMkt.getVariationsByItems(charges))
                testCharges = []
                for charge in clist:
                    if charge not in prevCharges:
                        testCharges.append(charge)
                        prevCharges += sMkt.getVariationsByItems([charge])
                for c in testCharges:
                    charges.append(c)
                    additionalLauncher = Module(mod.item)
                    mods.append(additionalLauncher)
            for i in range(len(mods)):
                mods[i].charge = charges[i]
                mods[i].reloadForce = True
                mods[i].state = 2
                if setType == "launcher" and i > 0:
                    additionalLaunchers.append(mods[i])
        modSet += additionalLaunchers
        return modSet
Esempio n. 29
0
def getAbyssalTypes():
    return set([r.resultingTypeID for r in gamedata_session.query(DynamicItem.resultingTypeID).distinct()])
Esempio n. 30
0
def getMetaData(field):
    if isinstance(field, basestring):
        data = gamedata_session.query(MetaData).get(field)
    else:
        raise TypeError("Need string as argument")
    return data
Esempio n. 31
0
def getAlphaCloneList(eager=None):
    eager = processEager(eager)
    clones = gamedata_session.query(AlphaClone).options(*eager).all()
    return clones
Esempio n. 32
0
def getAllImplantSets():
    implantSets = gamedata_session.query(ImplantSet).all()
    return implantSets
Esempio n. 33
0
def getAbyssalTypes():
    return set([
        r.resultingTypeID for r in gamedata_session.query(
            DynamicItem.resultingTypeID).distinct()
    ])
Esempio n. 34
0
def getAlphaCloneList(eager=None):
    eager = processEager(eager)
    clones = gamedata_session.query(AlphaClone).options(*eager).all()
    return clones
Esempio n. 35
0
def getMutaplasmid(lookfor, eager=None):
    if isinstance(lookfor, int):
        item = gamedata_session.query(DynamicItem).filter(DynamicItem.ID == lookfor).first()
    else:
        raise TypeError("Need integer as argument")
    return item
Esempio n. 36
0
def getMetaData(field):
    if isinstance(field, basestring):
        data = gamedata_session.query(MetaData).get(field)
    else:
        raise TypeError("Need string as argument")
    return data
Esempio n. 37
0
def getMutaplasmid(lookfor, eager=None):
    if isinstance(lookfor, int):
        item = gamedata_session.query(DynamicItem).filter(DynamicItem.ID == lookfor).first()
    else:
        raise TypeError("Need integer as argument")
    return item
Esempio n. 38
0
    def getTestSet(setType):
        def getT2ItemsWhere(additionalFilter,
                            mustBeOffensive=False,
                            category="Module"):
            # Used to obtain a smaller subset of items while still containing examples of each group.
            T2_META_LEVEL = 5
            categoryID = getCategory(category).categoryID
            result = gamedata_session.query(Item).join(ItemEffect, Group, Attribute).\
                      filter(
                          additionalFilter,
                          Item.metaLevel == T2_META_LEVEL,
                          Group.categoryID == categoryID,
                      ).all()
            if mustBeOffensive:
                result = filter(lambda t: t.offensive is True, result)
            return list(result)

        def getChargeType(item, setType):
            if setType == "turret":
                return str(item.attributes["chargeGroup1"].value) + "-" + str(
                    item.attributes["chargeSize"].value)
            return str(item.attributes["chargeGroup1"].value)

        if setType in EfsPort.wepTestSet.keys():
            return EfsPort.wepTestSet[setType]
        else:
            EfsPort.wepTestSet[setType] = []
        modSet = EfsPort.wepTestSet[setType]

        if setType == "drone":
            ilist = getT2ItemsWhere(True, True, "Drone")
            for item in ilist:
                drone = Drone(item)
                drone.amount = 1
                drone.amountActive = 1
                drone.itemModifiedAttributes.parent = drone
                modSet.append(drone)
            return modSet

        turretFittedEffectID = gamedata_session.query(Effect).filter(
            Effect.name == "turretFitted").first().effectID
        launcherFittedEffectID = gamedata_session.query(Effect).filter(
            Effect.name == "launcherFitted").first().effectID
        if setType == "launcher":
            effectFilter = ItemEffect.effectID == launcherFittedEffectID
            reqOff = False
        else:
            effectFilter = ItemEffect.effectID == turretFittedEffectID
            reqOff = True
        ilist = getT2ItemsWhere(effectFilter, reqOff)
        previousChargeTypes = []
        # Get modules from item list
        for item in ilist:
            chargeType = getChargeType(item, setType)
            # Only add turrets if we don"t already have one with the same size and ammo type.
            if setType == "launcher" or chargeType not in previousChargeTypes:
                previousChargeTypes.append(chargeType)
                mod = Module(item)
                modSet.append(mod)

        sMkt = Market.getInstance()
        # Due to typed missile damage bonuses we"ll need to add extra launchers to cover all four types.
        additionalLaunchers = []
        for mod in modSet:
            clist = list(
                gamedata_session.query(Item).options().filter(
                    Item.groupID == mod.getModifiedItemAttr(
                        "chargeGroup1")).all())
            mods = [mod]
            charges = [clist[0]]
            if setType == "launcher":
                # We don"t want variations of missiles we already have
                prevCharges = list(sMkt.getVariationsByItems(charges))
                testCharges = []
                for charge in clist:
                    if charge not in prevCharges:
                        testCharges.append(charge)
                        prevCharges += sMkt.getVariationsByItems([charge])
                for c in testCharges:
                    charges.append(c)
                    additionalLauncher = Module(mod.item)
                    mods.append(additionalLauncher)
            for i in range(len(mods)):
                mods[i].charge = charges[i]
                mods[i].reloadForce = True
                mods[i].state = 2
                if setType == "launcher" and i > 0:
                    additionalLaunchers.append(mods[i])
        modSet += additionalLaunchers
        return modSet
Esempio n. 39
0
def getMetaGroups():
    return gamedata_session.query(MetaGroup).all()