Skip to content

fix(campaign): 低心情撤退后切换后续活动任务 - #767

Open
a2893005741 wants to merge 8 commits into
wess09:devfrom
a2893005741:agent/low-emotion-withdraw-task-chain
Open

fix(campaign): 低心情撤退后切换后续活动任务#767
a2893005741 wants to merge 8 commits into
wess09:devfrom
a2893005741:agent/low-emotion-withdraw-task-chain

Conversation

@a2893005741

@a2893005741 a2893005741 commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

变更

  • 仅在“计算心情消耗”模式下,低心情强制出击弹窗改为取消并撤退。
  • 游戏端已出现低心情弹窗时,将当前出击舰队按 0 心情记录并延后当前活动任务,避免旧记录值使任务立即重跑。
  • Event、Event2 撤退后分别唤起 Event2、Event3;Event3 则交回调度器执行后续任务。
  • 撤退过程中处理战斗结算与掉落界面,确保能回到关卡界面。

原因

原流程会在忽略心情的配置下确认强制出击;而游戏端提示已低心情时,本地记录可能仍是较高的旧值,导致延后时间被计算为当前时间。

验证

  • python -m unittest tests.test_low_emotion_withdraw
  • python -m py_compile module/campaign/campaign_base.py module/campaign/run.py
  • git diff --check

Summary by Sourcery

通过在活动中推迟当前事件任务、调整情绪恢复的调度,并确保 UI 可靠返回到关卡界面,来处理低情绪撤退情形。

New Features:

  • 添加活动级的低情绪撤退处理逻辑,用于更新情绪记录、延迟当前事件任务,并可根据调度器优先级选择性地切换到下一个事件地图。

Bug Fixes:

  • 修改低情绪强制出击的处理方式,使在情绪消耗计算模式下,提示会被取消且地图被撤退,防止过期的情绪值导致同一任务被立即重新调度。

Enhancements:

  • 扩展撤退流程以处理战斗准备页面、战斗结果、经验、舰船、物品以及状态弹窗,确保撤退操作始终能返回到关卡 UI。

Tests:

  • 添加单元测试,覆盖低情绪撤退行为、情绪恢复计算、事件任务串联,以及战斗准备和战斗结果界面的撤退处理。
Original summary in English

Summary by Sourcery

Handle low-emotion withdrawal in campaigns by postponing the current event task, adjusting emotion recovery scheduling, and ensuring the UI reliably returns to the stage screen.

New Features:

  • Add campaign-level low-emotion withdrawal handling that updates emotion records, delays the current event task, and optionally switches to the next event map based on scheduler priority.

Bug Fixes:

  • Change low-emotion forced sortie handling so that in emotion-consumption calculation mode the prompt is canceled and the map is withdrawn, preventing stale emotion values from causing immediate rescheduling of the same task.

Enhancements:

  • Extend the withdrawal flow to process battle preparation pages, battle results, experience, ship, item, and status popups so withdrawal consistently returns to the stage UI.

Tests:

  • Add unit tests covering low-emotion withdrawal behavior, emotion recovery calculation, event task chaining, and withdrawal handling of battle preparation and result screens.
Original summary in English

Summary by Sourcery

通过在活动中推迟当前事件任务、调整情绪恢复的调度,并确保 UI 可靠返回到关卡界面,来处理低情绪撤退情形。

New Features:

  • 添加活动级的低情绪撤退处理逻辑,用于更新情绪记录、延迟当前事件任务,并可根据调度器优先级选择性地切换到下一个事件地图。

Bug Fixes:

  • 修改低情绪强制出击的处理方式,使在情绪消耗计算模式下,提示会被取消且地图被撤退,防止过期的情绪值导致同一任务被立即重新调度。

Enhancements:

  • 扩展撤退流程以处理战斗准备页面、战斗结果、经验、舰船、物品以及状态弹窗,确保撤退操作始终能返回到关卡 UI。

Tests:

  • 添加单元测试,覆盖低情绪撤退行为、情绪恢复计算、事件任务串联,以及战斗准备和战斗结果界面的撤退处理。
Original summary in English

Summary by Sourcery

Handle low-emotion withdrawal in campaigns by postponing the current event task, adjusting emotion recovery scheduling, and ensuring the UI reliably returns to the stage screen.

New Features:

  • Add campaign-level low-emotion withdrawal handling that updates emotion records, delays the current event task, and optionally switches to the next event map based on scheduler priority.

Bug Fixes:

  • Change low-emotion forced sortie handling so that in emotion-consumption calculation mode the prompt is canceled and the map is withdrawn, preventing stale emotion values from causing immediate rescheduling of the same task.

Enhancements:

  • Extend the withdrawal flow to process battle preparation pages, battle results, experience, ship, item, and status popups so withdrawal consistently returns to the stage UI.

Tests:

  • Add unit tests covering low-emotion withdrawal behavior, emotion recovery calculation, event task chaining, and withdrawal handling of battle preparation and result screens.

新特性:

  • 引入活动层面的低情绪撤退处理逻辑,可推迟当前事件任务,并在需要时切换到序列中的下一个事件地图。

错误修复:

  • 调整低情绪强制出击的处理方式,使在情绪消耗计算模式下的提示被取消并直接从地图撤退,防止使用过期情绪值导致同一任务被立即重新排程。

功能改进:

  • 扩展撤退流程以处理战斗准备、战斗结果、经验、舰船、道具和状态弹窗,确保撤退操作能可靠地返回到关卡舞台界面。

测试:

  • 添加单元测试,覆盖低情绪撤退行为、任务延迟与事件切换逻辑,以及战斗准备和战斗结果界面的撤退处理。
Original summary in English

Summary by Sourcery

通过在活动中推迟当前事件任务、调整情绪恢复的调度,并确保 UI 可靠返回到关卡界面,来处理低情绪撤退情形。

New Features:

  • 添加活动级的低情绪撤退处理逻辑,用于更新情绪记录、延迟当前事件任务,并可根据调度器优先级选择性地切换到下一个事件地图。

Bug Fixes:

  • 修改低情绪强制出击的处理方式,使在情绪消耗计算模式下,提示会被取消且地图被撤退,防止过期的情绪值导致同一任务被立即重新调度。

Enhancements:

  • 扩展撤退流程以处理战斗准备页面、战斗结果、经验、舰船、物品以及状态弹窗,确保撤退操作始终能返回到关卡 UI。

Tests:

  • 添加单元测试,覆盖低情绪撤退行为、情绪恢复计算、事件任务串联,以及战斗准备和战斗结果界面的撤退处理。
Original summary in English

Summary by Sourcery

Handle low-emotion withdrawal in campaigns by postponing the current event task, adjusting emotion recovery scheduling, and ensuring the UI reliably returns to the stage screen.

New Features:

  • Add campaign-level low-emotion withdrawal handling that updates emotion records, delays the current event task, and optionally switches to the next event map based on scheduler priority.

Bug Fixes:

  • Change low-emotion forced sortie handling so that in emotion-consumption calculation mode the prompt is canceled and the map is withdrawn, preventing stale emotion values from causing immediate rescheduling of the same task.

Enhancements:

  • Extend the withdrawal flow to process battle preparation pages, battle results, experience, ship, item, and status popups so withdrawal consistently returns to the stage UI.

Tests:

  • Add unit tests covering low-emotion withdrawal behavior, emotion recovery calculation, event task chaining, and withdrawal handling of battle preparation and result screens.
Original summary in English

Summary by Sourcery

通过在活动中推迟当前事件任务、调整情绪恢复的调度,并确保 UI 可靠返回到关卡界面,来处理低情绪撤退情形。

New Features:

  • 添加活动级的低情绪撤退处理逻辑,用于更新情绪记录、延迟当前事件任务,并可根据调度器优先级选择性地切换到下一个事件地图。

Bug Fixes:

  • 修改低情绪强制出击的处理方式,使在情绪消耗计算模式下,提示会被取消且地图被撤退,防止过期的情绪值导致同一任务被立即重新调度。

Enhancements:

  • 扩展撤退流程以处理战斗准备页面、战斗结果、经验、舰船、物品以及状态弹窗,确保撤退操作始终能返回到关卡 UI。

Tests:

  • 添加单元测试,覆盖低情绪撤退行为、情绪恢复计算、事件任务串联,以及战斗准备和战斗结果界面的撤退处理。
Original summary in English

Summary by Sourcery

Handle low-emotion withdrawal in campaigns by postponing the current event task, adjusting emotion recovery scheduling, and ensuring the UI reliably returns to the stage screen.

New Features:

  • Add campaign-level low-emotion withdrawal handling that updates emotion records, delays the current event task, and optionally switches to the next event map based on scheduler priority.

Bug Fixes:

  • Change low-emotion forced sortie handling so that in emotion-consumption calculation mode the prompt is canceled and the map is withdrawn, preventing stale emotion values from causing immediate rescheduling of the same task.

Enhancements:

  • Extend the withdrawal flow to process battle preparation pages, battle results, experience, ship, item, and status popups so withdrawal consistently returns to the stage UI.

Tests:

  • Add unit tests covering low-emotion withdrawal behavior, emotion recovery calculation, event task chaining, and withdrawal handling of battle preparation and result screens.

新功能:

  • 添加战役级别的低情绪撤退处理:更新情绪记录、延迟当前事件任务,并在需要时切换到序列中的下一个事件地图。

缺陷修复:

  • 修改低情绪强制出击处理逻辑,仅在使用情绪消耗计算时才进行取消与撤退,避免过期的情绪值导致同一任务被立即重新排期。

优化与增强:

  • 扩展撤退逻辑,使其处理战斗结算、经验、舰船、物品以及状态弹窗,确保撤退过程可靠地回到关卡界面。
Original summary in English

Summary by Sourcery

