eliasku / 13

Fast-action P2P multiplayer game 13 (js13k-2022)
https://iioi.herokuapp.com/
94 stars 27 forks source link

[Config] Load game config from JSON file #21

Closed 3kh0 closed 1 year ago

3kh0 commented 2 years ago

I would be nice to have a config file in server folder that you can use to change how the game works, like how often npcs spawn, what HP they need to be at to panic, how much each weapon does damage wise (set the damage each bullet does), if it should reset kills on death, things like that. This would be a .json file

eliasku commented 1 year ago

It looks like static game data. Right now we have these configs right in client code. We could make it more dynamic (load / share / add to room settings / add to replay file)

3kh0 commented 1 year ago

That would be pretty cool

eliasku commented 1 year ago

I've created the next issue to continue implementation of the general idea: https://github.com/eliasku/13/issues/133 Right now you will be able to experiment with config.json file for your own server

eliasku commented 1 year ago

Modify game config

  1. Recommended way to change global game configuration is via packages/tools/src/config.ts file. It provides types and some good utilities to compose the final configuration.
  2. Generate packages/client/assets/config.json by running npm run config.
  3. Run npm start or npm run build - scripts will copy packages/client/assets/config.json to public/config.json, it will be loaded by the game and will be used for all global configuration.

If you need some new option from the code to be exposed in config.json, please create the issue.