enhance(reversi): improve desync handling

This commit is contained in:
syuilo 2024-01-23 10:51:59 +09:00
parent f48f7149f8
commit e8ba0b3f54
17 changed files with 206 additions and 60 deletions

View file

@ -36,7 +36,8 @@
"built"
],
"dependencies": {
"crc-32": "1.2.2",
"esbuild": "0.19.11",
"glob": "^10.3.10"
"glob": "10.3.10"
}
}

View file

@ -3,6 +3,8 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
import CRC32 from 'crc-32';
/**
* true ...
* false ...
@ -204,6 +206,13 @@ export class Game {
return ([] as number[]).concat(...diffVectors.map(effectsInLine));
}
public calcCrc32(): number {
return CRC32.str(JSON.stringify({
board: this.board,
turn: this.turn,
}));
}
public get isEnded(): boolean {
return this.turn === null;
}