create game runner

This commit is contained in:
Evan
2025-02-01 12:05:11 -08:00
parent 8a4644637a
commit 8443095d89
10 changed files with 100 additions and 32 deletions
+50
View File
@@ -0,0 +1,50 @@
import { getConfig } from "./configuration/Config";
import { EventBus } from "./EventBus";
import { Executor } from "./execution/ExecutionManager";
import { Game } from "./game/Game";
import { createGame } from "./game/GameImpl";
import { loadTerrainMap } from "./game/TerrainMapLoader";
import { GameConfig, Turn } from "./Schemas";
export interface GameUpdate {
players: PlayerUpdate[]
units: UnitUpdate[]
}
export interface PlayerUpdate {
}
export interface UnitUpdate {
}
export interface TileUpdate {
x: number
y: number
isBorder: boolean
}
export async function createGameRunner(gameID: string, gameConfig: GameConfig): Promise<GameRunner> {
const config = getConfig(gameConfig)
const terrainMap = await loadTerrainMap(gameConfig.gameMap);
const eventBus = new EventBus()
const game = createGame(terrainMap.map, terrainMap.miniMap, eventBus, config)
return new GameRunner(game, eventBus, new Executor(game, gameID))
}
export class GameRunner {
constructor(private game: Game, private eventBus: EventBus, private execManager: Executor) {
}
public executeNextTick(turn: Turn): GameUpdate {
this.game.executeNextTick()
return null
}
}