diff --git a/packages/backend/src/core/MahjongService.ts b/packages/backend/src/core/MahjongService.ts index e4abbe8076..9a6422340e 100644 --- a/packages/backend/src/core/MahjongService.ts +++ b/packages/backend/src/core/MahjongService.ts @@ -376,7 +376,7 @@ export class MahjongService implements OnApplicationShutdown, OnModuleInit { } @bindThis - private async dahai(room: Room, engine: Mahjong.MasterGameEngine, house: Mahjong.House, tile: Mahjong.Tile, riichi = false) { + private async dahai(room: Room, engine: Mahjong.MasterGameEngine, house: Mahjong.House, tile: Mahjong.TileId, riichi = false) { const res = engine.commit_dahai(house, tile, riichi); room.gameState = engine.state; await this.saveRoom(room); @@ -384,8 +384,6 @@ export class MahjongService implements OnApplicationShutdown, OnModuleInit { const aiHouses = [[1, room.user1Ai], [2, room.user2Ai], [3, room.user3Ai], [4, room.user4Ai]].filter(([id, ai]) => ai).map(([id, ai]) => engine.getHouse(id)); if (res.asking) { - console.log('asking', res); - const answers: CallingAnswers = { pon: null, cii: null, @@ -478,11 +476,10 @@ export class MahjongService implements OnApplicationShutdown, OnModuleInit { } @bindThis - public async commit_dahai(roomId: MiMahjongGame['id'], user: MiUser, tile: string, riichi = false) { + public async commit_dahai(roomId: MiMahjongGame['id'], user: MiUser, tile: Mahjong.TileId, riichi = false) { const room = await this.getRoom(roomId); if (room == null) return; if (room.gameState == null) return; - if (!Mahjong.isTile(tile)) return; const engine = new Mahjong.MasterGameEngine(room.gameState); const myHouse = getHouseOfUserId(room, engine, user.id); @@ -493,7 +490,7 @@ export class MahjongService implements OnApplicationShutdown, OnModuleInit { } @bindThis - public async commit_ankan(roomId: MiMahjongGame['id'], user: MiUser, tile: string) { + public async commit_ankan(roomId: MiMahjongGame['id'], user: MiUser, tile: Mahjong.TileId) { const room = await this.getRoom(roomId); if (room == null) return; if (room.gameState == null) return; @@ -511,7 +508,7 @@ export class MahjongService implements OnApplicationShutdown, OnModuleInit { } @bindThis - public async commit_kakan(roomId: MiMahjongGame['id'], user: MiUser, tile: string) { + public async commit_kakan(roomId: MiMahjongGame['id'], user: MiUser, tile: Mahjong.TileId) { const room = await this.getRoom(roomId); if (room == null) return; if (room.gameState == null) return; @@ -643,11 +640,10 @@ export class MahjongService implements OnApplicationShutdown, OnModuleInit { if (engine.state.riichis[house]) { // リーチ時はアガリ牌でない限りツモ切り - const handTiles = engine.state.handTiles[house]; - const horaSets = Mahjong.getHoraSets(handTiles); + const horaSets = Mahjong.getHoraSets(engine.handTileTypes[house]); if (horaSets.length === 0) { setTimeout(() => { - this.dahai(room, engine, house, handTiles.at(-1)); + this.dahai(room, engine, house, engine.state.handTiles[house].at(-1)); }, 500); return; } diff --git a/packages/backend/src/server/api/stream/channels/mahjong-room.ts b/packages/backend/src/server/api/stream/channels/mahjong-room.ts index b2e2ccdb92..de7fc4f467 100644 --- a/packages/backend/src/server/api/stream/channels/mahjong-room.ts +++ b/packages/backend/src/server/api/stream/channels/mahjong-room.ts @@ -94,7 +94,7 @@ class MahjongRoomChannel extends Channel { } @bindThis - private async dahai(tile: string, riichi = false) { + private async dahai(tile: number, riichi = false) { if (this.user == null) return; this.mahjongService.commit_dahai(this.roomId!, this.user, tile, riichi); @@ -136,14 +136,14 @@ class MahjongRoomChannel extends Channel { } @bindThis -private async ankan(tile: string) { +private async ankan(tile: number) { if (this.user == null) return; this.mahjongService.commit_ankan(this.roomId!, this.user, tile); } @bindThis - private async kakan(tile: string) { + private async kakan(tile: number) { if (this.user == null) return; this.mahjongService.commit_kakan(this.roomId!, this.user, tile); diff --git a/packages/frontend/assets/mahjong/tiles/m5r.png b/packages/frontend/assets/mahjong/tiles/m5r.png new file mode 100644 index 0000000000..7347fb14ba Binary files /dev/null and b/packages/frontend/assets/mahjong/tiles/m5r.png differ diff --git a/packages/frontend/assets/mahjong/tiles/p5r.png b/packages/frontend/assets/mahjong/tiles/p5r.png new file mode 100644 index 0000000000..6454624dce Binary files /dev/null and b/packages/frontend/assets/mahjong/tiles/p5r.png differ diff --git a/packages/frontend/assets/mahjong/tiles/s5r.png b/packages/frontend/assets/mahjong/tiles/s5r.png new file mode 100644 index 0000000000..09b1b884bf Binary files /dev/null and b/packages/frontend/assets/mahjong/tiles/s5r.png differ diff --git a/packages/frontend/src/pages/mahjong/huro.vue b/packages/frontend/src/pages/mahjong/huro.vue index 10923f23b4..1c6da57efb 100644 --- a/packages/frontend/src/pages/mahjong/huro.vue +++ b/packages/frontend/src/pages/mahjong/huro.vue @@ -5,26 +5,26 @@ SPDX-License-Identifier: AGPL-3.0-only @@ -36,7 +36,7 @@ import XTile from './tile.vue'; const props = defineProps<{ huro: Mahjong.Huro; variation: string; - doras: Mahjong.Tile[]; + doras: Mahjong.TileType[]; }>(); diff --git a/packages/frontend/src/pages/mahjong/room.game.vue b/packages/frontend/src/pages/mahjong/room.game.vue index 99471d50da..e1ab9bcff7 100644 --- a/packages/frontend/src/pages/mahjong/room.game.vue +++ b/packages/frontend/src/pages/mahjong/room.game.vue @@ -76,28 +76,28 @@ SPDX-License-Identifier: AGPL-3.0-only
- +
- +
- +
- +
@@ -106,20 +106,20 @@ SPDX-License-Identifier: AGPL-3.0-only
- +
- +
@@ -259,7 +259,7 @@ const canHora = computed(() => { return Mahjong.getHoraSets(engine.value.myHandTiles).length > 0; }); -const selectableTiles = ref(null); +const selectableTiles = ref(null); const ronSerifHouses = reactive>({ e: false, s: false, w: false, n: false }); const ciiSerifHouses = reactive>({ e: false, s: false, w: false, n: false }); const ponSerifHouses = reactive>({ e: false, s: false, w: false, n: false }); @@ -267,43 +267,6 @@ const kanSerifHouses = reactive>({ e: false, s: f const tsumoSerifHouses = reactive>({ e: false, s: false, w: false, n: false }); const riichiSerifHouses = reactive>({ e: false, s: false, w: false, n: false }); -/* -console.log(Mahjong.getTilesForRiichi([ - 'm1', - 'm2', - 'm2', - 'm3', - 'm3', - 'm5', - 'm6', - 'p4', - 'p5', - 'p6', - 's6', - 's7', - 's8', - 'm7', -])); -*/ -/* -console.log(Mahjong.getHoraSets([ - 'm3', - 'm3', - 'm4', - 'm4', - 'm5', - 'm5', - 'p4', - 'p4', - 'p7', - 'p8', - 'p9', - 's4', - 's5', - 's6', -])); -*/ - /* if (room.value.isStarted && !room.value.isEnded) { useInterval(() => { @@ -354,7 +317,7 @@ let ankanSelect = false; let kakanSelect = false; let ciiSelect = false; -function chooseTile(tile: Mahjong.Tile, ev: MouseEvent) { +function chooseTile(tile: Mahjong.TileId, ev: MouseEvent) { if (!isMyTurn.value) return; iTsumoed.value = false; @@ -390,22 +353,22 @@ function riichi() { if (!isMyTurn.value) return; riichiSelect = true; - selectableTiles.value = Mahjong.getTilesForRiichi(engine.value.myHandTiles); - console.log(Mahjong.getTilesForRiichi(engine.value.myHandTiles)); + selectableTiles.value = Mahjong.getTilesForRiichi(engine.value.myHandTileTypes); + console.log(Mahjong.getTilesForRiichi(engine.value.myHandTileTypes)); } function ankan() { if (!isMyTurn.value) return; ankanSelect = true; - selectableTiles.value = engine.value.getAnkanableTiles(); + selectableTiles.value = engine.value.getAnkanableTiles().map(id => Mahjong.findTileByIdOrFail(id).t); } function kakan() { if (!isMyTurn.value) return; kakanSelect = true; - selectableTiles.value = engine.value.getKakanableTiles(); + selectableTiles.value = engine.value.getKakanableTiles().map(id => Mahjong.findTileByIdOrFail(id).t); } function tsumoHora() { @@ -957,7 +920,6 @@ onUnmounted(() => { aspect-ratio: 0.7; transition: translate 0.1s ease; cursor: pointer; - overflow: clip; } .myTile:hover { translate: 0 -10px; @@ -967,6 +929,7 @@ onUnmounted(() => { opacity: 0.7; pointer-events: none; } +/* .myTileDora { &:after { content: ""; @@ -982,6 +945,7 @@ onUnmounted(() => { pointer-events: none; } } +*/ .myTileBg { position: absolute; top: 0; diff --git a/packages/frontend/src/pages/mahjong/tile.vue b/packages/frontend/src/pages/mahjong/tile.vue index bd9911eada..ba823414aa 100644 --- a/packages/frontend/src/pages/mahjong/tile.vue +++ b/packages/frontend/src/pages/mahjong/tile.vue @@ -6,7 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only @@ -15,12 +15,12 @@ import { computed } from 'vue'; import * as Mahjong from 'misskey-mahjong'; const props = defineProps<{ - tile: Mahjong.Tile; + tile: Mahjong.TileInstance; variation: string; - doras: Mahjong.Tile[]; + doras: Mahjong.TileType[]; }>(); -const isDora = computed(() => props.doras.includes(props.tile)); +const isDora = computed(() => props.doras.includes(props.tile.t)); diff --git a/packages/misskey-mahjong/src/engine.master.ts b/packages/misskey-mahjong/src/engine.master.ts index b375296fe3..d41f1ffbc4 100644 --- a/packages/misskey-mahjong/src/engine.master.ts +++ b/packages/misskey-mahjong/src/engine.master.ts @@ -14,7 +14,7 @@ function $(tileId: TileId): Common.TileInstance { } function $type(tileId: TileId): TileType { - return Common.findTileByIdOrFail(tileId).t; + return $(tileId).t; } //#endregion @@ -148,7 +148,7 @@ export class MasterGameEngine { } public static createInitialState(): MasterState { - const ikasama: TileId[] = [125, 129, 9, 54, 57, 61, 77, 81, 85, 133, 134, 135, 121, 122]; + const ikasama: TileId[] = [125, 129, 9, 56, 57, 61, 77, 81, 85, 133, 134, 135, 121, 122]; const tiles = [...Common.TILE_ID_MAP.keys()]; tiles.sort(() => Math.random() - 0.5); diff --git a/packages/misskey-mahjong/src/engine.player.ts b/packages/misskey-mahjong/src/engine.player.ts index f4a7e8d119..91ec136424 100644 --- a/packages/misskey-mahjong/src/engine.player.ts +++ b/packages/misskey-mahjong/src/engine.player.ts @@ -13,7 +13,7 @@ function $(tileId: TileId): Common.TileInstance { } function $type(tileId: TileId): TileType { - return Common.findTileByIdOrFail(tileId).t; + return $(tileId).t; } //#endregion