通过在活动中推迟当前事件任务、调整情绪恢复的调度,并确保 UI 可靠返回到关卡界面,来处理低情绪撤退情形。

New Features:

  • 添加活动级的低情绪撤退处理逻辑,用于更新情绪记录、延迟当前事件任务,并可根据调度器优先级选择性地切换到下一个事件地图。

Bug Fixes:

  • 修改低情绪强制出击的处理方式,使在情绪消耗计算模式下,提示会被取消且地图被撤退,防止过期的情绪值导致同一任务被立即重新调度。

Enhancements:

  • 扩展撤退流程以处理战斗准备页面、战斗结果、经验、舰船、物品以及状态弹窗,确保撤退操作始终能返回到关卡 UI。

Tests:

  • 添加单元测试,覆盖低情绪撤退行为、情绪恢复计算、事件任务串联,以及战斗准备和战斗结果界面的撤退处理。
Original summary in English

Summary by Sourcery

Handle low-emotion withdrawal in campaigns by postponing the current event task, adjusting emotion recovery scheduling, and ensuring the UI reliably returns to the stage screen.

New Features:

  • Add campaign-level low-emotion withdrawal handling that updates emotion records, delays the current event task, and optionally switches to the next event map based on scheduler priority.

Bug Fixes:

  • Change low-emotion forced sortie handling so that in emotion-consumption calculation mode the prompt is canceled and the map is withdrawn, preventing stale emotion values from causing immediate rescheduling of the same task.

Enhancements:

  • Extend the withdrawal flow to process battle preparation pages, battle results, experience, ship, item, and status popups so withdrawal consistently returns to the stage UI.

Tests:

  • Add unit tests covering low-emotion withdrawal behavior, emotion recovery calculation, event task chaining, and withdrawal handling of battle preparation and result screens.
Original summary in English

Summary by Sourcery

通过在活动中推迟当前事件任务、调整情绪恢复的调度,并确保 UI 可靠返回到关卡界面,来处理低情绪撤退情形。

New Features:

  • 添加活动级的低情绪撤退处理逻辑,用于更新情绪记录、延迟当前事件任务,并可根据调度器优先级选择性地切换到下一个事件地图。

Bug Fixes:

  • 修改低情绪强制出击的处理方式,使在情绪消耗计算模式下,提示会被取消且地图被撤退,防止过期的情绪值导致同一任务被立即重新调度。

Enhancements:

  • 扩展撤退流程以处理战斗准备页面、战斗结果、经验、舰船、物品以及状态弹窗,确保撤退操作始终能返回到关卡 UI。

Tests:

  • 添加单元测试,覆盖低情绪撤退行为、情绪恢复计算、事件任务串联,以及战斗准备和战斗结果界面的撤退处理。
Original summary in English

Summary by Sourcery

Handle low-emotion withdrawal in campaigns by postponing the current event task, adjusting emotion recovery scheduling, and ensuring the UI reliably returns to the stage screen.

New Features:

  • Add campaign-level low-emotion withdrawal handling that updates emotion records, delays the current event task, and optionally switches to the next event map based on scheduler priority.

Bug Fixes:

  • Change low-emotion forced sortie handling so that in emotion-consumption calculation mode the prompt is canceled and the map is withdrawn, preventing stale emotion values from causing immediate rescheduling of the same task.

Enhancements:

  • Extend the withdrawal flow to process battle preparation pages, battle results, experience, ship, item, and status popups so withdrawal consistently returns to the stage UI.

Tests:

  • Add unit tests covering low-emotion withdrawal behavior, emotion recovery calculation, event task chaining, and withdrawal handling of battle preparation and result screens.

新特性:

  • 引入活动层面的低情绪撤退处理逻辑,可推迟当前事件任务,并在需要时切换到序列中的下一个事件地图。

错误修复:

  • 调整低情绪强制出击的处理方式,使在情绪消耗计算模式下的提示被取消并直接从地图撤退,防止使用过期情绪值导致同一任务被立即重新排程。

功能改进:

  • 扩展撤退流程以处理战斗准备、战斗结果、经验、舰船、道具和状态弹窗,确保撤退操作能可靠地返回到关卡舞台界面。

测试:

  • 添加单元测试,覆盖低情绪撤退行为、任务延迟与事件切换逻辑,以及战斗准备和战斗结果界面的撤退处理。
Original summary in English

Summary by Sourcery

通过在活动中推迟当前事件任务、调整情绪恢复的调度,并确保 UI 可靠返回到关卡界面,来处理低情绪撤退情形。

New Features:

  • 添加活动级的低情绪撤退处理逻辑,用于更新情绪记录、延迟当前事件任务,并可根据调度器优先级选择性地切换到下一个事件地图。

Bug Fixes:

  • 修改低情绪强制出击的处理方式,使在情绪消耗计算模式下,提示会被取消且地图被撤退,防止过期的情绪值导致同一任务被立即重新调度。

Enhancements:

  • 扩展撤退流程以处理战斗准备页面、战斗结果、经验、舰船、物品以及状态弹窗,确保撤退操作始终能返回到关卡 UI。

Tests:

  • 添加单元测试,覆盖低情绪撤退行为、情绪恢复计算、事件任务串联,以及战斗准备和战斗结果界面的撤退处理。
Original summary in English

Summary by Sourcery

Handle low-emotion withdrawal in campaigns by postponing the current event task, adjusting emotion recovery scheduling, and ensuring the UI reliably returns to the stage screen.

New Features:

  • Add campaign-level low-emotion withdrawal handling that updates emotion records, delays the current event task, and optionally switches to the next event map based on scheduler priority.

Bug Fixes:

  • Change low-emotion forced sortie handling so that in emotion-consumption calculation mode the prompt is canceled and the map is withdrawn, preventing stale emotion values from causing immediate rescheduling of the same task.

Enhancements:

  • Extend the withdrawal flow to process battle preparation pages, battle results, experience, ship, item, and status popups so withdrawal consistently returns to the stage UI.

Tests:

  • Add unit tests covering low-emotion withdrawal behavior, emotion recovery calculation, event task chaining, and withdrawal handling of battle preparation and result screens.
Original summary in English

Summary by Sourcery

通过在活动中推迟当前事件任务、调整情绪恢复的调度,并确保 UI 可靠返回到关卡界面,来处理低情绪撤退情形。

New Features:

  • 添加活动级的低情绪撤退处理逻辑,用于更新情绪记录、延迟当前事件任务,并可根据调度器优先级选择性地切换到下一个事件地图。

Bug Fixes:

  • 修改低情绪强制出击的处理方式,使在情绪消耗计算模式下,提示会被取消且地图被撤退,防止过期的情绪值导致同一任务被立即重新调度。

Enhancements:

  • 扩展撤退流程以处理战斗准备页面、战斗结果、经验、舰船、物品以及状态弹窗,确保撤退操作始终能返回到关卡 UI。

Tests:

  • 添加单元测试,覆盖低情绪撤退行为、情绪恢复计算、事件任务串联,以及战斗准备和战斗结果界面的撤退处理。
Original summary in English

Summary by Sourcery

Handle low-emotion withdrawal in campaigns by postponing the current event task, adjusting emotion recovery scheduling, and ensuring the UI reliably returns to the stage screen.

New Features:

  • Add campaign-level low-emotion withdrawal handling that updates emotion records, delays the current event task, and optionally switches to the next event map based on scheduler priority.

Bug Fixes:

  • Change low-emotion forced sortie handling so that in emotion-consumption calculation mode the prompt is canceled and the map is withdrawn, preventing stale emotion values from causing immediate rescheduling of the same task.

Enhancements:

  • Extend the withdrawal flow to process battle preparation pages, battle results, experience, ship, item, and status popups so withdrawal consistently returns to the stage UI.

Tests:

  • Add unit tests covering low-emotion withdrawal behavior, emotion recovery calculation, event task chaining, and withdrawal handling of battle preparation and result screens.

新功能:

  • 新增活动层面的低情绪值撤退处理逻辑,用于更新情绪记录、延迟当前活动任务,并在需要时切换到下一个事件关卡。
  • 确保撤退操作能够顺利经过战斗结算与掉落界面,使流程能够稳定返回到地图 UI。

错误修复:

  • 修改活动中的低情绪值强制出击处理逻辑,仅在使用情绪消耗计算时执行取消与撤退,避免错误的情绪记录导致任务被立即重新调度。
Original summary in English

Summary by Sourcery

通过在活动中推迟当前事件任务、调整情绪恢复的调度,并确保 UI 可靠返回到关卡界面,来处理低情绪撤退情形。

New Features:

  • 添加活动级的低情绪撤退处理逻辑,用于更新情绪记录、延迟当前事件任务,并可根据调度器优先级选择性地切换到下一个事件地图。

Bug Fixes:

  • 修改低情绪强制出击的处理方式,使在情绪消耗计算模式下,提示会被取消且地图被撤退,防止过期的情绪值导致同一任务被立即重新调度。

Enhancements:

  • 扩展撤退流程以处理战斗准备页面、战斗结果、经验、舰船、物品以及状态弹窗,确保撤退操作始终能返回到关卡 UI。

Tests:

  • 添加单元测试,覆盖低情绪撤退行为、情绪恢复计算、事件任务串联,以及战斗准备和战斗结果界面的撤退处理。
Original summary in English

Summary by Sourcery

Handle low-emotion withdrawal in campaigns by postponing the current event task, adjusting emotion recovery scheduling, and ensuring the UI reliably returns to the stage screen.

New Features:

  • Add campaign-level low-emotion withdrawal handling that updates emotion records, delays the current event task, and optionally switches to the next event map based on scheduler priority.

