/** * The structured tree produced by {@link parseLines} (the client port of the * reference `LineBuilder.createLines`, PORTING.md §8b). The tree mirrors the * reference's Flutter widget layout — a vertical stack of rows, each holding * text / icon / element-use segments, with sub-line boxes, conditional (dotted) * boxes, columns, row-groups, element images and dividers nested as the * reference lays them out. The Svelte renderer walks this tree; it carries no * theme-specific image paths so the renderer can pick the right assets. */ export type Align = 'left' | 'center' | 'right'; /** The font-size / color treatment for a segment (the reference `LineStyles`). */ export type LineStyle = | 'normal' | 'small' | 'mid' | 'midSquished' | 'elite' | 'eliteSmall' | 'eliteMid' | 'divider' | 'dividerThin' | 'special'; // --- Leaf segments --------------------------------------------------------- /** A run of plain text (a card line's words). */ export interface TextSeg { kind: 'text'; text: string; style: LineStyle; } /** An ability token (a `%token%` icon). `label` is the English display name * (the renderer translates it via the in-game `t()`); `null` in Frosthaven * style, where tokens render icon-only. */ export interface TokenSeg { kind: 'token'; /** The raw token key (e.g. `attack`, `poison`, `use`). */ token: string; /** Resolved graphic key (e.g. `move` → `flying` for a flyer). */ gfx: string; /** True when the graphic should overflow its line (FH condition icons). */ overflow: boolean; /** True for the five elements (affects icon sizing). */ isElement: boolean; style: LineStyle; } /** A "use element" overlay: an element icon with the `use` graphic + a colon. */ export interface ElementUseSeg { kind: 'elementUse'; element: string; style: LineStyle; } // --- Structural nodes ------------------------------------------------------ /** A vertical stack (the card body, or a `[c]…[/c]` column). */ export interface ColumnNode { kind: 'column'; align: Align; children: Node[]; } /** A single laid-out line. Children are segments plus any trailing sub-line / * conditional / column / row-group the line carries. */ export interface RowNode { kind: 'row'; align: Align; children: Node[]; } /** A horizontal group of side-by-side content (an `[r]…[/r]` row-group). */ export interface RowGroupNode { kind: 'rowgroup'; align: Align; children: Node[]; } /** A gray rounded box holding sub-line rows (the FH sub-line background). */ export interface SubLineNode { kind: 'subline'; /** True when the card is a boss stat card (darker box). */ boss: boolean; /** True when the box wraps a conditional (element-use) effect. */ conditional: boolean; children: Node[]; } /** A dotted-border box (the FH conditional / element-use graphic). */ export interface ConditionalNode { kind: 'conditional'; elementUse: boolean; /** Whether the top "element" banner is drawn (the reference `belongs`). */ belongs: boolean; boss: boolean; children: Node[]; } /** A standalone element image (a `¤ element` line). */ export interface ImageNode { kind: 'image'; gfx: string; element: boolean; } /** A horizontal divider (`*....` line). */ export interface DividerNode { kind: 'divider'; thin: boolean; boss: boolean; } export type Node = | TextSeg | TokenSeg | ElementUseSeg | ColumnNode | RowNode | RowGroupNode | SubLineNode | ConditionalNode | ImageNode | DividerNode; // --- Parser inputs --------------------------------------------------------- export interface LineBuildOptions { /** Left-aligned (boss stat card) layout. */ left: boolean; /** Resolve `%attack% - 1` against the monster's stats (per line). */ applyStats: boolean; /** Force the elite/normal split even with no standees. */ applyAll: boolean; align: Align; /** True for Frosthaven-styled editions. */ frosthavenStyle: boolean; /** The user's card scale factor (the reference `scale`). */ scale: number; /** The monster, for stat application + the flyer `move`→`flying` swap. */ monster?: import('./statApplier').StatMonster | null; /** True when the monster type is a flyer (move token → flying graphic). */ flying?: boolean; /** True for a boss stat card (darker boxes, left dividers). */ bossStatCard?: boolean; /** * In-game translation for token display names (the reference translates * them at parse time). The card's own lines are pre-translated by the * caller before `parseLines` is called, so only the token labels need * translating here. Defaults to the identity. */ translate?: (s: string) => string; }