@echo off
title AiRPG Launcher
color 0A

echo ============================================
echo           AiRPG - Text Adventure
echo ============================================
echo.

REM Check if node_modules exists
if not exist "node_modules" (
    echo [INSTALL] First-time setup detected...
    echo.
    echo Installing server dependencies...
    call npm install
    if errorlevel 1 (
        echo.
        echo [ERROR] Failed to install server dependencies!
        echo Please make sure Node.js is installed.
        pause
        exit /b 1
    )
    
    echo.
    echo Installing client dependencies...
    cd client
    call npm install
    if errorlevel 1 (
        echo.
        echo [ERROR] Failed to install client dependencies!
        cd ..
        pause
        exit /b 1
    )
    cd ..
    
    echo.
    echo [SUCCESS] Installation complete!
    echo.
)

echo [INFO] Starting AiRPG...
echo.
echo Make sure LM Studio is running with a model loaded!
echo.

start "" npm start
exit
