@echo off
echo ==========================================
echo   Bubble Tycoon Installer
echo ==========================================
echo.

set INSTALL_DIR=%CD%\Bubble Tycoon
set S3_URL=https://bubble-tycoon-updates.s3.amazonaws.com

echo Installing to: %INSTALL_DIR%
echo.

if not exist "%INSTALL_DIR%" mkdir "%INSTALL_DIR%"

echo Downloading Bubble Tycoon...
powershell -Command "Invoke-WebRequest -UseBasicParsing -Uri '%S3_URL%/Bubble Tycoon.exe' -OutFile '%INSTALL_DIR%\Bubble Tycoon.exe'"
if errorlevel 1 (
    echo Failed to download Bubble Tycoon.exe
    pause
    exit /b 1
)

echo Downloading updater...
powershell -Command "Invoke-WebRequest -UseBasicParsing -Uri '%S3_URL%/updater.exe' -OutFile '%INSTALL_DIR%\updater.exe'"
if errorlevel 1 (
    echo Failed to download updater.exe
    pause
    exit /b 1
)

echo Downloading version info...
powershell -Command "Invoke-WebRequest -UseBasicParsing -Uri '%S3_URL%/version.txt' -OutFile '%INSTALL_DIR%\version.txt'"

echo.
echo Creating desktop shortcut...
powershell -Command "$ws = New-Object -ComObject WScript.Shell; $s = $ws.CreateShortcut([Environment]::GetFolderPath('Desktop') + '\Bubble Tycoon.lnk'); $s.TargetPath = '%INSTALL_DIR%\Bubble Tycoon.exe'; $s.WorkingDirectory = '%INSTALL_DIR%'; $s.Save()"

echo.
echo ==========================================
echo   Installation complete!
echo   Bubble Tycoon is in: %INSTALL_DIR%
echo   A shortcut has been added to your desktop.
echo ==========================================
echo.
pause
