feat(framework): platform State 类型(登录驱动子集) + 只读视图接口
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -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<PlayerState>; }
|
||||
export interface ReadonlyRoomStore { readonly state: ReadonlyReactive<RoomState>; }
|
||||
export interface ReadonlyAppStore { readonly state: ReadonlyReactive<AppState>; }
|
||||
@@ -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 透传
|
||||
}
|
||||
Reference in New Issue
Block a user