From f930d2943eff20a33855f1c92427a274925f12ee Mon Sep 17 00:00:00 2001 From: hypercross Date: Sat, 4 Apr 2026 14:05:23 +0800 Subject: [PATCH] refactor: remove host options --- src/core/game-host.ts | 15 ++------------- tests/core/game-host.test.ts | 4 ++-- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/src/core/game-host.ts b/src/core/game-host.ts index 75655ff..9d154ab 100644 --- a/src/core/game-host.ts +++ b/src/core/game-host.ts @@ -1,14 +1,10 @@ -import { ReadonlySignal, signal, Signal } from '@preact/signals-core'; -import type { CommandSchema, CommandRegistry, CommandResult, PromptEvent } from '@/utils/command'; +import { ReadonlySignal, Signal } from '@preact/signals-core'; +import type { CommandSchema, CommandRegistry, PromptEvent } from '@/utils/command'; import type { MutableSignal } from '@/utils/mutable-signal'; import { createGameContext } from './game'; export type GameHostStatus = 'created' | 'running' | 'disposed'; -export interface GameHostOptions { - autoStart?: boolean; -} - export interface GameModule> { registry: CommandRegistry>; createInitialState: () => TState; @@ -32,7 +28,6 @@ export class GameHost> { constructor( registry: CommandRegistry>, createInitialState: () => TState, - options?: GameHostOptions ) { this._createInitialState = createInitialState; this._eventListeners = new Map(); @@ -55,10 +50,6 @@ export class GameHost> { this.state = this._state; this._setupPromptTracking(); - - if (options?.autoStart !== false) { - this._status.value = 'running'; - } } private _setupPromptTracking() { @@ -145,11 +136,9 @@ export class GameHost> { export function createGameHost>( module: GameModule, - options?: GameHostOptions ): GameHost { return new GameHost( module.registry, module.createInitialState, - options ); } diff --git a/tests/core/game-host.test.ts b/tests/core/game-host.test.ts index ab296de..431c6b9 100644 --- a/tests/core/game-host.test.ts +++ b/tests/core/game-host.test.ts @@ -34,10 +34,10 @@ describe('GameHost', () => { expect(Object.keys(host.state.value.parts).length).toBe(0); }); - it('should have status "running" by default', () => { + it('should have status "created" by default', () => { const { host } = createTestHost(); - expect(host.status.value).toBe('running'); + expect(host.status.value).toBe('created'); }); it('should have null activePromptSchema initially', () => {