import spec from '../../image-prompts/ootd.json' /** 낮 최고기온 구간 × 스타일 × 사람별 옷. 옷 목록·카드 글자는 image-prompts/ootd.json 한 곳에서 정한다. * 그림은 src/assets/ootd/<구간>-<사람>-<스타일>.webp 가 있으면 자동으로 붙는다 (npm run gen-image -- ootd <구간|스타일>) */ export type Outfit = { persona: string; label: string; labels: string[]; outer: string; image?: string } export type OotdBand = { id: string; from: number } const IMAGES = import.meta.glob('../assets/ootd/*.webp', { eager: true, import: 'default' }) type Persona = keyof typeof spec.personas type StyleId = keyof typeof spec.styles const PERSONAS = Object.keys(spec.personas) as Persona[] export const OOTD_STYLES = (Object.keys(spec.styles) as StyleId[]).map((id) => ({ id, label: spec.styles[id].label })) export const DEFAULT_STYLE: StyleId = 'casual' const styleOf = (id?: string): StyleId => (id && id in spec.styles ? (id as StyleId) : DEFAULT_STYLE) export const styleLabel = (id?: string) => spec.styles[styleOf(id)].label export const OOTD_BANDS: OotdBand[] = spec.bands.map((b) => ({ id: b.id, from: b.from })) export function ootdBand(maxC: number) { return OOTD_BANDS.find((b) => maxC >= b.from) ?? OOTD_BANDS[OOTD_BANDS.length - 1] } /** 그 구간·스타일의 6명 옷 */ /** 그 구간·스타일의 6명 옷. bandId 를 주면 기온 대신 그 구간 (예시 카드용) */ export function ootdOutfits(maxC: number, style?: string, bandId?: string): Outfit[] { const band = spec.bands.find((b) => b.id === (bandId || ootdBand(maxC).id))! const st = styleOf(style) return PERSONAS.map((p) => { const o = band.outfits[st][p] return { persona: p, label: spec.personas[p].label, labels: o.labels, outer: o.outer, image: IMAGES[`../assets/ootd/${band.id}-${p}-${st}.webp`] } }) }