mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 13:50:43 +00:00
load mini map synchronously
This commit is contained in:
@@ -211,11 +211,11 @@
|
||||
* add cities DONE 12/4/2024
|
||||
* write multiplayer games to GCS DONE 12/6/2024
|
||||
* write single player games to GCS DONE 12/7/2024
|
||||
* record game difficulty DONE 12/7/2024
|
||||
* standardize game ids DONE 12/7/2024
|
||||
* bufix: mini map doesn't load in time DONE 12/7/2024
|
||||
* bugfix: private game host game doesn't start
|
||||
* bufix: mini map doesn't load in time
|
||||
* record game winner
|
||||
* record game difficulty
|
||||
* standardize game ids
|
||||
* record commit hash of game
|
||||
* store metadata in BigQuery
|
||||
* replay stored games
|
||||
|
||||
@@ -6,7 +6,7 @@ import { Config, getConfig } from "../core/configuration/Config";
|
||||
import { createRenderer, GameRenderer } from "./graphics/GameRenderer";
|
||||
import { InputHandler, MouseUpEvent, ZoomEvent, DragEvent, MouseDownEvent } from "./InputHandler"
|
||||
import { ClientID, ClientIntentMessageSchema, ClientJoinMessageSchema, ClientMessageSchema, GameConfig, GameID, Intent, ServerMessage, ServerMessageSchema, ServerSyncMessage, Turn } from "../core/Schemas";
|
||||
import { loadTerrainMap, TerrainMapImpl } from "../core/game/TerrainMapLoader";
|
||||
import { createMiniMap, loadTerrainMap, TerrainMapImpl } from "../core/game/TerrainMapLoader";
|
||||
import { and, bfs, dist, manhattanDist } from "../core/Util";
|
||||
import { WinCheckExecution } from "../core/execution/WinCheckExecution";
|
||||
import { SendAttackIntentEvent, SendSpawnIntentEvent, Transport } from "./Transport";
|
||||
@@ -74,9 +74,10 @@ export function joinLobby(lobbyConfig: LobbyConfig, onjoin: () => void): () => v
|
||||
export async function createClientGame(gameConfig: GameConfig, eventBus: EventBus, transport: Transport, gameID: GameID, clientID: ClientID): Promise<GameRunner> {
|
||||
const config = getConfig()
|
||||
|
||||
const terrainMap = await loadTerrainMap(gameConfig.gameMap)
|
||||
const terrainMap = await loadTerrainMap(gameConfig.gameMap);
|
||||
const miniMap = await createMiniMap(terrainMap);
|
||||
|
||||
let game = createGame(terrainMap, eventBus, config, gameConfig)
|
||||
let game = createGame(terrainMap, miniMap, eventBus, config, gameConfig)
|
||||
|
||||
const worker = new WorkerClient(game, gameConfig.gameMap)
|
||||
console.log('going to init path finder')
|
||||
|
||||
@@ -12,8 +12,8 @@ import { ClientID, GameConfig } from "../Schemas";
|
||||
import { DisplayMessageEvent, MessageType } from "../../client/graphics/layers/EventsDisplay";
|
||||
import { UnitImpl } from "./UnitImpl";
|
||||
|
||||
export function createGame(terrainMap: TerrainMapImpl, eventBus: EventBus, config: Config, gameConfig: GameConfig): Game {
|
||||
return new GameImpl(terrainMap, eventBus, config, gameConfig)
|
||||
export function createGame(terrainMap: TerrainMapImpl, miniMap: TerrainMap, eventBus: EventBus, config: Config, gameConfig: GameConfig): Game {
|
||||
return new GameImpl(terrainMap, miniMap, eventBus, config, gameConfig)
|
||||
}
|
||||
|
||||
export type CellString = string
|
||||
@@ -38,10 +38,10 @@ export class GameImpl implements MutableGame {
|
||||
allianceRequests: AllianceRequestImpl[] = []
|
||||
alliances_: AllianceImpl[] = []
|
||||
|
||||
private _terrainMiniMap: TerrainMap = null
|
||||
|
||||
constructor(
|
||||
private _terrainMap: TerrainMapImpl,
|
||||
private _miniMap: TerrainMap,
|
||||
public eventBus: EventBus,
|
||||
private _config: Config,
|
||||
private _gameConfig: GameConfig,
|
||||
@@ -64,10 +64,6 @@ export class GameImpl implements MutableGame {
|
||||
new Cell(n.coordinates[0], n.coordinates[1]),
|
||||
n.strength
|
||||
))
|
||||
createMiniMap(_terrainMap).then(m => {
|
||||
console.log('mini map loaded!')
|
||||
this._terrainMiniMap = m
|
||||
})
|
||||
}
|
||||
|
||||
gameConfig(): GameConfig {
|
||||
@@ -438,10 +434,7 @@ export class GameImpl implements MutableGame {
|
||||
}
|
||||
|
||||
public terrainMiniMap(): TerrainMap {
|
||||
if (this._terrainMiniMap == null) {
|
||||
throw Error('mini map not loaded')
|
||||
}
|
||||
return this._terrainMiniMap
|
||||
return this._miniMap
|
||||
}
|
||||
|
||||
displayMessage(message: string, type: MessageType, playerID: PlayerID | null): void {
|
||||
|
||||
Reference in New Issue
Block a user