# ATHELGARD — Windows install, one line, no Git Bash required. # # irm https://www.bountywarz.com/install.ps1 | iex # # install.sh assumes a POSIX shell, which on Windows means the player must already have installed # Git for Windows before they can run the thing that installs Git for Windows. This is the same # install expressed in the shell every Windows machine already has, and it provisions its own # prerequisites through winget rather than sending a beginner to two download pages. # # It also drops a desktop shortcut, because "open a terminal and type athelgard" is the last cliff # for someone who has never opened a terminal: double-clicking the owl opens straight into her. # # Override with $env:ATHELGARD_REPO / $env:ATHELGARD_DIR / $env:ATHELGARD_BRANCH. $ErrorActionPreference = 'Stop' $Repo = if ($env:ATHELGARD_REPO) { $env:ATHELGARD_REPO } else { 'https://github.com/NyxSpecter4/bountywarz.git' } $Dir = if ($env:ATHELGARD_DIR) { $env:ATHELGARD_DIR } else { Join-Path $HOME 'bountywarz' } $Branch = if ($env:ATHELGARD_BRANCH) { $env:ATHELGARD_BRANCH } else { 'main' } function Say ($m) { Write-Host " $m" } function Die ($m) { Write-Host ""; Write-Host " install failed: $m" -ForegroundColor Red; Write-Host ""; exit 1 } function Have ($c) { [bool](Get-Command $c -ErrorAction SilentlyContinue) } Write-Host "" Write-Host " ATHELGARD — installing into $Dir" Write-Host "" # winget ships with Windows 10 1809+ and 11. Where it is missing we cannot silently provision, so # name the two downloads instead of failing with a bare "not found". function Ensure ($cmd, $wingetId, $human) { if (Have $cmd) { return } if (-not (Have 'winget')) { Die "$human is not installed, and winget is unavailable to install it for you. Install $human, then re-run this line." } Say "$human is missing — installing it for you (this takes a minute)" winget install --id $wingetId --silent --accept-source-agreements --accept-package-agreements | Out-Null # winget writes PATH into the registry; this session will not see it without a reload. $env:Path = [Environment]::GetEnvironmentVariable('Path', 'Machine') + ';' + [Environment]::GetEnvironmentVariable('Path', 'User') if (-not (Have $cmd)) { Die "$human was installed but is not on PATH yet. Close this window, open a new PowerShell, and re-run this line." } } Ensure 'git' 'Git.Git' 'Git' Ensure 'node' 'OpenJS.NodeJS.LTS' 'Node.js' $major = [int](node -p "parseInt(process.versions.node)") if ($major -lt 20) { Die "node $(node -v) is too old — Athelgard needs 20 or newer (22 recommended)." } if (Test-Path (Join-Path $Dir '.git')) { Say "found an existing copy — updating it rather than cloning a second one" git -C $Dir fetch origin --quiet # Never move someone's branch out from under them; npm rewrites package-lock.json on every # install, so it must not count as their work or re-runs would freeze at the first version. $dirty = git -C $Dir status --porcelain -- ':(exclude)package-lock.json' if ($dirty) { Say "you have uncommitted changes — leaving your branch alone" } else { git -C $Dir checkout $Branch --quiet git -C $Dir pull --ff-only --quiet } } else { Say "cloning $Repo" git clone --quiet $Repo $Dir git -C $Dir checkout $Branch --quiet } Set-Location $Dir Say "installing dependencies (this takes a minute)" npm.cmd install --silent --no-audit --no-fund | Out-Null Say "putting 'athelgard' on your PATH" npm.cmd link --silent 2>$null | Out-Null if (-not (Have 'athelgard')) { npm.cmd install -g . --silent 2>$null | Out-Null } # The shortcut is the whole point of this file: someone who has never opened a terminal gets an # icon that opens one already inside the game. $lnk = Join-Path ([Environment]::GetFolderPath('Desktop')) 'Athelgard.lnk' try { $shell = New-Object -ComObject WScript.Shell $s = $shell.CreateShortcut($lnk) $s.TargetPath = 'powershell.exe' $s.Arguments = "-NoExit -Command `"node '$Dir\bin\athelgard-cli'`"" $s.WorkingDirectory = $Dir $icon = Join-Path $Dir 'owl-favicon-1024.ico' if (Test-Path $icon) { $s.IconLocation = $icon } $s.Description = 'Athelgard — learn to hunt bugs in a safe range' $s.Save() Say "put an Athelgard icon on your desktop — double-click it to play" } catch { Say "could not create the desktop shortcut; run her from a terminal instead" } Write-Host "" node bin/athelgard-cli hunt 2>$null | Select-Object -First 24 Write-Host "" if (Have 'athelgard') { Write-Host " Installed. Start here:" Write-Host "" Write-Host " athelgard" Write-Host "" Write-Host " She will introduce herself, take your callsign and open your first range." } else { Write-Host " Installed, but the bare 'athelgard' command does not resolve in this window yet." Write-Host " Double-click the Athelgard icon on your desktop, or run her directly:" Write-Host "" Write-Host " node $Dir\bin\athelgard-cli" } Write-Host "" Write-Host " Or play with no install at all: https://www.bountywarz.com/play" Write-Host ""