#!/bin/bash
# ============================================================
#  UT99 Custom Skins — macOS Client Installer
# ============================================================
#  Downloads and installs all custom skins from the LAN file
#  server so they appear in Player Setup before joining.
#
#  Usage:  bash client-install-mac.sh
# ============================================================

set -euo pipefail

UT=~/Library/Application\ Support/Unreal\ Tournament
CADDY="http://10.0.0.180/ut99/client-install/raw"

# Verify UT99 install exists
if [[ ! -d "$UT/System" ]]; then
  echo "ERROR: UT99 not found at $UT"
  echo "Edit the UT variable at the top of this script if your install path differs."
  exit 1
fi

echo "=== UT99 Custom Skins Installer ==="
echo "Install path: $UT"
echo ""

# --- System files (.u, .int) ---
echo "--- Downloading System files (.u, .int) ---"
cd "$UT/System"

# Mr. Burns
curl -fSL -O "$CADDY/burns.u" -O "$CADDY/burns.int" -O "$CADDY/burnskins.int" \
  -O "$CADDY/burnsvoice.u" -O "$CADDY/burnsvoice.int"

# Bender
curl -fSL -O "$CADDY/Bender.u" -O "$CADDY/Bender.int" -O "$CADDY/BenderSkins.int" \
  -O "$CADDY/Bendervoice.u" -O "$CADDY/Bendervoice.int"

# Homer
curl -fSL -O "$CADDY/Homer.u" -O "$CADDY/Homer.int" \
  -O "$CADDY/HomerSkins.int" -O "$CADDY/HomerJayPackage.u" -O "$CADDY/HomerJayPackage.int"

# Spawn
curl -fSL -O "$CADDY/alcspawn.u" -O "$CADDY/alcspawn.int" -O "$CADDY/alcspawnSkins.int"

# Robocop
curl -fSL -O "$CADDY/rbcp.u" -O "$CADDY/rbcp.int" -O "$CADDY/rbcpskins.int"

# ED-209
curl -fSL -O "$CADDY/e209.u" -O "$CADDY/e209.int" -O "$CADDY/e209Skins.int"

# Magneto
curl -fSL -O "$CADDY/magn.u" -O "$CADDY/magn.int" -O "$CADDY/magnSkins.int"

# Wolverine
curl -fSL -O "$CADDY/Wolverine.u" -O "$CADDY/Wolverine.int" -O "$CADDY/Wolverineskins.int"

# Trinity
curl -fSL -O "$CADDY/trinity.u" -O "$CADDY/trinity.int" -O "$CADDY/trinityskins.int"

# Han Solo
curl -fSL -O "$CADDY/hansolo.u" -O "$CADDY/hansolo.int" -O "$CADDY/hansoloskins.int"

# Shibuki
curl -fSL -O "$CADDY/Shibuki.u" -O "$CADDY/Shibuki.int" -O "$CADDY/ShibukiSkins.int"

# Darth Vader
curl -fSL -O "$CADDY/vadr.u" -O "$CADDY/vadr.int" -O "$CADDY/vadrSkins.int"

echo ""

# --- Textures (.utx) — may need sudo ---
echo "--- Downloading Textures (.utx) — may prompt for password ---"
cd "$UT/Textures"

sudo curl -fSL \
  -O "$CADDY/burnskins.utx" \
  -O "$CADDY/BenderSkins.utx" \
  -O "$CADDY/HomerSkins.utx" \
  -O "$CADDY/alcspawnSkins.utx" \
  -O "$CADDY/rbcpskins.utx" \
  -O "$CADDY/e209Skins.utx" \
  -O "$CADDY/magnSkins.utx" \
  -O "$CADDY/Wolverineskins.utx" \
  -O "$CADDY/trinityskins.utx" \
  -O "$CADDY/hansoloskins.utx" \
  -O "$CADDY/ShibukiSkins.utx" \
  -O "$CADDY/vadrSkins.utx"

echo ""
echo "=== Done! 13 custom skins installed ==="
echo "Mr. Burns, Bender, Homer, Spawn, Robocop, ED-209,"
echo "Magneto, Wolverine, Trinity, Han Solo, Shibuki, Darth Vader"
echo ""
echo "Launch UT99 and check Player Setup to select a skin."
