refactor: remove setup command from host creation
This commit is contained in:
parent
ae98e0735a
commit
22d40fdc50
|
|
@ -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
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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 };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue