Add loaded charges to XML export
This commit is contained in:
@@ -520,7 +520,6 @@ class Fit(object):
|
||||
doc = xml.dom.minidom.Document()
|
||||
fittings = doc.createElement("fittings")
|
||||
doc.appendChild(fittings)
|
||||
|
||||
for fit in fits:
|
||||
fitting = doc.createElement("fitting")
|
||||
fitting.setAttribute("name", fit.name)
|
||||
@@ -531,7 +530,8 @@ class Fit(object):
|
||||
shipType = doc.createElement("shipType")
|
||||
shipType.setAttribute("value", fit.ship.item.name)
|
||||
fitting.appendChild(shipType)
|
||||
|
||||
|
||||
charges = {}
|
||||
slotNum = {}
|
||||
for module in fit.modules:
|
||||
if module.isEmpty:
|
||||
@@ -548,6 +548,12 @@ class Fit(object):
|
||||
hardware.setAttribute("slot", "%s slot %d" % (slotName, slotId))
|
||||
fitting.appendChild(hardware)
|
||||
|
||||
if module.charge:
|
||||
if not module.charge.name in charges:
|
||||
charges[module.charge.name] = 0
|
||||
# `or 1` because some charges (ie scripts) are without qty
|
||||
charges[module.charge.name] += module.numShots or 1
|
||||
|
||||
for drone in fit.drones:
|
||||
hardware = doc.createElement("hardware")
|
||||
hardware.setAttribute("qty", "%d" % drone.amount)
|
||||
@@ -555,6 +561,13 @@ class Fit(object):
|
||||
hardware.setAttribute("type", drone.item.name)
|
||||
fitting.appendChild(hardware)
|
||||
|
||||
for name, qty in charges.items():
|
||||
hardware = doc.createElement("hardware")
|
||||
hardware.setAttribute("qty", "%d" % qty)
|
||||
hardware.setAttribute("slot", "cargo")
|
||||
hardware.setAttribute("type", name)
|
||||
fitting.appendChild(hardware)
|
||||
|
||||
return doc.toprettyxml()
|
||||
|
||||
@reconstructor
|
||||
|
||||
Reference in New Issue
Block a user