Exemple #1
0
 def getShipSize(groupID):
     # Size groupings are somewhat arbitrary but allow for a more managable number of top level groupings in a tree structure.
     frigateGroupNames = ["Frigate", "Shuttle", "Corvette", "Assault Frigate", "Covert Ops", "Interceptor",
                          "Stealth Bomber", "Electronic Attack Ship", "Expedition Frigate", "Logistics Frigate"]
     destroyerGroupNames = ["Destroyer", "Interdictor", "Tactical Destroyer", "Command Destroyer"]
     cruiserGroupNames = ["Cruiser", "Heavy Assault Cruiser", "Logistics", "Force Recon Ship",
                          "Heavy Interdiction Cruiser", "Combat Recon Ship", "Strategic Cruiser"]
     bcGroupNames = ["Combat Battlecruiser", "Command Ship", "Attack Battlecruiser"]
     bsGroupNames = ["Battleship", "Elite Battleship", "Black Ops", "Marauder"]
     capitalGroupNames = ["Titan", "Dreadnought", "Freighter", "Carrier", "Supercarrier",
                          "Capital Industrial Ship", "Jump Freighter", "Force Auxiliary"]
     indyGroupNames = ["Industrial", "Deep Space Transport", "Blockade Runner",
                       "Mining Barge", "Exhumer", "Industrial Command Ship"]
     miscGroupNames = ["Capsule", "Prototype Exploration Ship"]
     shipSizes = [
         {"name": "Frigate", "groupIDs": map(lambda s: getGroup(s).ID, frigateGroupNames)},
         {"name": "Destroyer", "groupIDs": map(lambda s: getGroup(s).ID, destroyerGroupNames)},
         {"name": "Cruiser", "groupIDs": map(lambda s: getGroup(s).ID, cruiserGroupNames)},
         {"name": "Battlecruiser", "groupIDs": map(lambda s: getGroup(s).ID, bcGroupNames)},
         {"name": "Battleship", "groupIDs": map(lambda s: getGroup(s).ID, bsGroupNames)},
         {"name": "Capital", "groupIDs": map(lambda s: getGroup(s).ID, capitalGroupNames)},
         {"name": "Industrial", "groupIDs": map(lambda s: getGroup(s).ID, indyGroupNames)},
         {"name": "Misc", "groupIDs": map(lambda s: getGroup(s).ID, miscGroupNames)}
     ]
     for size in shipSizes:
         if groupID in size["groupIDs"]:
             return size["name"]
     sizeNotFoundMsg = "ShipSize not found for groupID: " + str(groupID)
     return sizeNotFoundMsg
Exemple #2
0
 def getShipSize(groupID):
     # Size groupings are somewhat arbitrary but allow for a more manageable number of top level groupings in a tree structure.
     frigateGroupNames = ["Frigate", "Shuttle", "Corvette", "Assault Frigate", "Covert Ops", "Interceptor",
                          "Stealth Bomber", "Electronic Attack Ship", "Expedition Frigate", "Logistics Frigate"]
     destroyerGroupNames = ["Destroyer", "Interdictor", "Tactical Destroyer", "Command Destroyer"]
     cruiserGroupNames = ["Cruiser", "Heavy Assault Cruiser", "Logistics", "Force Recon Ship",
                          "Heavy Interdiction Cruiser", "Combat Recon Ship", "Strategic Cruiser"]
     bcGroupNames = ["Combat Battlecruiser", "Command Ship", "Attack Battlecruiser"]
     bsGroupNames = ["Battleship", "Elite Battleship", "Black Ops", "Marauder"]
     capitalGroupNames = ["Titan", "Dreadnought", "Freighter", "Carrier", "Supercarrier",
                          "Capital Industrial Ship", "Jump Freighter", "Force Auxiliary"]
     indyGroupNames = ["Industrial", "Deep Space Transport", "Blockade Runner",
                       "Mining Barge", "Exhumer", "Industrial Command Ship"]
     miscGroupNames = ["Capsule", "Prototype Exploration Ship"]
     shipSizes = [
         {"name": "Frigate", "groupIDs": map(lambda s: getGroup(s).ID, frigateGroupNames)},
         {"name": "Destroyer", "groupIDs": map(lambda s: getGroup(s).ID, destroyerGroupNames)},
         {"name": "Cruiser", "groupIDs": map(lambda s: getGroup(s).ID, cruiserGroupNames)},
         {"name": "Battlecruiser", "groupIDs": map(lambda s: getGroup(s).ID, bcGroupNames)},
         {"name": "Battleship", "groupIDs": map(lambda s: getGroup(s).ID, bsGroupNames)},
         {"name": "Capital", "groupIDs": map(lambda s: getGroup(s).ID, capitalGroupNames)},
         {"name": "Industrial", "groupIDs": map(lambda s: getGroup(s).ID, indyGroupNames)},
         {"name": "Misc", "groupIDs": map(lambda s: getGroup(s).ID, miscGroupNames)}
     ]
     for size in shipSizes:
         if groupID in size["groupIDs"]:
             return size["name"]
     sizeNotFoundMsg = "ShipSize not found for groupID: " + str(groupID)
     return sizeNotFoundMsg
