summaryrefslogtreecommitdiff
path: root/share/hackvr/examples/tictactoe/game.sh
diff options
context:
space:
mode:
authorepoch <epoch@hack.thebackupbox.net>2020-04-14 11:50:30 +0000
committerepoch <epoch@hack.thebackupbox.net>2020-04-14 11:50:30 +0000
commit459bff40e078a3979573000a903b288bcc9a8d3f (patch)
treecd8e75a66129042803729924352de80d7a5f5041 /share/hackvr/examples/tictactoe/game.sh
parentede4c08f4f15a516a748f8ed89b4f6b06b845c2a (diff)
parent9f5c79eff1a3fae473bbdd12afcb77875d8548af (diff)
downloadhackvr-459bff40e078a3979573000a903b288bcc9a8d3f.tar.gz
hackvr-459bff40e078a3979573000a903b288bcc9a8d3f.zip
Merge branch 'master' of /var/git/hackvr
Diffstat (limited to 'share/hackvr/examples/tictactoe/game.sh')
-rwxr-xr-xshare/hackvr/examples/tictactoe/game.sh52
1 files changed, 28 insertions, 24 deletions
diff --git a/share/hackvr/examples/tictactoe/game.sh b/share/hackvr/examples/tictactoe/game.sh
index b4187dd..92192cc 100755
--- a/share/hackvr/examples/tictactoe/game.sh
+++ b/share/hackvr/examples/tictactoe/game.sh
@@ -4,30 +4,34 @@ BOARDFILE=board_orig
cat camera.pos $BOARDFILE
echo "go. player: $turn" >&2
grep --line-buffered action \
- | while read user derp group;do
-# echo FUCK >&2
- if grep "_reset" <<<$group >/dev/null;then
- printf "%s deleteallexcept .\n" "$user"
- cat $BOARDFILE
- continue
- elif grep "_exit" <<<$group >/dev/null;then #this doesn't work in local games. :/
- exit 0
- elif grep "_" <<<$group >/dev/null;then
-# xmessage "CUT IT OUT"
- echo CUT IT OUT > /dev/stderr
- continue
- else
- turn=$(expr \( $turn + 1 \) % 2)
- #printf "# turn: %d\n" "$turn" > /dev/stderr
- printf "$user deletegroup %s\n" "$group"
- #printf "$user deletegroup %s\n" "$group" > /dev/stderr
+ | while read user action group;do
+ if [ $action = "action" ];then
+ if grep "_reset" <<<$group >/dev/null;then
+ printf "%s deleteallexcept %s\n" "$user" "$user"
+ cat $BOARDFILE
+ continue
+ elif grep "_exit" <<<$group >/dev/null;then
+ #if a program wants to exit, it should just exit.
+ #the program may have been ran by some other program.
+ #maybe just filter out server-side quit messages for your own username?
+ #any user quit will cause any hackvr to quit?
+ #printf "%s quit\n" "$user"
+ exit 0
+ elif grep "_" <<<$group >/dev/null;then
+ echo CUT IT OUT > /dev/stderr
+ continue
+ elif grep "^board" <<<$group >/dev/null;then
+ turn=$(expr \( $turn + 1 \) % 2)
+ #printf "# turn: %d\n" "$turn" > /dev/stderr
+ printf "%s deletegroup %s\n" "$user" "$group"
+ #printf "$user deletegroup %s\n" "$group" > /dev/stderr
#need to get the first point of the group clicked and translate the new shape by that much
- translatex="$(grep "$group" $BOARDFILE | grep -v '^#' | tr -s ' ' | cut '-d ' -f5)"
- translatey="$(grep "$group" $BOARDFILE | grep -v '^#' | tr -s ' ' | cut '-d ' -f6)"
- cat "marker$turn" | offsetshape.sh $translatex "$(expr "$translatey" - 2 )" 0
-# printf "%s move %s %s 2\n" "_marker" "$(expr "$translatex")" "$(expr "$translatey" - 2 )"
- #printf "%s move %s %s 2\n" "_marker" "$(expr "$translatex")" "$(expr "$translatey" - 2 )" >/dev/stderr
- grep "$group" $BOARDFILE | sed "s/$group/_marker2/g" #this is to make it still show the square around it.
- printf "%s renamegroup _marker _marker%s%s\n" "$user" "$(date +%s)" "$RANDOM"
+ translatex="$(grep "$group" $BOARDFILE | grep -v '^#' | tr -s ' ' | cut '-d ' -f5)"
+ translatey="$(grep "$group" $BOARDFILE | grep -v '^#' | tr -s ' ' | cut '-d ' -f6)"
+ cat "marker$turn" | offsetshape.sh $translatex "$(expr "$translatey" - 2 )" 0
+ grep "$group" $BOARDFILE | sed "s/$group/_marked/g"
+ else
+ xmessage "what? $group"
+ fi
fi
done