import type { Artifact } from "../types/domain";
import type { GoodDatabase } from "../types/global";

const slotToGood: Record<Artifact["slot"], string> = {
  flower: "flower",
  plume: "plume",
  sands: "sands",
  goblet: "goblet",
  circlet: "circlet",
};

export function exportGood(artifacts: Artifact[]): GoodDatabase {
  return {
    format: "GOOD",
    version: 2,
    source: "Genshin Artifact Assistant",
    artifacts: artifacts.map((artifact) => ({
      setKey: artifact.setKey,
      slotKey: slotToGood[artifact.slot],
      rarity: artifact.rarity,
      level: artifact.level,
      mainStatKey: artifact.mainStat,
      substats: artifact.substats.map((substat) => ({
        key: substat.key,
        value: substat.value,
      })),
      lock: artifact.locked,
    })),
  };
}
