feat: 根据review将check_skip_plot_button移动到BattleProcess里面

This commit is contained in:
Lancarus
2023-10-07 02:14:45 +08:00
parent 6d85d57c74
commit 206a7042e2
3 changed files with 29 additions and 2 deletions

View File

@@ -408,7 +408,6 @@ bool asst::BattleHelper::check_skip_plot_button(const cv::Mat& reusable)
bool asst::BattleHelper::check_in_battle(const cv::Mat& reusable, bool weak)
{
cv::Mat image = reusable.empty() ? m_inst_helper.ctrler()->get_image() : reusable;
check_skip_plot_button(image);
if (weak) {
BattlefieldMatcher analyzer(image);
m_in_battle = analyzer.analyze().has_value();

View File

@@ -336,7 +336,10 @@ bool asst::BattleProcessTask::wait_condition(const Action& action)
const std::string& name = get_name_from_group(action.name);
update_image_if_empty();
while (!need_exit()) {
if (!update_deployment(false, image)) {
if (check_skip_plot_button(image)) {
speed_up();
}
else if (!update_deployment(false, image)) {
return false;
}
if (auto iter = m_cur_deployment_opers.find(name);
@@ -375,3 +378,25 @@ void asst::BattleProcessTask::sleep_and_do_strategy(unsigned millisecond)
std::this_thread::yield();
}
}
bool asst::BattleProcessTask::check_in_battle(const cv::Mat& reusable, bool weak)
{
LogTraceFunction;
cv::Mat image = reusable;
return check_skip_plot_button(image) ? speed_up() && false : BattleHelper::check_in_battle(image, weak);
}
bool asst::BattleProcessTask::wait_until_end(bool weak)
{
LogTraceFunction;
cv::Mat image = ctrler()->get_image();
while (!need_exit() && check_in_battle(image, weak)) {
do_strategic_action(image);
std::this_thread::yield();
image = ctrler()->get_image();
}
return true;
}

View File

@@ -39,6 +39,9 @@ namespace asst
bool enter_bullet_time(const std::string& name, const Point& location);
void sleep_and_do_strategy(unsigned millisecond);
bool check_in_battle(const cv::Mat& reusable = cv::Mat(), bool weak = true);
bool wait_until_end(bool weak = true);
battle::copilot::CombatData m_combat_data;
std::unordered_map</*group*/ std::string, /*oper*/ std::string> m_oper_in_group;