blob: 6bbded0c8fda087d65a6b64c165e628940bc9efa (
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
|
/**
* Class-metadata lookup for the rows: art, colour, per-level health. Loaded
* from the campaign edition JSON (via the shared `gameData` client) and
* cached per class.
*/
import { gameData, type ClassData } from './gameData';
export type { ClassData };
const cache = new Map<string, Promise<ClassData | null>>();
export function classInfo(edition: string, className: string): Promise<ClassData | null> {
const key = `${edition}/${className}`;
let promise = cache.get(key);
if (!promise) {
promise = gameData
.loadCampaign(edition)
.then((c) => c.classes.find((x) => x.id === className) ?? null)
.catch(() => null);
cache.set(key, promise);
}
return promise;
}
/** True for the Escort / Objective classes (no initiative input). */
export function isObjectiveOrEscort(className: string): boolean {
return className === 'Escort' || className === 'Objective';
}
|