/
tossug-arena
executable file
·55 lines (51 loc) · 1.64 KB
/
tossug-arena
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/bash
# CC0, Wei-Lun Chao <bluebat@member.fsf.org>, 2018
shopt -s extglob
ARENA_MATCH=$1 # name of match file
ARENA_PLAYER1=$2 # name of player1
ARENA_PLAYER2=$3 # name of player2
ARENA_PLAYER3=$4 # name of player3
ARENA_GAME="" # game type from match file
ARENA_UI="" # game ui from match file
ARENA_THEME="" # ui theme from match file
[ "$0" = "./tossug-arena" ] && DATADIR="$PWD" || DATADIR=/usr/share/tossug-arena
RANDOM=`date +%s` # set random seed
if [ $# -eq 0 ] ; then
echo "TOSSUG Arena: Gamelets Arena for poor AI Players"
echo "Usage:"
echo -e "\ttossug-arena MATCH[-log] [ PLAYER1 [ PLAYER2 [ PLAYER3 ]]]"
echo
echo "available MATCHs:"
cd "$DATADIR/matches"
echo -e "\t"`ls !(Human*|*-log)`
echo "available PLAYERs: (Human as reserved default)"
cd "$DATADIR/players"
for i in * ; do
echo -en "\tfor $i: "
cd "$DATADIR/players/$i"
for j in * ; do
echo -n "$j "
done
echo
done
exit 1
fi
if ! [ -f "$DATADIR/matches/$ARENA_MATCH" ] ; then
echo "match file: $DATADIR/matches/$ARENA_MATCH not found."
exit 1
fi
source "$DATADIR/matches/$ARENA_MATCH"
if ! [ -x "$DATADIR/interfaces/$ARENA_GAME/$ARENA_UI/main" ] ; then
echo "ui file: $DATADIR/interfaces/$ARENA_GAME/$ARENA_UI/main not found."
exit 1
fi
if [ -z "$ARENA_PLAYER1" -o "${ARENA_PLAYER1,,}" = human ] ; then
ARENA_PLAYER1=Human1
fi
if [ -z "$ARENA_PLAYER2" -o "${ARENA_PLAYER2,,}" = human ] ; then
ARENA_PLAYER2=Human2
fi
if [ -z "$ARENA_PLAYER3" -o "${ARENA_PLAYER3,,}" = human ] ; then
ARENA_PLAYER3=Human3
fi
exec "$DATADIR/interfaces/$ARENA_GAME/$ARENA_UI/main" "$ARENA_THEME" "$ARENA_PLAYER1" "$ARENA_PLAYER2" "$ARENA_PLAYER3"