enhance(reversi): tweak reversi

This commit is contained in:
syuilo
2024-01-20 13:14:46 +09:00
parent f86d0186d2
commit b9a81edae5
16 changed files with 225 additions and 131 deletions

View File

@@ -45,7 +45,7 @@ class ReversiGameChannel extends Channel {
switch (type) {
case 'ready': this.ready(body); break;
case 'updateSettings': this.updateSettings(body.key, body.value); break;
case 'putStone': this.putStone(body.pos); break;
case 'putStone': this.putStone(body.pos, body.id); break;
case 'syncState': this.syncState(body.crc32); break;
}
}
@@ -72,14 +72,14 @@ class ReversiGameChannel extends Channel {
}
@bindThis
private async putStone(pos: number) {
private async putStone(pos: number, id: string) {
if (this.user == null) return;
// TODO: キャッシュしたい
const game = await this.reversiGamesRepository.findOneBy({ id: this.gameId! });
if (game == null) throw new Error('game not found');
this.reversiService.putStoneToGame(game, this.user, pos);
this.reversiService.putStoneToGame(game, this.user, pos, id);
}
@bindThis