From 7659e1fac555b0c1a30af7ad22e71588cb7671a0 Mon Sep 17 00:00:00 2001 From: Joywayer Date: Sun, 28 Jun 2026 21:39:39 +0800 Subject: [PATCH] =?UTF-8?q?feat(framework):=20platform=20State=20=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B(=E7=99=BB=E5=BD=95=E9=A9=B1=E5=8A=A8=E5=AD=90?= =?UTF-8?q?=E9=9B=86)=20+=20=E5=8F=AA=E8=AF=BB=E8=A7=86=E5=9B=BE=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.8 (1M context) --- .../assets/framework/platform/readonly.ts | 6 +++ .../assets/framework/platform/stores/types.ts | 42 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 cocoscreator_projects/YouleNexus/assets/framework/platform/readonly.ts create mode 100644 cocoscreator_projects/YouleNexus/assets/framework/platform/stores/types.ts diff --git a/cocoscreator_projects/YouleNexus/assets/framework/platform/readonly.ts b/cocoscreator_projects/YouleNexus/assets/framework/platform/readonly.ts new file mode 100644 index 0000000..cc9e5ae --- /dev/null +++ b/cocoscreator_projects/YouleNexus/assets/framework/platform/readonly.ts @@ -0,0 +1,6 @@ +import type { ReadonlyReactive } from '../core/reactive.ts'; +import type { PlayerState, AppState, RoomState } from './stores/types.ts'; + +export interface ReadonlyPlayerStore { readonly state: ReadonlyReactive; } +export interface ReadonlyRoomStore { readonly state: ReadonlyReactive; } +export interface ReadonlyAppStore { readonly state: ReadonlyReactive; } diff --git a/cocoscreator_projects/YouleNexus/assets/framework/platform/stores/types.ts b/cocoscreator_projects/YouleNexus/assets/framework/platform/stores/types.ts new file mode 100644 index 0000000..87fa47f --- /dev/null +++ b/cocoscreator_projects/YouleNexus/assets/framework/platform/stores/types.ts @@ -0,0 +1,42 @@ +import type { ChannelIdentity } from '../../config/identity.ts'; + +/** PlayerState(C_Player A 组,login 始终下发;openid 等仅 deviceLogin 下发,做可选)。 */ +export interface PlayerState { + playerid: number; + nickname: string; avatar: string; sex: number; + openid?: string; unionid?: string | number; province?: string; city?: string; + bean: number; roomcard: number; score: number; charm: number; + taskstate: number; advanced: number; + bankpower: number; bank: number; bankpwd: number; + ip: string; sign: string | null; tel: string | null; + invitecode: string | null; initCard: number | string; initBean: number | string; +} + +export type ConnectionPhase = + | 'idle' | 'connecting' | 'connected' | 'loggedIn' + | 'reconnecting' | 'slow' | 'kicked' | 'loginFailed'; + +/** AppState(GameData 子集:身份 + 服务器 + 代理/版本 + 连接相位)。 */ +export interface AppState { + identity: ChannelIdentity | null; // 来自 bootstrap + servers: string[]; + agentid: string | number; // login 回填(旧 GameData.AgentId,protocol/04:183) + channelid: string | number; // login 回填(旧 GameData.ChannelId,protocol/04:184) + agentname: string; + agentmode: number; + gameversion: number; + phase: ConnectionPhase; +} + +/** RoomState(Desk B 组,仅在房/重连时下发)。 */ +export interface RoomState { + inRoom: boolean; + roomcode: string | null; + isbattle: number; // 0未开局/1已开局 + roommode: number; // 0普通/1星星场 + seat: number; // 自己的座位(-1 未入座) + isowner: number; // 1房主/0非 + asetcount: number; makewar: number; needprepare: number; infinite: number; + players: unknown[]; // 按座位下标(可含 null);完整建模留后续切片 + deskinfo: unknown; // 子游戏对局快照,opaque 透传 +}