Exemple #3
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.typeName == "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.typeName == propName, propMods))))
        mwd5mn = mapPropData("5MN Microwarpdrive II")
        mwd50mn = mapPropData("50MN Microwarpdrive II")
        mwd500mn = mapPropData("500MN Microwarpdrive II")
        mwd50000mn = mapPropData("50000MN Microwarpdrive II")
        if rigSize == PortEftRigSize.SMALL or rigSize is None:
            propID = mwd5mn["id"] if shipPower > mwd5mn["powerReq"] else None
        elif rigSize == PortEftRigSize.MEDIUM:
            propID = mwd50mn[
                "id"] if shipPower > mwd50mn["powerReq"] else mwd5mn["id"]
        elif rigSize == PortEftRigSize.LARGE:
            propID = mwd500mn[
                "id"] if shipPower > mwd500mn["powerReq"] else mwd50mn["id"]
        elif rigSize == PortEftRigSize.CAPITAL:
            propID = mwd50000mn[
                "id"] if shipPower > mwd50000mn["powerReq"] else mwd500mn["id"]

        if propID is None:
            return None
        cmd = CalcAddLocalModuleCommand(fitID, ModuleInfo(itemID=propID))
        cmd.Do()
        if cmd.needsGuiRecalc:
            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
        cmd = CalcRemoveLocalModulesCommand(fitID, [mwdPosition])
        cmd.Do()
        if cmd.needsGuiRecalc:
            sFit.recalc(fit)
        fit = eos.db.getFit(fitID)
        return mwdPropSpeed
Exemple #4
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
Exemple #5
0
    def getWeaponBonusMultipliers(fit):
        def sumDamage(attr):
            totalDamage = 0
            for damageType in [
                    "emDamage", "thermalDamage", "kineticDamage",
                    "explosiveDamage"
            ]:
                if attr(damageType) is not None:
                    totalDamage += attr(damageType)
            return totalDamage

        def getCurrentMultipliers(tf):
            fitMultipliers = {}
            getDroneMulti = lambda d: sumDamage(d.getModifiedItemAttr
                                                ) * d.getModifiedItemAttr(
                                                    "damageMultiplier")
            fitMultipliers["drones"] = list(map(getDroneMulti, tf.drones))

            getFitTurrets = lambda f: filter(
                lambda mod: mod.hardpoint == FittingHardpoint.TURRET, f.modules
            )
            getTurretMulti = lambda mod: mod.getModifiedItemAttr(
                "damageMultiplier") / mod.getCycleParameters().averageTime
            fitMultipliers["turrets"] = list(
                map(getTurretMulti, getFitTurrets(tf)))

            getFitLaunchers = lambda f: filter(
                lambda mod: mod.hardpoint == FittingHardpoint.MISSILE, f.
                modules)
            getLauncherMulti = lambda mod: sumDamage(
                mod.getModifiedChargeAttr) / mod.getCycleParameters(
                ).averageTime
            fitMultipliers["launchers"] = list(
                map(getLauncherMulti, getFitLaunchers(tf)))
            return fitMultipliers

        multipliers = {"turret": 1, "launcher": 1, "droneBandwidth": 1}
        drones = EfsPort.getTestSet("drone")
        launchers = EfsPort.getTestSet("launcher")
        turrets = EfsPort.getTestSet("turret")
        for weaponTypeSet in [turrets, launchers, drones]:
            for mod in weaponTypeSet:
                mod.owner = fit
        turrets = list(
            filter(lambda mod: mod.getModifiedItemAttr("damageMultiplier"),
                   turrets))
        launchers = list(
            filter(lambda mod: sumDamage(mod.getModifiedChargeAttr),
                   launchers))

        # Since the effect modules are fairly opaque a mock test fit is used to test the impact of traits.
        # standin class used to prevent . notation causing issues when used as an arg
        class standin:
            pass

        tf = standin()
        tf.modules = HandledList(turrets + launchers)
        tf.character = fit.character
        tf.ship = fit.ship
        tf.drones = HandledList(drones)
        tf.fighters = HandledList([])
        tf.boosters = HandledList([])
        tf.extraAttributes = fit.extraAttributes
        tf.mode = fit.mode
        preTraitMultipliers = getCurrentMultipliers(tf)
        for effect in fit.ship.item.effects.values():
            if effect.isImplemented:
                effect.handler(tf, tf.ship, [], None, effect=effect)
        # Factor in mode effects for T3 Destroyers
        if fit.mode is not None:
            for effect in fit.mode.item.effects.values():
                if effect.isImplemented:
                    effect.handler(tf, fit.mode, [], None, effect=effect)
        if fit.ship.item.groupID == getGroup("Strategic Cruiser").ID:
            subSystems = list(
                filter(
                    lambda mod: mod.slot == FittingSlot.SUBSYSTEM and mod.item,
                    fit.modules))
            for sub in subSystems:
                for effect in sub.item.effects.values():
                    if effect.isImplemented:
                        effect.handler(tf, sub, [], None, effect=effect)
        postTraitMultipliers = getCurrentMultipliers(tf)
        getMaxRatio = lambda dictA, dictB, key: max(
            map(lambda a, b: b / a, dictA[key], dictB[key]))
        multipliers["turret"] = round(
            getMaxRatio(preTraitMultipliers, postTraitMultipliers, "turrets"),
            6)
        multipliers["launcher"] = round(
            getMaxRatio(preTraitMultipliers, postTraitMultipliers,
                        "launchers"), 6)
        multipliers["droneBandwidth"] = round(
            getMaxRatio(preTraitMultipliers, postTraitMultipliers, "drones"),
            6)
        Fit.getInstance().recalc(fit)
        return multipliers