Bug Fixes:

  • Change low-emotion forced sortie handling so that in emotion-consumption calculation mode the prompt is canceled and the map is withdrawn, preventing stale emotion values from causing immediate rescheduling of the same task.

Enhancements:

  • Extend the withdrawal flow to process battle preparation pages, battle results, experience, ship, item, and status popups so withdrawal consistently returns to the stage UI.

Tests:

  • Add unit tests covering low-emotion withdrawal behavior, emotion recovery calculation, event task chaining, and withdrawal handling of battle preparation and result screens.
Original summary in English

Summary by Sourcery

通过在活动中推迟当前事件任务、调整情绪恢复的调度,并确保 UI 可靠返回到关卡界面,来处理低情绪撤退情形。

New Features:

  • 添加活动级的低情绪撤退处理逻辑,用于更新情绪记录、延迟当前事件任务,并可根据调度器优先级选择性地切换到下一个事件地图。

Bug Fixes:

  • 修改低情绪强制出击的处理方式,使在情绪消耗计算模式下,提示会被取消且地图被撤退,防止过期的情绪值导致同一任务被立即重新调度。

Enhancements:

  • 扩展撤退流程以处理战斗准备页面、战斗结果、经验、舰船、物品以及状态弹窗,确保撤退操作始终能返回到关卡 UI。

Tests:

  • 添加单元测试,覆盖低情绪撤退行为、情绪恢复计算、事件任务串联,以及战斗准备和战斗结果界面的撤退处理。
Original summary in English

Summary by Sourcery

Handle low-emotion withdrawal in campaigns by postponing the current event task, adjusting emotion recovery scheduling, and ensuring the UI reliably returns to the stage screen.

New Features:

  • Add campaign-level low-emotion withdrawal handling that updates emotion records, delays the current event task, and optionally switches to the next event map based on scheduler priority.

Bug Fixes:

  • Change low-emotion forced sortie handling so that in emotion-consumption calculation mode the prompt is canceled and the map is withdrawn, preventing stale emotion values from causing immediate rescheduling of the same task.

Enhancements:

  • Extend the withdrawal flow to process battle preparation pages, battle results, experience, ship, item, and status popups so withdrawal consistently returns to the stage UI.

Tests:

  • Add unit tests covering low-emotion withdrawal behavior, emotion recovery calculation, event task chaining, and withdrawal handling of battle preparation and result screens.

新特性:

  • 引入活动层面的低情绪撤退处理逻辑,可推迟当前事件任务,并在需要时切换到序列中的下一个事件地图。

错误修复:

  • 调整低情绪强制出击的处理方式,使在情绪消耗计算模式下的提示被取消并直接从地图撤退,防止使用过期情绪值导致同一任务被立即重新排程。

功能改进:

  • 扩展撤退流程以处理战斗准备、战斗结果、经验、舰船、道具和状态弹窗,确保撤退操作能可靠地返回到关卡舞台界面。

测试:

  • 添加单元测试,覆盖低情绪撤退行为、任务延迟与事件切换逻辑,以及战斗准备和战斗结果界面的撤退处理。
Original summary in English

Summary by Sourcery

通过在活动中推迟当前事件任务、调整情绪恢复的调度,并确保 UI 可靠返回到关卡界面,来处理低情绪撤退情形。

New Features:

  • 添加活动级的低情绪撤退处理逻辑,用于更新情绪记录、延迟当前事件任务,并可根据调度器优先级选择性地切换到下一个事件地图。

Bug Fixes:

  • 修改低情绪强制出击的处理方式,使在情绪消耗计算模式下,提示会被取消且地图被撤退,防止过期的情绪值导致同一任务被立即重新调度。

Enhancements:

  • 扩展撤退流程以处理战斗准备页面、战斗结果、经验、舰船、物品以及状态弹窗,确保撤退操作始终能返回到关卡 UI。

Tests:

  • 添加单元测试,覆盖低情绪撤退行为、情绪恢复计算、事件任务串联,以及战斗准备和战斗结果界面的撤退处理。
Original summary in English

Summary by Sourcery

Handle low-emotion withdrawal in campaigns by postponing the current event task, adjusting emotion recovery scheduling, and ensuring the UI reliably returns to the stage screen.

New Features:

  • Add campaign-level low-emotion withdrawal handling that updates emotion records, delays the current event task, and optionally switches to the next event map based on scheduler priority.

Bug Fixes:

  • Change low-emotion forced sortie handling so that in emotion-consumption calculation mode the prompt is canceled and the map is withdrawn, preventing stale emotion values from causing immediate rescheduling of the same task.

Enhancements:

  • Extend the withdrawal flow to process battle preparation pages, battle results, experience, ship, item, and status popups so withdrawal consistently returns to the stage UI.

Tests:

  • Add unit tests covering low-emotion withdrawal behavior, emotion recovery calculation, event task chaining, and withdrawal handling of battle preparation and result screens.
Original summary in English

Summary by Sourcery

通过在活动中推迟当前事件任务、调整情绪恢复的调度,并确保 UI 可靠返回到关卡界面,来处理低情绪撤退情形。

New Features:

  • 添加活动级的低情绪撤退处理逻辑,用于更新情绪记录、延迟当前事件任务,并可根据调度器优先级选择性地切换到下一个事件地图。

Bug Fixes:

  • 修改低情绪强制出击的处理方式,使在情绪消耗计算模式下,提示会被取消且地图被撤退,防止过期的情绪值导致同一任务被立即重新调度。

Enhancements:

  • 扩展撤退流程以处理战斗准备页面、战斗结果、经验、舰船、物品以及状态弹窗,确保撤退操作始终能返回到关卡 UI。

Tests:

  • 添加单元测试,覆盖低情绪撤退行为、情绪恢复计算、事件任务串联,以及战斗准备和战斗结果界面的撤退处理。
Original summary in English

Summary by Sourcery

Handle low-emotion withdrawal in campaigns by postponing the current event task, adjusting emotion recovery scheduling, and ensuring the UI reliably returns to the stage screen.

New Features:

  • Add campaign-level low-emotion withdrawal handling that updates emotion records, delays the current event task, and optionally switches to the next event map based on scheduler priority.

Bug Fixes:

  • Change low-emotion forced sortie handling so that in emotion-consumption calculation mode the prompt is canceled and the map is withdrawn, preventing stale emotion values from causing immediate rescheduling of the same task.

Enhancements:

  • Extend the withdrawal flow to process battle preparation pages, battle results, experience, ship, item, and status popups so withdrawal consistently returns to the stage UI.

Tests:

  • Add unit tests covering low-emotion withdrawal behavior, emotion recovery calculation, event task chaining, and withdrawal handling of battle preparation and result screens.

新功能:

  • 添加战役级别的低情绪撤退处理:更新情绪记录、延迟当前事件任务,并在需要时切换到序列中的下一个事件地图。

缺陷修复:

  • 修改低情绪强制出击处理逻辑,仅在使用情绪消耗计算时才进行取消与撤退,避免过期的情绪值导致同一任务被立即重新排期。

优化与增强:

  • 扩展撤退逻辑,使其处理战斗结算、经验、舰船、物品以及状态弹窗,确保撤退过程可靠地回到关卡界面。
Original summary in English

Summary by Sourcery

通过在活动中推迟当前事件任务、调整情绪恢复的调度,并确保 UI 可靠返回到关卡界面,来处理低情绪撤退情形。

New Features:

  • 添加活动级的低情绪撤退处理逻辑,用于更新情绪记录、延迟当前事件任务,并可根据调度器优先级选择性地切换到下一个事件地图。

Bug Fixes:

  • 修改低情绪强制出击的处理方式,使在情绪消耗计算模式下,提示会被取消且地图被撤退,防止过期的情绪值导致同一任务被立即重新调度。

Enhancements:

  • 扩展撤退流程以处理战斗准备页面、战斗结果、经验、舰船、物品以及状态弹窗,确保撤退操作始终能返回到关卡 UI。

Tests:

  • 添加单元测试,覆盖低情绪撤退行为、情绪恢复计算、事件任务串联,以及战斗准备和战斗结果界面的撤退处理。
Original summary in English

Summary by Sourcery

Handle low-emotion withdrawal in campaigns by postponing the current event task, adjusting emotion recovery scheduling, and ensuring the UI reliably returns to the stage screen.

New Features:

  • Add campaign-level low-emotion withdrawal handling that updates emotion records, delays the current event task, and optionally switches to the next event map based on scheduler priority.

Bug Fixes:

  • Change low-emotion forced sortie handling so that in emotion-consumption calculation mode the prompt is canceled and the map is withdrawn, preventing stale emotion values from causing immediate rescheduling of the same task.

Enhancements:

  • Extend the withdrawal flow to process battle preparation pages, battle results, experience, ship, item, and status popups so withdrawal consistently returns to the stage UI.

Tests:

  • Add unit tests covering low-emotion withdrawal behavior, emotion recovery calculation, event task chaining, and withdrawal handling of battle preparation and result screens.
Original summary in English

Summary by Sourcery

通过在活动中推迟当前事件任务、调整情绪恢复的调度,并确保 UI 可靠返回到关卡界面,来处理低情绪撤退情形。

New Features:

  • 添加活动级的低情绪撤退处理逻辑,用于更新情绪记录、延迟当前事件任务,并可根据调度器优先级选择性地切换到下一个事件地图。

Bug Fixes:

  • 修改低情绪强制出击的处理方式,使在情绪消耗计算模式下,提示会被取消且地图被撤退,防止过期的情绪值导致同一任务被立即重新调度。

Enhancements:

  • 扩展撤退流程以处理战斗准备页面、战斗结果、经验、舰船、物品以及状态弹窗,确保撤退操作始终能返回到关卡 UI。

Tests:

  • 添加单元测试,覆盖低情绪撤退行为、情绪恢复计算、事件任务串联,以及战斗准备和战斗结果界面的撤退处理。
