Skip to content

Config files

Jerome Renaux edited this page Jan 21, 2020 · 1 revision

Many parameters of the game are stored in configuration files, to allow adjusting them without touching the source code.

NB: many many parameters are still hard-coded; feel free to contribute by moving some of them to the config files!

The config files are located in the /config folder. They are written in JSON5 format (an enhanced version of JSON that allows for comments for example) and managed by the config npm package, which offers a lot of nice features.

Environments

One of the features offered by the config package is the ability to load different config files in different environments. In addition, config files can 'inherit' from each other based on their load order, as explained here. In Westward, two main config files are defined.

default.json5 is the main config file containing all the parameters. It is the first config file to be parsed, acting as the root for all configuration parameters. The values defined in that file will be applied to the game unless they are overridden in deployment.json5.

deployment.json5 is the config file used in production, for the online version of the game. It only contains the config parameters whose values need to override the default ones. For example, default.json5 has the value client.boot.autoBoot set to true, which skips the title screen to make testing locally faster. But deployment.json5 overrides it to false, because in production we don't want to skip the title screen.

For deployment.json5 to be read, the NODE_CONFIG_ENV environment variable must be set to deployment in the .env file.