# V Rising — panel-native dedicated server module (Wine).
#
# Windows-only dedicated server. Same pattern as Empyrion:
# Debian + Wine + Xvfb + tini, SteamCMD with platform:windows.
#
# Reference: https://github.com/StunlockStudios/vrising-dedicated-server-instructions
# CLI/env-var flags override JSON, so the panel ships its config via env →
# entrypoint flags rather than rewriting ServerHostSettings.json. Avoids
# the per-boot JSON-rewrite race that bit ARK SA's INI flow.

id: v-rising
name: "V Rising"
version: 0.2.0
authors:
  - panel contributors

supported_modes:
  - docker

runtime:
  docker:
    image: panel-v-rising: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: "Settings/ServerHostSettings.json + Saves/"
      - name: "Game Files"
        path: /game
        hint: "Server binaries"
    env:
      # ---- Host settings (ServerHostSettings.json equivalents) ----
      SERVER_NAME: "panel V Rising"
      SERVER_DESCRIPTION: "A V Rising server hosted by panel."
      SERVER_PASSWORD: ""           # blank = open server
      MAX_PLAYERS: "40"
      MAX_ADMINS: "4"
      SAVE_NAME: "panel"
      LIST_ON_STEAM: "true"
      LIST_ON_EOS: "true"
      SECURE: "true"                # VAC
      SERVER_FPS: "30"
      LOWER_FPS_WHEN_EMPTY: "true"
      # ---- Game-rule presets (set GAME_SETTINGS_PRESET to "" if you
      #      want to edit individual rules in ServerGameSettings.json
      #      manually — otherwise the preset wins silently) ----
      GAME_SETTINGS_PRESET: ""        # e.g. StandardPvP, StandardPvE, Duo_PvP, Solo_PvP, HardcorePvP
      GAME_DIFFICULTY_PRESET: ""      # e.g. (engine accepts files in StreamingAssets/GameSettingPresets/)
      # ---- Port mappings (mirrored by the agent's port allocator) ----
      GAME_PORT: "9876"
      QUERY_PORT: "9877"
      # ---- RCON (off by default — turn on per-instance once you need it) ----
      RCON_ENABLED: "false"
      RCON_PORT: "25575"
      RCON_PASSWORD: ""
      # ---- Legacy panel default; entrypoint reads the new keys above ----
      ADMIN_PASSWORD: "changeme"
    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:
  # `env:` tells the agent which container env var to set with the
  # allocated host port. The entrypoint uses these to assemble VRising's
  # `-gamePort` / `-queryPort` launch flags so multiple instances on the
  # same agent get distinct, non-colliding sockets.
  - { name: game,  proto: udp, default: 9876,  required: true, env: GAME_PORT }
  - { name: query, proto: udp, default: 9877,  required: true, env: QUERY_PORT }

resources:
  min_ram_mb: 6144
  recommended_ram_mb: 12288

# What gets archived when an operator clicks Back-up-now. The save
# directory contains the world (Saves/) and the per-server settings
# (Settings/). The entrypoint regenerates Settings/ from defaults if
# absent, so technically only Saves/ has to be preserved — but operators
# expect their custom server name + password to come back too.
backup:
  include:
    - "Saves"        # world data
    - "Settings"     # ServerHostSettings.json + ServerGameSettings.json
  exclude:
    - "logs"         # rotates with operator + entrypoint
  notes: "World saves + settings (~MB-scale). Game install regenerates from SteamCMD next start."
# Log-derived player events. Regexes converted from CubeCoders'
# AMPTemplates (v-rising.kvp) — .NET (?<n>) syntax -> Go (?P<n>).
# Sourced-from-template; not yet exercised against a live client.
events:
  join:
    pattern: 'User ''\{Steam (?P<id>\d+)\}'' ''\d+'', approvedUserIndex: \d+, Character: ''(?P<name>[^'']*)'' connected'
    kind: join
  leave:
    pattern: 'User ''\{Steam (?P<id>\d+)\}'' disconnected\. approvedUserIndex: \d+ Reason: (?P<reason>.+)$'
    kind: leave


update_providers:
  - id: stable
    kind: steamcmd
    app_id: "1829350"
    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: '/\[Server\]\s*Startup Completed/i'
appearance:
  emoji: "🧛"
  grad: "linear-gradient(135deg,#3b0a0a,#991b1b)"
  art: "/game-art/v-rising.jpg"
  steam: "1604030"
