From 880bdea7d3d141e41309f6a8a4b6680f31dc6b9b Mon Sep 17 00:00:00 2001 From: Weiyou Wang <44151844+Alan-Charred@users.noreply.github.com> Date: Wed, 22 Oct 2025 22:20:50 +1100 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=B0=86=20Copilot=20ActionType::R?= =?UTF-8?q?esetTimer=20=E6=9B=B4=E6=94=B9=E4=B8=BA=E6=9B=B4=E9=80=82?= =?UTF-8?q?=E5=90=88=E7=9A=84=20ResetStopwatch=20(#14507)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: 为 ActionType::ResetTimer 加入中文变种 * refactor: Timer -> Stopwatch --- src/MaaCore/Common/AsstBattleDef.h | 18 +++++++++--------- .../Config/Miscellaneous/CopilotConfig.cpp | 9 +++++---- src/MaaCore/Task/BattleHelper.cpp | 6 +++--- src/MaaCore/Task/BattleHelper.h | 4 ++-- .../Task/Miscellaneous/BattleProcessTask.cpp | 10 +++++----- 5 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/MaaCore/Common/AsstBattleDef.h b/src/MaaCore/Common/AsstBattleDef.h index 1277a73bc3..64d46c5357 100644 --- a/src/MaaCore/Common/AsstBattleDef.h +++ b/src/MaaCore/Common/AsstBattleDef.h @@ -217,15 +217,15 @@ using OperUsageGroups = std::vector; enum class ActionType { - Deploy, // 部署干员 - UseSkill, // 开技能 - Retreat, // 撤退干员 - SkillUsage, // 技能用法 - SwitchSpeed, // 切换二倍速 - BulletTime, // 使用 1/5 的速度 - Output, // 仅输出,什么都不操作,界面上也不显示 - SkillDaemon, // 什么都不做,有技能开技能,直到战斗结束 - ResetTimer, // 重置全局计时器 (试验性功能) + Deploy, // 部署干员 + UseSkill, // 开技能 + Retreat, // 撤退干员 + SkillUsage, // 技能用法 + SwitchSpeed, // 切换二倍速 + BulletTime, // 使用 1/5 的速度 + Output, // 仅输出,什么都不操作,界面上也不显示 + SkillDaemon, // 什么都不做,有技能开技能,直到战斗结束 + ResetStopwatch, // 重置全局计时器 (试验性功能) /* for TRN */ MoveCamera, // 引航者试炼,移动镜头 diff --git a/src/MaaCore/Config/Miscellaneous/CopilotConfig.cpp b/src/MaaCore/Config/Miscellaneous/CopilotConfig.cpp index a40ac52f3a..7694ff5a6d 100644 --- a/src/MaaCore/Config/Miscellaneous/CopilotConfig.cpp +++ b/src/MaaCore/Config/Miscellaneous/CopilotConfig.cpp @@ -177,10 +177,11 @@ std::vector asst::CopilotConfig::parse_actions(co { "checkifstartover", ActionType::CheckIfStartOver }, { "检查重开", ActionType::CheckIfStartOver }, - { "ResetTimer", ActionType::ResetTimer }, - { "RESETTIMER", ActionType::ResetTimer }, - { "resettimer", ActionType::ResetTimer }, - { "Resettimer", ActionType::ResetTimer }, + { "ResetStopwatch", ActionType::ResetStopwatch }, + { "RESETSTOPWATCH", ActionType::ResetStopwatch }, + { "resetstopwatch", ActionType::ResetStopwatch }, + { "Resetstopwatch", ActionType::ResetStopwatch }, + { "重置全局计时器", ActionType::ResetStopwatch }, }; std::string type_str = action_info.get("type", "Deploy"); diff --git a/src/MaaCore/Task/BattleHelper.cpp b/src/MaaCore/Task/BattleHelper.cpp index 84d9188971..99111db325 100644 --- a/src/MaaCore/Task/BattleHelper.cpp +++ b/src/MaaCore/Task/BattleHelper.cpp @@ -54,7 +54,7 @@ void asst::BattleHelper::clear() m_in_battle = false; m_kills = 0; m_total_kills = 0; - m_timer_enabled = false; + m_stopwatch_enabled = false; m_cur_deployment_opers.clear(); m_battlefield_opers.clear(); m_used_tiles.clear(); @@ -1035,11 +1035,11 @@ std::optional asst::BattleHelper::get_oper_rect_on_deployment(const int asst::BattleHelper::elapsed_time() { - if (!m_timer_enabled) { + if (!m_stopwatch_enabled) { return -1; } auto now = std::chrono::steady_clock::now(); - auto elapsed_ms = std::chrono::duration_cast(now - m_baseline_time).count(); + auto elapsed_ms = std::chrono::duration_cast(now - m_stopwatch_start_time).count(); if (elapsed_ms > std::numeric_limits::max()) { Log.error(__FUNCTION__, "| elapsed time exceeds int maximum"); return std::numeric_limits::max(); diff --git a/src/MaaCore/Task/BattleHelper.h b/src/MaaCore/Task/BattleHelper.h index 9813e25575..942315975e 100644 --- a/src/MaaCore/Task/BattleHelper.h +++ b/src/MaaCore/Task/BattleHelper.h @@ -119,8 +119,8 @@ protected: int m_kills = 0; int m_total_kills = 0; int m_cost = 0; - bool m_timer_enabled = false; - std::chrono::steady_clock::time_point m_baseline_time; + bool m_stopwatch_enabled = false; + std::chrono::steady_clock::time_point m_stopwatch_start_time; std::vector m_cur_deployment_opers; diff --git a/src/MaaCore/Task/Miscellaneous/BattleProcessTask.cpp b/src/MaaCore/Task/Miscellaneous/BattleProcessTask.cpp index 00fae1a896..9d4e4a3559 100644 --- a/src/MaaCore/Task/Miscellaneous/BattleProcessTask.cpp +++ b/src/MaaCore/Task/Miscellaneous/BattleProcessTask.cpp @@ -264,9 +264,9 @@ 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; + case ActionType::ResetStopwatch: + m_stopwatch_start_time = std::chrono::steady_clock::now(); + m_stopwatch_enabled = true; break; case ActionType::SkillDaemon: @@ -306,7 +306,7 @@ void asst::BattleProcessTask::notify_action(const battle::copilot::Action& actio { ActionType::MoveCamera, "MoveCamera" }, { ActionType::DrawCard, "DrawCard" }, { ActionType::CheckIfStartOver, "CheckIfStartOver" }, - { ActionType::Deploy, "ResetTimer" }, + { ActionType::ResetStopwatch, "ResetStopwatch" }, }; json::value info = basic_info_with_what("CopilotAction"); @@ -401,7 +401,7 @@ bool asst::BattleProcessTask::wait_condition(const Action& action) // 等待全局计时器 if (action.elapsed_time > 0) { - if (m_timer_enabled) { + if (m_stopwatch_enabled) { update_image_if_empty(); while (!need_exit()) { if (elapsed_time() >= action.elapsed_time) {