Original summary in English

Summary by Sourcery

Handle low-emotion withdrawal in campaigns by postponing the current event task, adjusting emotion recovery scheduling, and ensuring the UI reliably returns to the stage screen.

New Features:

  • Add campaign-level low-emotion withdrawal handling that updates emotion records, delays the current event task, and optionally switches to the next event map based on scheduler priority.

Bug Fixes:

  • Change low-emotion forced sortie handling so that in emotion-consumption calculation mode the prompt is canceled and the map is withdrawn, preventing stale emotion values from causing immediate rescheduling of the same task.

Enhancements:

  • Extend the withdrawal flow to process battle preparation pages, battle results, experience, ship, item, and status popups so withdrawal consistently returns to the stage UI.

Tests:

  • Add unit tests covering low-emotion withdrawal behavior, emotion recovery calculation, event task chaining, and withdrawal handling of battle preparation and result screens.

新特性:

  • 引入活动层面的低情绪撤退处理逻辑,可推迟当前事件任务,并在需要时切换到序列中的下一个事件地图。

错误修复:

  • 调整低情绪强制出击的处理方式,使在情绪消耗计算模式下的提示被取消并直接从地图撤退,防止使用过期情绪值导致同一任务被立即重新排程。

功能改进:

  • 扩展撤退流程以处理战斗准备、战斗结果、经验、舰船、道具和状态弹窗,确保撤退操作能可靠地返回到关卡舞台界面。

测试:

  • 添加单元测试,覆盖低情绪撤退行为、任务延迟与事件切换逻辑,以及战斗准备和战斗结果界面的撤退处理。
Original summary in English

Summary by Sourcery

通过在活动中推迟当前事件任务、调整情绪恢复的调度,并确保 UI 可靠返回到关卡界面,来处理低情绪撤退情形。

New Features:

  • 添加活动级的低情绪撤退处理逻辑,用于更新情绪记录、延迟当前事件任务,并可根据调度器优先级选择性地切换到下一个事件地图。

Bug Fixes:

  • 修改低情绪强制出击的处理方式,使在情绪消耗计算模式下,提示会被取消且地图被撤退,防止过期的情绪值导致同一任务被立即重新调度。

Enhancements:

  • 扩展撤退流程以处理战斗准备页面、战斗结果、经验、舰船、物品以及状态弹窗,确保撤退操作始终能返回到关卡 UI。

Tests:

  • 添加单元测试,覆盖低情绪撤退行为、情绪恢复计算、事件任务串联,以及战斗准备和战斗结果界面的撤退处理。
Original summary in English

Summary by Sourcery

Handle low-emotion withdrawal in campaigns by postponing the current event task, adjusting emotion recovery scheduling, and ensuring the UI reliably returns to the stage screen.

New Features:

  • Add campaign-level low-emotion withdrawal handling that updates emotion records, delays the current event task, and optionally switches to the next event map based on scheduler priority.

Bug Fixes:

  • Change low-emotion forced sortie handling so that in emotion-consumption calculation mode the prompt is canceled and the map is withdrawn, preventing stale emotion values from causing immediate rescheduling of the same task.

Enhancements:

  • Extend the withdrawal flow to process battle preparation pages, battle results, experience, ship, item, and status popups so withdrawal consistently returns to the stage UI.

Tests:

  • Add unit tests covering low-emotion withdrawal behavior, emotion recovery calculation, event task chaining, and withdrawal handling of battle preparation and result screens.
Original summary in English

Summary by Sourcery

通过在活动中推迟当前事件任务、调整情绪恢复的调度,并确保 UI 可靠返回到关卡界面,来处理低情绪撤退情形。

New Features:

  • 添加活动级的低情绪撤退处理逻辑,用于更新情绪记录、延迟当前事件任务,并可根据调度器优先级选择性地切换到下一个事件地图。

Bug Fixes:

  • 修改低情绪强制出击的处理方式,使在情绪消耗计算模式下,提示会被取消且地图被撤退,防止过期的情绪值导致同一任务被立即重新调度。

Enhancements:

  • 扩展撤退流程以处理战斗准备页面、战斗结果、经验、舰船、物品以及状态弹窗,确保撤退操作始终能返回到关卡 UI。

Tests:

  • 添加单元测试,覆盖低情绪撤退行为、情绪恢复计算、事件任务串联,以及战斗准备和战斗结果界面的撤退处理。
Original summary in English

Summary by Sourcery

Handle low-emotion withdrawal in campaigns by postponing the current event task, adjusting emotion recovery scheduling, and ensuring the UI reliably returns to the stage screen.

New Features:

  • Add campaign-level low-emotion withdrawal handling that updates emotion records, delays the current event task, and optionally switches to the next event map based on scheduler priority.

Bug Fixes:

  • Change low-emotion forced sortie handling so that in emotion-consumption calculation mode the prompt is canceled and the map is withdrawn, preventing stale emotion values from causing immediate rescheduling of the same task.

Enhancements:

  • Extend the withdrawal flow to process battle preparation pages, battle results, experience, ship, item, and status popups so withdrawal consistently returns to the stage UI.

Tests:

  • Add unit tests covering low-emotion withdrawal behavior, emotion recovery calculation, event task chaining, and withdrawal handling of battle preparation and result screens.

@github-actions

github-actions Bot commented Aug 14, 2026

Copy link
Copy Markdown

CI 检查报告

检查结果

检查 结果 耗时
Post PR report ➖ unknown -

导入冒烟测试

  • 结果:✅
  • 扫描模块:499(通过 496,已知失败 3,意外失败 0,过期白名单 0)

@sourcery-ai

sourcery-ai Bot commented Aug 14, 2026

Copy link
Copy Markdown

Reviewer's Guide

为战役事件实现低心情撤退流程:在计算模式下拦截低心情强制出击弹窗,通过引导撤退流程依次导航准备界面和结果界面,将心情记录重置为 0,将当前事件任务延后到计算出的恢复时间,并可选地切换到下一个已配置的事件任务,同时用单元测试覆盖相关行为。

战役运行中低心情撤退流程的时序图

sequenceDiagram
    actor User
    participant CampaignBase
    participant CampaignRun
    participant MapOperation as CampaignMapOperation
    participant Emotion
    participant Config

    User->>CampaignBase: handle_combat_low_emotion()
    CampaignBase->>CampaignBase: handle_popup_cancel(IGNORE_LOW_EMOTION)
    alt Emotion_Mode == calculate and popup cancelled
        CampaignBase->>CampaignBase: low_emotion_withdrawn = True
        CampaignBase-->>CampaignRun: CampaignEnd(LowEmotionWithdraw)
    else other emotion modes
        CampaignBase->>CampaignBase: super.handle_combat_low_emotion()
    end

    CampaignRun->>CampaignRun: run()
    CampaignRun->>CampaignBase: campaign.run()
    CampaignBase-->>CampaignRun: CampaignEnd(LowEmotionWithdraw)
    CampaignRun->>CampaignRun: catch CampaignEnd
    CampaignRun->>CampaignRun: handle_low_emotion_withdrawal()
    alt low_emotion_withdrawn
        CampaignRun->>MapOperation: withdraw(skip_first_screenshot=False)
        loop withdraw loop
            MapOperation->>MapOperation: handle_withdraw_battle_preparation()
            MapOperation->>MapOperation: handle_enter_map_preparation_cancel()
            MapOperation->>MapOperation: handle_withdraw_result()
            MapOperation->>MapOperation: handle_popup_confirm(WITHDRAW/COMBAT_STATUS)
            MapOperation->>MapOperation: handle_in_stage()
        end

        CampaignRun->>Emotion: emotion.update()
        CampaignRun->>Emotion: emotion.record()
        CampaignRun->>Emotion: get_recovered_for_battle(campaign._map_battle)
        Emotion-->>CampaignRun: recovered datetime
        CampaignRun->>Config: task_delay(target=recovered)
        CampaignRun->>CampaignRun: get_low_emotion_next_event_task(task)
        alt next_event exists
            CampaignRun->>Config: task_call(next_event, force_call=False)
            Config-->>CampaignRun: success
            CampaignRun->>Config: update()
        end
        CampaignRun->>Config: task_stop('[低心情] 已撤退并延后当前任务')
        CampaignRun->>CampaignBase: low_emotion_withdrawn = False
    else no low_emotion_withdrawn
        CampaignRun-->>User: propagate CampaignEnd
    end
Loading

File-Level Changes

Change Details Files
添加战役层面的低心情撤退钩子,用于在计算模式下取消强制出击,并将处理逻辑交由运行器。
  • 引入 CampaignBase.low_emotion_withdrawn 标志,用于追踪待处理的低心情撤退。
  • 在 CampaignBase 中重写 handle_combat_low_emotion,当 Emotion_Mode=='calculate' 时,取消 IGNORE_LOW_EMOTION 弹窗、设置标志,并抛出 CampaignEnd 以退出战斗准备。
  • 通过委托给原有实现,保持非计算模式下的确认行为不变。
module/campaign/campaign_base.py
实现运行器逻辑以执行撤退、将舰队心情重置为 0、将当前任务延后至恢复时间,并可选地启动下一个事件任务。
  • 添加 CampaignRun.get_low_emotion_next_event_task,通过 parse_task_priority 从 SCHEDULER_PRIORITY 计算下一个事件任务。
  • 添加 CampaignRun.handle_low_emotion_withdrawal,运行 campaign.withdraw,重新计算心情,将相关 fleet.current 值置零,调用 Emotion.get_recovered_for_battle,将当前任务延后至恢复时间,并在存在下一个事件任务时调用该任务并刷新配置。
  • 将 handle_low_emotion_withdrawal 集成到 CampaignRun.run 中,包括在 low_emotion_withdrawn 被设置时对 CampaignEnd 的特殊处理,并在成功处理后以带描述原因的方式停止当前任务。
