Skip to content

feat(fight): 支持关卡开放状态及今日提示 - #99

Open
GlennnnnX wants to merge 1 commit into
MaaAssistantArknights:masterfrom
GlennnnnX:codex/stage-availability
Open

feat(fight): 支持关卡开放状态及今日提示#99
GlennnnnX wants to merge 1 commit into
MaaAssistantArknights:masterfrom
GlennnnnX:codex/stage-availability

Conversation

@GlennnnnX

@GlennnnnX GlennnnnX commented Jul 13, 2026

Copy link
Copy Markdown

修改内容

为刷理智设置增加完整的关卡开放状态,并在任务列表底部增加基础版「今日关卡小提示」。

  • 根据 clientChannel 使用对应服务器时区,并以服务器时间 04:00 作为换日边界
  • 内置常驻资源本与 PR-A/B/C/D 芯片本的每周开放表
  • 读取 gui/StageActivityV2.json,展示有效活动关卡,并支持 resourceCollection 期间资源本全部开放
  • 关卡选择器按「常用 / 今日开放 / 活动 / 今日未开放」分组;芯片本显示职业简称
  • 已持久化但今日关闭的已知关卡会在任务执行前自动重置为「当前/上次」
  • API 请求失败时使用缓存和内置开放表,不阻断关卡选择
  • 修复 Fight 参数追加失败被误报为连接失败的问题,并丢弃部分构造的 task handle
  • 增加固定显示的「今日关卡小提示」,包含当日资源本、芯片本、周一/周日剿灭提醒和活动剩余时间

Related to MaaAssistantArknights/MaaAssistantArknights#9973.

本实现参考了 #42 的 SwiftUI 接入位置,但重新实现了日期、服务器时区、04:00 换日、活动数据、fallback 与测试逻辑。

验证

  • MeoAsstMacTests:12/12 tests passed
  • Debug arm64 build:BUILD SUCCEEDED
  • swift-format lint --strict(本次新增/实质修改的 Swift 文件)
  • xcstringstool compile Resources/Localizable.xcstrings
  • git diff --check
  • 真实客户端 UI smoke test:今日提示固定显示,切换到非刷理智详情时仍可见;周一开放关卡内容正确
  • 手工验证:关闭关卡持久化警告、执行前自动重置、非法手输关卡不再显示连接失败

本 PR 不包含

  • 多个备选关卡按开放状态自动选择
  • 活动材料库存/推荐刷取数量

这些可以在本 PR 的基础上单独迭代,避免扩大当前改动范围。

Summary by Sourcery

在战斗设置和任务列表中支持“按服务器区分的关卡开放状态”和“每日关卡小提示”,同时加强任务启动错误处理并规范化关卡配置。

New Features:

  • 引入一个由内置排期和 StageActivityV2.json 支持的关卡目录,用于根据服务器确定关卡开放状态和每日提示。
  • 在战斗设置中新增分组关卡选择器,将常用关卡、今日开放关卡、活动关卡和今日关闭关卡分组显示,并可选展示当前不可用的素材/芯片关卡。
  • 向应用暴露 MaaCore 版本,并在战斗配置副标题中使用内置的芯片关卡显示名称。
  • 在任务列表下方常驻显示“今日关卡小提示”面板,总结今日推荐的素材/芯片关卡、剿灭作战提醒以及活动剩余天数。

Bug Fixes:

  • 区分战斗任务参数追加失败与核心连接失败,并在任务启动失败时改进错误日志记录。
  • 在任务执行前自动规范化并重置今日已关闭的已保存战斗关卡,避免出现无效的关卡配置。

Enhancements:

  • 与 OTA 资源一同加载并刷新关卡目录,在活动数据缺失或异常时优雅回退。
  • 收紧任务句柄生命周期,当追加任务失败时丢弃核心句柄并清理任务状态。
  • 扩展任务列表布局,增加用于每日关卡小提示的固定底部区域,同时保留现有任务交互行为。

Tests:

  • 添加 StageCatalog 单元测试,覆盖每周排期、服务器日 04:00 刷新、素材收集覆盖规则、别传活动时间窗口和版本门控、规范化行为以及每日总结生成。
Original summary in English

Summary by Sourcery

Support server-aware stage availability and daily stage tips in fight settings and task list, while hardening task startup error handling and stage configuration normalization.

