feat: 跳过使用未准备好的技能 && 全局计时器 (#13913)

* feat: skip_if_not_ready

* feat: elapsed_time

* feat: WpfGui log 输出计时器信息

* chore: Auto update by pre-commit hooks [skip changelog]

* feat: 不默认启用全局计时器

* refactor: 支持 ResetTimer 拼写变种

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Weiyou Wang
2025-10-20 01:35:37 +11:00
committed by GitHub
parent 45025dd168
commit 1edd006982
11 changed files with 83 additions and 7 deletions

View File

@@ -228,7 +228,9 @@ bool asst::BattleProcessTask::do_action(const battle::copilot::Action& action, s
break;
case ActionType::UseSkill:
ret = m_in_bullet_time ? click_skill() : (location.empty() ? use_skill(name) : use_skill(location));
ret = m_in_bullet_time ? click_skill(!action.skip_if_not_ready)
: (location.empty() ? use_skill(name, !action.skip_if_not_ready)
: use_skill(location, !action.skip_if_not_ready));
if (ret) {
m_in_bullet_time = false;
}
@@ -262,6 +264,11 @@ bool asst::BattleProcessTask::do_action(const battle::copilot::Action& action, s
ret = move_camera(action.distance);
break;
case ActionType::ResetTimer:
m_baseline_time = std::chrono::steady_clock::now();
m_timer_enabled = true;
break;
case ActionType::SkillDaemon:
ret = wait_until_end();
break;
@@ -299,15 +306,15 @@ void asst::BattleProcessTask::notify_action(const battle::copilot::Action& actio
{ ActionType::MoveCamera, "MoveCamera" },
{ ActionType::DrawCard, "DrawCard" },
{ ActionType::CheckIfStartOver, "CheckIfStartOver" },
{ ActionType::Deploy, "ResetTimer" },
};
json::value info = basic_info_with_what("CopilotAction");
info["details"] |= json::object {
{ "action", ActionNames.at(action.type) },
{ "target", action.name },
{ "doc", action.doc },
{ "doc_color", action.doc_color },
};
info["details"] |= json::object { { "action", ActionNames.at(action.type) },
{ "target", action.name },
{ "doc", action.doc },
{ "doc_color", action.doc_color },
{ "elapsed_time", elapsed_time() } };
callback(AsstMsg::SubTaskExtraInfo, info);
}
@@ -392,6 +399,25 @@ bool asst::BattleProcessTask::wait_condition(const Action& action)
}
}
// 等待全局计时器
if (action.elapsed_time > 0) {
if (m_timer_enabled) {
update_image_if_empty();
while (!need_exit()) {
if (elapsed_time() >= action.elapsed_time) {
break;
}
if (!check_in_battle(image)) {
return false;
}
do_strategy_and_update_image();
}
}
else {
Log.warn(__FUNCTION__, "| Timer not enabled. Reset required before use.");
}
}
// 部署干员还要额外等待费用够或 CD 转好
if (action.type == ActionType::Deploy) {
const std::string& name = get_name_from_group(action.name);