# Enshrouded — panel-native dedicated server module.
#
# The dedicated server is WINDOWS-ONLY (SteamCMD app 2278520 — no Linux
# depot; a plain Linux install fails with "Invalid platform", verified
# 2026-07-14). An earlier scaffold claimed "native Linux" — wrong. AMP runs
# the exe under Proton GE; we run it under Wine + Xvfb like windrose/empyrion
# (update provider `platform: windows`).
# No traditional RCON — server console is stdin-only.
#
# Reference: https://github.com/CubeCoders/AMPTemplates (enshrouded.kvp)

id: enshrouded
name: "Enshrouded"
version: 0.1.0
authors:
  - panel contributors

supported_modes:
  - docker

runtime:
  docker:
    image: panel-enshrouded: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: "enshrouded_server.json + savegame/"
      - name: "Game Files"
        path: /game
        hint: "Server binaries"
    env:
      SERVER_NAME: "panel Enshrouded"
      SERVER_PASSWORD: "letmein"
      MAX_PLAYERS: "16"
      # Pre-declared so the agent's resolve.go filter lets the
      # panel-allocated port flow through to the container env (same
      # pattern as soulmask). Modern Enshrouded (post "Melodies of the
      # Mire", 2024) has a SINGLE UDP port — queryPort in
      # enshrouded_server.json; gamePort was removed from the config.
      QUERY_PORT: "15637"
    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:
  # Single UDP port — current Enshrouded merged game+query into one
  # "queryPort" (AMP's enshroudedports.json declares only QueryPort).
  - { name: query, proto: udp, default: 15637, required: true, env: QUERY_PORT }

resources:
  min_ram_mb: 8192
  recommended_ram_mb: 16384      # Enshrouded is memory-hungry

rcon:
  # Enshrouded admin is stdin-only (no network RCON in-game).
  adapter: stdio
  commands:
    save: "save"
    shutdown: "shutdown"
# Log-derived player events. Regexes converted from CubeCoders'
# AMPTemplates (enshrouded.kvp) — .NET (?<n>) syntax -> Go (?P<n>).
# Sourced-from-template; not yet exercised against a live client.
events:
  join:
    pattern: '\[server\] Player ''(?P<name>[^'']+)'' logged in with Permissions:'
    kind: join
  leave:
    pattern: '\[server\] Remove Player ''(?P<name>[^'']+)''$'
    kind: leave


update_providers:
  - id: stable
    kind: steamcmd
    app_id: "2278520"
    install_path: /game
    platform: windows          # server is Windows-only; no Linux depot

# --- 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.
# AMP's Console.AppReadyRegex: ^.*\[Session\] 'HostOnline' \(up\)!$
# VERIFIED live 2026-07-14 (agent01 smoke test): the exact ready line is
#   [Session] 'HostOnline' (up)!
# Install 8.3 GB on disk; boot start->HostOnline ~25 s (warm Wine prefix);
# external A2S_INFO on the single UDP port answered off-host.
ready_pattern: "/\\[Session\\] 'HostOnline' \\(up\\)!/i"
appearance:
  emoji: "🌫️"
  grad: "linear-gradient(135deg,#4a2c2a,#a45e4a)"
  art: "/game-art/enshrouded.jpg"
  steam: "1203620"
