// Personagem do estilo Cartoon montado por PEÇAS (não é desenho pronto): o mesmo personagem sai igual em // qualquer cena e história, mudando só expressão, pose e o que tem na mão. Guardado na biblioteca de // personagens (assets/characters//character.json) e copiado no spec de cada trecho. export const BUILDS = ["slim", "average", "heavy"] as const; export const HAIR_STYLES = ["short", "side", "bun", "long", "curly", "spiky", "bald", "cap"] as const; export const BEARD_STYLES = ["none", "stubble", "mustache", "full", "goatee", "long"] as const; export const GLASSES = ["none", "round", "square", "sun"] as const; export const BROWS = ["thin", "thick"] as const; /** "robe" = túnica longa até a canela (com faixa na cintura), de roupa antiga. */ export const TOP_STYLES = ["shirt", "jacket", "hoodie", "dress", "uniform", "robe"] as const; export const BOTTOM_STYLES = ["pants", "shorts", "skirt"] as const; export const HEAD_SHAPES = ["round", "oval", "square", "wide"] as const; export const NOSES = ["button", "curve", "round", "long", "wide"] as const; /** Calçado: sapato fechado (cor em `shoes`), sandália de tiras ou pé descalço. */ export const FOOTWEAR = ["shoes", "sandals", "bare"] as const; /** Acessórios desenhados por cima da roupa (combináveis). */ export const ACCESSORIES = ["towel", "whistle", "tie", "vest", "helmet", "watch", "badge", "apron", "scarf", "headset", "chain"] as const; export type Accessory = (typeof ACCESSORIES)[number]; // Expressões e poses são ATALHOS do rig (rig.ts): parâmetros contínuos que dá para ajustar e misturar. import { EXPRESSION_NAMES, POSE_NAMES, type ExpressionName, type PoseName } from "./rig"; export const EXPRESSIONS = EXPRESSION_NAMES; export const POSES = POSE_NAMES; export type Expression = ExpressionName; export type Pose = PoseName; export type CharacterLook = { build: (typeof BUILDS)[number]; /** Altura relativa (0,85 a 1,15). Criança ≈ 0,8 é aceito também. */ height: number; skin: string; hair: { style: (typeof HAIR_STYLES)[number]; color: string }; beard: { style: (typeof BEARD_STYLES)[number]; color: string }; glasses: (typeof GLASSES)[number]; brows: (typeof BROWS)[number]; top: { style: (typeof TOP_STYLES)[number]; color: string; accent?: string }; bottom: { style: (typeof BOTTOM_STYLES)[number]; color: string }; shoes: string; /** Tipo de calçado (padrão "shoes"); a cor continua em `shoes`. */ footwear?: (typeof FOOTWEAR)[number]; /** Detalhe de ilustração (opcionais; sem eles o personagem sai no traço simples). */ head?: (typeof HEAD_SHAPES)[number]; nose?: (typeof NOSES)[number]; /** Pálpebra de cima de base (0 olho aberto … 0,6 meio caído, olhar cansado/esperto). */ lids?: number; /** Rugas (0 nenhuma … 1 muitas: testa e canto dos olhos). */ wrinkles?: number; /** Barriga saliente (o "forte" de barriga). */ belly?: boolean; accessories?: Accessory[]; /** Cor dos acessórios principais (toalha, gravata, colete, capacete…). */ accessoryColor?: string; }; /** Ficha do personagem na biblioteca. `kind: "3d"` aponta para a pessoa articulada da Godot (godot/kits). */ export type Character = { schemaVersion: 1; id: string; name: string; /** Texto curto que aparece na etiqueta (ex.: "Engenheiro de minas · 58 anos"). */ caption?: string; description?: string; kind: "cartoon" | "3d"; look: CharacterLook; /** Só kind "3d": parâmetros da pessoa articulada da Godot. */ godot?: Record; createdAt?: string; updatedAt?: string; }; export const DEFAULT_LOOK: CharacterLook = { build: "average", height: 1, skin: "#c98a5e", hair: { style: "short", color: "#3a2a1e" }, beard: { style: "none", color: "#3a2a1e" }, glasses: "none", brows: "thin", top: { style: "shirt", color: "#4f7a4a", accent: "#e8b13a" }, bottom: { style: "pants", color: "#2b3350" }, shoes: "#1b1b22", }; const HEX = /^#[0-9a-f]{6}$/i; const one = (list: T, v: unknown): v is T[number] => typeof v === "string" && list.includes(v); /** Confere a aparência e devolve os problemas (vazio = ok). */ export function validateLook(look: unknown): string[] { const l = look as Partial | null; if (!l || typeof l !== "object") return ["look precisa ser um objeto"]; const errors: string[] = []; if (!one(BUILDS, l.build)) errors.push(`build: ${BUILDS.join("|")}`); if (typeof l.height !== "number" || !(l.height >= 0.6 && l.height <= 1.2)) errors.push("height entre 0,6 e 1,2"); for (const [k, v] of [["skin", l.skin], ["hair.color", l.hair?.color], ["beard.color", l.beard?.color], ["top.color", l.top?.color], ["bottom.color", l.bottom?.color], ["shoes", l.shoes]] as const) { if (typeof v !== "string" || !HEX.test(v)) errors.push(`${k}: cor #rrggbb`); } if (l.top?.accent !== undefined && !HEX.test(l.top.accent)) errors.push("top.accent: cor #rrggbb"); if (!one(HAIR_STYLES, l.hair?.style)) errors.push(`hair.style: ${HAIR_STYLES.join("|")}`); if (!one(BEARD_STYLES, l.beard?.style)) errors.push(`beard.style: ${BEARD_STYLES.join("|")}`); if (!one(GLASSES, l.glasses)) errors.push(`glasses: ${GLASSES.join("|")}`); if (!one(BROWS, l.brows)) errors.push(`brows: ${BROWS.join("|")}`); if (!one(TOP_STYLES, l.top?.style)) errors.push(`top.style: ${TOP_STYLES.join("|")}`); if (!one(BOTTOM_STYLES, l.bottom?.style)) errors.push(`bottom.style: ${BOTTOM_STYLES.join("|")}`); if (l.head !== undefined && !one(HEAD_SHAPES, l.head)) errors.push(`head: ${HEAD_SHAPES.join("|")}`); if (l.nose !== undefined && !one(NOSES, l.nose)) errors.push(`nose: ${NOSES.join("|")}`); if (l.lids !== undefined && !(typeof l.lids === "number" && l.lids >= 0 && l.lids <= 0.8)) errors.push("lids entre 0 e 0,8"); if (l.wrinkles !== undefined && !(typeof l.wrinkles === "number" && l.wrinkles >= 0 && l.wrinkles <= 1)) errors.push("wrinkles entre 0 e 1"); if (l.accessories !== undefined && (!Array.isArray(l.accessories) || l.accessories.some((a) => !one(ACCESSORIES, a)))) errors.push(`accessories: ${ACCESSORIES.join("|")}`); if (l.footwear !== undefined && !one(FOOTWEAR, l.footwear)) errors.push(`footwear: ${FOOTWEAR.join("|")}`); if (l.accessoryColor !== undefined && !HEX.test(l.accessoryColor)) errors.push("accessoryColor: cor #rrggbb"); return errors; } export const isExpression = (v: unknown): v is Expression => typeof v === "string" && (EXPRESSIONS as string[]).includes(v); export const isPose = (v: unknown): v is Pose => typeof v === "string" && (POSES as string[]).includes(v);