-
Notifications
You must be signed in to change notification settings - Fork 1
/
run_bot
131 lines (118 loc) · 4.27 KB
/
run_bot
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/bash
#
# This is a script for running a TripleA bot on a Unix-like system.
#
# To run this script, change to the directory in which you unpacked the
# headless game server archive, and type "./run_bot" and specifies options.
# Full usage details are found under --help, "./run_bot -h".
#
###############################################################################
# VARIABLE DEFAULTS START HERE
###############################################################################
#
# The TripleA username that owns the bot.
#
# This is a required variable. The default is empty string which will be replaced
# with the value passed into the script. The script will not run without a username.
#
USER=
#
# The folder from which the bot will load game maps.
#
# The default value is the folder in which the TripleA game client stores
# maps that it downloads. Under normal circumstances, you will not have to
# change this variable. However, if you customized the settings in your
# TripleA client to use a different maps folder, you should change this
# variable to refer to the same location.
#
# DO NOT CHANGE!!!
# This is set to the location of the software install.
#
MAPS_FOLDER="/opt/triplea/downloadedMaps"
#
# The port on which the bot will listen for connections. This port must be
# reachable from the Internet, so you may have to configure your firewall
# appropriately.
#
# Under normal circumstances, you will not have to change this variable.
# However, if you choose to run multiple bots on your system, you need to
# select a different available port for each bot.
#
BOT_PORT=3300
#
# The name of the bot as displayed in the lobby. Each bot must have a unique
# name.
#
# The default value uses a combination of your username and the local port
# you selected above on which the bot will run. Under normal circumstances,
# you will not have to change this variable.
#
# Here the value is set to blank and later set to the default if an override is not
# provided through start options.
#
BOT_NAME=
#
# The hostname of the lobby to which the bot will connect.
#
# The default value is the hostname for the TripleA community's public lobby.
# Under normal circumstances, you will not have to change this variable.
#
LOBBY_URI="https://prod2-lobby.triplea-game.org"
###############################################################################
# VARIABLE DEFAULTS END HERE
#
# DO NOT MODIFY ANYTHING BELOW THIS LINE!
###############################################################################
display_usage() {
echo -e "\nUsage: run_bot <-u username> [OPTIONS]\n"
echo -e "A TripleA bot runner"
echo -e "\nOptions:"
echo -e " -b, --bot_name Name the bot uses in the lobby (default \"Bot_{username}_{port}\")"
echo -e " -h, --help Display this help and exit"
echo -e " -l, --lobby Hostname of the lobby to which the bot will connect (default \"https://lobby.triplea-game.org\")"
echo -e " -p, --port Port to run the bot on (default 3300)"
echo -e " -u, --username Your TripleA Username"
}
if [ $# = 0 ]; then
display_usage
exit
fi
while [ "$1" != "" ]; do
case $1 in
-b | --bot_name ) shift
BOT_NAME="Bot_$1"
;;
-h | --help ) display_usage
exit
;;
-l | --lobby ) shift
LOBBY_URI="$1"
;;
-p | --port ) shift
BOT_PORT=$1
;;
-u | --username ) shift
USER="$1"
;;
* ) display_usage
exit 1
esac
shift
done
if [ "$USER" = "" ]; then
echo -e "\nERROR: The username cannot be blank.\n"
display_usage
exit
fi
if [ "$BOT_NAME" = "" ]; then
BOT_NAME="Bot_${USER}_${BOT_PORT}"
fi
java \
-server \
-Xmx256M \
-Djava.awt.headless=true \
-jar /opt/bin/triplea-game-headless-*.jar \
-Ptriplea.lobby.uri="$LOBBY_URI" \
-Ptriplea.map.folder="$MAPS_FOLDER" \
-Ptriplea.name="$BOT_NAME" \
-Ptriplea.port="$BOT_PORT"