#!/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)"