fix: real project README and save-file version validation

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
claude (duplicate_chess)
2026-05-19 01:18:35 -04:00
parent ead4839df4
commit 5db04109a2
3 changed files with 32 additions and 42 deletions
+4
View File
@@ -20,4 +20,8 @@ describe('notation', () => {
it('rejects a file that is not a duplicate-chess save', () => {
expect(() => deserialize('{"variant":"chess","version":1,"moves":[]}')).toThrow();
});
it('rejects an unsupported save version', () => {
expect(() => deserialize('{"variant":"duplicate-chess","version":99,"moves":[]}')).toThrow();
});
});
+3
View File
@@ -21,5 +21,8 @@ export function deserialize(json: string): HistoryEntry[] {
if (data.variant !== 'duplicate-chess' || !Array.isArray(data.moves)) {
throw new Error('Not a duplicate-chess save file');
}
if (data.version !== 1) {
throw new Error('Unsupported save version');
}
return data.moves;
}