ref: c975372b175fdf14e5c1158c705303fc73c116c7
dir: /rc/spectate/
#!/bin/rc rfork e flagfmt='r:transcribe, h:help' args='gamedir' eval `{aux/getflags $*} game=$1 player=() lstat=() lmsg=() uppid=() if(~ $help 1 || ! ~ $#* 1) { aux/usage exit usage } board=$game/white ctl=$game/ctl fn sighup sigint sigterm{ exit } fn upboard { player=`{cat $ctl | grep turn | sed 's/^([a-z]*)''.*/\1/g'} board=$game/$player } fn prtboard { if(~ $#transcribe 0) { cat $board } if not { cat $board | \ sed 's/♙/p/g' | sed 's/♟/q/g' | \ sed 's/♖/ᴙ/g' | sed 's/♜/ᴚ/g' | \ sed 's/♘/N/g' | sed 's/♞/ᴎ/g' | \ sed 's/♗/ᴇ/g' | sed 's/♝/ᴈ/g' | \ sed 's/♕/S/g' | sed 's/♛/Z/g' | \ sed 's/♔/ᴍ/g' | sed 's/♚/ᴡ/g' } } fn status { gst=`{cat $ctl | sed 1q} msg=`{cat $ctl | sed 2q | tail -n 1} wtm=`{cat $ctl | sed 3q | tail -n 1 | awk '{print $3}'} wtb=`{cat $ctl | sed 4q | tail -n 1 | awk '{print $3}'} echo $msg ' W' $wtm 'B' $wtb } sleep 0.5 while() { if(! test -f $ctl) { echo 'ctl file' $ctl 'not found' exit } cstat=`{cat $ctl | sed 1q} msg=`{cat $ctl | sed 2q | tail -n 1} if(! ~ $"msg $"lmsg) { lmsg=$msg upboard prtboard status } if(! ~ $"cstat $"lstat) { lstat=$cstat echo '!!!' $cstat } sleep 0.5 }