module/campaign/run.py
module/config/task_priority.py
重构心情恢复计算为可复用方法,供出击前检查和低心情撤退共用。
  • 将恢复时间计算抽取为 Emotion.get_recovered_for_battle,既支持公共心情模式也支持按舰队心情模式,并应用 reduce_per_battle_before_entering。
  • 重写 Emotion._check_reduce,让其委托给 get_recovered_for_battle,并同时返回恢复时间以及是否需要延后。
  • 在使用新辅助方法以提高一致性的同时,保持 Emotion.check_reduce 的行为不变。
module/combat/emotion.py
拓展地图撤退操作,以在撤退过程中干净地退出准备界面并处理战斗结果界面。
  • 在 MapOperation 中定义 WITHDRAW_RESULT_HANDLERS,用于列出可能存在于 combat-mixin 任务中的可选结果处理器。
  • 添加 MapOperation.handle_withdraw_battle_preparation 以检测 BATTLE_PREPARATION 并在打开撤退界面前点击 BACK_ARROW。
  • 添加 MapOperation.handle_enter_map_preparation_cancel 以通过 MAP_PREPARATION_CANCEL 从 MAP_PREPARATION 或 FLEET_PREPARATION 退出回到关卡选择界面。
  • 添加 MapOperation.handle_withdraw_result,用于在可用时处理战斗状态、经验、舰船和物品结果处理器,并在无处理器时回退到确认 COMBAT_STATUS 弹窗。
  • 将这些处理器串联到 MapOperation.withdraw,使撤退流程在等待关卡界面前循环处理准备界面和结果界面。
module/map/map_operation.py
module/combat/assets.py
module/map/assets.py
添加单元测试以验证低心情撤退行为、心情恢复计算、事件串联以及撤退 UI 处理。
  • 为 CampaignBase.handle_combat_low_emotion 添加测试,以验证计算模式与非计算模式下的行为以及 low_emotion_withdrawn 的正确设置。
  • 覆盖 CampaignRun.handle_low_emotion_withdrawal 在公共心情与按舰队心情模式、缺失舰队记录、多舰队延后语义以及基于 SCHEDULER_PRIORITY 的下一事件选择方面的行为。
  • 添加针对 Emotion.get_recovered_for_battle 计算语义的测试。
  • 测试 MapOperation/MaritimeEscort 撤退流程,包括战斗状态处理、准备界面退出、结果 UI 处理以及 COMBAT_STATUS 弹窗回退。
  • 为 RapidOCR.OCRVersion.PPOCRV6 添加一个小型兼容性垫片,以允许在较旧 RapidOCR 版本下导入战役模块的测试运行。
tests/test_low_emotion_withdraw.py

Tips and commands

Interacting with Sourcery

  • 触发新审核: 在 Pull Request 中评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审核评论。
  • 从审核评论生成 GitHub Issue: 通过回复审核评论请求 Sourcery 从该评论创建一个 issue。你也可以在审核评论中回复 @sourcery-ai issue 来从该评论创建 issue。
  • 生成 Pull Request 标题: 在 Pull Request 标题任意位置写上 @sourcery-ai,即可随时生成标题。你也可以在 Pull Request 中评论 @sourcery-ai title 来随时(重新)生成标题。
  • 生成 Pull Request 摘要: 在 Pull Request 正文任意位置写上 @sourcery-ai summary,即可在该位置随时生成 PR 摘要。你也可以在 Pull Request 中评论 @sourcery-ai summary 来随时(重新)生成摘要。
  • 生成审阅者指南: 在 Pull Request 中评论 @sourcery-ai guide,即可随时(重新)生成审阅者指南。
  • 解决所有 Sourcery 评论: 在 Pull Request 中评论 @sourcery-ai resolve,以解决所有 Sourcery 评论。如果你已经处理完所有评论且不希望再看到它们,这会很有用。
  • 取消所有 Sourcery 审核: 在 Pull Request 中评论 @sourcery-ai dismiss,以取消所有现有 Sourcery 审核。如果你希望从一次新的审核开始,这尤其有用——别忘了再评论 @sourcery-ai review 来触发新的审核!

Customizing Your Experience

访问你的 dashboard 以:

  • 启用或禁用审核功能,例如 Sourcery 自动生成的 Pull Request 摘要、审阅者指南等。
  • 更改审核语言。
  • 添加、移除或编辑自定义审核说明。
  • 调整其他审核设置。

Getting Help

Original review guide in English

Reviewer's Guide

Implements a low-emotion withdrawal flow for campaign events: intercepting the low-emotion forced sortie prompt in calculate mode, performing a guided withdrawal that navigates preparation and result UIs, resetting emotion records to 0, delaying the current event task to the computed recovery time, and optionally switching to the next configured event task, with unit tests covering the behavior.

Sequence diagram for low emotion withdrawal flow in campaign run

sequenceDiagram
    actor User
    participant CampaignBase
    participant CampaignRun
    participant MapOperation as CampaignMapOperation
    participant Emotion
    participant Config

    User->>CampaignBase: handle_combat_low_emotion()
    CampaignBase->>CampaignBase: handle_popup_cancel(IGNORE_LOW_EMOTION)
    alt Emotion_Mode == calculate and popup cancelled
        CampaignBase->>CampaignBase: low_emotion_withdrawn = True
        CampaignBase-->>CampaignRun: CampaignEnd(LowEmotionWithdraw)
    else other emotion modes
        CampaignBase->>CampaignBase: super.handle_combat_low_emotion()
    end

    CampaignRun->>CampaignRun: run()
    CampaignRun->>CampaignBase: campaign.run()
    CampaignBase-->>CampaignRun: CampaignEnd(LowEmotionWithdraw)
    CampaignRun->>CampaignRun: catch CampaignEnd
    CampaignRun->>CampaignRun: handle_low_emotion_withdrawal()
    alt low_emotion_withdrawn
        CampaignRun->>MapOperation: withdraw(skip_first_screenshot=False)
        loop withdraw loop
            MapOperation->>MapOperation: handle_withdraw_battle_preparation()
            MapOperation->>MapOperation: handle_enter_map_preparation_cancel()
            MapOperation->>MapOperation: handle_withdraw_result()
            MapOperation->>MapOperation: handle_popup_confirm(WITHDRAW/COMBAT_STATUS)
            MapOperation->>MapOperation: handle_in_stage()
        end

        CampaignRun->>Emotion: emotion.update()
        CampaignRun->>Emotion: emotion.record()
        CampaignRun->>Emotion: get_recovered_for_battle(campaign._map_battle)
        Emotion-->>CampaignRun: recovered datetime
        CampaignRun->>Config: task_delay(target=recovered)
        CampaignRun->>CampaignRun: get_low_emotion_next_event_task(task)
        alt next_event exists
            CampaignRun->>Config: task_call(next_event, force_call=False)
            Config-->>CampaignRun: success
            CampaignRun->>Config: update()
        end
        CampaignRun->>Config: task_stop('[低心情] 已撤退并延后当前任务')
        CampaignRun->>CampaignBase: low_emotion_withdrawn = False
    else no low_emotion_withdrawn
        CampaignRun-->>User: propagate CampaignEnd
    end
Loading

File-Level Changes

Change Details Files
Add a campaign-level low-emotion withdrawal hook that cancels forced sorties in calculate mode and defers handling to the runner.
  • Introduce CampaignBase.low_emotion_withdrawn flag to track pending low-emotion withdrawals.
  • Override handle_combat_low_emotion in CampaignBase to, in Emotion_Mode=='calculate', cancel the IGNORE_LOW_EMOTION popup, set the flag, and raise CampaignEnd to exit combat preparation.
  • Preserve the previous confirm behavior for non-calculate emotion modes by delegating to the original implementation.
module/campaign/campaign_base.py
Implement runner logic to perform withdrawal, reset fleet emotion to 0, delay the current task to recovery time, and optionally start the next event task.
  • Add CampaignRun.get_low_emotion_next_event_task to compute the next event task from SCHEDULER_PRIORITY via parse_task_priority.
  • Add CampaignRun.handle_low_emotion_withdrawal to run campaign.withdraw, recompute emotion, zero relevant fleet.current values, call Emotion.get_recovered_for_battle, delay the current task to the recovery time, and, if available, call the next event task and refresh config.
  • Integrate handle_low_emotion_withdrawal into CampaignRun.run, including special handling of CampaignEnd when low_emotion_withdrawn is set, and stopping the current task with a descriptive reason after successful handling.
module/campaign/run.py
module/config/task_priority.py
Refactor emotion recovery calculation into a reusable method used by both pre-sortie checks and low-emotion withdrawal.
  • Extract recovery time computation into Emotion.get_recovered_for_battle, handling both public and per-fleet emotion modes and applying reduce_per_battle_before_entering.
  • Rewrite Emotion._check_reduce to delegate to get_recovered_for_battle and return both the recovery time and whether a delay is needed.
  • Keep Emotion.check_reduce behavior intact while using the new helper for consistency.
module/combat/emotion.py
Extend map withdrawal operations to cleanly exit preparation screens and process battle result UIs during withdrawal.
  • Define WITHDRAW_RESULT_HANDLERS in MapOperation to list optional result handlers that may be present in combat-mixin tasks.
  • Add MapOperation.handle_withdraw_battle_preparation to detect BATTLE_PREPARATION and click BACK_ARROW before opening withdrawal.
  • Add MapOperation.handle_enter_map_preparation_cancel to exit MAP_PREPARATION or FLEET_PREPARATION back to the stage selection via MAP_PREPARATION_CANCEL.
  • Add MapOperation.handle_withdraw_result to process battle status, exp, ship, and item result handlers if available, and fall back to confirming COMBAT_STATUS popups.
  • Wire these handlers into MapOperation.withdraw so that withdrawal loops through preparation and result UIs before waiting for the stage screen.
