summaryrefslogtreecommitdiff
path: root/web/src/lib/game/line/lineStyle.ts
diff options
context:
space:
mode:
Diffstat (limited to 'web/src/lib/game/line/lineStyle.ts')
-rw-r--r--web/src/lib/game/line/lineStyle.ts52
1 files changed, 52 insertions, 0 deletions
diff --git a/web/src/lib/game/line/lineStyle.ts b/web/src/lib/game/line/lineStyle.ts
new file mode 100644
index 0000000..6d10482
--- /dev/null
+++ b/web/src/lib/game/line/lineStyle.ts
@@ -0,0 +1,52 @@
+/**
+ * Resolved font metrics for an ability-line segment (the reference `LineStyles`,
+ * PORTING.md §8b). The web card is centre-aligned and non-left, matching the
+ * reference's ability-card `createLines` call; only the Frosthaven/Gloomhaven
+ * split and the elite color vary. Sizes are in px at `scale` 1 — the renderer
+ * multiplies by the card's `scale`.
+ */
+
+import type { LineStyle } from './types';
+
+export interface ResolvedLine {
+ /** Font size in px at scale 1. */
+ size: number;
+ /** Unitless line-height. */
+ height: number;
+ color: string;
+}
+
+const WHITE = '#ffffff';
+const BLACK = '#000000';
+const ELITE = '#ffe600'; // Colors.yellow
+
+export function resolveStyle(
+ style: LineStyle,
+ frosthavenStyle: boolean,
+ left: boolean
+): ResolvedLine {
+ const color = left ? BLACK : WHITE;
+ switch (style) {
+ case 'normal':
+ return { size: frosthavenStyle ? 13.1 : 12.56, height: frosthavenStyle ? 0.84 : 0.85, color };
+ case 'mid':
+ return { size: frosthavenStyle ? 9.52 : 8.8, height: frosthavenStyle ? 1.0 : 0.85, color };
+ case 'midSquished':
+ return { size: frosthavenStyle ? 9.52 : 8.8, height: 0.8, color };
+ case 'small':
+ return { size: 8.0, height: 0.8, color };
+ case 'elite':
+ return { size: frosthavenStyle ? 13.1 : 12.56, height: frosthavenStyle ? 0.84 : 0.85, color: ELITE };
+ case 'eliteSmall':
+ return { size: 8.0, height: 1.0, color: ELITE };
+ case 'eliteMid':
+ return { size: frosthavenStyle ? 9.52 : 8.8, height: frosthavenStyle ? 1.0 : 0.85, color: ELITE };
+ case 'divider':
+ return { size: 6.4, height: 0.7, color };
+ case 'dividerThin':
+ return { size: 4.8, height: 0.1, color };
+ case 'special':
+ // The reference renders this as transparent Majalla text (a spacer).
+ return { size: 8.8, height: 1.0, color: 'transparent' };
+ }
+}