#!/usr/bin/env bash
# 2-node + console cross-pod damage test (task #47 re-diagnosis).
# A = shooter (BT_MP_FORCE_DMG auto-dispatches unaimed TakeDamage at the first
# replicant once/sec). Both nodes run BT_MP_LOG so each enumerates candidates
# (mp-self = own mech id; mp-cand = every peer/replicant id). Comparing A's
# dispatched id vs B's own-master id tests H3 (id mismatch) directly.
set -x
cd /c/git/bt411/content || exit 1
rm -f mp_a.log mp_b.log

BT_LOG=mp_a.log BT_AFFINITY=0x1 BT_MP_FORCE_DMG=1 BT_MP_LOG=1 BT_MP_NET=1 \
  ../build/Debug/btl4.exe -egg MP.EGG -net 1501 &
PA=$!
sleep 2

BT_LOG=mp_b.log BT_AFFINITY=0x2 BT_MP_LOG=1 BT_MP_NET=1 \
  ../build/Debug/btl4.exe -egg MP.EGG -net 1601 &
PB=$!
sleep 4

python ../tools/btconsole.py MP.EGG 127.0.0.1:1501 127.0.0.1:1601 &
PC=$!

# let the mesh form, replicate, and FORCE_DMG fire several times
sleep 45

kill $PC 2>/dev/null
taskkill //F //IM btl4.exe 2>/dev/null
taskkill //F //IM python.exe 2>/dev/null
echo "=== DONE ==="
