Skip to content

Commit bbed9b5

Browse files
committed
Add deathmatch loop for starter bot
1 parent e53c103 commit bbed9b5

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package ru.croccode.hypernull.bot;
2+
3+
import java.io.IOException;
4+
import java.net.InetSocketAddress;
5+
import java.net.Socket;
6+
import java.nio.file.Paths;
7+
8+
import ru.croccode.hypernull.io.SocketSession;
9+
10+
public class DeathmatchLoop {
11+
12+
public static void main(String[] args) throws IOException {
13+
String configPath = args.length > 0
14+
? args[0]
15+
: "bot.properties";
16+
BotConfig botConfig = BotConfig.load(Paths.get(configPath));
17+
18+
while (true) {
19+
try {
20+
Socket socket = new Socket();
21+
socket.setTcpNoDelay(true);
22+
socket.setSoTimeout(300_000);
23+
socket.connect(new InetSocketAddress(
24+
botConfig.getServerHost(),
25+
botConfig.getServerPort()));
26+
27+
SocketSession session = new SocketSession(socket);
28+
StarterBot bot = new StarterBot(botConfig.getBotName(), botConfig.getMode());
29+
new BotMatchRunner(bot, session).run();
30+
} catch (Exception e) {
31+
e.printStackTrace();
32+
}
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)