Exemple #6
0
    def getWeaponBonusMultipliers(fit):
        def sumDamage(attr):
            totalDamage = 0
            for damageType in ["emDamage", "thermalDamage", "kineticDamage", "explosiveDamage"]:
                if attr(damageType) is not None:
                    totalDamage += attr(damageType)
            return totalDamage

        def getCurrentMultipliers(tf):
            fitMultipliers = {}
            getDroneMulti = lambda d: sumDamage(d.getModifiedItemAttr) * d.getModifiedItemAttr("damageMultiplier")
            fitMultipliers["drones"] = list(map(getDroneMulti, tf.drones))

            getFitTurrets = lambda f: filter(lambda mod: mod.hardpoint == Hardpoint.TURRET, f.modules)
            getTurretMulti = lambda mod: mod.getModifiedItemAttr("damageMultiplier") / mod.cycleTime
            fitMultipliers["turrets"] = list(map(getTurretMulti, getFitTurrets(tf)))

            getFitLaunchers = lambda f: filter(lambda mod: mod.hardpoint == Hardpoint.MISSILE, f.modules)
            getLauncherMulti = lambda mod: sumDamage(mod.getModifiedChargeAttr) / mod.cycleTime
            fitMultipliers["launchers"] = list(map(getLauncherMulti, getFitLaunchers(tf)))
            return fitMultipliers

        multipliers = {"turret": 1, "launcher": 1, "droneBandwidth": 1}
        drones = EfsPort.getTestSet("drone")
        launchers = EfsPort.getTestSet("launcher")
        turrets = EfsPort.getTestSet("turret")
        for weaponTypeSet in [turrets, launchers, drones]:
            for mod in weaponTypeSet:
                mod.owner = fit
        turrets = list(filter(lambda mod: mod.getModifiedItemAttr("damageMultiplier"), turrets))
        launchers = list(filter(lambda mod: sumDamage(mod.getModifiedChargeAttr), launchers))

        # Since the effect modules are fairly opaque a mock test fit is used to test the impact of traits.
        # standin class used to prevent . notation causing issues when used as an arg
        class standin():
            pass
        tf = standin()
        tf.modules = HandledList(turrets + launchers)
        tf.character = fit.character
        tf.ship = fit.ship
        tf.drones = HandledList(drones)
        tf.fighters = HandledList([])
        tf.boosters = HandledList([])
        tf.extraAttributes = fit.extraAttributes
        tf.mode = fit.mode
        preTraitMultipliers = getCurrentMultipliers(tf)
        for effect in fit.ship.item.effects.values():
            if effect._Effect__effectModule is not None:
                effect.handler(tf, tf.ship, [])
        # Factor in mode effects for T3 Destroyers
        if fit.mode is not None:
            for effect in fit.mode.item.effects.values():
                if effect._Effect__effectModule is not None:
                    effect.handler(tf, fit.mode, [])
        if fit.ship.item.groupID == getGroup("Strategic Cruiser").ID:
            subSystems = list(filter(lambda mod: mod.slot == Slot.SUBSYSTEM and mod.item, fit.modules))
            for sub in subSystems:
                for effect in sub.item.effects.values():
                    if effect._Effect__effectModule is not None:
                        effect.handler(tf, sub, [])
        postTraitMultipliers = getCurrentMultipliers(tf)
        getMaxRatio = lambda dictA, dictB, key: max(map(lambda a, b: b / a, dictA[key], dictB[key]))
        multipliers["turret"] = round(getMaxRatio(preTraitMultipliers, postTraitMultipliers, "turrets"), 6)
        multipliers["launcher"] = round(getMaxRatio(preTraitMultipliers, postTraitMultipliers, "launchers"), 6)
        multipliers["droneBandwidth"] = round(getMaxRatio(preTraitMultipliers, postTraitMultipliers, "drones"), 6)
        Fit.getInstance().recalc(fit)
        return multipliers