From 4183fec4ab8b590bbbfa25307e2353cb8435249f Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 30 Jan 2024 11:34:57 +0900 Subject: [PATCH] wip --- packages/backend/src/core/MahjongService.ts | 7 +------ packages/misskey-mahjong/src/engine.master.ts | 5 +++++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/backend/src/core/MahjongService.ts b/packages/backend/src/core/MahjongService.ts index c71e18fb85..27a3c5c495 100644 --- a/packages/backend/src/core/MahjongService.ts +++ b/packages/backend/src/core/MahjongService.ts @@ -519,14 +519,9 @@ export class MahjongService implements OnApplicationShutdown, OnModuleInit { const engine = new Mahjong.MasterGameEngine(room.gameState); const myHouse = getHouseOfUserId(room, engine, user.id); - if (riichi) { - if (Mahjong.Utils.getHoraTiles(engine.state.handTiles[myHouse]).length === 0) return; - if (engine.state.points[myHouse] < 1000) return; - } - await this.clearTurnWaitingTimer(room.id); - await this.dahai(room, engine, myHouse, tile); + await this.dahai(room, engine, myHouse, tile, riichi); } @bindThis diff --git a/packages/misskey-mahjong/src/engine.master.ts b/packages/misskey-mahjong/src/engine.master.ts index 20df90bac8..6a3bd45ca4 100644 --- a/packages/misskey-mahjong/src/engine.master.ts +++ b/packages/misskey-mahjong/src/engine.master.ts @@ -238,6 +238,11 @@ export class MasterGameEngine { public commit_dahai(house: House, tile: Tile, riichi = false) { if (this.state.turn !== house) throw new Error('Not your turn'); + if (riichi) { + if (Utils.getHoraTiles(this.state.handTiles[house]).length === 0) throw new Error('Not tenpai'); + if (this.state.points[house] < 1000) throw new Error('Not enough points'); + } + const handTiles = this.state.handTiles[house]; if (!handTiles.includes(tile)) throw new Error('No such tile in your hand'); handTiles.splice(handTiles.indexOf(tile), 1);