summaryrefslogtreecommitdiff
path: root/web/src/lib/game/conditions.ts
blob: b7579ac5f8be5599649669aadae8a632cc6cbac4 (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
/**
 * The `Condition` enum (server `lib/core/enums.dart`). The state serializes
 * conditions as their index; the wire commands `addCondition` /
 * `removeCondition` take the enum *name*.
 */

export const CONDITIONS = [
	{ name: 'stun', label: 'Stunned' },
	{ name: 'immobilize', label: 'Immobilized' },
	{ name: 'disarm', label: 'Disarmed' },
	{ name: 'wound', label: 'Wounded' },
	{ name: 'wound2', label: 'Wounded x2' },
	{ name: 'muddle', label: 'Muddled' },
	{ name: 'poison', label: 'Poisoned' },
	{ name: 'poison2', label: 'Poisoned x2' },
	{ name: 'poison3', label: 'Poisoned x3' },
	{ name: 'poison4', label: 'Poisoned x4' },
	{ name: 'bane', label: 'Bane' },
	{ name: 'brittle', label: 'Brittle' },
	{ name: 'chill', label: 'Chilled' },
	{ name: 'infect', label: 'Infected' },
	{ name: 'impair', label: 'Impaired' },
	{ name: 'rupture', label: 'Ruptured' },
	{ name: 'plague', label: 'Plagued' },
	{ name: 'strengthen', label: 'Strengthened' },
	{ name: 'invisible', label: 'Invisible' },
	{ name: 'regenerate', label: 'Regenerating' },
	{ name: 'ward', label: 'Warded' },
	{ name: 'dodge', label: 'Dodging' },
	{ name: 'safeguard', label: 'Safeguard' },
	{ name: 'shield', label: 'Shielded' },
	{ name: 'retaliate', label: 'Retaliating' },
	// character1..4 are custom per-character slots; they are managed by the
	// game data, not the condition menu, so they are excluded here.
] as const;

export type ConditionName = (typeof CONDITIONS)[number]['name'];

/** Human label for a condition index (falling back to the index). */
export function conditionLabel(index: number): string {
	const c = CONDITIONS[index];
	return c ? c.label : `condition ${index}`;
}

/** Wire name for a condition index (falling back to the index). */
export function conditionName(index: number): string {
	const c = CONDITIONS[index];
	return c ? c.name : `condition${index}`;
}

/** True when [index] is chill or plague (rendered with a coloured chip). */
export function conditionChipClass(index: number): string {
	const name = CONDITIONS[index]?.name;
	if (name === 'chill') return 'cond cond--chill';
	if (name === 'plague') return 'cond cond--plague';
	return 'cond';
}