mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-17 10:00:44 +08:00
feat: 初步完成保全干员部署逻辑
This commit is contained in:
@@ -41,7 +41,7 @@ bool asst::BattleProcessTask::_run()
|
||||
update_deployment(true);
|
||||
to_group();
|
||||
|
||||
for (size_t i = 0; i < m_combat_data.actions.size() && !need_exit(); ++i) {
|
||||
for (size_t i = 0; i < get_combat_data().actions.size() && !need_exit(); ++i) {
|
||||
do_action(i);
|
||||
}
|
||||
|
||||
@@ -56,6 +56,11 @@ void asst::BattleProcessTask::clear()
|
||||
m_in_bullet_time = false;
|
||||
}
|
||||
|
||||
bool asst::BattleProcessTask::do_strategic_action(const cv::Mat& reusable)
|
||||
{
|
||||
return use_all_ready_skill(reusable);
|
||||
}
|
||||
|
||||
bool asst::BattleProcessTask::set_stage_name(const std::string& stage_name)
|
||||
{
|
||||
LogTraceFunction;
|
||||
@@ -78,7 +83,7 @@ void asst::BattleProcessTask::load_cache()
|
||||
{
|
||||
LogTraceFunction;
|
||||
|
||||
for (const auto& oper_list : m_combat_data.groups | views::values) {
|
||||
for (const auto& oper_list : get_combat_data().groups | views::values) {
|
||||
for (const auto& oper : oper_list) {
|
||||
load_avatar_cache(oper.name, true);
|
||||
}
|
||||
@@ -89,7 +94,7 @@ void asst::BattleProcessTask::load_cache()
|
||||
bool asst::BattleProcessTask::to_group()
|
||||
{
|
||||
std::unordered_map<std::string, std::vector<std::string>> groups;
|
||||
for (const auto& [group_name, oper_list] : m_combat_data.groups) {
|
||||
for (const auto& [group_name, oper_list] : get_combat_data().groups) {
|
||||
std::vector<std::string> oper_name_list;
|
||||
ranges::transform(oper_list, std::back_inserter(oper_name_list), [](const auto& oper) { return oper.name; });
|
||||
groups.emplace(group_name, std::move(oper_name_list));
|
||||
@@ -125,7 +130,7 @@ bool asst::BattleProcessTask::to_group()
|
||||
}
|
||||
|
||||
for (const auto& [group_name, oper_name] : m_oper_in_group) {
|
||||
auto& this_group = m_combat_data.groups[group_name];
|
||||
auto& this_group = get_combat_data().groups[group_name];
|
||||
// there is a build error on macOS
|
||||
// https://github.com/MaaAssistantArknights/MaaAssistantArknights/actions/runs/3779762713/jobs/6425284487
|
||||
const std::string& oper_name_for_lambda = oper_name;
|
||||
@@ -141,7 +146,7 @@ bool asst::BattleProcessTask::to_group()
|
||||
|
||||
bool asst::BattleProcessTask::do_action(size_t action_index)
|
||||
{
|
||||
const auto& action = m_combat_data.actions.at(action_index);
|
||||
const auto& action = get_combat_data().actions.at(action_index);
|
||||
|
||||
notify_action(action);
|
||||
|
||||
@@ -149,7 +154,7 @@ bool asst::BattleProcessTask::do_action(size_t action_index)
|
||||
return false;
|
||||
}
|
||||
if (action.pre_delay > 0) {
|
||||
sleep_with_use_ready_skill(action.pre_delay);
|
||||
sleep_and_do_not_urgent(action.pre_delay);
|
||||
// 等待之后画面可能会变化,更新下干员信息
|
||||
update_deployment();
|
||||
}
|
||||
@@ -196,9 +201,12 @@ bool asst::BattleProcessTask::do_action(size_t action_index)
|
||||
case ActionType::SkillDaemon:
|
||||
ret = wait_for_end();
|
||||
break;
|
||||
default:
|
||||
ret = do_derived_action(action_index);
|
||||
break;
|
||||
}
|
||||
|
||||
sleep_with_use_ready_skill(action.post_delay);
|
||||
sleep_and_do_not_urgent(action.post_delay);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -228,8 +236,8 @@ bool asst::BattleProcessTask::wait_condition(const Action& action)
|
||||
auto update_image_if_empty = [&]() {
|
||||
if (image.empty()) image = ctrler()->get_image();
|
||||
};
|
||||
auto use_all_ready_skill_then_update_image = [&]() {
|
||||
use_all_ready_skill(image);
|
||||
auto do_strategy_and_update_image = [&]() {
|
||||
do_strategic_action(image);
|
||||
image = ctrler()->get_image();
|
||||
};
|
||||
|
||||
@@ -246,7 +254,7 @@ bool asst::BattleProcessTask::wait_condition(const Action& action)
|
||||
break;
|
||||
}
|
||||
}
|
||||
use_all_ready_skill_then_update_image();
|
||||
do_strategy_and_update_image();
|
||||
} while (!need_exit());
|
||||
}
|
||||
|
||||
@@ -257,7 +265,7 @@ bool asst::BattleProcessTask::wait_condition(const Action& action)
|
||||
if (m_kills >= action.kills) {
|
||||
break;
|
||||
}
|
||||
use_all_ready_skill_then_update_image();
|
||||
do_strategy_and_update_image();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -268,7 +276,7 @@ bool asst::BattleProcessTask::wait_condition(const Action& action)
|
||||
if (m_cost >= action.costs) {
|
||||
break;
|
||||
}
|
||||
use_all_ready_skill_then_update_image();
|
||||
do_strategy_and_update_image();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -282,7 +290,7 @@ bool asst::BattleProcessTask::wait_condition(const Action& action)
|
||||
if (cooling_count == action.cooling) {
|
||||
break;
|
||||
}
|
||||
use_all_ready_skill_then_update_image();
|
||||
do_strategy_and_update_image();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -296,7 +304,7 @@ bool asst::BattleProcessTask::wait_condition(const Action& action)
|
||||
iter != m_cur_deployment_opers.cend() && iter->second.available) {
|
||||
break;
|
||||
}
|
||||
use_all_ready_skill_then_update_image();
|
||||
do_strategy_and_update_image();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -308,11 +316,11 @@ bool asst::BattleProcessTask::enter_bullet_time_for_next_action(size_t next_inde
|
||||
{
|
||||
LogTraceFunction;
|
||||
|
||||
if (next_index > m_combat_data.actions.size()) {
|
||||
if (next_index > get_combat_data().actions.size()) {
|
||||
Log.error("Bullet time does not have the next step!");
|
||||
return false;
|
||||
}
|
||||
const auto& next_action = m_combat_data.actions.at(next_index);
|
||||
const auto& next_action = get_combat_data().actions.at(next_index);
|
||||
|
||||
bool ret = false;
|
||||
switch (next_action.type) {
|
||||
@@ -333,7 +341,7 @@ bool asst::BattleProcessTask::enter_bullet_time_for_next_action(size_t next_inde
|
||||
return ret;
|
||||
}
|
||||
|
||||
void asst::BattleProcessTask::sleep_with_use_ready_skill(unsigned millisecond)
|
||||
void asst::BattleProcessTask::sleep_and_do_not_urgent(unsigned millisecond)
|
||||
{
|
||||
LogTraceScope(__FUNCTION__ + std::to_string(millisecond));
|
||||
|
||||
@@ -342,7 +350,7 @@ void asst::BattleProcessTask::sleep_with_use_ready_skill(unsigned millisecond)
|
||||
const auto delay = millisecond * 1ms;
|
||||
|
||||
while (!need_exit() && std::chrono::steady_clock::now() - start < delay) {
|
||||
use_all_ready_skill();
|
||||
do_strategic_action();
|
||||
std::this_thread::yield();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user