This commit is contained in:
syuilo 2024-01-29 20:35:25 +09:00
parent d427d24ca4
commit 547b74c9b2
4 changed files with 38 additions and 11 deletions

View file

@ -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: {

View file

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

View file

@ -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 = [

View file

@ -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) {