feat(game): 添加房间玩家状态同步功能
- 定义 RoomPlayerUpdatePayload 接口用于处理房间状态更新 - 在游戏动作中新增 ROOM_PLAYER_UPDATE 类型支持 - 实现游戏状态管理器中的房间玩家更新逻辑 - 重构成都麻将页面以使用新的状态管理机制 - 添加从 WebSocket 消息转换为游戏动作的功能 - 更新房间离开时的 WebSocket 消息发送逻辑 - 优化玩家手牌显示和选择逻辑 - 调整房间状态显示逻辑以匹配新状态模型 - 修复座位索引计算和庄家标识逻辑 - 更新全局样式中的图标按钮样式 - 替换大厅页面的刷新图标为 SVG 图像 - 升级 pnpm 包管理器版本 - 扩展玩家状态类型定义以支持显示名称和缺门信息
This commit is contained in:
@@ -1,6 +1,25 @@
|
||||
import type {GameState, PendingClaimState} from "../types/state";
|
||||
import type {Tile} from "../types/tile.ts";
|
||||
|
||||
export interface RoomPlayerUpdatePayload {
|
||||
room_id?: string
|
||||
status?: string
|
||||
player_count?: number
|
||||
player_ids?: string[]
|
||||
players?: Array<{
|
||||
Index?: number
|
||||
index?: number
|
||||
PlayerID?: string
|
||||
player_id?: string
|
||||
PlayerName?: string
|
||||
player_name?: string
|
||||
Ready?: boolean
|
||||
ready?: boolean
|
||||
MissingSuit?: string | null
|
||||
missing_suit?: string | null
|
||||
}>
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 游戏动作定义(只描述“发生了什么”)
|
||||
@@ -52,4 +71,10 @@ export type GameAction =
|
||||
playerId: string
|
||||
action: 'peng' | 'gang' | 'hu' | 'pass'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 房间玩家更新(等待房间人数变化)
|
||||
| {
|
||||
type: 'ROOM_PLAYER_UPDATE'
|
||||
payload: RoomPlayerUpdatePayload
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user