# Sons Of The Forest — panel-native dedicated server module (Wine).
#
# Windows-only dedicated server. Same pattern as V Rising + Empyrion:
# Debian + Wine + Xvfb + tini, SteamCMD with platform:windows.
#
# Reference: https://github.com/CubeCoders/AMPTemplates (SonsOfTheForest.kvp)

id: sons-of-the-forest
name: "Sons Of The Forest"
version: 0.1.0
authors:
  - panel contributors

supported_modes:
  - docker

runtime:
  docker:
    image: panel-sons-of-the-forest:latest
    # Host networking -- container shares the host net namespace, so
    # any port the game/mod binds is directly on the LAN. AMP-like
    # model. Multi-instance safety comes from env-driven per-instance
    # ports (panel allocator + env: mapping on each ports entry).
    network_mode: host
    browseable_root: /game-saves
    browseable_roots:
      - name: "Saves & Configs"
        path: /game-saves
        hint: "dedicatedserver.cfg + Saves/"
      - name: "Game Files"
        path: /game
        hint: "Server binaries"
    env:
      SERVER_NAME: "panel Sons Of The Forest"
      MAX_PLAYERS: "8"
      SERVER_PASSWORD: ""
      # Pre-declared so allocator-derived ports survive resolve.go's filter.
      GAME_PORT: "8766"
      QUERY_PORT: "27016"
      BLOBSYNC_PORT: "9700"
    volumes:
      - { type: volume, name: "panel-$INSTANCE_ID-saves", container: "/game-saves" }
      - { type: volume, name: "panel-$INSTANCE_ID-game",  container: "/game" }
      - { target: "$DATA_PATH/logs", container: "/game-saves/logs" }

ports:
  - { name: game,  proto: udp, default: 8766, required: true, env: GAME_PORT }
  - { name: query, proto: udp, default: 27016, required: true, env: QUERY_PORT }
# NOTE: name stays "join" (SOTF calls it BlobSync) — the running prod
# controller's in-memory manifest allocates ports by this name, and the
# agent maps allocation→env by matching the same name. Renaming it only
# works after a controller restart; the env var is what the game sees.
  - { name: join, proto: udp, default: 9700, required: true, env: BLOBSYNC_PORT }

resources:
  min_ram_mb: 8192
  recommended_ram_mb: 16384

# No rcon: AMP's kvp claims AdminMethod=STDIO, but live smoke test
# (2026-07-14) showed the server ignores stdin entirely — `save`, `help`
# and `stop` all produced zero reaction under wine+xvfb-run. Admin is
# in-game only (like empyrion). Graceful stop = SIGTERM via entrypoint trap.
# Log-derived player events. Regexes converted from CubeCoders'
# AMPTemplates (sons-of-the-forest.kvp) — .NET (?<n>) syntax -> Go (?P<n>).
# Sourced-from-template; not yet exercised against a live client.
events:
  join:
    pattern: 'Steam auth successful for client \d+ with steam id (?P<id>\S+?)[.,] username (?P<name>.+)$'
    kind: join
  leave:
    pattern: 'Unregistering client \d+ with steam id (?P<id>\S+?)[.,] username (?P<name>.+)$'
    kind: leave


update_providers:
  - id: stable
    kind: steamcmd
    app_id: "2465200"
    platform: windows
    install_path: /game

# --- Manifest-driven UI metadata (WI-07) --------------------------
# Consumed by the CONTROLLER/dashboard only (the controller loads its
# own ./modules copy at startup); the agent ignores these at runtime.
# ready_pattern is a JavaScript regex (slash-delimited when it needs
# flags) moved verbatim from the dashboard's READY_PATTERNS map.
ready_pattern: '/Dedicated server loaded|\[Self-Tests\] Please restart the server/i'
appearance:
  emoji: "🌲"
  grad: "linear-gradient(135deg,#14532d,#4d7c0f)"
  art: "/game-art/sons-of-the-forest.jpg"
  steam: "1326470"
