Files
WT-Offline/apps/server/src/game-data/datasets/dataset.ts
T
N0VAN0M4LY 5d1d7001b8 feat(saves): edit account levels and avatars
Read rank thresholds and available avatar artwork from the selected copy. Persist avatar selections in the player profile and preserve free research points when a level changes.
2026-11-29 18:19:05 +08:00

27 lines
1.1 KiB
TypeScript

/**
* A dataset: a set of static facts extracted from the player's game files. 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;
readText(pack: GamePackName, path: string): string;
readBytes(pack: GamePackName, path: string): Uint8Array;
/** 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;
}