summaryrefslogtreecommitdiff
path: root/web/src/lib/game/line/tokens.ts
blob: ed070ba889cb0a13e94436a9a17e58ef3a5e48d5 (plain)
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
/**
 * The ability-line token table and element check (the reference `LineBuilder`'s
 * `tokens` map + `isElement`, PORTING.md §8b). Token keys are the `%token%`
 * names used in card lines; values are the display labels (translated by the
 * in-game `t()` at render time, so the English label is the key's translation).
 */

export const TOKENS: Record<string, string> = {
	attack: 'Attack',
	move: 'Move',
	teleport: 'Teleport',
	range: 'Range',
	heal: 'Heal',
	target: 'Target',
	shield: 'Shield',
	loot: 'Loot',
	retaliate: 'Retaliate',
	jump: 'Jump',
	stun: 'STUN',
	wound: 'WOUND',
	disarm: 'DISARM',
	immobilize: 'IMMOBILIZE',
	poison: 'POISON',
	invisible: 'INVISIBLE',
	strengthen: 'STRENGTHEN',
	muddle: 'MUDDLE',
	regenerate: 'REGENERATE',
	ward: 'WARD',
	impair: 'IMPAIR',
	bane: 'BANE',
	brittle: 'BRITTLE',
	chill: 'CHILL',
	infect: 'INFECT',
	rupture: 'RUPTURE',
	push: 'PUSH',
	pull: 'PULL',
	pierce: 'PIERCE',
	curse: 'CURSE',
	enfeeble: 'ENFEEBLE',
	empower: 'EMPOWER',
	bless: 'BLESS',
	safeguard: 'SAFEGUARD',
	flip: 'ROLLING',
	damage: 'damage',
	and: 'and'
};

/** True when [name] is one of the five elements (or "any"). */
export function isElement(name: string): boolean {
	return (
		name.includes('air') ||
		name.includes('earth') ||
		name.includes('fire') ||
		name.includes('ice') ||
		name.includes('dark') ||
		name.includes('light') ||
		name === 'any'
	);
}

/**
 * Tokens whose graphic has both a Gloomhaven and a Frosthaven variant
 * (the reference `hasGHVersion` / `_ghVersionSet`). Only these get the `_fh`
 * image suffix when the card renders in Frosthaven style; the rest reuse the
 * single graphic.
 */
const GH_VERSION_SET = new Set([
	'attack',
	'damage',
	'disarm',
	'flying',
	'heal',
	'immobilize',
	'invisible',
	'jump',
	'loot',
	'move',
	'pierce',
	'poison',
	'push',
	'pull',
	'stun',
	'target',
	'range',
	'retaliate',
	'shield',
	'strengthen',
	'teleport',
	'use',
	'wound'
]);

export function hasGHVersion(name: string): boolean {
	return GH_VERSION_SET.has(name);
}