mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-20 02:55:38 +08:00
style: 优化部分 initializer_list 的格式
This commit is contained in:
@@ -242,7 +242,10 @@ void Assistant::working_proc()
|
||||
lock.unlock();
|
||||
// only one instance of working_proc running, unlock here to allow set_task_param to the running task
|
||||
|
||||
json::value callback_json = json::object { { "taskchain", task_ptr->get_task_chain() }, { "taskid", id } };
|
||||
json::value callback_json = json::object {
|
||||
{ "taskchain", task_ptr->get_task_chain() },
|
||||
{ "taskid", id },
|
||||
};
|
||||
task_callback(AsstMsg::TaskChainStart, callback_json, this);
|
||||
|
||||
task_ptr->set_exit_flag(&m_thread_idle).set_ctrler(m_ctrler).set_status(m_status);
|
||||
|
||||
@@ -488,7 +488,10 @@ asst::AutoRecruitTask::calc_task_result_type asst::AutoRecruitTask::recruit_calc
|
||||
{
|
||||
json::value cb_info = basic_info();
|
||||
cb_info["what"] = "RecruitTagsRefreshed";
|
||||
cb_info["details"] = json::object { { "count", refresh_count }, { "refresh_limit", refresh_limit } };
|
||||
cb_info["details"] = json::object {
|
||||
{ "count", refresh_count },
|
||||
{ "refresh_limit", refresh_limit },
|
||||
};
|
||||
callback(AsstMsg::SubTaskExtraInfo, cb_info);
|
||||
Log.trace("recruit tags refreshed", std::to_string(refresh_count), " times, rerunning recruit task");
|
||||
}
|
||||
@@ -689,8 +692,11 @@ void asst::AutoRecruitTask::upload_to_penguin(const json::value& details)
|
||||
body["stageId"] = "recruit";
|
||||
auto& all_drops = body["drops"];
|
||||
for (const auto& tag : details.at("tags").as_array()) {
|
||||
all_drops.array_emplace(
|
||||
json::object { { "dropType", "NORMAL_DROP" }, { "itemId", tag.as_string() }, { "quantity", 1 } });
|
||||
all_drops.array_emplace(json::object {
|
||||
{ "dropType", "NORMAL_DROP" },
|
||||
{ "itemId", tag.as_string() },
|
||||
{ "quantity", 1 },
|
||||
});
|
||||
}
|
||||
body["source"] = "MeoAssistant";
|
||||
body["version"] = Version;
|
||||
|
||||
@@ -89,9 +89,11 @@ bool asst::BattleFormationTask::select_opers_in_cur_page()
|
||||
}
|
||||
});
|
||||
|
||||
static const std::array<Rect, 3> SkillRectArray = { Task.get("BattleQuickFormationSkill1")->specific_rect,
|
||||
Task.get("BattleQuickFormationSkill2")->specific_rect,
|
||||
Task.get("BattleQuickFormationSkill3")->specific_rect };
|
||||
static const std::array<Rect, 3> SkillRectArray = {
|
||||
Task.get("BattleQuickFormationSkill1")->specific_rect,
|
||||
Task.get("BattleQuickFormationSkill2")->specific_rect,
|
||||
Task.get("BattleQuickFormationSkill3")->specific_rect,
|
||||
};
|
||||
|
||||
int skill = 1;
|
||||
for (const auto& res : opers_result) {
|
||||
|
||||
@@ -1218,10 +1218,12 @@ cv::Mat asst::Controller::get_image(bool raw)
|
||||
}
|
||||
if (!success && !need_exit()) {
|
||||
Log.error(__FUNCTION__, "screencap failed!");
|
||||
json::value info = json::object { { "uuid", m_uuid },
|
||||
{ "what", "ScreencapFailed" },
|
||||
{ "why", "ScreencapFailed" },
|
||||
{ "details", json::object {} } };
|
||||
json::value info = json::object {
|
||||
{ "uuid", m_uuid },
|
||||
{ "what", "ScreencapFailed" },
|
||||
{ "why", "ScreencapFailed" },
|
||||
{ "details", json::object {} },
|
||||
};
|
||||
m_callback(AsstMsg::ConnectionInfo, info, m_callback_arg);
|
||||
|
||||
const static cv::Size d_size(m_scale_size.first, m_scale_size.second);
|
||||
|
||||
@@ -68,8 +68,11 @@ void asst::DepotRecognitionTask::callback_analyze_result()
|
||||
auto& arkplanner_data_items = arkplanner_obj["items"];
|
||||
|
||||
for (const auto& [item_id, item_info] : m_all_items) {
|
||||
arkplanner_data_items.array_emplace(
|
||||
json::object({ { "id", item_id }, { "have", item_info.quantity }, { "name", item_info.item_name } }));
|
||||
arkplanner_data_items.array_emplace(json::object {
|
||||
{ "id", item_id },
|
||||
{ "have", item_info.quantity },
|
||||
{ "name", item_info.item_name },
|
||||
});
|
||||
}
|
||||
arkplanner["data"] = arkplanner_obj.to_string();
|
||||
}
|
||||
|
||||
@@ -86,9 +86,11 @@ bool ProcessTask::_run()
|
||||
return false;
|
||||
}
|
||||
json::value info = basic_info();
|
||||
info["details"] = json::object { { "to_be_recognized", json::array(m_cur_tasks_name) },
|
||||
{ "cur_retry", m_cur_retry },
|
||||
{ "retry_times", m_retry_times } };
|
||||
info["details"] = json::object {
|
||||
{ "to_be_recognized", json::array(m_cur_tasks_name) },
|
||||
{ "cur_retry", m_cur_retry },
|
||||
{ "retry_times", m_retry_times },
|
||||
};
|
||||
Log.info(info.to_string());
|
||||
|
||||
auto front_task_ptr = Task.get(m_cur_tasks_name.front());
|
||||
@@ -134,8 +136,11 @@ bool ProcessTask::_run()
|
||||
|
||||
if (exec_times >= max_times) {
|
||||
info["what"] = "ExceededLimit";
|
||||
info["details"] =
|
||||
json::object { { "task", cur_name }, { "exec_times", exec_times }, { "max_times", max_times } };
|
||||
info["details"] = json::object {
|
||||
{ "task", cur_name },
|
||||
{ "exec_times", exec_times },
|
||||
{ "max_times", max_times },
|
||||
};
|
||||
Log.info("exec times exceeded the limit", info.to_string());
|
||||
callback(AsstMsg::SubTaskExtraInfo, info);
|
||||
m_cur_tasks_name = m_cur_task_ptr->exceeded_next;
|
||||
@@ -146,11 +151,13 @@ bool ProcessTask::_run()
|
||||
m_cur_retry = 0;
|
||||
++exec_times;
|
||||
|
||||
info["details"] = json::object { { "task", cur_name },
|
||||
{ "action", static_cast<int>(m_cur_task_ptr->action) },
|
||||
{ "exec_times", exec_times },
|
||||
{ "max_times", max_times },
|
||||
{ "algorithm", static_cast<int>(m_cur_task_ptr->algorithm) } };
|
||||
info["details"] = json::object {
|
||||
{ "task", cur_name },
|
||||
{ "action", static_cast<int>(m_cur_task_ptr->action) },
|
||||
{ "exec_times", exec_times },
|
||||
{ "max_times", max_times },
|
||||
{ "algorithm", static_cast<int>(m_cur_task_ptr->algorithm) },
|
||||
};
|
||||
|
||||
callback(AsstMsg::SubTaskStart, info);
|
||||
|
||||
|
||||
@@ -241,9 +241,10 @@ bool asst::RoguelikeBattleTaskPlugin::auto_battle()
|
||||
}
|
||||
}
|
||||
|
||||
static const std::array<BattleRole, 9> RoleOrder = { BattleRole::Warrior, BattleRole::Pioneer, BattleRole::Medic,
|
||||
BattleRole::Tank, BattleRole::Sniper, BattleRole::Caster,
|
||||
BattleRole::Support, BattleRole::Special, BattleRole::Drone };
|
||||
static const std::array<BattleRole, 9> RoleOrder = {
|
||||
BattleRole::Warrior, BattleRole::Pioneer, BattleRole::Medic, BattleRole::Tank, BattleRole::Sniper,
|
||||
BattleRole::Caster, BattleRole::Support, BattleRole::Special, BattleRole::Drone,
|
||||
};
|
||||
const auto use_oper_task_ptr = Task.get("BattleUseOper");
|
||||
const auto swipe_oper_task_ptr = Task.get("BattleSwipeOper");
|
||||
|
||||
|
||||
@@ -39,9 +39,11 @@ int asst::RoguelikeRecruitImageAnalyzer::match_elite(const Rect& raw_roi)
|
||||
{
|
||||
LogTraceFunction;
|
||||
|
||||
static const std::unordered_map<std::string, int> EliteTaskName = { { "Roguelike1RecruitElite0", 0 },
|
||||
{ "Roguelike1RecruitElite1", 1 },
|
||||
{ "Roguelike1RecruitElite2", 2 } };
|
||||
static const std::unordered_map<std::string, int> EliteTaskName = {
|
||||
{ "Roguelike1RecruitElite0", 0 },
|
||||
{ "Roguelike1RecruitElite1", 1 },
|
||||
{ "Roguelike1RecruitElite2", 2 },
|
||||
};
|
||||
|
||||
int elite_result = 0;
|
||||
double max_score = 0;
|
||||
|
||||
@@ -61,9 +61,11 @@ std::string asst::RoguelikeSkillSelectionImageAnalyzer::name_analyze(const Rect&
|
||||
|
||||
std::vector<asst::Rect> asst::RoguelikeSkillSelectionImageAnalyzer::skill_analyze(const Rect& roi)
|
||||
{
|
||||
static const std::vector<std::string> TasksName = { "Roguelike1SkillSelectionMove1",
|
||||
"Roguelike1SkillSelectionMove2",
|
||||
"Roguelike1SkillSelectionMove3" };
|
||||
static const std::array<std::string, 3> TasksName = {
|
||||
"Roguelike1SkillSelectionMove1",
|
||||
"Roguelike1SkillSelectionMove2",
|
||||
"Roguelike1SkillSelectionMove3",
|
||||
};
|
||||
std::vector<Rect> result;
|
||||
result.reserve(TasksName.size());
|
||||
|
||||
|
||||
@@ -228,7 +228,12 @@ void asst::StageDropsTaskPlugin::upload_to_penguin()
|
||||
body["stageId"] = stage_id;
|
||||
auto& all_drops = body["drops"];
|
||||
for (const auto& drop : m_cur_info_json["drops"].as_array()) {
|
||||
static const std::vector<std::string> filter = { "NORMAL_DROP", "EXTRA_DROP", "FURNITURE", "SPECIAL_DROP" };
|
||||
static const std::array<std::string, 4> filter = {
|
||||
"NORMAL_DROP",
|
||||
"EXTRA_DROP",
|
||||
"FURNITURE",
|
||||
"SPECIAL_DROP",
|
||||
};
|
||||
std::string drop_type = drop.at("dropType").as_string();
|
||||
if (ranges::find(filter, drop_type) == filter.cend()) {
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user