mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-18 18:20:39 +08:00
feat:获得每一层预见的密文板
This commit is contained in:
@@ -13495,6 +13495,15 @@
|
||||
124
|
||||
]
|
||||
},
|
||||
"Sami@Roguelike@CiphertextBoardGainOcrNextLevel": {
|
||||
"baseTask": "Sami@Roguelike@CiphertextBoardGainOcr",
|
||||
"roi": [
|
||||
290,
|
||||
640,
|
||||
151,
|
||||
34
|
||||
]
|
||||
},
|
||||
"Sami@Roguelike@CiphertextBoardUseConfirm": {
|
||||
"algorithm": "OcrDetect",
|
||||
"action": "ClickSelf",
|
||||
@@ -13536,7 +13545,7 @@
|
||||
],
|
||||
"specificRect_Doc": "x拿来当文字灰度二值化下限用",
|
||||
"specificRect": [
|
||||
110,
|
||||
135,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
|
||||
@@ -56,6 +56,7 @@ namespace asst
|
||||
static inline const std::string RoguelikeDifficulty = "RoguelikeDifficulty";
|
||||
|
||||
static inline const std::string RoguelikeCiphertextBoardOverview = "RoguelikeCiphertextBoardOverview";
|
||||
static inline const std::string RoguelikeCiphertextBoardFloor = "RoguelikeCiphertextBoardFloor";
|
||||
|
||||
static inline const std::string ProcessTaskLastTimePrefix = "#LastTime#";
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ bool asst::RoguelikeCiphertextBoardGainTaskPlugin::verify(AsstMsg msg, const jso
|
||||
if (task_view.starts_with(roguelike_name)) {
|
||||
task_view.remove_prefix(roguelike_name.length());
|
||||
}
|
||||
m_ocr_next_level = false;
|
||||
if (task_view == "Roguelike@CiphertextBoardGain") {
|
||||
m_ocr_after_combat = false;
|
||||
return true;
|
||||
@@ -37,6 +38,10 @@ bool asst::RoguelikeCiphertextBoardGainTaskPlugin::verify(AsstMsg msg, const jso
|
||||
m_ocr_after_combat = true;
|
||||
return true;
|
||||
}
|
||||
if (task_view == "Roguelike@NextLevel") {
|
||||
m_ocr_next_level = true;
|
||||
return true;
|
||||
}
|
||||
/* 可能是没点科技树会单独掉一个密文板,很快能点出来,暂时不做识别
|
||||
if (task_view == "Roguelike@GetDrop2") {
|
||||
m_ocr_after_combat = true;
|
||||
@@ -57,6 +62,29 @@ bool asst::RoguelikeCiphertextBoardGainTaskPlugin::_run()
|
||||
auto image = ctrler()->get_image();
|
||||
|
||||
OCRer analyzer(image);
|
||||
std::string ciphertext_board = "None";
|
||||
if (m_ocr_next_level) {
|
||||
analyzer.set_task_info(theme + "@Roguelike@CiphertextBoardGainOcrNextLevel");
|
||||
if (analyzer.analyze()) {
|
||||
ciphertext_board = analyzer.get_result().front().text;
|
||||
}
|
||||
store_to_status(ciphertext_board, Status::RoguelikeCiphertextBoardFloor);
|
||||
json::array ciphertext_board_floor_array = get_array(Status::RoguelikeCiphertextBoardFloor);
|
||||
// 到达第二层后,获得上一层预见的密文板
|
||||
if (ciphertext_board_floor_array.size() >= 2) {
|
||||
std::string ciphertext_board_last_floor = (ciphertext_board_floor_array.end() - 2)->to_string();
|
||||
if (ciphertext_board_last_floor.size() >= 2 && ciphertext_board_last_floor.front() == '"' &&
|
||||
ciphertext_board_last_floor.back() == '"') {
|
||||
ciphertext_board_last_floor =
|
||||
ciphertext_board_last_floor.substr(1, ciphertext_board_last_floor.size() - 2);
|
||||
}
|
||||
if (ciphertext_board_last_floor != "None") {
|
||||
store_to_status(ciphertext_board_last_floor, Status::RoguelikeCiphertextBoardOverview);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
std::string task_name = m_ocr_after_combat ? theme + "@Roguelike@CiphertextBoardGainOcrAfterCombat"
|
||||
: theme + "@Roguelike@CiphertextBoardGainOcr";
|
||||
analyzer.set_task_info(task_name);
|
||||
@@ -64,19 +92,26 @@ bool asst::RoguelikeCiphertextBoardGainTaskPlugin::_run()
|
||||
if (!analyzer.analyze()) {
|
||||
return false;
|
||||
}
|
||||
std::string ciphertext_board = analyzer.get_result().front().text;
|
||||
|
||||
std::string overview_str =
|
||||
status()->get_str(Status::RoguelikeCiphertextBoardOverview).value_or(json::value().to_string());
|
||||
json::value overview_json = json::parse(overview_str).value_or(json::value());
|
||||
auto& overview = overview_json.as_array();
|
||||
// 把ciphertext_board存到overview里
|
||||
overview.emplace_back(ciphertext_board);
|
||||
status()->set_str(Status::RoguelikeCiphertextBoardOverview, overview.to_string());
|
||||
|
||||
ciphertext_board = analyzer.get_result().front().text;
|
||||
store_to_status(ciphertext_board, Status::RoguelikeCiphertextBoardOverview);
|
||||
if (m_ocr_after_combat) {
|
||||
ctrler()->click(analyzer.get_result().front().rect);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool asst::RoguelikeCiphertextBoardGainTaskPlugin::store_to_status(std::string ciphertext_board, auto& status_string)
|
||||
{
|
||||
json::array overview = get_array(status_string);
|
||||
overview.emplace_back(ciphertext_board);
|
||||
status()->set_str(status_string, overview.to_string());
|
||||
return true;
|
||||
}
|
||||
|
||||
json::array asst::RoguelikeCiphertextBoardGainTaskPlugin::get_array(auto& status_string)
|
||||
{
|
||||
std::string overview_str = status()->get_str(status_string).value_or(json::value().to_string());
|
||||
json::value overview_json = json::parse(overview_str).value_or(json::value());
|
||||
return overview_json.as_array();
|
||||
}
|
||||
|
||||
@@ -17,7 +17,11 @@ namespace asst
|
||||
virtual bool _run() override;
|
||||
|
||||
private:
|
||||
json::array get_array(auto& status_string);
|
||||
bool store_to_status(std::string ciphertext_board, auto& status_string);
|
||||
// 战斗后识别密文板
|
||||
mutable bool m_ocr_after_combat = false;
|
||||
// 进入新一层后识别密文板
|
||||
mutable bool m_ocr_next_level = false;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ bool asst::RoguelikeShoppingTaskPlugin::_run()
|
||||
status()->get_str(Status::RoguelikeCiphertextBoardOverview).value_or(json::value().to_string());
|
||||
|
||||
auto& overview = json::parse(overview_str).value_or(json::value()).as_array();
|
||||
// 把ciphertext_board存到overview里
|
||||
// 把goods.name存到密文板overview里
|
||||
overview.push_back(goods.name);
|
||||
status()->set_str(Status::RoguelikeCiphertextBoardOverview, overview.to_string());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user