refactor: remove setup command from host creation

This commit is contained in:
hypercross 2026-04-04 12:48:51 +08:00
parent ae98e0735a
commit 22d40fdc50
2 changed files with 1 additions and 7 deletions

View File

@ -26,18 +26,15 @@ export class GameHost<TState extends Record<string, unknown>> {
private _activePromptSchema: Signal<CommandSchema | null>; private _activePromptSchema: Signal<CommandSchema | null>;
private _activePromptPlayer: Signal<string | null>; private _activePromptPlayer: Signal<string | null>;
private _createInitialState: () => TState; private _createInitialState: () => TState;
private _setupCommand: string;
private _eventListeners: Map<'setup' | 'dispose', Set<() => void>>; private _eventListeners: Map<'setup' | 'dispose', Set<() => void>>;
private _isDisposed = false; private _isDisposed = false;
constructor( constructor(
registry: CommandRegistry<MutableSignal<TState>>, registry: CommandRegistry<MutableSignal<TState>>,
createInitialState: () => TState, createInitialState: () => TState,
setupCommand: string,
options?: GameHostOptions options?: GameHostOptions
) { ) {
this._createInitialState = createInitialState; this._createInitialState = createInitialState;
this._setupCommand = setupCommand;
this._eventListeners = new Map(); this._eventListeners = new Map();
const initialState = createInitialState(); const initialState = createInitialState();
@ -148,13 +145,11 @@ export class GameHost<TState extends Record<string, unknown>> {
export function createGameHost<TState extends Record<string, unknown>>( export function createGameHost<TState extends Record<string, unknown>>(
module: GameModule<TState>, module: GameModule<TState>,
setupCommand: string,
options?: GameHostOptions options?: GameHostOptions
): GameHost<TState> { ): GameHost<TState> {
return new GameHost( return new GameHost(
module.registry, module.registry,
module.createInitialState, module.createInitialState,
setupCommand,
options options
); );
} }

View File

@ -12,8 +12,7 @@ import { MutableSignal } from '@/utils/mutable-signal';
function createTestHost() { function createTestHost() {
const host = createGameHost( const host = createGameHost(
{ registry, createInitialState }, { registry, createInitialState }
'setup'
); );
return { host }; return { host };
} }