diff --git a/MeoAssistance/MeoAssistance.vcxproj b/MeoAssistance/MeoAssistance.vcxproj
index 286fb2eb6f..b47a0a137c 100644
--- a/MeoAssistance/MeoAssistance.vcxproj
+++ b/MeoAssistance/MeoAssistance.vcxproj
@@ -197,7 +197,7 @@
-
+
\ No newline at end of file
diff --git a/MeoAssistance/include/Configer.h b/MeoAssistance/include/Configer.h
index 8d80f4e0a3..7594c63b4f 100644
--- a/MeoAssistance/include/Configer.h
+++ b/MeoAssistance/include/Configer.h
@@ -40,10 +40,12 @@ namespace asst {
struct TaskInfo {
std::string filename;
double threshold = 0;
+ double cache_threshold = 0;
TaskType type;
std::vector next;
int exec_times = 0;
int max_times = INT_MAX;
+ std::vector exceeded_next;
asst::Rect specific_area;
int pre_delay = 0;
int rear_delay = 0;
@@ -70,6 +72,9 @@ namespace asst {
static std::optional getParam(const std::string& type, const std::string& param);
static void clearExecTimes();
+
+ constexpr static double DefaultThreshold = 0.98;
+ constexpr static double DefaultCacheThreshold = 0.9998;
private:
Configer() = default;
diff --git a/MeoAssistance/src/Assistance.cpp b/MeoAssistance/src/Assistance.cpp
index 7d840a996d..c9ddc80c1f 100644
--- a/MeoAssistance/src/Assistance.cpp
+++ b/MeoAssistance/src/Assistance.cpp
@@ -65,7 +65,7 @@ std::optional Assistance::setSimulator(const std::string& simulator
else {
ret = create_handles(simulator_name);
}
- if (ret && m_pWindow->showWindow() && m_pWindow->resizeWindow() ) {
+ if (ret && m_pWindow->showWindow() && m_pWindow->resizeWindow()) {
m_inited = true;
return cor_name;
}
@@ -121,12 +121,13 @@ void Assistance::workingProc(Assistance* pThis)
std::string matched_task;
Rect matched_rect;
for (auto&& task_name : pThis->m_next_tasks) {
- double threshold = Configer::m_tasks[task_name].threshold;
+ auto&& task = Configer::m_tasks[task_name];
+ double threshold = task.threshold;
auto&& [algorithm, value, rect] = pThis->m_pIder->findImage(curImg, task_name, threshold);
DebugTrace(task_name, "Type:", algorithm, "Value:", value);
if (algorithm == 0 ||
(algorithm == 1 && value >= threshold)
- || (algorithm == 2 && value >= 0.9998)) {
+ || (algorithm == 2 && value >= task.cache_threshold)) {
matched_task = task_name;
matched_rect = rect;
break;
@@ -134,47 +135,49 @@ void Assistance::workingProc(Assistance* pThis)
}
if (!matched_task.empty()) {
- auto && task = Configer::m_tasks[matched_task];
- DebugTraceInfo("Matched:", matched_task, "Type:", static_cast(task.type));
+ auto&& task = Configer::m_tasks[matched_task];
+ DebugTraceInfo("***Matched***", matched_task, "Type:", static_cast(task.type));
if (task.pre_delay > 0) {
DebugTrace("PreDelay", task.pre_delay);
std::this_thread::sleep_for(std::chrono::milliseconds(task.pre_delay));
}
- switch (task.type) {
- case TaskType::ClickRect:
- matched_rect = task.specific_area;
- case TaskType::ClickSelf:
- if (task.max_times != INT_MAX) {
- DebugTrace("CurTimes:", task.exec_times, "MaxTimes:", task.max_times);
- }
- if (task.exec_times >= task.max_times) {
- DebugTraceInfo("Reached limit, Stop.");
+
+ if (task.max_times != INT_MAX) {
+ DebugTrace("CurTimes:", task.exec_times, "MaxTimes:", task.max_times);
+ }
+ if (task.exec_times < task.max_times) {
+ switch (task.type) {
+ case TaskType::ClickRect:
+ matched_rect = task.specific_area;
+ case TaskType::ClickSelf:
+ pThis->m_pCtrl->clickRange(matched_rect);
+ break;
+ case TaskType::ClickRand:
+ pThis->m_pCtrl->clickRange(pThis->m_pCtrl->getWindowRect());
+ break;
+ case TaskType::DoNothing:
+ break;
+ case TaskType::Stop:
+ DebugTrace("TaskType is Stop");
pThis->stop(false);
continue;
+ break;
+ default:
+ DebugTraceError("Unknown option type:", static_cast(task.type));
+ break;
}
- pThis->m_pCtrl->clickRange(matched_rect);
++task.exec_times;
- break;
- case TaskType::ClickRand:
- pThis->m_pCtrl->clickRange(pThis->m_pCtrl->getWindowRect());
- break;
- case TaskType::DoNothing:
- break;
- case TaskType::Stop:
- DebugTrace("TaskType is Stop");
- pThis->stop(false);
- continue;
- break;
- default:
- DebugTraceError("Unknown option type:", static_cast(task.type));
- break;
+ if (task.rear_delay > 0) {
+ DebugTrace("RearDelay", task.rear_delay);
+ std::this_thread::sleep_for(std::chrono::milliseconds(task.rear_delay));
+ }
+ pThis->m_next_tasks = Configer::m_tasks[matched_task].next;
}
- if (task.rear_delay > 0) {
- DebugTrace("RearDelay", task.rear_delay);
- std::this_thread::sleep_for(std::chrono::milliseconds(task.rear_delay));
+ else {
+ DebugTraceInfo("Reached limit");
+ pThis->m_next_tasks = Configer::m_tasks[matched_task].exceeded_next;
}
- pThis->m_next_tasks = Configer::m_tasks[matched_task].next;
std::string nexts_str;
for (auto&& name : pThis->m_next_tasks) {
nexts_str += name + ",";
diff --git a/MeoAssistance/src/Configer.cpp b/MeoAssistance/src/Configer.cpp
index 9758944ce3..6e5b07bd34 100644
--- a/MeoAssistance/src/Configer.cpp
+++ b/MeoAssistance/src/Configer.cpp
@@ -47,7 +47,18 @@ bool Configer::reload()
for (auto&& [name, task_json] : tasks_obj) {
TaskInfo task_info;
task_info.filename = task_json["filename"].as_string();
- task_info.threshold = task_json["threshold"].as_double();
+ if (task_json.exist("threshold")) {
+ task_info.threshold = task_json["threshold"].as_double();
+ }
+ else {
+ task_info.threshold = DefaultThreshold;
+ }
+ if (task_json.exist("cache_threshold")) {
+ task_info.cache_threshold = task_json["cache_threshold"].as_double();
+ }
+ else {
+ task_info.cache_threshold = DefaultCacheThreshold;
+ }
std::string type = task_json["type"].as_string();
std::transform(type.begin(), type.end(), type.begin(), std::tolower);
if (type == "clickself") {
@@ -78,6 +89,15 @@ bool Configer::reload()
if (task_json.exist("maxTimes")) {
task_info.max_times = task_json["maxTimes"].as_integer();
}
+ if (task_json.exist("exceededNext")) {
+ auto next_arr = task_json["exceededNext"].as_array();
+ for (auto&& name : next_arr) {
+ task_info.exceeded_next.emplace_back(name.as_string());
+ }
+ }
+ else {
+ task_info.exceeded_next.emplace_back("Stop");
+ }
if (task_json.exist("preDelay")) {
task_info.pre_delay = task_json["preDelay"].as_integer();
}
diff --git a/Tools/Sanity/main.cpp b/Tools/Sanity/main.cpp
index ca20e979a8..1751481903 100644
--- a/Tools/Sanity/main.cpp
+++ b/Tools/Sanity/main.cpp
@@ -17,7 +17,7 @@ int main(int argc, char** argv)
}
DebugTraceInfo("Start");
- asst.start("SanityBegin");
+ asst.start("VisitBegin");
getchar();
diff --git a/resource/CreditStore.png b/resource/CreditStore.png
new file mode 100644
index 0000000000..2e992f886b
Binary files /dev/null and b/resource/CreditStore.png differ
diff --git a/resource/Mall.png b/resource/Mall.png
new file mode 100644
index 0000000000..24fc087e39
Binary files /dev/null and b/resource/Mall.png differ
diff --git a/resource/PopupCancel.png b/resource/PopupCancel.png
new file mode 100644
index 0000000000..89a1f94eae
Binary files /dev/null and b/resource/PopupCancel.png differ
diff --git a/resource/PopupConfirm.png b/resource/PopupConfirm.png
new file mode 100644
index 0000000000..06e01ece20
Binary files /dev/null and b/resource/PopupConfirm.png differ
diff --git a/resource/config.json b/resource/config.json
index 010e77eb38..e87a89fcd7 100644
--- a/resource/config.json
+++ b/resource/config.json
@@ -242,9 +242,7 @@
]
},
"StartButton2": {
- "id": 2,
"filename": "StartButton2.png",
- "threshold": 0.99,
"type": "clickSelf",
"rearDelay": 10000,
"next": [
@@ -253,7 +251,6 @@
},
"PRTS": {
"filename": "PRTS.png",
- "threshold": 0.98,
"type": "doNothing",
"next": [
"PRTS",
@@ -279,7 +276,6 @@
},
"Loading": {
"filename": "Loading.png",
- "threshold": 0.99,
"type": "doNothing",
"next": [
"StartButton1"
@@ -287,7 +283,6 @@
},
"UseMedicine": {
"filename": "UseMedicine.png",
- "threshold": 0.99,
"type": "doNothing",
"next": [
"MedicineConfirm"
@@ -295,7 +290,6 @@
},
"MedicineConfirm": {
"filename": "MedicineConfirm.png",
- "threshold": 0.98,
"type": "clickSelf",
"next": [
"StartButton1"
@@ -303,7 +297,6 @@
},
"UseStone": {
"filename": "UseStone.png",
- "threshold": 0.99,
"type": "doNothing",
"next": [
"StoneConfirm"
@@ -311,7 +304,6 @@
},
"StoneConfirm": {
"filename": "MedicineConfirm.png",
- "threshold": 0.98,
"type": "clickSelf",
"maxTimes": 0,
"next": [
@@ -320,7 +312,6 @@
},
"PrtsErrorConfirm": {
"filename": "PrtsErrorConfirm.png",
- "threshold": 0.98,
"type": "doNothing",
"next": [
"AbandonAction"
@@ -328,7 +319,6 @@
},
"AbandonAction": {
"filename": "AbandonAction.png",
- "threshold": 0.98,
"type": "clickSelf",
"next": [
"Random"
@@ -349,7 +339,6 @@
},
"ReturnToFriends": {
"filename": "Return.png",
- "threshold": 0.98,
"type": "clickSelf",
"next": [
"Friends",
@@ -358,7 +347,6 @@
},
"Friends": {
"filename": "Friends.png",
- "threshold": 0.98,
"type": "clickSelf",
"next": [
"FriendsList"
@@ -366,7 +354,6 @@
},
"FriendsList": {
"filename": "FriendsList.png",
- "threshold": 0.98,
"type": "clickSelf",
"next": [
"StartToVisit"
@@ -374,7 +361,6 @@
},
"StartToVisit": {
"filename": "StartToVisit.png",
- "threshold": 0.98,
"type": "clickSelf",
"next": [
"VisitNext"
@@ -384,12 +370,47 @@
"filename": "VisitNext.png",
"threshold": 0.99,
"type": "clickSelf",
- "maxTimes": 20,
+ "maxTimes": 21,
+ "exceededNext": [
+ "ReturnToMall"
+ ],
"next": [
"VisitNext",
"VisitNextBlack"
]
},
+ "ReturnToMall": {
+ "filename": "Return.png",
+ "type": "clickSelf",
+ "next": [
+ "Mall",
+ "ReturnToMall",
+ "ReturnToMallConfirm"
+ ]
+ },
+ "ReturnToMallConfirm": {
+ "filename": "PopupConfirm.png",
+ "type": "clickSelf",
+ "next": [
+ "ReturnToMall"
+ ]
+ },
+ "Mall": {
+ "filename": "Mall.png",
+ "threshold": 0.94,
+ "type": "clickSelf",
+ "next": [
+ "CreditStore"
+ ]
+ },
+ "CreditStore": {
+ "filename": "CreditStore.png",
+ "threshold": 0.91,
+ "type": "clickSelf",
+ "next": [
+ "Stop"
+ ]
+ },
"VisitLimited": {
"filename": "VisitLimited.png",
"threshold": 0.65,
@@ -398,7 +419,14 @@
},
"VisitNextBlack": {
"filename": "VisitNextBlack.png",
- "threshold": 0.98,
+ "type": "doNothing",
+ "next": [
+ "ReturnToMall"
+ ]
+ },
+ "Stop": {
+ "filename": "",
+ "threshold": 0,
"type": "stop",
"next": []
}