diff --git a/plugins/inara.py b/plugins/inara.py index 1cae5c64..3fd42f34 100644 --- a/plugins/inara.py +++ b/plugins/inara.py @@ -871,7 +871,7 @@ def journal_entry( # noqa: C901, CCR001 cur_ship['shipRebuyCost'] = state['Rebuy'] new_add_event('setCommanderShip', entry['timestamp'], cur_ship) - make_slef(state, entry) + make_slef(entry) # Stored modules if event_name == 'StoredModules': @@ -1478,51 +1478,30 @@ def make_loadout(state: dict[str, Any]) -> dict[str, Any]: # noqa: CCR001 } -def make_slef(state: dict[str, Any], entry) -> None: +def make_slef(entry) -> None: initial_dict = { "header": {"appName": appname, "appVersion": str(appversion())} } data_dict = {} - loadout = make_loadout(state) - modules = loadout['shipLoadout'] - mod_dict = [] - for module in modules: - if module['slotName']: - builder = { - 'Slot': module['slotName'], - 'Item': module['itemName'] - } - if module.get('itemHealth'): - builder.update({'ItemHealth': module['itemHealth']}) - if module.get('isOn'): - builder.update({'On': True}) - elif not module.get('isOn'): - builder.update({'On': False}) - if module.get('itemPriority'): - builder.update({'Priority': module['itemPriority']}) - if module.get('itemValue'): - builder.update({'Value': module['itemValue']}) - if not module.get('itemValue'): - builder.update({'Value': 0}) - if module.get('slotName') == 'FuelTank': - cap = module['itemName'].split('size') - cap = cap[1].split('_') - cap = 2**int(cap[0]) - ship = edmc_data.ship_name_map[state["ShipType"]] - fuel = {'Main': cap, 'Reserve': ships[ship]['reserveFuelCapacity']} - data_dict.update({"FuelCapacity": fuel}) - mod_dict.append(builder) + for module in entry['Modules']: + if module.get('Slot') == 'FuelTank': + cap = module['Item'].split('size') + cap = cap[1].split('_') + cap = 2 ** int(cap[0]) + ship = edmc_data.ship_name_map[entry["Ship"]] + fuel = {'Main': cap, 'Reserve': ships[ship]['reserveFuelCapacity']} + data_dict.update({"FuelCapacity": fuel}) data_dict.update({ - 'Ship': state["ShipType"], - 'ShipName': state['ShipName'], - 'ShipIdent': state['ShipIdent'], - 'HullValue': state['HullValue'], - 'ModulesValue': state['ModulesValue'], - 'Rebuy': state['Rebuy'], + 'Ship': entry["Ship"], + 'ShipName': entry['ShipName'], + 'ShipIdent': entry['ShipIdent'], + 'HullValue': entry['HullValue'], + 'ModulesValue': entry['ModulesValue'], + 'Rebuy': entry['Rebuy'], 'MaxJumpRange': entry['MaxJumpRange'], 'UnladenMass': entry['UnladenMass'], 'CargoCapacity': entry['CargoCapacity'], - 'Modules': mod_dict, + 'Modules': entry['Modules'], }) initial_dict.update({'data': data_dict}) json.dump(initial_dict, open('inara.json', 'w'), indent=4)