#!/usr/bin/env bash
# The rink pass between segments (MwRinkUpdate, the puck rules and phase
# handler MwRinkPhases) and the rink entries (MwRinkPhases.enter) against
# the simulation recordings (needs `tools/bin/py -m mw_harness sim-record`
# first), nothing masked. One Godot process per recording (they are large).
#   tools/bin/pass-check [NAME ...] [--show N] [--from I] [--count N] [--only TEXT]
#   tools/bin/pass-check NAME --detail PASS     # one pair in detail
#   tools/bin/pass-check [NAME ...] --fixture   # compare/fixtures/rink_gaps.json
#   tools/bin/pass-check [NAME ...] --phase-fixture   # compare/fixtures/rink_phases.json
#   tools/bin/visit-check: whole visits (--visit)
# -j N: N recordings at once (the output as one at a time).
source "$(dirname "${BASH_SOURCE[0]}")/_common.sh"
here="$(dirname "${BASH_SOURCE[0]}")"
source "$here/_recordings.sh"
names=(); opts=()
while (( $# )); do
  case "$1" in
    -j) export MW_JOBS="$2"; shift 2 ;;
    --only|--show|--from|--count|--detail) opts+=("$1" "$2"); shift 2 ;;
    --*) opts+=("$1"); shift ;;
    *) names+=("$1"); shift ;;
  esac
done
# the fixtures: one process over the names given (none: the default sets)
for o in "${opts[@]}"; do
  if [[ "$o" == --fixture || "$o" == --phase-fixture ]]; then
    exec "$here/godot-headless" -s res://test/sim/pass_check.gd -- "${names[@]}" "${opts[@]}"
  fi
done
if (( ${#names[@]} == 0 )); then
  names=("${MW_REC_V2[@]}" "${MW_REC_V3[@]}" "${MW_REC_SOAK[@]}")
fi
mw_each_recording res://test/sim/pass_check.gd "${names[@]}" -- "${opts[@]}"
