-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
49 lines (43 loc) · 1.15 KB
/
main.cpp
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
typedef struct IUnknown IUnknown;
#include <BWAPI.h>
#include <BWAPI/Client.h>
#include <chrono>
#include <iostream>
#include <memory>
#include <thread>
#include "ZergHell.h"
void reconnect() {
while (!BWAPI::BWAPIClient.connect()) {
std::this_thread::sleep_for(std::chrono::milliseconds{ 1000 });
}
}
int main() {
std::cout << "Connecting..." << std::endl;
reconnect();
while (true) {
std::unique_ptr<ZergHell> bot;
std::cout << "waiting to enter match" << std::endl;
while (!BWAPI::Broodwar->isInGame()) {
BWAPI::BWAPIClient.update();
if (!BWAPI::BWAPIClient.isConnected()) {
std::cout << "Reconnecting..." << std::endl;
reconnect();
}
}
std::cout << "starting match!" << std::endl;
std::cout << "Map: " << BWAPI::Broodwar->mapName() << std::endl;
while (BWAPI::Broodwar->isInGame()) {
for (auto& e : BWAPI::Broodwar->getEvents()) {
switch (e.getType()) {
case BWAPI::EventType::MatchStart:
bot = std::make_unique<ZergHell>();
break;
default:
break;
}
}
bot->onFrame();
BWAPI::BWAPIClient.update();
}
}
}