From 1ea098f4b4d4fb345a2a021ac1b3ea73036661ad Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 28 Jan 2024 20:34:45 +0900 Subject: [PATCH] wip --- packages/backend/src/core/MahjongService.ts | 6 +++--- .../frontend/src/pages/mahjong/room.game.vue | 21 +++++++++++++++++-- packages/misskey-mahjong/src/utils.ts | 9 ++++++++ 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/packages/backend/src/core/MahjongService.ts b/packages/backend/src/core/MahjongService.ts index 7b96d6e6ed..692be75ab5 100644 --- a/packages/backend/src/core/MahjongService.ts +++ b/packages/backend/src/core/MahjongService.ts @@ -359,13 +359,13 @@ export class MahjongService implements OnApplicationShutdown, OnModuleInit { }; // リーチ中はポン、チー、カンできない - if (engine.isRiichiHouse(res.canPonHouse)) { + if (res.canPonHouse != null && engine.isRiichiHouse(res.canPonHouse)) { answers.pon = false; } - if (engine.isRiichiHouse(res.canCiiHouse)) { + if (res.canCiiHouse != null && engine.isRiichiHouse(res.canCiiHouse)) { answers.cii = false; } - if (engine.isRiichiHouse(res.canKanHouse)) { + if (res.canKanHouse != null && engine.isRiichiHouse(res.canKanHouse)) { answers.kan = false; } diff --git a/packages/frontend/src/pages/mahjong/room.game.vue b/packages/frontend/src/pages/mahjong/room.game.vue index 45f4fe4b37..fcccb8b319 100644 --- a/packages/frontend/src/pages/mahjong/room.game.vue +++ b/packages/frontend/src/pages/mahjong/room.game.vue @@ -118,13 +118,30 @@ const isMyTurn = computed(() => { }); const canRiichi = computed(() => { - return Mahjong.Utils.getHoraTiles(engine.value.myHandTiles).length > 0; + return Mahjong.Utils.getTilesForRiichi(engine.value.myHandTiles).length > 0; }); const canHora = computed(() => { return Mahjong.Utils.getHoraSets(engine.value.myHandTiles).length > 0; }); - +/* +console.log(Mahjong.Utils.getTilesForRiichi([ + 'm1', + 'm2', + 'm2', + 'm3', + 'm3', + 'm5', + 'm6', + 'p4', + 'p5', + 'p6', + 's6', + 's7', + 's8', + 'm7', +])); +*/ /* console.log(Mahjong.Utils.getHoraSets([ 'm3', diff --git a/packages/misskey-mahjong/src/utils.ts b/packages/misskey-mahjong/src/utils.ts index e1b8de0c0b..bed483548e 100644 --- a/packages/misskey-mahjong/src/utils.ts +++ b/packages/misskey-mahjong/src/utils.ts @@ -233,3 +233,12 @@ export function getHoraTiles(handTiles: Tile[]): Tile[] { return horaSets.length > 0; }); } + +export function getTilesForRiichi(handTiles: Tile[]): Tile[] { + return handTiles.filter(tile => { + const tempHandTiles = [...handTiles]; + tempHandTiles.splice(tempHandTiles.indexOf(tile), 1); + const horaTiles = getHoraTiles(tempHandTiles); + return horaTiles.length > 0; + }); +}