module/map/map_operation.py
module/combat/assets.py
module/map/assets.py
Add unit tests to validate low-emotion withdrawal behavior, emotion recovery calculation, event chaining, and withdrawal UI handling.
  • Introduce tests for calculate vs non-calculate emotion modes in CampaignBase.handle_combat_low_emotion and for proper setting of low_emotion_withdrawn.
  • Cover CampaignRun.handle_low_emotion_withdrawal for public vs per-fleet emotion, missing fleet records, multi-fleet delay semantics, and next-event selection based on SCHEDULER_PRIORITY.
  • Add tests for Emotion.get_recovered_for_battle’s calculation semantics.
  • Test MapOperation/MaritimeEscort withdrawal flow, including battle status processing, preparation exits, result UI handling, and COMBAT_STATUS popup fallback.
  • Add a small compatibility shim for RapidOCR.OCRVersion.PPOCRV6 to allow tests to import campaign modules under older RapidOCR versions.
tests/test_low_emotion_withdraw.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@a2893005741
a2893005741 marked this pull request as ready for review August 14, 2026 10:37

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我在这里给出了一些总体性的反馈:

  • CampaignBase.handle_combat_low_emotion 中,建议在低情绪弹窗已处理并触发撤退时返回 True,这样调用方就可以在进一步处理前进行短路,与原方法的语义保持一致。
  • handle_low_emotion_withdrawal 中,将硬编码的任务名称映射 {'Event': 'Event2', 'Event2': 'Event3'} 改为配置驱动或集中管理,可以避免事件流逻辑到处散落,也更方便未来调整事件序列。
  • MapOperation.withdraw 中,为战斗结果界面新增的连续 hasattr 检查,如果重构为一个单独的辅助函数,按顺序迭代已注册的处理器,而不是复制同样的模式四次,可能会更清晰、也更易维护。
面向 AI 代理的提示
Please address the comments from this code review:

## Overall Comments
- In `CampaignBase.handle_combat_low_emotion`, consider returning `True` when the low-emotion popup is handled and withdrawal is triggered so callers can short-circuit further handling consistently with the original method’s semantics.
- The hardcoded task name mapping `{'Event': 'Event2', 'Event2': 'Event3'}` in `handle_low_emotion_withdrawal` could be made configuration-driven or centralized to avoid scattering event flow logic and make future event sequence changes easier.
- The new chained `hasattr` checks in `MapOperation.withdraw` for battle result screens might be clearer and more maintainable if they are refactored into a single helper that iterates registered handlers in order instead of duplicating the same pattern four times.

Sourcery 对开源项目是免费的——如果你觉得我们的评审有帮助,请考虑分享给其他人 ✨
帮我变得更有用!请在每条评论上点击 👍 或 👎,我会根据你的反馈改进后续的评审。
Original comment in English

Hey - I've left some high level feedback:

  • In CampaignBase.handle_combat_low_emotion, consider returning True when the low-emotion popup is handled and withdrawal is triggered so callers can short-circuit further handling consistently with the original method’s semantics.
  • The hardcoded task name mapping {'Event': 'Event2', 'Event2': 'Event3'} in handle_low_emotion_withdrawal could be made configuration-driven or centralized to avoid scattering event flow logic and make future event sequence changes easier.
  • The new chained hasattr checks in MapOperation.withdraw for battle result screens might be clearer and more maintainable if they are refactored into a single helper that iterates registered handlers in order instead of duplicating the same pattern four times.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `CampaignBase.handle_combat_low_emotion`, consider returning `True` when the low-emotion popup is handled and withdrawal is triggered so callers can short-circuit further handling consistently with the original method’s semantics.
- The hardcoded task name mapping `{'Event': 'Event2', 'Event2': 'Event3'}` in `handle_low_emotion_withdrawal` could be made configuration-driven or centralized to avoid scattering event flow logic and make future event sequence changes easier.
- The new chained `hasattr` checks in `MapOperation.withdraw` for battle result screens might be clearer and more maintainable if they are refactored into a single helper that iterates registered handlers in order instead of duplicating the same pattern four times.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1f7cff4938

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread module/campaign/campaign_base.py Outdated
Comment thread module/campaign/run.py Outdated
@a2893005741
a2893005741 marked this pull request as draft August 14, 2026 10:46
@a2893005741
a2893005741 marked this pull request as ready for review August 14, 2026 10:55

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我发现了两个问题,并留下了一些总体反馈:

  • 建议在 CampaignBase 中初始化 low_emotion_withdrawn(例如在 __init__ 中),这样它的生命周期会更清晰,也避免依赖临时创建属性。
  • CampaignRun 中硬编码的映射 LOW_EMOTION_NEXT_EVENT = {'Event': 'Event2', 'Event2': 'Event3'} 会把逻辑和具体任务名强耦合;你可能希望改为由配置或任务元数据驱动,这样在事件名称变更时仍能保持一致性。
  • handle_low_emotion_withdrawal 中,非公开 emotion 路径假设 emotion.fleets 非空且可索引;为了避免在边缘配置下出现运行时错误,最好增加对空或异常 fleet 列表的防护。
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider initializing `low_emotion_withdrawn` in `CampaignBase` (e.g., in `__init__`) so its lifecycle is clearer and you don't rely on ad-hoc attribute creation.
- The hard-coded `LOW_EMOTION_NEXT_EVENT = {'Event': 'Event2', 'Event2': 'Event3'}` mapping in `CampaignRun` couples the logic to specific task names; you might want to make this driven by configuration or task metadata so it stays consistent when event names change.
- In `handle_low_emotion_withdrawal`, the non-public emotion path assumes `emotion.fleets` is non-empty and indexed; it may be safer to guard against empty or malformed fleet lists to avoid runtime errors in edge configurations.

## Individual Comments

### Comment 1
<location path="tests/test_low_emotion_withdraw.py" line_range="46-55" />
<code_context>
+        campaign.handle_popup_cancel.assert_not_called()
+        campaign.handle_popup_confirm.assert_called_once_with('IGNORE_LOW_EMOTION')
+
+    def test_withdrawal_delays_current_task_to_emotion_recovery(self):
+        recovered = datetime(2026, 8, 14, 12, 0, 0)
+        fleet = Mock()
+        fleet.fleet = 1
+        fleet.current = 75
+        fleet.get_recovered.return_value = recovered
+        emotion = Mock(using_public=False)
+        emotion.fleets = [fleet, Mock()]
+        campaign = SimpleNamespace(
+            low_emotion_withdrawn=True,
+            emotion=emotion,
+            withdraw=Mock(side_effect=CampaignEnd('Withdraw')),
+        )
+        runner = CampaignRun.__new__(CampaignRun)
+        runner.__dict__['campaign'] = campaign
+        runner.__dict__['config'] = Mock()
+        runner.config.task.command = 'Event'
+        runner.config.FLEET_2 = 0
+
+        self.assertTrue(runner.handle_low_emotion_withdrawal())
</code_context>
<issue_to_address>
**suggestion (testing):**`handle_low_emotion_withdrawal` 中的 `using_public`/`public_fleet` 分支增加测试覆盖。

当前测试只覆盖 `using_public=False`(单舰队和双舰队)。请再添加一个针对 `using_public=True` 分支的测试,其中设置 `emotion.public_fleet`。该测试应验证:只有 `public_fleet.current` 被设置为 0,并且 `public_fleet.get_recovered()` 的返回值被用作 `task_delay`。
</issue_to_address>

### Comment 2
<location path="tests/test_low_emotion_withdraw.py" line_range="146-155" />
<code_context>
+    def test_withdraw_processes_battle_result_before_waiting_for_stage(self):
</code_context>
<issue_to_address>
**suggestion (testing):** 扩展 `MapOperation` 的测试,以覆盖 `handle_withdraw_result``COMBAT_STATUS` 弹窗分支。

当所有特定处理函数都未消耗该界面时,`handle_withdraw_result` 会回退到 `handle_popup_confirm('COMBAT_STATUS')`。请添加一个测试:其中 `handle_battle_status``handle_exp_info``handle_get_ship``handle_get_items` 都返回 `False``handle_popup_confirm('COMBAT_STATUS')` 返回 `True`,并断言 `handle_withdraw_result()` 返回 `True`,以验证这个回退路径已被覆盖。

建议实现:

```python
    def test_withdraw_processes_battle_result_before_waiting_for_stage(self):
        operation = MapOperation.__new__(MapOperation)
        operation.device = SimpleNamespace(screenshot=Mock())
        operation.handle_battle_status = Mock(side_effect=[True, False])
        operation.handle_exp_info = Mock(return_value=False)
        operation.handle_get_ship = Mock(return_value=False)
        operation.handle_get_items = Mock(return_value=False)
        operation.handle_popup_confirm = Mock(return_value=False)
        operation.appear_then_click = Mock(return_value=False)
        operation.handle_auto_search_exit = Mock(return_value=False)
        operation.appear = Mock(return_value=False)

    def test_handle_withdraw_result_falls_back_to_combat_status_popup(self):
        operation = MapOperation.__new__(MapOperation)
        operation.device = SimpleNamespace(screenshot=Mock())
        operation.handle_battle_status = Mock(return_value=False)
        operation.handle_exp_info = Mock(return_value=False)
        operation.handle_get_ship = Mock(return_value=False)
        operation.handle_get_items = Mock(return_value=False)
        operation.handle_popup_confirm = Mock(return_value=True)

        result = operation.handle_withdraw_result()

        self.assertTrue(result)
        operation.handle_popup_confirm.assert_called_once_with('COMBAT_STATUS')

```

此更改假定 `MapOperation` 已在 `tests/test_low_emotion_withdraw.py` 中导入,并且 `handle_withdraw_result``MapOperation` 的实例方法。如果尚未导入 `MapOperation`,请在文件顶部添加 `from your_module_path import MapOperation`,并遵循现有的导入约定。
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
帮我变得更有用!请在每条评论上点击 👍 或 👎,我会根据你的反馈改进后续的评审。
Original comment in English

Hey - I've found 2 issues, and left some high level feedback:

  • Consider initializing low_emotion_withdrawn in CampaignBase (e.g., in __init__) so its lifecycle is clearer and you don't rely on ad-hoc attribute creation.
  • The hard-coded LOW_EMOTION_NEXT_EVENT = {'Event': 'Event2', 'Event2': 'Event3'} mapping in CampaignRun couples the logic to specific task names; you might want to make this driven by configuration or task metadata so it stays consistent when event names change.
  • In handle_low_emotion_withdrawal, the non-public emotion path assumes emotion.fleets is non-empty and indexed; it may be safer to guard against empty or malformed fleet lists to avoid runtime errors in edge configurations.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider initializing `low_emotion_withdrawn` in `CampaignBase` (e.g., in `__init__`) so its lifecycle is clearer and you don't rely on ad-hoc attribute creation.
- The hard-coded `LOW_EMOTION_NEXT_EVENT = {'Event': 'Event2', 'Event2': 'Event3'}` mapping in `CampaignRun` couples the logic to specific task names; you might want to make this driven by configuration or task metadata so it stays consistent when event names change.
- In `handle_low_emotion_withdrawal`, the non-public emotion path assumes `emotion.fleets` is non-empty and indexed; it may be safer to guard against empty or malformed fleet lists to avoid runtime errors in edge configurations.

## Individual Comments

### Comment 1
<location path="tests/test_low_emotion_withdraw.py" line_range="46-55" />
<code_context>
+        campaign.handle_popup_cancel.assert_not_called()
+        campaign.handle_popup_confirm.assert_called_once_with('IGNORE_LOW_EMOTION')
+
+    def test_withdrawal_delays_current_task_to_emotion_recovery(self):
+        recovered = datetime(2026, 8, 14, 12, 0, 0)
+        fleet = Mock()
+        fleet.fleet = 1
+        fleet.current = 75
+        fleet.get_recovered.return_value = recovered
+        emotion = Mock(using_public=False)
+        emotion.fleets = [fleet, Mock()]
+        campaign = SimpleNamespace(
+            low_emotion_withdrawn=True,
+            emotion=emotion,
+            withdraw=Mock(side_effect=CampaignEnd('Withdraw')),
+        )
+        runner = CampaignRun.__new__(CampaignRun)
+        runner.__dict__['campaign'] = campaign
+        runner.__dict__['config'] = Mock()
+        runner.config.task.command = 'Event'
+        runner.config.FLEET_2 = 0
+
+        self.assertTrue(runner.handle_low_emotion_withdrawal())
</code_context>
<issue_to_address>
**suggestion (testing):** Add coverage for `using_public`/`public_fleet` branch in `handle_low_emotion_withdrawal`.

Current tests only cover `using_public=False` (single and dual fleet). Please also add a test for the `using_public=True` branch where `emotion.public_fleet` is set. That test should ensure only `public_fleet.current` is set to 0 and that its `get_recovered()` result is used as the `task_delay` value.
</issue_to_address>

### Comment 2
<location path="tests/test_low_emotion_withdraw.py" line_range="146-155" />
<code_context>
+    def test_withdraw_processes_battle_result_before_waiting_for_stage(self):
</code_context>
<issue_to_address>
**suggestion (testing):** Extend `MapOperation` tests to cover the `COMBAT_STATUS` popup branch in `handle_withdraw_result`.

`handle_withdraw_result` falls back to `handle_popup_confirm('COMBAT_STATUS')` if none of the specific handlers consume the screen. Please add a test where `handle_battle_status`, `handle_exp_info`, `handle_get_ship`, and `handle_get_items` all return `False`, `handle_popup_confirm('COMBAT_STATUS')` returns `True`, and assert that `handle_withdraw_result()` returns `True`, to verify this fallback path is covered.

Suggested implementation:

```python
    def test_withdraw_processes_battle_result_before_waiting_for_stage(self):
        operation = MapOperation.__new__(MapOperation)
        operation.device = SimpleNamespace(screenshot=Mock())
        operation.handle_battle_status = Mock(side_effect=[True, False])
        operation.handle_exp_info = Mock(return_value=False)
        operation.handle_get_ship = Mock(return_value=False)
        operation.handle_get_items = Mock(return_value=False)
        operation.handle_popup_confirm = Mock(return_value=False)
        operation.appear_then_click = Mock(return_value=False)
        operation.handle_auto_search_exit = Mock(return_value=False)
        operation.appear = Mock(return_value=False)

    def test_handle_withdraw_result_falls_back_to_combat_status_popup(self):
        operation = MapOperation.__new__(MapOperation)
        operation.device = SimpleNamespace(screenshot=Mock())
        operation.handle_battle_status = Mock(return_value=False)
        operation.handle_exp_info = Mock(return_value=False)
        operation.handle_get_ship = Mock(return_value=False)
        operation.handle_get_items = Mock(return_value=False)
        operation.handle_popup_confirm = Mock(return_value=True)

        result = operation.handle_withdraw_result()

        self.assertTrue(result)
        operation.handle_popup_confirm.assert_called_once_with('COMBAT_STATUS')

```

This change assumes `MapOperation` is already imported in `tests/test_low_emotion_withdraw.py` and that `handle_withdraw_result` is an instance method on `MapOperation`. If `MapOperation` is not imported, add `from your_module_path import MapOperation` at the top of the file, matching existing import conventions.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread tests/test_low_emotion_withdraw.py
Comment thread tests/test_low_emotion_withdraw.py

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f9c7900bd2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread module/map/map_operation.py
@a2893005741
a2893005741 marked this pull request as draft August 14, 2026 10:59
@a2893005741
a2893005741 marked this pull request as ready for review August 14, 2026 11:18

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

嗨,我在这里给出了一些总体反馈:

  • LOW_EMOTION_NEXT_EVENT 映射中对特定任务名称("Event""Event2""Event3")进行了硬编码;建议考虑将这些配置移动到单独的配置文件或使用更通用的机制,这样未来的事件序列就不需要在这里修改代码。
  • handle_withdraw_result 通过 getattr 根据方法名进行分发;如果这些处理函数以后被重构或重命名,现有逻辑会在不报错的情况下悄悄失效,所以更安全的做法可能是直接引用已绑定的方法,或者在一个集中位置维护统一的结果处理函数列表。
面向 AI 代理的提示词
请根据本次代码评审中的评论进行修改:

## 总体评论
- `LOW_EMOTION_NEXT_EVENT` 映射中对特定任务名称(`"Event"``"Event2"``"Event3"`)进行了硬编码;建议考虑将这些配置移动到单独的配置文件或使用更通用的机制,这样未来的事件序列就不需要在这里修改代码。
- `handle_withdraw_result` 通过 `getattr` 根据方法名进行分发;如果这些处理函数以后被重构或重命名,现有逻辑会在不报错的情况下悄悄失效,所以更安全的做法可能是直接引用已绑定的方法,或者在一个集中位置维护统一的结果处理函数列表。

Sourcery 对开源项目免费——如果你觉得我们的评审有帮助,欢迎分享 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续评审。
Original comment in English

Hey - I've left some high level feedback:

  • The LOW_EMOTION_NEXT_EVENT mapping hardcodes specific task names ('Event', 'Event2', 'Event3'); consider moving this to a configuration or a more generic mechanism so future event sequences don’t require code changes here.
  • handle_withdraw_result dispatches on method names via getattr; if these handlers are refactored or renamed later this will silently stop working, so it may be safer to reference the bound methods directly or centralize the list of result handlers in one place.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The LOW_EMOTION_NEXT_EVENT mapping hardcodes specific task names ('Event', 'Event2', 'Event3'); consider moving this to a configuration or a more generic mechanism so future event sequences don’t require code changes here.
- handle_withdraw_result dispatches on method names via getattr; if these handlers are refactored or renamed later this will silently stop working, so it may be safer to reference the bound methods directly or centralize the list of result handlers in one place.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cd23d6cc5d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread module/campaign/run.py Outdated
for fleet in fleets:
fleet.current = 0
emotion.record()
recovered = max(fleet.get_recovered() for fleet in fleets)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 按下次出击消耗计算恢复时间

当舰队从 0 心情恢复到控制阈值时,这里未向 get_recovered() 传入下一次出击的预期消耗,因此任务会在刚达到阈值时被唤醒;随后 CampaignBase.run() 中的 emotion.check_reduce(self._map_battle) 又会发现心情不足并再次延迟任务。所有使用心情控制的关卡都会因此产生一次无效的 UI 导航和调度循环,应按下次关卡的预计消耗计算本次延迟目标。

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5e786aa5b6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread module/map/map_operation.py Outdated
@a2893005741
a2893005741 marked this pull request as draft August 14, 2026 11:32
@a2893005741
a2893005741 marked this pull request as ready for review August 14, 2026 11:38

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

嗨,我发现了 1 个问题,并留下了一些总体反馈:

  • handle_low_emotion_withdrawal 中,你先调用了 emotion.update(),然后再调用 emotion.get_recovered_for_battle(),而该方法内部又会再次调用 update()/record()/show();建议只依赖一条路径(例如只通过辅助方法)来完成这类操作,以避免重复的状态更新和额外的 IO。
  • get_low_emotion_next_event_task 每次调用都会重新解析并过滤调度器的优先级列表;如果这个方法被频繁调用,考虑在每个配置实例上缓存解析后的事件链,以减少重复解析并提升性能。
