Files
WT-Offline/packages/local-service/src/game-data/datasets/dataset.ts
T
N0VAN0M4LY 40af06edad Serve game modes from extracted mission data
Publish stable mode IDs and matching responses in the stock format.
Build the mission pools from the multiplayer mission data and provide
required fields and localized names. Load datasets before listening and
reuse cached results when the source file digests match.

Preserve invalid UTF-8 bytes when round-tripping BLK strings and names.
The game mode list appeared in the offline client.
2026-11-24 11:02:30 +08:00

26 lines
1.0 KiB
TypeScript

/**
* A dataset: a set of static facts extracted from the player's game files (implementation notes
* 3.4). Each dataset declares what it produces and reads its inputs only through the source
* it is given, so the cache knows exactly which files the result depends on.
*
* A dataset only records what the game files say; deciding what the facts mean for a game
* rule belongs to the rules layer.
*/
import type { BlkBlock } from '@wto/blk';
import type { GamePackName } from '../game-files.ts';
export interface DatasetSource {
readBlk(pack: GamePackName, path: string): BlkBlock;
/** Every file path in a pack, sorted. */
listFiles(pack: GamePackName): readonly string[];
}
export interface Dataset<T> {
/** File name of the cache entry; unique among datasets. */
readonly id: string;
/** Raise when the extraction code or the shape of the result changes: old cache entries are then ignored. */
readonly version: number;
/** The result must survive JSON.stringify / JSON.parse unchanged. */
extract(source: DatasetSource): T;
}