Files
o2o-weather/admin/src/cards/images.ts
T

27 lines
1.2 KiB
TypeScript

import type { CardData } from './data'
import { gakArt } from './gaks'
import { hasTarotBg } from './templates'
import { needsOuter, ootdOutfits } from './ootd'
import type { Copy } from './templates'
export type ImageNeed = { kind: string; ids: string[] }
/** 이 카드에 필요한 그림 중 아직 없는 것 (all 이면 전부). kind 는 image-prompts/<kind>.json, 그날 필요한 것만 Codex로 만든다. 타로는 그날 뽑힌 각 카드 그림 */
export function neededImages(templateId: string, d: CardData, copy: Copy, all = false): ImageNeed[] {
if (templateId === 'ootd') {
const ids = ootdOutfits(d.maxC, copy.style, undefined, needsOuter(d.maxC, d.morningC))
.filter((o) => all || !o.image)
.map((o) => o.imageId)
return ids.length ? [{ kind: 'ootd', ids }] : []
}
if (templateId === 'tarot') {
const out: ImageNeed[] = []
const ids = ['c1', 'c2', 'c3'].map((k) => copy[k]).filter((id) => id && (all || !gakArt(id)))
if (ids.length) out.push({ kind: 'gak-card', ids })
// 대주제 배경은 한 번만 만들고 다시 쓴다
if (copy.skin && (all || !hasTarotBg(copy.skin))) out.push({ kind: 'tarot-bg', ids: [copy.skin] })
return out
}
return []
}