# RuneScape: Dragonwilds dedicated server module.
#
# Native-Linux UE5 binary via SteamCMD app 4019830 (free-to-download tool;
# Jagex made the dedicated server public on Steam in 2026 with Update 0.11).
# Multi-depot app (Windows 4019831 + Linux 3501791) — so `platform: linux`
# is required, same class of issue as Palworld on Docker Desktop WSL2.
#
# No native RCON protocol — Jagex hasn't documented one. The admin console
# is in-process only. Panel surfaces the UE log in the Console tab; Players
# tab stays empty until Jagex ships an admin protocol (or we wire a log-tail
# based join/leave regex when we observe real player traffic).
#
# References:
#   https://dragonwilds.runescape.com/news/how-to-dedicated-servers
#   https://dragonwilds.runescape.wiki/w/Dedicated_Servers/Linux

id: dragonwilds
name: "RuneScape: Dragonwilds"
version: 0.1.0
authors:
  - panel contributors

supported_modes:
  - docker

runtime:
  docker:
    image: panel-dragonwilds: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: "RSDragonwilds/Saved/Config/LinuxServer/DedicatedServer.ini + world saves"
      - name: "Game Files"
        path: /game
        hint: "RSDragonwildsServer.sh, RSDragonwilds/Binaries/Linux/"
    env:
      SERVER_NAME: "panel Dragonwilds"
      SERVER_PORT: "7777"
      # Operators MUST supply these before the server will accept clients.
      # First boot generates a stub DedicatedServer.ini if these are empty;
      # the server still launches but refuses logins until populated.
      OWNER_ID: ""
      ADMIN_PASSWORD: ""
      DEFAULT_WORLD_NAME: "Gielinor"
    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" }

# Dragonwilds only documents one port: 7777/udp (game). No Steam query
# or RCON ports in the public docs. Additional server instances on the
# same host are expected to increment the port (7778, 7779, ...).
ports:
  - { name: game, proto: udp, default: 7777, required: true, env: SERVER_PORT }

resources:
  min_ram_mb: 4096
  recommended_ram_mb: 8192
# Log-derived player events. Regexes converted from CubeCoders'
# AMPTemplates (runescape-dragonwilds.kvp) — .NET (?<n>) syntax -> Go (?P<n>).
# Sourced-from-template; not yet exercised against a live client.
events:
  join:
    pattern: 'LogDomMatcherSession:\s+Player\s+ADDED\s+to\s+session\s+\[[^\]]+\]-\[(?P<name>[^\]]+)\]$'
    kind: join
  leave:
    pattern: 'LogDomMatcherSession:\s+Player\s+Removed\s+from\s+session\s+\[[^\]]+\]-\[(?P<name>[^\]]+)\]$'
    kind: leave
  chat:
    pattern: '^\[[\d\.]+-[\d\.:]+\]\[[\d ]+\]LogChat: (?P<name>.+?): (?P<msg>.*)$'
    kind: chat


update_providers:
  - id: stable
    kind: steamcmd
    app_id: "4019830"
    # Multi-depot — explicit platform required or SteamCMD auto-detect
    # mis-fires on Docker Desktop WSL2 with "Missing configuration".
    platform: linux
    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: '/LogInit: Display: Engine is initialized|LogGlobalStatus:\s*UEngine::LoadMap\s+Load\s+map\s+complete|LogLoad: Game Engine Initialized|LogNet: GameNetDriver/i'
appearance:
  emoji: "🐉"
  grad: "linear-gradient(135deg,#4c1d95,#f59e0b)"
  art: "/game-art/dragonwilds.jpg"
  steam: "1374490"
