From a0b573d66cb747b97877a1c14d409eea26a04aec Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Fri, 10 May 2024 23:09:30 +0200 Subject: [PATCH] feat: support import/export of ammo via EFT (#101) --- src/FormatAsEft/FormatAsEft.tsx | 6 ++++++ src/FormatEftToEsi/FormatEftToEsi.tsx | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/FormatAsEft/FormatAsEft.tsx b/src/FormatAsEft/FormatAsEft.tsx index 8a649b1..4ceadb2 100644 --- a/src/FormatAsEft/FormatAsEft.tsx +++ b/src/FormatAsEft/FormatAsEft.tsx @@ -65,6 +65,12 @@ export function useFormatAsEft() { if (module.quantity > 1) { eft += ` x${module.quantity}`; } + if (module.charge !== undefined) { + const chargeType = eveData.typeIDs?.[module.charge.type_id]; + if (chargeType !== undefined) { + eft += `, ${chargeType.name}`; + } + } eft += "\n"; } } diff --git a/src/FormatEftToEsi/FormatEftToEsi.tsx b/src/FormatEftToEsi/FormatEftToEsi.tsx index 341d030..f28f04e 100644 --- a/src/FormatEftToEsi/FormatEftToEsi.tsx +++ b/src/FormatEftToEsi/FormatEftToEsi.tsx @@ -99,6 +99,9 @@ export function useFormatEftToEsi() { const itemTypeId = lookupTypeByName(itemType); if (itemTypeId === undefined) throw new Error(`Unknown item '${itemType}'.`); + const chargeType = (line.split(",")[1] ?? "").trim(); + const chargeTypeId = lookupTypeByName(chargeType); + const effects = eveData.typeDogma?.[itemTypeId]?.dogmaEffects; if (effects === undefined) throw new Error(`No dogma effects defined for item '${itemType}'.`); const attributes = eveData.typeDogma?.[itemTypeId]?.dogmaAttributes; @@ -122,11 +125,18 @@ export function useFormatEftToEsi() { if (!slotType) continue; const flag = slotType === "droneBay" ? 87 : esiFlagMapping[slotType][slotIndex[slotType]]; + let charge = undefined; + if (chargeTypeId !== undefined) { + charge = { + type_id: chargeTypeId, + }; + } esiFit.items.push({ flag, quantity: itemCount, type_id: itemTypeId, + charge, }); slotIndex[slotType]++; }