diff --git a/src/core/game-host.ts b/src/core/game-host.ts index 92e9138..8bb144c 100644 --- a/src/core/game-host.ts +++ b/src/core/game-host.ts @@ -9,6 +9,11 @@ export interface GameHostOptions { autoStart?: boolean; } +export interface GameModule> { + registry: CommandRegistry>; + createInitialState: () => TState; +} + export class GameHost> { readonly state: ReadonlySignal; readonly commands: ReturnType>['commands']; @@ -142,10 +147,7 @@ export class GameHost> { } export function createGameHost>( - module: { - registry: CommandRegistry>; - createInitialState: () => TState; - }, + module: GameModule, setupCommand: string, options?: GameHostOptions ): GameHost { diff --git a/src/core/game.ts b/src/core/game.ts index 55690f0..7924560 100644 --- a/src/core/game.ts +++ b/src/core/game.ts @@ -10,6 +10,7 @@ import { parseCommandSchema, registerCommand } from "@/utils/command"; +import type { GameModule } from './game-host'; export interface IGameContext = {} > { state: MutableSignal; @@ -69,4 +70,10 @@ export function createGameCommand = {} , } export { GameHost, createGameHost } from './game-host'; -export type { GameHostStatus, GameHostOptions } from './game-host'; \ No newline at end of file +export type { GameHostStatus, GameHostOptions, GameModule } from './game-host'; + +export function createGameModule>( + module: GameModule +): GameModule { + return module; +} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index b01b8b4..60935a3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -7,8 +7,8 @@ export type { IGameContext } from './core/game'; export { createGameContext, createGameCommandRegistry } from './core/game'; -export type { GameHost, GameHostStatus, GameHostOptions } from './core/game-host'; -export { createGameHost } from './core/game-host'; +export type { GameHost, GameHostStatus, GameHostOptions, GameModule } from './core/game'; +export { createGameHost, createGameModule } from './core/game'; export type { Part } from './core/part'; export { flip, flipTo, roll, findPartById, isCellOccupied, getPartAtPosition, isCellOccupiedByRegion, getPartAtPositionInRegion } from './core/part';