mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-18 10:10:45 +08:00
feat: use ocr to check recruit timer
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 4.9 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 4.0 KiB |
@@ -3761,14 +3761,43 @@
|
||||
"action": "DoNothing",
|
||||
"rearDelay": 2000
|
||||
},
|
||||
"RecruitCheckTimeReduced": {
|
||||
"action": "DoNothing",
|
||||
"Doc": "检查时间是不是调整过",
|
||||
"RecruitTimerH": {
|
||||
"Doc": "识别公招小时数",
|
||||
"algorithm": "OcrDetect",
|
||||
"roi": [
|
||||
350,
|
||||
150,
|
||||
200,
|
||||
150
|
||||
400,
|
||||
180,
|
||||
100,
|
||||
90
|
||||
],
|
||||
"text": [
|
||||
"01",
|
||||
"02",
|
||||
"03",
|
||||
"04",
|
||||
"05",
|
||||
"06",
|
||||
"07",
|
||||
"08",
|
||||
"09"
|
||||
]
|
||||
},
|
||||
"RecruitTimerM": {
|
||||
"Doc": "识别公招分钟数",
|
||||
"algorithm": "OcrDetect",
|
||||
"roi": [
|
||||
570,
|
||||
180,
|
||||
100,
|
||||
90
|
||||
],
|
||||
"text": [
|
||||
"00",
|
||||
"10",
|
||||
"20",
|
||||
"30",
|
||||
"40",
|
||||
"50"
|
||||
]
|
||||
},
|
||||
"RecruitConfirm": {
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 4.0 KiB |
@@ -238,7 +238,7 @@ bool asst::AutoRecruitTask::recruit_one(const Rect& button)
|
||||
|
||||
if (need_exit()) return false;
|
||||
|
||||
if (m_set_time && !check_time_reduced()) {
|
||||
if (m_set_time && !check_timer()) {
|
||||
// timer was not set to 09:00:00 properly, likely the tag selection was also corrupted
|
||||
// see https://github.com/MaaAssistantArknights/MaaAssistantArknights/pull/300#issuecomment-1073287984
|
||||
// return and try later
|
||||
@@ -500,11 +500,29 @@ bool asst::AutoRecruitTask::recruit_begin()
|
||||
return task.run();
|
||||
}
|
||||
|
||||
bool asst::AutoRecruitTask::check_time_reduced()
|
||||
bool asst::AutoRecruitTask::check_timer()
|
||||
{
|
||||
ProcessTask task(*this, { "RecruitCheckTimeReduced" });
|
||||
task.set_retry_times(2);
|
||||
return task.run();
|
||||
const auto image = m_ctrler->get_image();
|
||||
|
||||
{
|
||||
OcrImageAnalyzer hour_ocr(image);
|
||||
hour_ocr.set_task_info("RecruitTimerH");
|
||||
hour_ocr.analyze();
|
||||
if (hour_ocr.get_result().empty()) return false;
|
||||
std::string desired_hour_str = std::string("0") + std::to_string(m_desired_time / 60);
|
||||
if (hour_ocr.get_result().front().text != desired_hour_str) return false;
|
||||
}
|
||||
if (m_desired_time % 60 == 0) return true; // minute counter stays untouched
|
||||
|
||||
{
|
||||
OcrImageAnalyzer minute_ocr(image);
|
||||
minute_ocr.set_task_info("RecruitTimerM");
|
||||
minute_ocr.analyze();
|
||||
if (minute_ocr.get_result().empty()) return false;
|
||||
std::string desired_minute_str = std::to_string((m_desired_time % 60) / 10) + "0";
|
||||
if (minute_ocr.get_result().front().text != desired_minute_str) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool asst::AutoRecruitTask::check_recruit_home_page()
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace asst
|
||||
bool recruit_one(const Rect&);
|
||||
bool check_recruit_home_page();
|
||||
bool recruit_begin();
|
||||
bool check_time_reduced();
|
||||
bool check_timer();
|
||||
bool recruit_now();
|
||||
bool confirm();
|
||||
bool refresh();
|
||||
@@ -53,6 +53,7 @@ namespace asst
|
||||
int m_max_times = 0;
|
||||
bool m_skip_robot = true;
|
||||
bool m_set_time = true;
|
||||
int m_desired_time = 9 * 60; // in minutes
|
||||
|
||||
int m_slot_fail = 0;
|
||||
int m_cur_times = 0;
|
||||
|
||||
Reference in New Issue
Block a user