refactor: 将 Copilot ActionType::ResetTimer 更改为更适合的 ResetStopwatch (#14507)

* refactor: 为 ActionType::ResetTimer 加入中文变种

* refactor: Timer -> Stopwatch
This commit is contained in:
Weiyou Wang
2025-10-22 22:20:50 +11:00
committed by GitHub
parent a0ed14b919
commit 795efbcd23
5 changed files with 24 additions and 23 deletions

View File

@@ -217,15 +217,15 @@ using OperUsageGroups = std::vector<OperUsageGroup>;
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, // 引航者试炼,移动镜头

View File

@@ -177,10 +177,11 @@ std::vector<asst::battle::copilot::Action> 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");

View File

@@ -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::Rect> 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<std::chrono::milliseconds>(now - m_baseline_time).count();
auto elapsed_ms = std::chrono::duration_cast<std::chrono::milliseconds>(now - m_stopwatch_start_time).count();
if (elapsed_ms > std::numeric_limits<int>::max()) {
Log.error(__FUNCTION__, "| elapsed time exceeds int maximum");
return std::numeric_limits<int>::max();

View File

@@ -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<battle::DeploymentOper> m_cur_deployment_opers;

View File

@@ -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) {