给 AI Agent 的 Prompt
请根据以下代码评审意见进行修改:

## 总体意见
-`handle_low_emotion_withdrawal` 中,你先调用了 `emotion.update()`,然后再调用 `emotion.get_recovered_for_battle()`,而该方法内部又会再次调用 `update()`/`record()`/`show()`;建议只依赖一条路径(例如只通过辅助方法)来完成这类操作,以避免重复的状态更新和额外的 IO。
- `get_low_emotion_next_event_task` 每次调用都会重新解析并过滤调度器的优先级列表;如果这个方法被频繁调用,考虑在每个配置实例上缓存解析后的事件链,以减少重复解析并提升性能。

## 具体意见

### 评论 1
<location path="module/combat/emotion.py" line_range="339-346" />
<code_context>

-    def _check_reduce(self, battle):
-        """检查战斗带来的情绪减少。
+    def get_recovered_for_battle(self, battle):
+        """计算完成下一次战役所需的情绪恢复时间。

</code_context>
<issue_to_address>
**suggestion (performance):** 在情绪处理流程中重复调用 update/record/show 可能是多余的,并会影响性能。

`get_recovered_for_battle` 的两个分支都会调用 `self.update()`, `self.record()`, 和 `self.show()`,而 `handle_low_emotion_withdrawal` 在调用 `get_recovered_for_battle` 之前还会修改 `fleet.current` 并调用一次 `emotion.record()`。这会导致一次低情绪事件触发多轮记录/展示流程。建议将这些副作用调用集中到单一位置(要么只在 `get_recovered_for_battle` 内部,要么只在它的调用方),以减少冗余的文件系统/UI 操作,并让恢复逻辑更易理解和维护。

建议的实现:

```python
    def get_recovered_for_battle(self, battle):
        """计算完成下一次战役所需的情绪恢复时间。

        本方法负责在计算完成后统一进行情绪状态的更新与记录,
        调用方无需再重复调用 update()/record()/show() 相关方法。

        Returns:
            datetime: 扣除下一次战役的预计情绪后达到控制阈值的时间。
        """
        # 计算完成下一次战役的预计情绪值以及恢复到阈值所需时间。
        # 注意:这里集中进行情绪状态更新与记录,避免重复的文件和 UI 操作。
        recovered_at = self._calculate_recovered_for_battle(battle)

        # 统一集中处理副作用:更新情绪、记录日志、刷新展示
        self.update()
        self.record()
        self.show()

        return recovered_at

```

```python
    def reduce_shipwreck(self):
        return 10

    def _calculate_recovered_for_battle(self, battle):
        """内部纯计算方法,仅负责返回恢复时间,不产生副作用。

        Args:
            battle: 用于计算下一次战役带来的情绪消耗及恢复时间的战役对象。

        Returns:
            datetime: 扣除下一次战役的预计情绪后达到控制阈值的时间。
        """
        # 这里应包含原来 get_recovered_for_battle 中的纯计算逻辑,
        # 将其中的 self.update()/self.record()/self.show() 等副作用调用挪到 get_recovered_for_battle 中。
        #
        # 由于当前上下文缺失,这里给出一个占位实现,开发者需要用原有计算逻辑替换。
        #
        # 示例:假设有 self.current_emotion, self.threshold, self.recovery_rate 等字段,
        # 可以根据 battle 的情绪消耗估算恢复到阈值的时间。
        # 下面的代码仅作为结构占位,避免运行错误。
        import datetime

        # 占位逻辑:立即达到阈值,返回当前时间
        return datetime.datetime.now()

```

1. 将原先 `get_recovered_for_battle` 中的纯计算逻辑(不包括 `self.update()`, `self.record()`, `self.show()` 调用)移动到新建的 `_calculate_recovered_for_battle` 方法中,并删除原方法内的这些副作用调用,只保留在 `get_recovered_for_battle` 中集中调用。
2. 在所有调用 `get_recovered_for_battle` 的地方(特别是 `handle_low_emotion_withdrawal`)删除额外的 `emotion.record()`, `emotion.update()`, `emotion.show()` 调用,确保每次低情绪事件只会触发一次记录/展示流程。
3. 如果 `handle_low_emotion_withdrawal` 在调用 `get_recovered_for_battle` 前后有独立的情绪记录(例如专门记录撤退事件),将这类业务性记录与通用情绪状态记录区分开:保留业务特定记录,但去除与状态更新重复的通用记录调用。
4. 检查是否存在其他分支或辅助方法在同一个低情绪处理流程中额外调用 `self.update()`, `self.record()`, `self.show()`;如有,统一改为只通过 `get_recovered_for_battle` 进行一次状态更新与展示,以避免多次文件系统和 UI 操作。
</issue_to_address>

Sourcery 对开源项目免费——如果你觉得我们的评审有帮助,欢迎分享 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续评审。
Original comment in English

Hey - I've found 1 issue, and left some high level feedback:

  • In handle_low_emotion_withdrawal you call emotion.update() and then emotion.get_recovered_for_battle(), which itself calls update()/record()/show() again; consider relying on one path (e.g. only the helper) to avoid redundant state updates and extra IO.
  • get_low_emotion_next_event_task recomputes and filters the parsed scheduler priority list on every call; if this is used frequently, caching the parsed event chain per config instance would reduce repeated parsing and improve performance.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `handle_low_emotion_withdrawal` you call `emotion.update()` and then `emotion.get_recovered_for_battle()`, which itself calls `update()`/`record()`/`show()` again; consider relying on one path (e.g. only the helper) to avoid redundant state updates and extra IO.
- `get_low_emotion_next_event_task` recomputes and filters the parsed scheduler priority list on every call; if this is used frequently, caching the parsed event chain per config instance would reduce repeated parsing and improve performance.

## Individual Comments

### Comment 1
<location path="module/combat/emotion.py" line_range="339-346" />
<code_context>

-    def _check_reduce(self, battle):
-        """检查战斗带来的情绪减少。
+    def get_recovered_for_battle(self, battle):
+        """计算完成下一次战役所需的情绪恢复时间。

</code_context>
<issue_to_address>
**suggestion (performance):** Repeated update/record/show calls in emotion handling may be redundant and impact performance.

Both branches of `get_recovered_for_battle` call `self.update()`, `self.record()`, and `self.show()`, while `handle_low_emotion_withdrawal` also mutates `fleet.current` and calls `emotion.record()` before invoking `get_recovered_for_battle`. This causes multiple record/show cycles for a single low-emotion event. Centralize these side-effect calls in a single place (either only inside `get_recovered_for_battle` or only in its caller) to reduce redundant filesystem/UI work and keep the recovery logic easier to follow.

Suggested implementation:

```python
    def get_recovered_for_battle(self, battle):
        """计算完成下一次战役所需的情绪恢复时间。

        本方法负责在计算完成后统一进行情绪状态的更新与记录,
        调用方无需再重复调用 update()/record()/show() 相关方法。

        Returns:
            datetime: 扣除下一次战役的预计情绪后达到控制阈值的时间。
        """
        # 计算完成下一次战役的预计情绪值以及恢复到阈值所需时间。
        # 注意:这里集中进行情绪状态更新与记录,避免重复的文件和 UI 操作。
        recovered_at = self._calculate_recovered_for_battle(battle)

        # 统一集中处理副作用:更新情绪、记录日志、刷新展示
        self.update()
        self.record()
        self.show()

        return recovered_at

```

```python
    def reduce_shipwreck(self):
        return 10

    def _calculate_recovered_for_battle(self, battle):
        """内部纯计算方法,仅负责返回恢复时间,不产生副作用。

        Args:
            battle: 用于计算下一次战役带来的情绪消耗及恢复时间的战役对象。

        Returns:
            datetime: 扣除下一次战役的预计情绪后达到控制阈值的时间。
        """
        # 这里应包含原来 get_recovered_for_battle 中的纯计算逻辑,
        # 将其中的 self.update()/self.record()/self.show() 等副作用调用挪到 get_recovered_for_battle 中。
        #
        # 由于当前上下文缺失,这里给出一个占位实现,开发者需要用原有计算逻辑替换。
        #
        # 示例:假设有 self.current_emotion, self.threshold, self.recovery_rate 等字段,
        # 可以根据 battle 的情绪消耗估算恢复到阈值的时间。
        # 下面的代码仅作为结构占位,避免运行错误。
        import datetime

        # 占位逻辑:立即达到阈值,返回当前时间
        return datetime.datetime.now()

```

1. 将原先 `get_recovered_for_battle` 中的纯计算逻辑(不包括 `self.update()`, `self.record()`, `self.show()` 调用)移动到新建的 `_calculate_recovered_for_battle` 方法中,并删除原方法内的这些副作用调用,只保留在 `get_recovered_for_battle` 中集中调用。
2. 在所有调用 `get_recovered_for_battle` 的地方(特别是 `handle_low_emotion_withdrawal`)删除额外的 `emotion.record()`, `emotion.update()`, `emotion.show()` 调用,确保每次低情绪事件只会触发一次记录/展示流程。
3. 如果 `handle_low_emotion_withdrawal` 在调用 `get_recovered_for_battle` 前后有独立的情绪记录(例如专门记录撤退事件),将这类业务性记录与通用情绪状态记录区分开:保留业务特定记录,但去除与状态更新重复的通用记录调用。
4. 检查是否存在其他分支或辅助方法在同一个低情绪处理流程中额外调用 `self.update()`, `self.record()`, `self.show()`;如有,统一改为只通过 `get_recovered_for_battle` 进行一次状态更新与展示,以避免多次文件系统和 UI 操作。
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread module/combat/emotion.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants