policesquadquest/play.sh
type-two a9e53ccc49 Hook up the engine's new title screen as the front door
MRPGI (fa7fa10) grew a title screen / world picker: point --game at a
folder of game folders and you get the shelf. cases/collection.json names
it POLICE SQUAD QUEST, and a bare ./play.sh now opens it instead of the
shell menu — arrow keys, Enter to play, Esc backs out of a case to the
shelf. ./play.sh <number> still jumps straight in.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-26 21:50:43 +10:00

42 lines
1.3 KiB
Bash
Executable File

#!/bin/sh
# Play a case: ./play.sh list them and pick
# ./play.sh 07 by number
# ./play.sh cases/case-07-from-the-files
# ponytail: MRPGI lives next door; no vendoring, no submodule.
set -e
ENGINE="${MRPGI:-$HOME/Documents/MRPGI}"
cd "$(dirname "$0")"
# Menu goes to stderr so the caller only captures the reply.
pick() {
{
echo "POLICE SQUAD QUEST — cases:"
echo
for d in cases/*/; do
n=$(basename "$d" | sed 's/^case-//; s/-.*//')
t=$(sed -n 's/.*"name"[^"]*"\([^"]*\)".*/\1/p' "$d/game.json" 2>/dev/null | head -1)
printf ' %s %s\n' "$n" "${t:-$(basename "$d")}"
done
echo
printf 'case number: '
} >&2
read -r reply
echo "$reply"
}
arg="$1"
# No arg: the engine's own title screen / world picker on the cases shelf.
[ -n "$arg" ] || exec cargo run --release -p mrpgi --manifest-path "$ENGINE/Cargo.toml" -- \
--game "$(pwd)/cases"
# A bare number selects by case prefix; anything else is treated as a path.
case "$arg" in
[0-9]*) CASE=$(ls -d cases/case-"$arg"-*/ 2>/dev/null | head -1) ;;
*) CASE="$arg" ;;
esac
[ -n "$CASE" ] && [ -f "$CASE/game.json" ] || { echo "no such case: $arg"; exit 1; }
exec cargo run --release -p mrpgi --manifest-path "$ENGINE/Cargo.toml" -- \
--game "$(cd "$CASE" && pwd)"