1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-25 16:44:05 +02:00

麻雀が動作できるように (#15815)

This commit is contained in:
Take-John
2025-04-13 18:29:56 +09:00
committed by GitHub
parent 7f9c84ebe8
commit 7d9a6a3f9d
8 changed files with 69 additions and 47 deletions

View File

@@ -74,20 +74,28 @@ type YakumanName = typeof YAKUMAN_NAMES[number];
export type YakuName = NormalYakuName | YakumanName;
export type HuroForCalcYaku = {
type Pon = {
type: 'pon';
tile: TileType;
} | {
};
type Cii = {
type: 'cii';
tiles: [TileType, TileType, TileType];
} | {
};
type Ankan = {
type: 'ankan';
tile: TileType;
} | {
};
type Minkan = {
type: 'minkan';
tile: TileType;
};
export type HuroForCalcYaku = Pon | Cii | Ankan | Minkan;
export type EnvForCalcYaku = {
/**
* 和了る人の手牌(副露牌は含まず、ツモ、ロン牌は含む)
@@ -604,7 +612,7 @@ new SeatWind('seat-wind-n', 'n'),
if (fourMentsuOneJyantou == null) return false;
const shuntsus = fourMentsuOneJyantou.mentsus.filter(tiles => isShuntu(tiles));
shuntsus.push(...state.huros.filter(huro => huro.type == 'cii').map(huro => huro.tiles));
shuntsus.push(...state.huros.filter((huro): huro is Cii => huro.type == 'cii').map(huro => huro.tiles));
if (shuntsus.some(tiles => tiles[0] === 'm1' && tiles[1] === 'm2' && tiles[2] === 'm3')) {
if (shuntsus.some(tiles => tiles[0] === 'm4' && tiles[1] === 'm5' && tiles[2] === 'm6')) {

View File

@@ -997,19 +997,19 @@ export class MasterGameEngine {
}
public calcCrc32ForUser1(): number {
// TODO
throw new Error('TODO');
}
public calcCrc32ForUser2(): number {
// TODO
throw new Error('TODO');
}
public calcCrc32ForUser3(): number {
// TODO
throw new Error('TODO');
}
public calcCrc32ForUser4(): number {
// TODO
throw new Error('TODO');
}
public getState(): MasterState {
@@ -1018,5 +1018,5 @@ export class MasterGameEngine {
}
function commit_dahai(state: MasterState): MasterState {
throw new Error('Not implemented');
}

View File

@@ -5,16 +5,22 @@
import { TileType } from './common.js';
export type Player = 1 | 2 | 3 | 4;
export type Operation = 'dahai';
export type OperationCode = 1;
export type Log = {
time: number;
player: 1 | 2 | 3 | 4;
operation: 'dahai';
tile: string;
player: Player;
operation: Operation;
tile: TileType;
};
export type SerializedLog = number[];
export type SerializedLog = [number, Player, OperationCode, TileCode];
export const TILE_MAP: Record<TileType, number> = {
export const TILE_MAP = {
'm1': 1,
'm2': 2,
'm3': 3,
@@ -49,9 +55,11 @@ export const TILE_MAP: Record<TileType, number> = {
'haku': 32,
'hatsu': 33,
'chun': 34,
};
} as const;
export function serializeTile(tile: TileType): number {
export type TileCode = typeof TILE_MAP extends Record<string, infer T> ? T : never;
export function serializeTile(tile: TileType): TileCode {
return TILE_MAP[tile];
}
@@ -59,8 +67,8 @@ export function deserializeTile(tile: number): TileType {
return Object.keys(TILE_MAP).find(key => TILE_MAP[key as TileType] === tile) as TileType;
}
export function serializeLogs(logs: Log[]) {
const _logs: number[][] = [];
export function serializeLogs(logs: Log[]): SerializedLog[] {
const _logs: SerializedLog[] = [];
for (let i = 0; i < logs.length; i++) {
const log = logs[i];
@@ -79,7 +87,7 @@ export function serializeLogs(logs: Log[]) {
return _logs;
}
export function deserializeLogs(logs: SerializedLog[]) {
export function deserializeLogs(logs: SerializedLog[]): Log[] {
const _logs: Log[] = [];
let time = 0;
@@ -97,7 +105,7 @@ export function deserializeLogs(logs: SerializedLog[]) {
time,
player: player,
operation: 'dahai',
tile: log[3],
tile: deserializeTile(log[3]),
});
break;
//case 1: