Load data from files #440

Open
opened 2025-04-29 12:33:47 -07:00 by scionaltera · 0 comments
scionaltera commented 2025-04-29 12:33:47 -07:00 (Migrated from github.com)

There are several types of data that are loaded into the game with classes such as CommandLoader. These classes were a simple way to set up a default state but they're not very flexible. If you wanted to customize your MUD in a persistent way (eg. removing the diagonal movement commands) you'd have to make a code change and from that point on you would always be fighting against git trying to overwrite your changes when you merge from upstream.

A better way to do this would be to make the loader classes load from a file, where the file is not managed by git.

There are currently four loader classes:

  • CommandLoader
  • WorldLoader
  • ProfessionLoader
  • SpeciesLoader

For this issue we'll ignore WorldLoader because that's covered by #406 already.

For each of the three remaining three loaders make the following changes:

  1. Define an appropriate file format. It should be human readable/editable. JSON might work but I don't like that it doesn't have comments. A custom format would be OK, or something like YAML or XML maybe?
  2. Create a default file in src/main/resources/ to load some minimal defaults from if no other source is available.
  3. If data exists in the database already, don't load anything from files (same as current behavior).
  4. If a custom file exists under ./data/{filename}, load that.
  5. If no custom file exists, load the default file from ./agonyforge-mud-demo/src/main/resources.
  6. Add the custom files to .gitignore.
There are several types of data that are loaded into the game with classes such as `CommandLoader`. These classes were a simple way to set up a default state but they're not very flexible. If you wanted to customize your MUD in a persistent way (eg. removing the diagonal movement commands) you'd have to make a code change and from that point on you would always be fighting against git trying to overwrite your changes when you merge from upstream. A better way to do this would be to make the loader classes load from a file, where the file is not managed by git. There are currently four loader classes: * CommandLoader * WorldLoader * ProfessionLoader * SpeciesLoader For this issue we'll ignore `WorldLoader` because that's covered by #406 already. For each of the three remaining three loaders make the following changes: 1. Define an appropriate file format. It should be human readable/editable. JSON might work but I don't like that it doesn't have comments. A custom format would be OK, or something like YAML or XML maybe? 1. Create a default file in `src/main/resources/` to load some minimal defaults from if no other source is available. 1. If data exists in the database already, don't load anything from files (same as current behavior). 1. If a custom file exists under `./data/{filename}`, load that. 1. If no custom file exists, load the default file from `./agonyforge-mud-demo/src/main/resources`. 1. Add the custom files to `.gitignore`.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
agony-forge/agonyforge#440
No description provided.