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 _activePromptPlayer: Signal<string | null>;
|
||||
private _createInitialState: () => TState;
|
||||
private _setupCommand: string;
|
||||
private _eventListeners: Map<'setup' | 'dispose', Set<() => void>>;
|
||||
private _isDisposed = false;
|
||||
|
||||
constructor(
|
||||
registry: CommandRegistry<MutableSignal<TState>>,
|
||||
createInitialState: () => TState,
|
||||
setupCommand: string,
|
||||
options?: GameHostOptions
|
||||
) {
|
||||
this._createInitialState = createInitialState;
|
||||
this._setupCommand = setupCommand;
|
||||
this._eventListeners = new Map();
|
||||
|
||||
const initialState = createInitialState();
|
||||
|
|
@ -148,13 +145,11 @@ export class GameHost<TState extends Record<string, unknown>> {
|
|||
|
||||
export function createGameHost<TState extends Record<string, unknown>>(
|
||||
module: GameModule<TState>,
|
||||
setupCommand: string,
|
||||
options?: GameHostOptions
|
||||
): GameHost<TState> {
|
||||
return new GameHost(
|
||||
module.registry,
|
||||
module.createInitialState,
|
||||
setupCommand,
|
||||
options
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,8 +12,7 @@ import { MutableSignal } from '@/utils/mutable-signal';
|
|||
|
||||
function createTestHost() {
|
||||
const host = createGameHost(
|
||||
{ registry, createInitialState },
|
||||
'setup'
|
||||
{ registry, createInitialState }
|
||||
);
|
||||
return { host };
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue