Skip to content

Commit

Permalink
add game config (#4)
Browse files Browse the repository at this point in the history
* add game config

* fix lint
  • Loading branch information
surz90 committed Aug 6, 2024
1 parent 2549b4f commit 4a3d49e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/gameConfig/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { getSDK } from '../sdk'

export enum ENV {
DEV = 'dev',
PRD = 'prd'
}

const GAME_SERVER_CONFIG: Record<string, string> = {
dev: 'https://exploration-games.decentraland.zone', //for local testing if you need different value
prd: 'https://exploration-games.decentraland.org' //PROD/live use this for launch
}

export let GAME_ID: string
export let GAME_SERVER: string

export function init() {
const { config } = getSDK()

GAME_ID = config.gameId
let _env = config.environment

if (_env !== ENV.PRD) _env = ENV.DEV

GAME_SERVER = GAME_SERVER_CONFIG[_env]
}
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import type playersType from '@dcl/sdk/players'
import type { syncEntity as SyncEntityType } from '@dcl/sdk/network'

import * as queue from './queue'
import * as gameConfig from './gameConfig'
import * as test from './test'
import { setSDK } from './sdk'

export type IConfig = {
gameId: string
environment: string
}

export let engine: IEngine
Expand All @@ -19,6 +21,7 @@ export function initLibrary(
) {
setSDK({ engine, syncEntity, players, config })
queue.initPlayersQueue()
gameConfig.init()
}
export * from './sdk'
export { queue, test }

0 comments on commit 4a3d49e

Please sign in to comment.