mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-03 15:40:45 +00:00
Refactor: Split config into Config and ServerConfig
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Config } from "../core/configuration/Config";
|
||||
import { Config, ServerConfig } from "../core/configuration/Config";
|
||||
import { ClientID, GameConfig, GameID } from "../core/Schemas";
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { Client } from "./Client";
|
||||
@@ -14,7 +14,7 @@ export class GameManager {
|
||||
|
||||
private games: GameServer[] = []
|
||||
|
||||
constructor(private config: Config) { }
|
||||
constructor(private config: ServerConfig) { }
|
||||
|
||||
public game(id: GameID): GameServer | null {
|
||||
return this.games.find(g => g.id == id)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ClientID, ClientMessage, ClientMessageSchema, GameConfig, GameRecordSchema, Intent, PlayerRecord, ServerPingMessageSchema, ServerStartGameMessage, ServerStartGameMessageSchema, ServerTurnMessageSchema, Turn } from "../core/Schemas";
|
||||
import { Config } from "../core/configuration/Config";
|
||||
import { Config, ServerConfig } from "../core/configuration/Config";
|
||||
import { Client } from "./Client";
|
||||
import WebSocket from 'ws';
|
||||
import { slog } from "./StructuredLog";
|
||||
@@ -35,7 +35,7 @@ export class GameServer {
|
||||
public readonly id: string,
|
||||
public readonly createdAt: number,
|
||||
public readonly isPublic: boolean,
|
||||
private config: Config,
|
||||
private config: ServerConfig,
|
||||
private gameConfig: GameConfig,
|
||||
|
||||
) { }
|
||||
|
||||
@@ -5,7 +5,7 @@ import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { GameManager } from './GameManager';
|
||||
import { ClientMessage, ClientMessageSchema, GameRecord, GameRecordSchema, LogSeverity } from '../core/Schemas';
|
||||
import { getConfig } from '../core/configuration/Config';
|
||||
import { getConfig, getServerConfig } from '../core/configuration/Config';
|
||||
import { slog } from './StructuredLog';
|
||||
import { Client } from './Client';
|
||||
import { GamePhase, GameServer } from './GameServer';
|
||||
@@ -23,7 +23,7 @@ const wss = new WebSocketServer({ server });
|
||||
app.use(express.static(path.join(__dirname, '../../out')));
|
||||
app.use(express.json())
|
||||
|
||||
const gm = new GameManager(getConfig())
|
||||
const gm = new GameManager(getServerConfig())
|
||||
|
||||
const bot = new DiscordBot();
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user