New Features:

  • Introduce a stage catalog backed by built-in schedules and StageActivityV2.json to determine per-server stage availability and daily tips.
  • Add a grouped stage picker in fight settings that separates common, today-open, event, and today-closed stages with optional display of unavailable resource/chip stages.
  • Expose MaaCore version to the app and use built-in display names for chip stages in fight configuration subtitles.
  • Show a persistent "今日关卡小提示" panel under the task list summarizing today’s recommended resource/chip stages, annihilation reminders, and remaining event days.

Bug Fixes:

  • Distinguish fight task parameter append failures from core connection failures and improve error logging when task start fails.
  • Automatically normalize and reset stored fight stages that are closed today before task execution to avoid invalid stage configurations.

Enhancements:

  • Load and refresh stage catalog together with OTA resources, falling back gracefully when activity data is missing or malformed.
  • Tighten task handle lifecycle by discarding the core handle and clearing task state when appending a task fails.
  • Extend task list layout with a fixed bottom area for the daily stage tips while preserving existing task interactions.

Tests:

  • Add StageCatalog unit tests covering weekly schedules, 04:00 server day rollover, resource collection overrides, side story activity windows and version gating, normalization behavior, and daily summary generation.

新功能:

  • StageActivityV2.json 中解析关卡目录,为素材和芯片关卡提供内置日程表,并处理按服务器划分的时间。
  • 在战斗设置中引入分组关卡选择器,展示常用关卡、今日开放关卡、活动关卡以及今日关闭关卡,并可选显示当前不可挑战的关卡。
  • 新增持久显示的每日关卡提示面板,总结今日推荐的素材/芯片关卡、剿灭作战提醒以及活动剩余时间。
  • 将 MaaCore 版本暴露给应用,并在战斗配置中使用芯片关卡的内置显示名称。

错误修复:

  • 避免将战斗参数追加失败错误误报为核心连接失败,并改进任务启动时的错误日志记录。
  • 在任务执行前自动重置今日已关闭的已存储战斗关卡为当前/最近使用的关卡,防止出现无效的关卡配置。

改进:

  • 与 OTA 资源一同加载并刷新关卡目录,当活动数据缺失或格式错误时提供回退方案。
  • 收紧任务句柄生命周期,在追加失败时丢弃核心句柄并清除相关状态。
  • 扩展任务列表布局,加入用于每日提示的固定底部区域,同时不干扰现有任务交互。

测试:

  • 新增 StageCatalog 单元测试,覆盖每周日程、4:00 服务器日切换、素材收集覆盖规则、支线故事活动时间窗口和版本门控、规范化行为以及“今日摘要”的生成。
Original summary in English

Summary by Sourcery

在战斗设置和任务列表中支持“按服务器区分的关卡开放状态”和“每日关卡小提示”,同时加强任务启动错误处理并规范化关卡配置。

New Features:

  • 引入一个由内置排期和 StageActivityV2.json 支持的关卡目录,用于根据服务器确定关卡开放状态和每日提示。
  • 在战斗设置中新增分组关卡选择器,将常用关卡、今日开放关卡、活动关卡和今日关闭关卡分组显示,并可选展示当前不可用的素材/芯片关卡。
  • 向应用暴露 MaaCore 版本,并在战斗配置副标题中使用内置的芯片关卡显示名称。
  • 在任务列表下方常驻显示“今日关卡小提示”面板,总结今日推荐的素材/芯片关卡、剿灭作战提醒以及活动剩余天数。

Bug Fixes:

  • 区分战斗任务参数追加失败与核心连接失败,并在任务启动失败时改进错误日志记录。
  • 在任务执行前自动规范化并重置今日已关闭的已保存战斗关卡,避免出现无效的关卡配置。

Enhancements:

  • 与 OTA 资源一同加载并刷新关卡目录,在活动数据缺失或异常时优雅回退。
  • 收紧任务句柄生命周期,当追加任务失败时丢弃核心句柄并清理任务状态。
  • 扩展任务列表布局,增加用于每日关卡小提示的固定底部区域,同时保留现有任务交互行为。

Tests:

  • 添加 StageCatalog 单元测试,覆盖每周排期、服务器日 04:00 刷新、素材收集覆盖规则、别传活动时间窗口和版本门控、规范化行为以及每日总结生成。
Original summary in English

Summary by Sourcery

Support server-aware stage availability and daily stage tips in fight settings and task list, while hardening task startup error handling and stage configuration normalization.

New Features:

  • Introduce a stage catalog backed by built-in schedules and StageActivityV2.json to determine per-server stage availability and daily tips.
  • Add a grouped stage picker in fight settings that separates common, today-open, event, and today-closed stages with optional display of unavailable resource/chip stages.
  • Expose MaaCore version to the app and use built-in display names for chip stages in fight configuration subtitles.
  • Show a persistent "今日关卡小提示" panel under the task list summarizing today’s recommended resource/chip stages, annihilation reminders, and remaining event days.

