Skip to content

Commit

Permalink
Added repair and cap data to EFS exports.
Browse files Browse the repository at this point in the history
  • Loading branch information
MaruMaruOO committed May 27, 2019
1 parent c3e055a commit 066f296
Showing 1 changed file with 64 additions and 6 deletions.
70 changes: 64 additions & 6 deletions service/port/efs.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from eos.utils.spoolSupport import SpoolType, SpoolOptions
from gui.fitCommands.calc.module.localAdd import CalcAddLocalModuleCommand
from gui.fitCommands.calc.module.localRemove import CalcRemoveLocalModulesCommand
from gui.fitCommands.calc.module.changeCharges import CalcChangeModuleChargesCommand
from gui.fitCommands.helpers import ModuleInfo


Expand All @@ -26,7 +27,7 @@

class EfsPort:
wepTestSet = {}
version = 0.03
version = 0.04

@staticmethod
def attrDirectMap(values, target, source):
Expand Down Expand Up @@ -96,6 +97,63 @@ def getPropData(fit, sFit):
"unpropedSig": fit.ship.getModifiedItemAttr("signatureRadius")
}

@staticmethod
def getModsInGroups(fit, modGroupNames):
matchingMods = list(filter(lambda mod: mod.item and mod.item.group.name in modGroupNames, fit.modules))
# Sort mods to prevent the order needlessly changing as pyfa updates.
matchingMods.sort(key=lambda mod: mod.item.ID)
matchingMods.sort(key=lambda mod: mod.item.group.ID)
return matchingMods

# Note this also includes data for any cap boosters as they "repair" cap.
@staticmethod
def getRepairData(fit, sFit):
modGroupNames = [
"Shield Booster", "Armor Repair Unit",
"Ancillary Shield Booster", "Ancillary Armor Repairer",
"Hull Repair Unit", "Capacitor Booster",
]
repairMods = EfsPort.getModsInGroups(fit, modGroupNames)
repairs = [];
for mod in repairMods:
stats = {}
EfsPort.attrDirectMap(["duration", "capacitorNeed"], stats, mod)
if mod.item.group.name in ["Armor Repair Unit", "Ancillary Armor Repairer"]:
stats["type"] = "Armor Repairer"
EfsPort.attrDirectMap(["armorDamageAmount"], stats, mod)
if mod.item.group.name == "Ancillary Armor Repairer":
stats["numShots"] = mod.numShots
EfsPort.attrDirectMap(["reloadTime", "chargedArmorDamageMultiplier"], stats, mod)
elif mod.item.group.name in ["Shield Booster", "Ancillary Shield Booster"]:
stats["type"] = "Shield Booster"
EfsPort.attrDirectMap(["shieldBonus"], stats, mod)
if mod.item.group.name == "Ancillary Shield Booster":
stats["numShots"] = mod.numShots
EfsPort.attrDirectMap(["reloadTime"], stats, mod)
c = mod.charge
if c:
sFit.recalc(fit)
CalcChangeModuleChargesCommand(
fit.ID,
projected=False,
chargeMap={mod.position: None},
commit=False).Do()
sFit.recalc(fit)
stats["unloadedCapacitorNeed"] = mod.getModifiedItemAttr("capacitorNeed")
CalcChangeModuleChargesCommand(
fit.ID,
projected=False,
chargeMap={mod.position: c.typeID},
commit=False).Do()
sFit.recalc(fit)
elif mod.item.group.name == "Capacitor Booster":
# The capacitorNeed is negative, which provides the boost.
stats["type"] = "Capacitor Booster"
stats["numShots"] = mod.numShots
EfsPort.attrDirectMap(["reloadTime"], stats, mod)
repairs.append(stats)
return repairs

@staticmethod
def getOutgoingProjectionData(fit):
# This is a subset of module groups capable of projection and a superset of those currently used by efs
Expand All @@ -108,10 +166,7 @@ def getOutgoingProjectionData(fit):
"Ancillary Remote Shield Booster", "Ancillary Remote Armor Repairer",
"Titan Phenomena Generator", "Non-Repeating Hardeners", "Mutadaptive Remote Armor Repairer"
]
projectedMods = list(filter(lambda mod: mod.item and mod.item.group.name in modGroupNames, fit.modules))
# Sort projections to prevent the order needlessly changing as pyfa updates.
projectedMods.sort(key=lambda mod: mod.item.ID)
projectedMods.sort(key=lambda mod: mod.item.group.ID)
projectedMods = EfsPort.getModsInGroups(fit, modGroupNames)
projections = []
for mod in projectedMods:
maxRangeDefault = 0
Expand Down Expand Up @@ -636,6 +691,8 @@ def exportEfs(fit, typeNotFitFlag, callback):
for cargo in fit.cargo:
cargoIDs.append(cargo.itemID)

repairs = EfsPort.getRepairData(fit, sFit)

def roundNumbers(data, digits):
if isinstance(data, str):
return
Expand Down Expand Up @@ -664,6 +721,7 @@ def roundNumbers(data, digits):
"scanStrength": fit.scanStrength, "weaponDPS": fit.getWeaponDps(spoolOptions=spoolOptions).total,
"alignTime": fit.alignTime, "signatureRadius": fitModAttr("signatureRadius"), "weapons": weaponSystems,
"scanRes": fitModAttr("scanResolution"), "capUsed": fit.capUsed, "capRecharge": fit.capRecharge,
"capacitorCapacity": fitModAttr("capacitorCapacity"), "rechargeRate": fitModAttr("rechargeRate"),
"rigSlots": fitModAttr("rigSlots"), "lowSlots": fitModAttr("lowSlots"),
"midSlots": fitModAttr("medSlots"), "highSlots": fitModAttr("hiSlots"),
"turretSlots": fitModAttr("turretSlotsLeft"), "launcherSlots": fitModAttr("launcherSlotsLeft"),
Expand All @@ -674,7 +732,7 @@ def roundNumbers(data, digits):
"droneControlRange": fitModAttr("droneControlRange"), "mass": fitModAttr("mass"),
"unpropedSpeed": propData["unpropedSpeed"], "unpropedSig": propData["unpropedSig"],
"usingMWD": propData["usingMWD"], "mwdPropSpeed": mwdPropSpeed, "projections": projections,
"modTypeIDs": modTypeIDs, "moduleNames": moduleNames, "cargoItemIDs": cargoIDs,
"repairs": repairs, "modTypeIDs": modTypeIDs, "moduleNames": moduleNames, "cargoItemIDs": cargoIDs,
"pyfaVersion": pyfaVersion, "efsExportVersion": EfsPort.version
}
# Recursively round any numbers in dicts to 6 decimal places.
Expand Down

0 comments on commit 066f296

Please sign in to comment.