# Soulmask — panel-native dedicated server module.
#
# Native Linux dedicated server. The Linux server ships under SteamCMD app
# 3017300 (Steam labels it "Soulmask Dedicated Server", and it is the app the
# community jsknnr/soulmask-dedicated-server image installs). It produces a
# native ELF: WS/Binaries/Linux/WSServer-Linux-Shipping + WSServer.sh.
#
# NOTE: app 3017310 is the WINDOWS-only build ("Soulmask Dedicated Server For
# Windows" — verified: its depot has no Linux binaries, only WSServer.exe /
# Win64). Do NOT install it on Linux; it never boots. An earlier version of
# this module led with 3017310 and treated 3017300 as "content", which meant
# the server never got a runnable binary. Fixed 2026-07-08: 3017300 only.
#
# Reference: https://github.com/jsknnr/soulmask-dedicated-server (native Linux,
# no Proton) — installs STEAM_APP_ID 3017300, launches WSServer.sh.

id: soulmask
name: "Soulmask"
version: 0.1.0
authors:
  - panel contributors

supported_modes:
  - docker

runtime:
  docker:
    image: panel-soulmask: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: "WS/Saved/ + GameUserSettings.ini"
      - name: "Game Files"
        path: /game
        hint: "Server binaries, WS/Content/"
    env:
      SERVER_NAME: "panel Soulmask"
      MAX_PLAYERS: "30"
      ADMIN_PASSWORD: "changeme"
      # Pre-declared so the agent's resolve.go filter lets panel-allocated
      # ports flow through to the container env. The entrypoint passes these
      # as -Port / -QueryPort; without them the server binds the hardcoded
      # 8777/27015 and ignores the panel allocation (breaks multi-instance +
      # the opnfwd forward). Defaults match the port defaults.
      GAME_PORT: "8777"
      QUERY_PORT: "27015"
      # Server-level settings passed as launch args by the entrypoint.
      GAME_MODE: "pve"          # pve | pvp
      SERVER_PASSWORD: ""       # join password (-PSW); empty = open
      SAVING: "600"             # world save interval (seconds)
      BACKUP: "900"             # backup interval (seconds)
    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" }
      # Panel-rendered GameXishu.json (deep gameplay settings, all 3 sections).
      # The entrypoint copies this into WS/Saved/GameplaySettings/ where the
      # server reads it on boot (confirmed: logGameXishu LoadFromJsonFile
      # Success). read_only so the template stays authoritative.
      - { target: "$DATA_PATH/GameXishu.json.rendered", container: "/game-saves/GameXishu.json.rendered", read_only: true }

ports:
  - { name: game,   proto: udp, default: 8777,  required: true,  env: GAME_PORT }
  - { name: query,  proto: udp, default: 27015, required: true,  env: QUERY_PORT }
  - { name: admin,  proto: tcp, default: 8888,  internal: true }   # REST admin

resources:
  min_ram_mb: 6144
  recommended_ram_mb: 12288
# Log-derived player events. Regexes converted from CubeCoders'
# AMPTemplates (soulmask.kvp) — .NET (?<n>) syntax -> Go (?P<n>).
# Sourced-from-template; not yet exercised against a live client.
events:
  join:
    pattern: 'logStoreGamemode: player ready\. Addr:.*?, Netuid:(?P<id>\d+), Name:(?P<name>.+)$'
    kind: join
  leave:
    pattern: 'logStoreGamemode: Display: player leave world\. (?P<id>\d+)$'
    kind: leave


update_providers:
  # 3017300 is the native Linux dedicated server (ELF WSServer-Linux-Shipping).
  # This single app is the complete install — NOT 3017310 (Windows-only).
  - id: stable
    kind: steamcmd
    app_id: "3017300"
    install_path: /game

# Deep gameplay settings (harvest/xp/decay/damage/consumption ratios) are
# rendered from config_values into GameXishu.json — the 276-key × 3-section
# file the server reads on boot. Same durable-render path 7DTD uses; gamehost
# routes soulmask settings-saves through config-render (DurableConfig=true).
config_files:
  - path: GameXishu.json.rendered
    format: json
    template: templates/GameXishu.json.tmpl

# --- 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: '/Starting up WSServer|Network connection saved/i'
appearance:
  emoji: "🗿"
  grad: "linear-gradient(135deg,#3a2416,#7a5230)"
  art: "/game-art/soulmask.jpg"
  steam: "2646460"
