opt.加入一点奇怪的语法糖(

This commit is contained in:
MistEO
2022-01-08 02:00:35 +08:00
parent d2e129ebd7
commit a33ed4fffb
13 changed files with 148 additions and 130 deletions

View File

@@ -164,11 +164,10 @@ bool asst::Assistant::append_start_up(bool only_append)
std::unique_lock<std::mutex> lock(m_mutex);
auto task_ptr = std::make_shared<ProcessTask>(task_callback, (void*)this);
task_ptr->set_task_chain("StartUp");
task_ptr->set_tasks({ "StartUp" });
task_ptr->set_times_limit("ReturnToTerminal", 0);
task_ptr->set_times_limit("Terminal", 0);
auto task_ptr = std::make_shared<ProcessTask>(task_callback, (void*)this, "StartUp");
task_ptr->set_tasks({ "StartUp" })
.set_times_limit("ReturnToTerminal", 0)
.set_times_limit("Terminal", 0);
m_tasks_queue.emplace(task_ptr);
@@ -189,32 +188,29 @@ bool asst::Assistant::append_fight(const std::string& stage, int mecidine, int s
constexpr const char* TaskChain = "Fight";
// 进入选关界面(主界面的“终端”点进去)
auto terminal_task_ptr = std::make_shared<ProcessTask>(task_callback, (void*)this);
terminal_task_ptr->set_task_chain(TaskChain);
terminal_task_ptr->set_tasks({ "StageBegin" });
terminal_task_ptr->set_times_limit("LastBattle", 0);
terminal_task_ptr->set_times_limit("StartButton1", 0);
terminal_task_ptr->set_times_limit("StartButton2", 0);
terminal_task_ptr->set_times_limit("MedicineConfirm", 0);
terminal_task_ptr->set_times_limit("StoneConfirm", 0);
auto terminal_task_ptr = std::make_shared<ProcessTask>(task_callback, (void*)this, TaskChain);
terminal_task_ptr->set_tasks({ "StageBegin" })
.set_times_limit("LastBattle", 0)
.set_times_limit("StartButton1", 0)
.set_times_limit("StartButton2", 0)
.set_times_limit("MedicineConfirm", 0)
.set_times_limit("StoneConfirm", 0);
// 进入对应的关卡
auto stage_task_ptr = std::make_shared<ProcessTask>(task_callback, (void*)this);
stage_task_ptr->set_task_chain(TaskChain);
stage_task_ptr->set_tasks({ stage });
stage_task_ptr->set_times_limit("StartButton1", 0);
stage_task_ptr->set_times_limit("StartButton2", 0);
stage_task_ptr->set_times_limit("MedicineConfirm", 0);
stage_task_ptr->set_times_limit("StoneConfirm", 0);
auto stage_task_ptr = std::make_shared<ProcessTask>(task_callback, (void*)this, TaskChain);
stage_task_ptr->set_tasks({ stage })
.set_times_limit("StartButton1", 0)
.set_times_limit("StartButton2", 0)
.set_times_limit("MedicineConfirm", 0)
.set_times_limit("StoneConfirm", 0);
// 开始战斗任务
auto fight_task_ptr = std::make_shared<ProcessTask>(task_callback, (void*)this);
fight_task_ptr->set_task_chain(TaskChain);
fight_task_ptr->set_tasks({ "FightBegin" });
fight_task_ptr->set_times_limit("MedicineConfirm", mecidine);
fight_task_ptr->set_times_limit("StoneConfirm", stone);
fight_task_ptr->set_times_limit("StartButton1", times);
fight_task_ptr->set_times_limit("StartButton2", times);
auto fight_task_ptr = std::make_shared<ProcessTask>(task_callback, (void*)this, TaskChain);
fight_task_ptr->set_tasks({ "FightBegin" })
.set_times_limit("MedicineConfirm", mecidine)
.set_times_limit("StoneConfirm", stone)
.set_times_limit("StartButton1", times)
.set_times_limit("StartButton2", times);
std::unique_lock<std::mutex> lock(m_mutex);
@@ -262,13 +258,12 @@ bool asst::Assistant::append_mall(bool with_shopping, bool only_append)
std::unique_lock<std::mutex> lock(m_mutex);
const std::string task_chain = "Mall";
const std::string TaskChain = "Mall";
append_process_task("MallBegin", task_chain);
append_process_task("MallBegin", TaskChain);
if (with_shopping) {
auto shopping_task_ptr = std::make_shared<CreditShoppingTask>(task_callback, (void*)this);
shopping_task_ptr->set_task_chain(task_chain);
auto shopping_task_ptr = std::make_shared<CreditShoppingTask>(task_callback, (void*)this, TaskChain);
m_tasks_queue.emplace(shopping_task_ptr);
}
@@ -292,10 +287,9 @@ bool Assistant::append_process_task(const std::string& task_name, std::string ta
task_chain = task_name;
}
auto task_ptr = std::make_shared<ProcessTask>(task_callback, (void*)this);
task_ptr->set_task_chain(task_chain);
task_ptr->set_tasks({ task_name });
task_ptr->set_retry_times(retry_times);
auto task_ptr = std::make_shared<ProcessTask>(task_callback, (void*)this, task_chain);
task_ptr->set_tasks({ task_name })
.set_retry_times(retry_times);
m_tasks_queue.emplace(task_ptr);
@@ -316,14 +310,13 @@ bool asst::Assistant::append_recruit(unsigned max_times, const std::vector<int>&
append_process_task("RecruitBegin", TaskChain);
auto recruit_task_ptr = std::make_shared<AutoRecruitTask>(task_callback, (void*)this);
recruit_task_ptr->set_max_times(max_times);
recruit_task_ptr->set_need_refresh(need_refresh);
recruit_task_ptr->set_use_expedited(use_expedited);
recruit_task_ptr->set_select_level(select_level);
recruit_task_ptr->set_confirm_level(confirm_level);
recruit_task_ptr->set_task_chain(TaskChain);
recruit_task_ptr->set_retry_times(AutoRecruitTaskRetryTimesDefault);
auto recruit_task_ptr = std::make_shared<AutoRecruitTask>(task_callback, (void*)this, TaskChain);
recruit_task_ptr->set_max_times(max_times)
.set_need_refresh(need_refresh)
.set_use_expedited(use_expedited)
.set_select_level(select_level)
.set_confirm_level(confirm_level)
.set_retry_times(AutoRecruitTaskRetryTimesDefault);
m_tasks_queue.emplace(recruit_task_ptr);
@@ -342,11 +335,10 @@ bool Assistant::append_debug()
{
constexpr static const char* DebugTaskChain = "Debug";
auto shift_task_ptr = std::make_shared<InfrastControlTask>(task_callback, (void*)this);
auto shift_task_ptr = std::make_shared<InfrastControlTask>(task_callback, (void*)this, DebugTaskChain);
shift_task_ptr->set_work_mode(infrast::WorkMode::Aggressive);
shift_task_ptr->set_facility("Control");
shift_task_ptr->set_product("MoodAddition");
shift_task_ptr->set_task_chain(DebugTaskChain);
m_tasks_queue.emplace(shift_task_ptr);
}
@@ -363,10 +355,9 @@ bool Assistant::start_recruit_calc(const std::vector<int>& select_level, bool se
std::unique_lock<std::mutex> lock(m_mutex);
auto task_ptr = std::make_shared<RecruitTask>(task_callback, (void*)this);
task_ptr->set_param(select_level, set_time);
auto task_ptr = std::make_shared<RecruitTask>(task_callback, (void*)this, "RecruitCalc");
task_ptr->set_retry_times(OpenRecruitTaskRetryTimesDefault);
task_ptr->set_task_chain("RecruitCalc");
task_ptr->set_param(select_level, set_time);
m_tasks_queue.emplace(task_ptr);
return start(false);
@@ -392,45 +383,37 @@ bool asst::Assistant::append_infrast(infrast::WorkMode work_mode, const std::vec
append_infrast_begin();
auto info_task_ptr = std::make_shared<InfrastInfoTask>(task_callback, (void*)this);
info_task_ptr->set_work_mode(work_mode);
info_task_ptr->set_task_chain(InfrastTaskCahin);
info_task_ptr->set_mood_threshold(dorm_threshold);
auto info_task_ptr = std::make_shared<InfrastInfoTask>(task_callback, (void*)this, InfrastTaskCahin);
info_task_ptr->set_work_mode(work_mode)
.set_mood_threshold(dorm_threshold);
m_tasks_queue.emplace(info_task_ptr);
// 因为后期要考虑多任务间的联动等所以这些任务的声明暂时不放到for循环中
auto mfg_task_ptr = std::make_shared<InfrastMfgTask>(task_callback, (void*)this);
mfg_task_ptr->set_work_mode(work_mode);
mfg_task_ptr->set_task_chain(InfrastTaskCahin);
mfg_task_ptr->set_mood_threshold(dorm_threshold);
mfg_task_ptr->set_uses_of_drone(uses_of_drones);
auto trade_task_ptr = std::make_shared<InfrastTradeTask>(task_callback, (void*)this);
trade_task_ptr->set_work_mode(work_mode);
trade_task_ptr->set_task_chain(InfrastTaskCahin);
trade_task_ptr->set_mood_threshold(dorm_threshold);
trade_task_ptr->set_uses_of_drone(uses_of_drones);
auto power_task_ptr = std::make_shared<InfrastPowerTask>(task_callback, (void*)this);
power_task_ptr->set_work_mode(work_mode);
power_task_ptr->set_task_chain(InfrastTaskCahin);
power_task_ptr->set_mood_threshold(dorm_threshold);
auto office_task_ptr = std::make_shared<InfrastOfficeTask>(task_callback, (void*)this);
office_task_ptr->set_work_mode(work_mode);
office_task_ptr->set_task_chain(InfrastTaskCahin);
office_task_ptr->set_mood_threshold(dorm_threshold);
auto recpt_task_ptr = std::make_shared<InfrastReceptionTask>(task_callback, (void*)this);
recpt_task_ptr->set_work_mode(work_mode);
recpt_task_ptr->set_task_chain(InfrastTaskCahin);
recpt_task_ptr->set_mood_threshold(dorm_threshold);
auto control_task_ptr = std::make_shared<InfrastControlTask>(task_callback, (void*)this);
control_task_ptr->set_work_mode(work_mode);
control_task_ptr->set_task_chain(InfrastTaskCahin);
control_task_ptr->set_mood_threshold(dorm_threshold);
auto mfg_task_ptr = std::make_shared<InfrastMfgTask>(task_callback, (void*)this, InfrastTaskCahin);
mfg_task_ptr->set_uses_of_drone(uses_of_drones)
.set_work_mode(work_mode)
.set_mood_threshold(dorm_threshold);
auto trade_task_ptr = std::make_shared<InfrastTradeTask>(task_callback, (void*)this, InfrastTaskCahin);
trade_task_ptr->set_uses_of_drone(uses_of_drones)
.set_work_mode(work_mode)
.set_mood_threshold(dorm_threshold);
auto power_task_ptr = std::make_shared<InfrastPowerTask>(task_callback, (void*)this, InfrastTaskCahin);
power_task_ptr->set_work_mode(work_mode)
.set_mood_threshold(dorm_threshold);
auto office_task_ptr = std::make_shared<InfrastOfficeTask>(task_callback, (void*)this, InfrastTaskCahin);
office_task_ptr->set_work_mode(work_mode)
.set_mood_threshold(dorm_threshold);
auto recpt_task_ptr = std::make_shared<InfrastReceptionTask>(task_callback, (void*)this, InfrastTaskCahin);
recpt_task_ptr->set_work_mode(work_mode)
.set_mood_threshold(dorm_threshold);
auto control_task_ptr = std::make_shared<InfrastControlTask>(task_callback, (void*)this, InfrastTaskCahin);
control_task_ptr->set_work_mode(work_mode)
.set_mood_threshold(dorm_threshold);
auto dorm_task_ptr = std::make_shared<InfrastDormTask>(task_callback, (void*)this);
dorm_task_ptr->set_work_mode(work_mode);
dorm_task_ptr->set_task_chain(InfrastTaskCahin);
dorm_task_ptr->set_mood_threshold(dorm_threshold);
auto dorm_task_ptr = std::make_shared<InfrastDormTask>(task_callback, (void*)this, InfrastTaskCahin);
dorm_task_ptr->set_work_mode(work_mode)
.set_mood_threshold(dorm_threshold);
for (const auto& facility : order) {
if (facility == "Dorm") {