28 lines
777 B
TypeScript
28 lines
777 B
TypeScript
|
|
import { readFileSync } from 'node:fs';
|
||
|
|
import { resolve } from 'node:path';
|
||
|
|
import { z } from 'zod';
|
||
|
|
|
||
|
|
const encounterRecord = z.object({
|
||
|
|
id: z.string().min(1),
|
||
|
|
tier: z.string(),
|
||
|
|
baseSuccessChance: z.number().min(0).max(1),
|
||
|
|
difficultyTags: z.array(z.string()),
|
||
|
|
perkTags: z.array(z.string()),
|
||
|
|
flavor: z.array(z.string()).min(1)
|
||
|
|
});
|
||
|
|
|
||
|
|
const encounterDocument = z.object({
|
||
|
|
schemaVersion: z.number().int().min(1),
|
||
|
|
records: z.array(encounterRecord)
|
||
|
|
});
|
||
|
|
|
||
|
|
function main(): void {
|
||
|
|
const file = resolve(process.cwd(), 'libs/encounter-library/src/lib/encounters.json');
|
||
|
|
const raw = readFileSync(file, 'utf-8');
|
||
|
|
const parsed = JSON.parse(raw) as unknown;
|
||
|
|
encounterDocument.parse(parsed);
|
||
|
|
process.stdout.write('Encounter library validation passed.\n');
|
||
|
|
}
|
||
|
|
|
||
|
|
main();
|