#!/usr/bin/env bash
# Play (and record) one OpenRA arena game. Usage: run-match --a <player> --b <player> [--out DIR] [--game-id ID]
set -euo pipefail
if [ -z "${DISPLAY:-}" ]; then
  export DISPLAY=:99
  if ! pgrep -x Xvfb >/dev/null 2>&1; then
    Xvfb :99 -screen 0 1920x1080x24 -nolisten tcp >/tmp/xvfb.log 2>&1 &
    sleep 2
  fi
fi
export HOME="${HOME:-/tmp}"
[ -w "$HOME" ] || export HOME=/tmp
export DOTNET_CLI_HOME="$HOME"
cd /opt/decision-ra
exec /opt/decision-ra/.venv/bin/python -u -m arena.jetty_run "$@"
