@echo off
setlocal EnableExtensions

set "PROJECT_DIR=%~dp0.."
set "PACKAGE_DIR=%PROJECT_DIR%\Builds\WindowsDevelopment"
set "DEMO_EXE=%PACKAGE_DIR%\AgrarianGame.exe"
set "SERVER_ENDPOINT=play.agrariangame.com:7777"

if not "%~1"=="" (
  if /I not "%~1"=="--check-tools" (
    set "SERVER_ENDPOINT=%~1"
  )
)

if not exist "%DEMO_EXE%" (
  echo ERROR: Packaged demo executable not found: "%DEMO_EXE%"
  exit /b 2
)

if /I "%~1"=="--check-tools" (
  echo READY: packaged client exists for two-client connection smoke test.
  exit /b 0
)

echo Agrarian two-client connection smoke test
echo -----------------------------------------
echo Package: "%PACKAGE_DIR%"
echo Server: %SERVER_ENDPOINT%
echo.
echo Starting client A...
start "Agrarian Client A" "%DEMO_EXE%" %SERVER_ENDPOINT% -log -windowed -ResX=1280 -ResY=720
timeout /t 8 /nobreak >nul

echo Starting client B...
start "Agrarian Client B" "%DEMO_EXE%" %SERVER_ENDPOINT% -log -windowed -ResX=1280 -ResY=720

echo.
echo Confirm both clients reach Ground Zero, see matching time/weather, and
echo remain connected long enough to start the smoke test in:
echo Docs\Ops\MultiplayerLatencyTestPlan.md
echo.
exit /b 0
