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

@@ -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;
}