Bug Fixes:

  • Distinguish fight task parameter append failures from core connection failures and improve error logging when task start fails.
  • Automatically normalize and reset stored fight stages that are closed today before task execution to avoid invalid stage configurations.

Enhancements:

  • Load and refresh stage catalog together with OTA resources, falling back gracefully when activity data is missing or malformed.
  • Tighten task handle lifecycle by discarding the core handle and clearing task state when appending a task fails.
  • Extend task list layout with a fixed bottom area for the daily stage tips while preserving existing task interactions.

Tests:

  • Add StageCatalog unit tests covering weekly schedules, 04:00 server day rollover, resource collection overrides, side story activity windows and version gating, normalization behavior, and daily summary generation.

@GlennnnnX
GlennnnnX marked this pull request as ready for review July 13, 2026 14:59

@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 - 我在这里给出了一些整体性的反馈:

  • clientChannel 推导 StageServer 的逻辑,以及使用 MAAProvider.version 的逻辑在多个视图中重复出现(例如 FightSettingsViewTodayStageTipView);建议将这些逻辑集中到 MAAViewModel 上的辅助方法中,以避免逻辑偏移并简化未来的更改。
  • StageCatalog.reloadStageCatalog(at:) 及相关调用中,resetUnavailableFightStages(now:) 会在每次目录重载后无条件调用(包括失败的情况);如果之后需要与任务开始时间严格保持一致,建议从调用方传入同一个 now 值,而不是在多个位置分别捕获 Date()
面向 AI 代理的提示
请处理本次代码审查中的这些评论:

## 总体评论
-`clientChannel` 推导 `StageServer` 的逻辑,以及使用 `MAAProvider.version` 的逻辑在多个视图中重复出现(例如 `FightSettingsView``TodayStageTipView`);建议将这些逻辑集中到 `MAAViewModel` 上的辅助方法中,以避免逻辑偏移并简化未来的更改。
-`StageCatalog.reloadStageCatalog(at:)` 及相关调用中,`resetUnavailableFightStages(now:)` 会在每次目录重载后无条件调用(包括失败的情况);如果之后需要与任务开始时间严格保持一致,建议从调用方传入同一个 `now` 值,而不是在多个位置分别捕获 `Date()`

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

Hey - I've left some high level feedback:

  • The logic to derive StageServer from clientChannel and to use MAAProvider.version is duplicated in multiple views (e.g., FightSettingsView and TodayStageTipView); consider centralizing these into helper methods on MAAViewModel to avoid drift and simplify future changes.
  • In StageCatalog.reloadStageCatalog(at:) and related calls, resetUnavailableFightStages(now:) is invoked unconditionally after any catalog reload (including failure cases); if this ever needs to be time-consistent with task start, consider passing the same now value through from the caller rather than capturing Date() multiple times.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The logic to derive `StageServer` from `clientChannel` and to use `MAAProvider.version` is duplicated in multiple views (e.g., `FightSettingsView` and `TodayStageTipView`); consider centralizing these into helper methods on `MAAViewModel` to avoid drift and simplify future changes.
- In `StageCatalog.reloadStageCatalog(at:)` and related calls, `resetUnavailableFightStages(now:)` is invoked unconditionally after any catalog reload (including failure cases); if this ever needs to be time-consistent with task start, consider passing the same `now` value through from the caller rather than capturing `Date()` multiple 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.

@GlennnnnX

Copy link
Copy Markdown
Author

Thanks for the review!

For the StageServer / MAAProvider.version duplication, I agree that these expressions appear in a few places. They are currently only one-line value derivations, though, so I would prefer to keep them local rather than expand MAAViewModel's API solely for this PR. If the mapping gains more logic or more call sites later, centralizing it would make sense.

For the time consistency point, the current behavior is intentional:

  • reloadStageCatalog captures the current time once when it normalizes persisted stages, including when falling back to the built-in schedule after activity-data loading fails.
  • Task execution captures a new time immediately before appending tasks. This is important around the server's 04:00 day boundary: execution should use the actual start time rather than an earlier catalog-load time.
  • With a failed activity-data load, unknown activity stages are preserved, while known built-in resource/chip stages can still be normalized safely using the fallback schedule.

Given that, I plan to keep the current implementation for this PR, but will revisit the helper extraction if the shared derivation grows.

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.

1 participant