gameserverclient/quick.sh

73 lines
1.4 KiB
Bash
Raw Normal View History

2017-06-01 23:20:54 +00:00
#!/bin/bash
GAME="$1"
DEMO=0
BASENAME=$(basename $0)
if [ "$BASENAME" = "demo.sh" ]
then
DEMO=1
fi
2017-06-01 23:20:54 +00:00
if [ "$GAME" = "random" ]
then
2017-06-03 20:59:40 +00:00
ITEMS=$(curl -sL http://asciiexpress.net/gameserver/links.html | wc -l)
LINE=$(( RANDOM % ITEMS + 1))
else
2020-03-12 20:12:38 +00:00
ITEMS=$(curl -sL http://asciiexpress.net/gameserver/links.html | awk -F\" '{print $4}' | sort -f | grep -i "$GAME" | wc -l)
2017-06-01 23:20:54 +00:00
if (( ITEMS == 0 ))
then
echo "game $GAME not found" >&2
2017-06-01 23:20:54 +00:00
exit 1
fi
2020-03-12 20:12:38 +00:00
curl -sL http://asciiexpress.net/gameserver/links.html | awk -F\" '{print $4}' | sort -f | grep -i "$GAME" | nl -nln
2017-06-01 23:20:54 +00:00
ITEM=1
if (( ITEMS > 1 ))
then
echo
echo -n "pick one: "
read ITEM
test -z "$ITEM" && ITEM=1
fi
2020-03-12 20:12:38 +00:00
LINE=$(curl -sL http://asciiexpress.net/gameserver/links.html | awk -F\" '{print $4}' | sort -f | grep -ni "$GAME" | head -$ITEM | tail -1 | awk -F: '{print $1}')
2017-06-01 23:20:54 +00:00
fi
DOWN=$((LINE - 1))
2020-04-21 23:31:37 +00:00
TITLE=$(curl -sL http://asciiexpress.net/gameserver/links.html | sort -f | head -$LINE | tail -1 | awk -F\" '{print $4}')
2017-06-01 23:20:54 +00:00
echo
echo -n "${TITLE}..."
2017-06-01 23:20:54 +00:00
if ! OUTPUT=$(
osascript quick.scrp \
gameserverclient.dsk \
c_gameserverdisk_splash.tiff $((5 + DEMO * 10)) \
c_gameserverdisk_mainscreen.tiff $((5 + DEMO * 10)) \
$DOWN \
$DEMO
2017-06-01 23:20:54 +00:00
)
then
echo FAILED
exit 1
fi
if echo $OUTPUT | grep ERROR >/dev/null 2>&1
then
echo FAILED
echo $OUTPUT
echo
exit 1
fi
rm -f quick.aif
echo LAUNCHED
echo
#xdotool windowfocus $WINDOWID 2>/dev/null
#osascript -e 'activate application "XQuartz"'