aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-06-14 22:42:27 -0400
committerhistoria <[not public]>2026-06-14 22:42:27 -0400
commiteb37418b933d7bd996658209e867ea3f3e3806ec (patch)
tree9988922fe95300a83177b76bcdfb9420c240c655
parenta6f0ad79e2e3a5b7c11eef1ffc3233f3a2766f77 (diff)
downloadthehouseoficarus-eb37418b933d7bd996658209e867ea3f3e3806ec.tar.gz
feat: default config file generated if doesn't exist
-rw-r--r--cmd/mud/main.go5
-rw-r--r--config.yaml3
-rw-r--r--internal/config/config.go9
3 files changed, 15 insertions, 2 deletions
diff --git a/cmd/mud/main.go b/cmd/mud/main.go
index cc8c96b..6940cd6 100644
--- a/cmd/mud/main.go
+++ b/cmd/mud/main.go
@@ -26,7 +26,10 @@ func main() {
cfg, err := config.Load(*configPath)
if err != nil {
if os.IsNotExist(err) {
- log.Printf("config file %s not found, using defaults (telnet :4000)", *configPath)
+ log.Printf("config file %s not found, creating with defaults", *configPath)
+ if err := config.SaveDefault(*configPath); err != nil {
+ log.Fatalf("failed to create config: %v", err)
+ }
cfg = config.Default()
} else {
log.Fatalf("failed to load config: %v", err)
diff --git a/config.yaml b/config.yaml
index 448aa68..cf54642 100644
--- a/config.yaml
+++ b/config.yaml
@@ -1,5 +1,6 @@
game:
- maxWidth: 70 # maximum width for room description text when displayed alongside the mini-map
+ tick_length: 600 # milliseconds per game tick (min 50)
+ game_speed: 1.0 # multiplier for all tick timers (default 1.0)
telnet:
enabled: true
diff --git a/internal/config/config.go b/internal/config/config.go
index d397fae..a86689e 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -67,3 +67,12 @@ func Load(path string) (*Config, error) {
}
return cfg, nil
}
+
+func SaveDefault(path string) error {
+ cfg := Default()
+ data, err := yaml.Marshal(cfg)
+ if err != nil {
+ return err
+ }
+ return os.WriteFile(path, data, 0644)
+}