@echo off
chcp 65001 >nul
setlocal
echo [LoL Pacemaker] Preparing the in-game overlay...
echo   - LoL settings: Video - Window Mode = Borderless (full screen hides the HUD)
echo   - The HUD waits in the lobby and turns LIVE once the game starts.
echo   - Keep only this one window open.
set "PY_CMD="
python -c "import sys; sys.exit(0 if sys.version_info >= (3, 9) else 1)" >nul 2>nul && set "PY_CMD=python"
if not defined PY_CMD (py -3 -c "import sys; sys.exit(0 if sys.version_info >= (3, 9) else 1)" >nul 2>nul && set "PY_CMD=py -3")
for %%V in (314 313 312 311 310 39) do if not defined PY_CMD if exist "%LocalAppData%\Programs\Python\Python%%V\python.exe" set "PY_CMD="%LocalAppData%\Programs\Python\Python%%V\python.exe""
for %%V in (314 313 312 311 310 39) do if not defined PY_CMD if exist "%ProgramFiles%\Python%%V\python.exe" set "PY_CMD="%ProgramFiles%\Python%%V\python.exe""
if not defined PY_CMD (
  echo Python 3.9+ not found. Trying to install Python 3.12 with winget...
  winget install -e --id Python.Python.3.12 --silent --accept-package-agreements --accept-source-agreements >nul 2>nul
)
if not defined PY_CMD (
  python -c "import sys; sys.exit(0 if sys.version_info >= (3, 9) else 1)" >nul 2>nul && set "PY_CMD=python"
  if not defined PY_CMD (py -3 -c "import sys; sys.exit(0 if sys.version_info >= (3, 9) else 1)" >nul 2>nul && set "PY_CMD=py -3")
  for %%V in (314 313 312 311 310 39) do if not defined PY_CMD if exist "%LocalAppData%\Programs\Python\Python%%V\python.exe" set "PY_CMD="%LocalAppData%\Programs\Python\Python%%V\python.exe""
  for %%V in (314 313 312 311 310 39) do if not defined PY_CMD if exist "%ProgramFiles%\Python%%V\python.exe" set "PY_CMD="%ProgramFiles%\Python%%V\python.exe""
)
if not defined PY_CMD (
  echo Python 3.9 or newer is required. Opening the download page.
  start https://www.python.org/downloads/windows/
  pause
  exit /b 1
)
set "APP_DIR=%TEMP%\lol-pace-client"
if not exist "%APP_DIR%\client" mkdir "%APP_DIR%\client"
curl.exe -fsSL "https://jjm.eta.pyhub.kr/download/bridge.py" -o "%APP_DIR%\client\bridge.py"
if errorlevel 1 (
  powershell -NoProfile -Command "Invoke-WebRequest -Uri 'https://jjm.eta.pyhub.kr/download/bridge.py' -OutFile '%APP_DIR%\client\bridge.py'"
)
pushd "%APP_DIR%"
echo [LoL Pacemaker] Starting the always-on-top HUD. Close this window to stop.
%PY_CMD% -m client.bridge --server "https://jjm.eta.pyhub.kr" --insecure-local --overlay --launch-popup --repin-sec 3 --save-match --record "%APP_DIR%\records"
popd
pause
