diff --git a/packages/backend/src/core/GlobalEventService.ts b/packages/backend/src/core/GlobalEventService.ts index 5271c6f57b..050f0a7e68 100644 --- a/packages/backend/src/core/GlobalEventService.ts +++ b/packages/backend/src/core/GlobalEventService.ts @@ -226,6 +226,12 @@ export interface MahjongRoomEventTypes { callee: Mahjong.Common.House; tile: Mahjong.Common.Tile; }; + kanned: { + caller: Mahjong.Common.House; + callee: Mahjong.Common.House; + tile: Mahjong.Common.Tile; + rinsyan: Mahjong.Common.Tile; + }; ronned: { }; hora: { diff --git a/packages/backend/src/core/MahjongService.ts b/packages/backend/src/core/MahjongService.ts index af40fea9b5..1c36aea0c1 100644 --- a/packages/backend/src/core/MahjongService.ts +++ b/packages/backend/src/core/MahjongService.ts @@ -315,9 +315,20 @@ export class MahjongService implements OnApplicationShutdown, OnModuleInit { const userId = engine.state.user1House === engine.state.turn ? room.user1Id : engine.state.user2House === engine.state.turn ? room.user2Id : engine.state.user3House === engine.state.turn ? room.user3Id : room.user4Id; this.waitForTurn(room, userId, engine); } else if (res.type === 'kanned') { - // TODO + this.globalEventService.publishMahjongRoomStream(room.id, 'kanned', { caller: res.caller, callee: res.callee, tile: res.tile, rinsyan: res.rinsyan }); + const userId = engine.state.user1House === engine.state.turn ? room.user1Id : engine.state.user2House === engine.state.turn ? room.user2Id : engine.state.user3House === engine.state.turn ? room.user3Id : room.user4Id; + this.waitForTurn(room, userId, engine); } else if (res.type === 'ronned') { - this.globalEventService.publishMahjongRoomStream(room.id, 'ronned', { }); + this.globalEventService.publishMahjongRoomStream(room.id, 'ronned', { + callers: res.callers, + callee: res.callee, + handTiles: { + e: engine.state.handTiles.e, + s: engine.state.handTiles.s, + w: engine.state.handTiles.w, + n: engine.state.handTiles.n, + }, + }); this.endKyoku(room, engine); } } diff --git a/packages/misskey-mahjong/src/common.ts b/packages/misskey-mahjong/src/common.ts index 349d23f335..31a3594fb0 100644 --- a/packages/misskey-mahjong/src/common.ts +++ b/packages/misskey-mahjong/src/common.ts @@ -55,14 +55,13 @@ export type Huro = { type: 'cii'; tiles: [Tile, Tile, Tile]; from: House; -} | { - type: 'minkan'; - tile: Tile; - from: House; } | { type: 'ankan'; tile: Tile; - from: House; +} | { + type: 'minkan'; + tile: Tile; + from: House | null; // null で加槓 }; export const yakuNames = [ diff --git a/packages/misskey-mahjong/src/engine.master.ts b/packages/misskey-mahjong/src/engine.master.ts index 6da22b23ec..7ca7f78828 100644 --- a/packages/misskey-mahjong/src/engine.master.ts +++ b/packages/misskey-mahjong/src/engine.master.ts @@ -233,8 +233,6 @@ export class MasterGameEngine { } this.endKyoku(); - - // TODO: 役情報を返す } public commit_dahai(house: House, tile: Tile, riichi = false) { @@ -381,12 +379,18 @@ export class MasterGameEngine { }; if (this.state.ronAsking != null && answers.ron.length > 0) { + const callers = this.state.ronAsking.callers; + const callee = this.state.ronAsking.callee; + this.ron(answers.ron, this.state.ronAsking.callee); return { type: 'ronned', + callers, + callee, }; } + // 大明槓 if (this.state.kanAsking != null && answers.kan) { const caller = this.state.kanAsking.caller; const callee = this.state.kanAsking.callee; @@ -394,10 +398,17 @@ export class MasterGameEngine { const tile = this.state.hoTiles[callee].pop()!; this.state.huros[caller].push({ type: 'minkan', tile, from: callee }); + const rinsyan = this.tsumo(); + clearAsking(); this.state.turn = caller; - // TODO - return; + return { + type: 'kanned', + caller, + callee, + tile, + rinsyan, + }; } if (this.state.ponAsking != null && answers.pon) {