enhance(reversi): improve desync handling
This commit is contained in:
parent
f48f7149f8
commit
e8ba0b3f54
17 changed files with 206 additions and 60 deletions
|
|
@ -36,7 +36,8 @@
|
|||
"built"
|
||||
],
|
||||
"dependencies": {
|
||||
"crc-32": "1.2.2",
|
||||
"esbuild": "0.19.11",
|
||||
"glob": "^10.3.10"
|
||||
"glob": "10.3.10"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue