1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
/**
* 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;
}
|