forked from MaaAssistantArknights/MaaAssistantArknights
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
137 lines (112 loc) · 3.08 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
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
132
133
134
135
136
137
#include "AsstCaller.h"
#include <filesystem>
#include <iostream>
#include <stdio.h>
#include <string>
#include <thread>
int main([[maybe_unused]] int argc, char** argv)
{
const auto cur_path = std::filesystem::path(argv[0]).parent_path();
// 可以将日志、调试图片等存到别的目录下,需要在最一开始调用。不调用默认保存到资源同目录
// AsstSetUserDir(cur_path.c_str());
// 这里默认读取的是可执行文件同目录下 resource 文件夹里的资源
bool loaded = AsstLoadResource(cur_path.string().c_str());
if (!loaded) {
std::cerr << "-------- load resource failed: official --------" << std::endl;
return -1;
}
#ifdef ASST_DEBUG
if (argc >= 2) {
std::string overseas_type(argv[1]); // "YoStarJP", "YoStarEN", "YoStarKR", "txwy"
std::cout << "load overseas_type:" << overseas_type << std::endl;
const auto overseas_path = cur_path / "resource" / "global" / overseas_type;
if (!AsstLoadResource(overseas_path.string().c_str())) {
std::cerr << "-------- load resource failed: " << overseas_type << " --------" << std::endl;
return -1;
}
}
#endif
auto ptr = AsstCreate();
if (ptr == nullptr) {
std::cerr << "create failed" << std::endl;
return -1;
}
#ifdef SMOKE_TESTING
std::cout << "Ended early for smoke testing." << std::endl;
return 0;
#endif
#ifndef ASST_DEBUG
AsstAsyncConnect(ptr, "adb", "127.0.0.1:5555", nullptr, true);
#else
AsstAsyncConnect(ptr, "adb", "127.0.0.1:5555", "DEBUG", true);
#endif
if (!AsstConnected(ptr)) {
std::cerr << "connect failed" << std::endl;
AsstDestroy(ptr);
ptr = nullptr;
return -1;
}
#ifndef ASST_DEBUG
/* 详细参数可参考 docs / 集成文档.md */
AsstAppendTask(ptr, "StartUp", nullptr);
AsstAppendTask(ptr, "Fight", R"(
{
"stage": "1-7"
}
)");
AsstAppendTask(ptr, "Recruit", R"(
{
"select":[4],
"confirm":[3,4],
"times":4
}
)");
AsstAppendTask(ptr, "Infrast", R"(
{
"facility": ["Mfg", "Trade", "Power", "Control", "Reception", "Office", "Dorm"],
"drones": "Money"
}
)");
AsstAppendTask(ptr, "Mall", R"(
{
"shopping": true,
"buy_first": [
"许可"
],
"black_list": [
"家具",
"碳"
]
}
)");
AsstAppendTask(ptr, "Award", R"(
{
"award": true,
"mail": true,
"recruit": true,
"orundum": true,
"mining": true,
"specialaccess": true
}
)");
AsstAppendTask(ptr, "Roguelike", R"(
{
"theme": "Sarkaz",
"mode": 1,
"squad": "蓝图测绘分队",
"roles": "稳扎稳打",
"core_char": "维什戴尔"
}
)");
#else
AsstAppendTask(ptr, "Debug", nullptr);
#endif
AsstStart(ptr);
while (AsstRunning(ptr)) {
std::this_thread::yield();
}
AsstStop(ptr);
AsstDestroy(ptr);
ptr = nullptr;
return 0;
}