# Satisfactory — panel-native dedicated server module.
#
# Native Linux binary from SteamCMD app 1690800. Admin is via Coffee Stain's
# HTTPS API on the game port (7777/tcp — separate from the UDP game traffic).
# No traditional RCON in v1; users admin via the in-game UI + API tokens.
#
# Reference: https://github.com/CubeCoders/AMPTemplates (SatisfactoryLinux.kvp)

id: satisfactory
name: "Satisfactory"
version: 0.1.0
authors:
  - panel contributors

supported_modes:
  - docker

runtime:
  docker:
    image: panel-satisfactory: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: "SaveGames/ + Engine/ + Game.ini"
      - name: "Game Files"
        path: /game
        hint: "Server binaries"
    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" }
    # Port env vars MUST be pre-declared here — the agent's ResolveDocker
    # only lets ConfigValues override keys that already exist in this map,
    # so the allocator's per-instance ports would otherwise be dropped.
    env:
      GAME_PORT: "7777"
      RELIABLE_PORT: "8888"

# Satisfactory 1.0+ port model: ONE game port (UDP game traffic + the
# HTTPS admin API on the same number over TCP — the server binds both
# itself under host networking) plus a TCP "reliable" messaging port.
# The pre-1.0 beacon/query ports no longer exist.
ports:
  - { name: game,     proto: udp, default: 7777, required: true, env: GAME_PORT }
  - { name: reliable, proto: tcp, default: 8888, required: true, env: RELIABLE_PORT }

resources:
  min_ram_mb: 6144
  recommended_ram_mb: 12288
# Log-derived player events. Regexes converted from CubeCoders'
# AMPTemplates (satisfactory.kvp) — .NET (?<n>) syntax -> Go (?P<n>).
# Sourced-from-template; not yet exercised against a live client.
events:
  join:
    pattern: 'LogNet: Login request: \?ClientIdentity=.+\?EntryTicket=.+?EncryptionToken=.+\?Name=(?P<name>.+?) userId: .+\(ForeignId=\[Type=.+ Handle=.+ RepData=\[(?P<id>.+)\]\) platform: '
    kind: join
  leave:
    pattern: 'LogNet: UChannel::Close: Sending CloseBunch\..+\[UNetConnection\] RemoteAddr: .+, Name: .+, Driver: .+, IsServer: YES, PC: .+, Owner: .+, UniqueId: .+\(ForeignId=\[Type=.+ Handle=.+ RepData=\[(?P<id>.+)\]\)'
    kind: leave


update_providers:
  - id: stable
    kind: steamcmd
    app_id: "1690800"
    install_path: /game
  - id: experimental
    kind: steamcmd
    app_id: "1690800"
    beta: experimental
    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.
# Verified against a real boot 2026-07-14 (v1.2.0-CL-495413): the net
# driver line is when the server becomes joinable (~5s after start).
# "Server startup time elapsed" follows at ~30s once level load settles.
ready_pattern: '/IpNetDriver listening on port \d+|Server startup time elapsed/i'
appearance:
  emoji: "🏭"
  grad: "linear-gradient(135deg,#d97706,#fbbf24)"
  art: "/game-art/satisfactory.jpg"
  steam: "526870"
