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.
27 lines
1.1 KiB
TypeScript
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;
|
|
}
|