mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-16 09:50:40 +08:00
feat: 新增抄作业功能循环次数设置
This commit is contained in:
@@ -10,25 +10,24 @@
|
||||
asst::CopilotTask::CopilotTask(const AsstCallback& callback, Assistant* inst)
|
||||
: InterfaceTask(callback, inst, TaskType),
|
||||
m_formation_task_ptr(std::make_shared<BattleFormationTask>(callback, inst, TaskType)),
|
||||
m_battle_task_ptr(std::make_shared<BattleProcessTask>(callback, inst, TaskType))
|
||||
m_battle_task_ptr(std::make_shared<BattleProcessTask>(callback, inst, TaskType)),
|
||||
m_stop_task_ptr(std::make_shared<ProcessTask>(callback, inst, TaskType))
|
||||
{
|
||||
for (int i = 0; i != 1000; ++i) {
|
||||
auto start_1_tp = std::make_shared<ProcessTask>(callback, inst, TaskType);
|
||||
start_1_tp->set_tasks({ "BattleStartPre" }).set_retry_times(0).set_ignore_error(true);
|
||||
m_subtasks.emplace_back(start_1_tp);
|
||||
auto start_1_tp = std::make_shared<ProcessTask>(callback, inst, TaskType);
|
||||
start_1_tp->set_tasks({ "BattleStartPre" }).set_retry_times(0).set_ignore_error(true);
|
||||
m_subtasks.emplace_back(start_1_tp);
|
||||
|
||||
m_subtasks.emplace_back(m_formation_task_ptr);
|
||||
m_subtasks.emplace_back(m_formation_task_ptr);
|
||||
|
||||
auto start_2_tp = std::make_shared<ProcessTask>(callback, inst, TaskType);
|
||||
start_2_tp->set_tasks({ "BattleStartAll" }).set_ignore_error(false);
|
||||
m_subtasks.emplace_back(start_2_tp);
|
||||
auto start_2_tp = std::make_shared<ProcessTask>(callback, inst, TaskType);
|
||||
start_2_tp->set_tasks({ "BattleStartAll" }).set_ignore_error(false);
|
||||
m_subtasks.emplace_back(start_2_tp);
|
||||
|
||||
m_subtasks.emplace_back(m_battle_task_ptr)->set_retry_times(0);
|
||||
m_subtasks.emplace_back(m_battle_task_ptr)->set_retry_times(0);
|
||||
|
||||
auto stop_task_ptr = std::make_shared<ProcessTask>(callback, inst, TaskType);
|
||||
stop_task_ptr->set_tasks({ "ClickCornerUntilStartButton" });
|
||||
m_subtasks.emplace_back(stop_task_ptr);
|
||||
}
|
||||
m_stop_task_ptr->set_tasks({ "ClickCornerUntilStartButton" });
|
||||
m_stop_task_ptr->set_enable(false);
|
||||
m_subtasks.emplace_back(m_stop_task_ptr);
|
||||
}
|
||||
|
||||
bool asst::CopilotTask::set_params(const json::value& params)
|
||||
@@ -59,5 +58,19 @@ bool asst::CopilotTask::set_params(const json::value& params)
|
||||
std::string support_unit_name = params.get("support_unit_name", std::string());
|
||||
m_formation_task_ptr->set_support_unit_name(std::move(support_unit_name));
|
||||
|
||||
size_t loop_times = params.get("loop_times", 1);
|
||||
if (loop_times > 1) {
|
||||
m_subtasks.reserve(m_subtasks.size() * loop_times);
|
||||
auto raw_end = m_subtasks.end();
|
||||
for (int i = 1; i < loop_times; ++i) {
|
||||
// FIXME: 如果多次调用 set_params,这里复制的会有问题
|
||||
m_subtasks.insert(m_subtasks.end(), m_subtasks.begin(), raw_end);
|
||||
}
|
||||
m_stop_task_ptr->set_enable(true);
|
||||
}
|
||||
else {
|
||||
m_stop_task_ptr->set_enable(false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user