MistEO
2022-09-30 23:31:05 +08:00
parent 0b32d6afaf
commit acb0687091
5 changed files with 62 additions and 10 deletions

View File

@@ -460,5 +460,21 @@
"Roguelike2CloseCollectionContinue",
"Roguelike2CloseCollectionClose"
]
},
"Roguelike2DiceConfirmThenAbandon": {
"Doc": "骰子的确认按钮",
"action": "ClickSelf",
"template": "Roguelike2DiceConfirm.png",
"cache": false,
"roi": [
551,
577,
174,
143
],
"templThreshold": 0.95,
"next": [
"Roguelike1ExitThenAbandon"
]
}
}

View File

@@ -7919,9 +7919,6 @@
234,
204
],
"exceededNext": [
"Roguelike1ExitThenAbandon"
],
"next": [
"Roguelike1StageTraderLeaveConfirm",
"Roguelike1StageTraderLeave"
@@ -7976,6 +7973,10 @@
295,
203
],
"exceededNext": [
"Roguelike2DiceConfirmThenAbandon",
"Roguelike1ExitThenAbandon"
],
"next": [
"Roguelike1StageTrader",
"Roguelike1StageSafeHouse",
@@ -7993,6 +7994,10 @@
"Roguelike2CloseCollectionClose"
]
},
"Roguelike2DiceConfirmThenAbandon": {
"template": "empty.png",
"templThreshold": 2.0
},
"Roguelike2CloseCollectionContinue": {
"template": "empty.png",
"templThreshold": 2.0

View File

@@ -50,7 +50,7 @@ bool asst::RoguelikeTask::set_params(const json::value& params)
case 0:
break;
case 1:
m_roguelike_task_ptr->set_times_limit("Roguelike1StageTraderLeave", 0);
m_roguelike_task_ptr->set_times_limit("Roguelike1StageTraderLeaveConfirm", 0, ProcessTask::TimesLimitType::Post);
break;
case 2:
[[unlikely]] m_roguelike_task_ptr->set_times_limit("Roguelike1StageTraderInvestCancel", 0);

View File

@@ -67,9 +67,9 @@ asst::ProcessTask& asst::ProcessTask::set_tasks(std::vector<std::string> tasks_n
return *this;
}
ProcessTask& asst::ProcessTask::set_times_limit(std::string name, int limit)
ProcessTask& asst::ProcessTask::set_times_limit(std::string name, int limit, TimesLimitType type)
{
m_times_limit[std::move(name)] = limit;
m_times_limit[std::move(name)] = TimesLimitData { limit, type };
return *this;
}
@@ -136,16 +136,19 @@ bool ProcessTask::_run()
int& exec_times = m_exec_times[cur_name];
int max_times = m_cur_task_ptr->max_times;
TimesLimitType limit_type = TimesLimitType::Pre;
if (auto iter = m_times_limit.find(cur_name); iter != m_times_limit.cend()) {
max_times = iter->second;
max_times = iter->second.times;
limit_type = iter->second.type;
}
if (exec_times >= max_times) {
if (limit_type == TimesLimitType::Pre && exec_times >= max_times) {
info["what"] = "ExceededLimit";
info["details"] = json::object {
{ "task", cur_name },
{ "exec_times", exec_times },
{ "max_times", max_times },
{ "limit_type", "pre" },
};
Log.info("exec times exceeded the limit", info.to_string());
callback(AsstMsg::SubTaskExtraInfo, info);
@@ -243,6 +246,21 @@ bool ProcessTask::_run()
callback(AsstMsg::SubTaskCompleted, info);
if (limit_type == TimesLimitType::Post && exec_times >= max_times) {
info["what"] = "ExceededLimit";
info["details"] = json::object {
{ "task", cur_name },
{ "exec_times", exec_times },
{ "max_times", max_times },
{ "limit_type", "post" },
};
Log.info("exec times exceeded the limit", info.to_string());
callback(AsstMsg::SubTaskExtraInfo, info);
m_cur_tasks_name = m_cur_task_ptr->exceeded_next;
sleep(m_task_delay);
continue;
}
if (m_cur_task_ptr->next.empty()) {
need_stop = true;
}

View File

@@ -8,6 +8,19 @@ namespace asst
// 流程任务,按照配置文件里的设置的流程运行
class ProcessTask : public AbstractTask
{
public:
enum class TimesLimitType
{
Pre,
Post,
};
struct TimesLimitData
{
int times = 0;
TimesLimitType type = TimesLimitType::Pre;
};
public:
using AbstractTask::AbstractTask;
ProcessTask(const AbstractTask& abs, std::vector<std::string> tasks_name);
@@ -19,7 +32,7 @@ namespace asst
ProcessTask& set_task_delay(int delay) noexcept;
ProcessTask& set_tasks(std::vector<std::string> tasks_name) noexcept;
ProcessTask& set_times_limit(std::string name, int limit);
ProcessTask& set_times_limit(std::string name, int limit, TimesLimitType type = TimesLimitType::Pre);
ProcessTask& set_rear_delay(std::string name, int delay);
protected:
@@ -36,7 +49,7 @@ namespace asst
std::vector<std::string> m_cur_tasks_name;
std::string m_pre_task_name;
std::unordered_map<std::string, int> m_rear_delay;
std::unordered_map<std::string, int> m_times_limit;
std::unordered_map<std::string, TimesLimitData> m_times_limit;
std::unordered_map<std::string, int> m_exec_times;
static constexpr int TaskDelayUnsetted = -1;
int m_task_delay = TaskDelayUnsetted;