import { RdDAlchimie } from "../rdd-alchimie.js"
import { RdDCarac } from "../rdd-carac.js"

const RE_STEP = /@(couleur|consistance)\{([^}]+)\}/gi

export function extraireEtapesAlchimie(manipulationHtml) {
  const steps = []
  let match
  while ((match = RE_STEP.exec(manipulationHtml)) !== null) {
    const type = match[1]
    const termes = match[2].trim()
    const difficulte = RdDAlchimie.getDifficulte(termes)
    const caracKey = RdDAlchimie.getCaracTache(type)
    const carac = RdDCarac.caracDetails(caracKey)
    steps.push({ type, termes, difficulte, caracKey, carac, raw: match[0] })
  }
  return steps
}
