mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-17 12:01:34 +00:00
add preprod, prod & dev config
This commit is contained in:
@@ -3,6 +3,8 @@ import { Colord, colord } from "colord";
|
||||
import { devConfig } from "./DevConfig";
|
||||
import { defaultConfig } from "./DefaultConfig";
|
||||
import { GameID } from "../Schemas";
|
||||
import { preprodConfig } from "./PreprodConfig";
|
||||
import { prodConfig } from "./ProdConfig";
|
||||
|
||||
export enum GameEnv {
|
||||
Dev,
|
||||
@@ -10,13 +12,18 @@ export enum GameEnv {
|
||||
}
|
||||
|
||||
export function getConfig(): Config {
|
||||
// TODO: 'prod' not found in prod env
|
||||
if (process.env.GAME_ENV == 'dev') {
|
||||
console.log('Using dev config')
|
||||
return devConfig
|
||||
} else {
|
||||
console.log('Using prod config')
|
||||
return defaultConfig
|
||||
switch (process.env.GAME_ENV) {
|
||||
case 'dev':
|
||||
console.log('using dev config')
|
||||
return devConfig
|
||||
case 'preprod':
|
||||
console.log('using preprod config')
|
||||
return preprodConfig
|
||||
case 'prod':
|
||||
console.log('using prod config')
|
||||
return prodConfig
|
||||
default:
|
||||
throw Error(`unsupported server configuration: ${process.env.GAME_ENV}`)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +32,7 @@ export function getGameEnv(): GameEnv {
|
||||
}
|
||||
|
||||
export interface Config {
|
||||
discordBotSecret(): string
|
||||
theme(): Theme;
|
||||
percentageTilesOwnedToWin(): number
|
||||
turnIntervalMs(): number
|
||||
|
||||
@@ -6,7 +6,9 @@ import { pastelTheme } from "./PastelTheme";
|
||||
|
||||
|
||||
|
||||
export class DefaultConfig implements Config {
|
||||
export abstract class DefaultConfig implements Config {
|
||||
abstract discordBotSecret(): string
|
||||
|
||||
difficultyModifier(difficulty: Difficulty): number {
|
||||
switch (difficulty) {
|
||||
case Difficulty.Easy:
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import { DefaultConfig } from "./DefaultConfig";
|
||||
|
||||
export const preprodConfig = new class extends DefaultConfig {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { DefaultConfig } from "./DefaultConfig";
|
||||
|
||||
export const prodConfig = new class extends DefaultConfig {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user