Add option to export implants/boosters via ESI

This commit is contained in:
DarkPhoenix
2023-10-31 00:01:16 +06:00
parent bafaed1d81
commit a484698a9d
5 changed files with 44 additions and 6 deletions

View File

@@ -56,7 +56,7 @@ INV_FLAG_DRONEBAY = 87
INV_FLAG_FIGHTER = 158
def exportESI(ofit, exportCharges, callback):
def exportESI(ofit, exportCharges, exportImplants, exportBoosters, callback):
# A few notes:
# max fit name length is 50 characters
# Most keys are created simply because they are required, but bogus data is okay
@@ -133,6 +133,22 @@ def exportESI(ofit, exportCharges, callback):
item['type_id'] = fighter.item.ID
fit['items'].append(item)
if exportImplants:
for implant in ofit.implants:
item = nested_dict()
item['flag'] = INV_FLAG_CARGOBAY
item['quantity'] = 1
item['type_id'] = implant.item.ID
fit['items'].append(item)
if exportBoosters:
for booster in ofit.boosters:
item = nested_dict()
item['flag'] = INV_FLAG_CARGOBAY
item['quantity'] = 1
item['type_id'] = booster.item.ID
fit['items'].append(item)
if len(fit['items']) == 0:
raise ESIExportException("Cannot export fitting: module list cannot be empty.")

View File

@@ -323,8 +323,8 @@ class Port:
return importESI(string)
@staticmethod
def exportESI(fit, exportCharges, callback=None):
return exportESI(fit, exportCharges, callback=callback)
def exportESI(fit, exportCharges, exportImplants, exportBoosters, callback=None):
return exportESI(fit, exportCharges, exportImplants, exportBoosters, callback=callback)
# XML-related methods
@staticmethod