feat(游戏数据): 新增驱动盘配置文件和代理人数据#2186
Conversation
新增多个驱动盘配置文件并更新代理人数据 添加代理人类型和属性类型的中文映射 实现代理人数据加载和保存功能 创建信息管理应用框架
📝 WalkthroughWalkthrough新增并规范化大量游戏数据(多个 agent 与 27 个 drive_disk YAML、slot 映射),并引入完整的信息管理模块(后端应用、工厂、配置、以及 Qt 前端界面)用于加载/编辑/保存 agent 数据与权重映射。 Changes
Sequence Diagram(s)sequenceDiagram
participant UI as "Qt UI (IntelManageInterface)"
participant App as "IntelManageApp"
participant FS as "文件系统 / YAML"
participant Slot as "slot_Mapping.json"
UI->>App: 请求加载 agent 列表 (on_interface_shown)
App->>FS: 列出 assets/game_data/agent/*.yml(跳过 '_' 文件)
FS-->>App: 返回 YAML 文件列表
loop 对每个 YAML 文件
App->>FS: 读取并 yaml.safe_load(file)
alt 解析成功且包含 agent_name
App->>Slot: 获取属性显示顺序与标签(按 dmg_type)
Slot-->>App: 返回列顺序与标签
App-->>App: enrich 数据(agent_type_cn / dmg_type_cn)
App-->>UI: 传回已加载的 agent 数据
else 读取/解析失败
App-->>App: 记录日志并跳过该文件
end
end
UI->>App: 用户编辑并点击保存
App->>FS: 调用 save_agent_data -> 写回安全命名的 `*.yml`
FS-->>App: 写入结果(成功/失败)
App-->>UI: 显示保存结果(成功/错误)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~40 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 6
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/zzz_od/gui/view/devtools/app_devtools_interface.py (1)
33-43:⚠️ Potential issue | 🟡 Minor给被修改的方法补上返回类型标注。
create_sub_interface只执行注册逻辑、不返回值,建议显式标注-> None,避免新增代码继续扩大未标注方法的范围。建议修复
- def create_sub_interface(self): + def create_sub_interface(self) -> None:As per coding guidelines:
**/*.py: All functions and methods must include type hints.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/zzz_od/gui/view/devtools/app_devtools_interface.py` around lines 33 - 43, The method create_sub_interface currently lacks a return type annotation; update its signature to include an explicit return type "-> None" (e.g., def create_sub_interface(self) -> None:) since it only performs registration via add_sub_interface calls and returns nothing, ensuring compliance with the project's Python type-hint rule for functions/methods.
🧹 Nitpick comments (7)
assets/game_data/agent/_README.md (1)
8-12: 属性类型映射可以考虑补充完整形式当前文档显示的是简化映射(如
ELECTRIC → 电),但代码中实际定义包含"属性"后缀(如ELECTRIC = '电属性')。虽然简化形式更易读,但建议在文档中说明这是简化映射,或者提供完整映射以避免混淆。另外,文档缺少
UNKNOWN → 未知枚举值。💡 可选的补充
可以在文档开头添加说明:
# 代理人类型和属性类型映射 ## 代理人类型 (Agent Type) ... ## 属性类型 (Damage Type) - 简化映射 以下为简化映射,代码中实际值会带有"属性"后缀(如:电属性) ELECTRIC → 电 ... UNKNOWN → 未知🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@assets/game_data/agent/_README.md` around lines 8 - 12, Update the attribute-type mapping in the README to match the code or explicitly note it's a simplified view: either replace entries like "ELECTRIC → 电" with the full code values (e.g. ELECTRIC = '电属性', FIRE = '火属性', ICE = '冰属性', PHYSICAL = '物理属性', ETHER = '以太属性') or add a clear heading stating these are simplified mappings and the actual enum values have the "属性" suffix; also add the missing UNKNOWN → 未知 (e.g. UNKNOWN = '未知属性') entry so the documentation matches the code's enum values.assets/game_data/drive_disk/free_jazz.yml (1)
3-3: 建议统一引号风格驱动盘配置文件的
code字段使用了无引号格式 (code: free_jazz),而代理人配置文件使用了引号格式 (code: 'ellen')。虽然两种格式在 YAML 中都有效,但建议统一使用引号格式以保持整个项目的一致性。♻️ 建议的修改
-code: free_jazz +code: 'free_jazz'🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@assets/game_data/drive_disk/free_jazz.yml` at line 3, The YAML 'code' field currently uses an unquoted value (code: free_jazz); update the value to a quoted string (e.g., code: "free_jazz" or code: 'free_jazz') to match the quoted style used elsewhere (like code: 'ellen'), ensuring consistent quoting across agent and drive disk config files and preserving the same identifier value.src/zzz_od/application/devtools/intel_manage/intel_manage_const.py (1)
1-4: 可选:为模块级常量补充类型注解常量含义明确,当前实现可用。如希望增强静态检查能力,可补充类型注解:
♻️ 建议改动
-APP_ID = 'intel_manage' -APP_NAME = '信息管理' -DEFAULT_GROUP = False -NEED_NOTIFY = False +APP_ID: str = 'intel_manage' +APP_NAME: str = '信息管理' +DEFAULT_GROUP: bool = False +NEED_NOTIFY: bool = False🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/zzz_od/application/devtools/intel_manage/intel_manage_const.py` around lines 1 - 4, Module-level constants APP_ID, APP_NAME, DEFAULT_GROUP, and NEED_NOTIFY lack type annotations; add explicit types to improve static checking by annotating them as APP_ID: str, APP_NAME: str, DEFAULT_GROUP: bool, and NEED_NOTIFY: bool so linters/type-checkers (e.g., mypy) can validate usages and catch type mistakes.src/zzz_od/application/devtools/intel_manage/intel_manage_config.py (1)
8-13: 建议使用super().__init__()调用父类构造函数当前显式调用
ApplicationConfig.__init__(self, ...)是可行的,但在单继承场景下使用super().__init__(...)更符合 Python 习惯,便于未来引入 mixin 或调整继承链。♻️ 建议改动
def __init__(self, instance_idx: int, group_id: str): - ApplicationConfig.__init__( - self, - app_id=intel_manage_const.APP_ID, - instance_idx=instance_idx, - group_id=group_id, - ) + super().__init__( + app_id=intel_manage_const.APP_ID, + instance_idx=instance_idx, + group_id=group_id, + )🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/zzz_od/application/devtools/intel_manage/intel_manage_config.py` around lines 8 - 13, 当前在类构造函数中直接调用 ApplicationConfig.__init__(self, ...),请改为使用 super().__init__(...) 以遵循 Python 习惯并支持未来的 mixin/继承调整:在当前类的 __init__ 方法中替换对 ApplicationConfig.__init__ 的显式调用为 super().__init__(app_id=intel_manage_const.APP_ID, instance_idx=instance_idx, group_id=group_id) 并保留其余参数和行为不变。src/zzz_od/application/devtools/intel_manage/intel_manage_app.py (2)
2-2: 改用内置泛型,并补齐enum_class参数类型。当前文件使用了
typing.Dict,且_get_enum_mapping()的参数没有类型标注;按项目 Python 3.11+ 约定应使用dict[...]。♻️ 建议调整
from pathlib import Path -from typing import Dict import yaml @@ - self.agent_data: Dict[str, dict] = {} + self.agent_data: dict[str, dict] = {} @@ - def load_agent_data(self) -> Dict[str, dict]: + def load_agent_data(self) -> dict[str, dict]: @@ - def _get_enum_mapping(self, enum_class) -> Dict[str, str]: + def _get_enum_mapping(self, enum_class: type) -> dict[str, str]: @@ - def get_agent_type_mapping(self) -> Dict[str, str]: + def get_agent_type_mapping(self) -> dict[str, str]: @@ - def get_dmg_type_mapping(self) -> Dict[str, str]: + def get_dmg_type_mapping(self) -> dict[str, str]:As per coding guidelines,
**: 使用内置泛型类型(list,dict)而不是从typing模块导入的类型(List,Dict);**/*.py: All functions and methods must include type hints.Also applies to: 26-31, 117-127
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/zzz_od/application/devtools/intel_manage/intel_manage_app.py` at line 2, 替换掉文件顶部对 typing.Dict 的导入并改为使用内置泛型 dict[...],并为函数 _get_enum_mapping 的参数 enum_class 补上类型注解(例如 Optional[Type[Enum]] 或更具体的枚举类型,根据实际使用场景),确保所有相关函数/方法遵循 Python 3.11+ 的内置泛型约定并补齐缺失的类型提示(参考符号:typing.Dict、_get_enum_mapping、enum_class)。
53-61: 避免吞掉非 IO/YAML 的编程错误。这里已经专门处理了
IOError和yaml.YAMLError,后续的裸Exception会把TypeError、逻辑错误等也当成数据文件问题跳过,排查会变困难。建议删除该兜底分支,或仅捕获确实可恢复的异常。As per coding guidelines,**/*.py: Avoid unnecessary try-catch blocks; let exceptions be raised unless meaningful handling is possible.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/zzz_od/application/devtools/intel_manage/intel_manage_app.py` around lines 53 - 61, The catch-all "except Exception as e" in the YAML loading loop (surrounding the with open(yml_file...) block inside the intel management code) is swallowing programming errors; remove that broad except or restrict it to specific, recoverable exceptions only so TypeError/NameError/logic bugs surface. Keep the existing except (IOError, yaml.YAMLError) as the only handlers and delete the trailing generic handler (and its self.log.error(...) continue), or replace it with a narrow exception class if there is a legitimate recoverable case to handle.src/zzz_od/gui/view/devtools/intel_manage_interface.py (1)
70-70: 补齐新增方法和回调的类型标注。这些方法/嵌套回调缺少返回值或参数类型标注,和项目的 Python 代码规范不一致;建议至少补上
-> None、parent: QWidget | None、验证器返回类型等。As per coding guidelines,**/*.py: All functions and methods must include type hints.Also applies to: 117-123, 138-138, 365-389, 421-465
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/zzz_od/gui/view/devtools/intel_manage_interface.py` at line 70, Add missing type annotations across the new methods and nested callbacks: change the constructor signature to def __init__(self, character_name: str, parent: QWidget | None = None) -> None and annotate all methods and nested callbacks with explicit return types (use -> None for handlers/callbacks that don't return a value). For any validator callbacks, add precise return type hints (e.g., -> bool for simple validators or the appropriate Tuple/Enum signature if implementing a QValidator-style validate method) and annotate all parameters (e.g., parent, event, value) with their QWidget/event/value types so every function in this module conforms to the project's type-hinting guideline.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@assets/game_data/agent/_README.md`:
- Around line 1-6: The README mapping is incorrect vs the AgentTypeEnum in code:
update the entries to match src/zzz_od/game_data/agent.py by changing the STUN
mapping to "STUN → 击破", removing the non-existent "BREAK → 击破" entry, and add
the missing enum mappings "ANOMALY → 异常" and "UNKNOWN → 未知"; verify the README
now mirrors the AgentTypeEnum values and names used in the AgentTypeEnum class.
In `@assets/game_data/agent/rina.yml`:
- Around line 1-3: The Rina YAML uses wrong enum values—update
assets/game_data/agent/rina.yml so the entries for Rina match the definitions in
src/zzz_od/game_data/agent.py (AgentEnum.RINA): set rare_type to RareTypeEnum.S
(or "S"), agent_type to AgentTypeEnum.SUPPORT (or "SUPPORT"), and dmg_type to
DmgTypeEnum.ELECTRIC (or "ELECTRIC") so the file reflects the correct RareType,
AgentType, and DmgType for Rina.
In `@assets/game_data/drive_disk/dawn_blossom.yml`:
- Around line 1-3: The drive disk YAML files (e.g.,
assets/game_data/drive_disk/dawn_blossom.yml) are never loaded; implement a
loader that scans assets/game_data/drive_disk, parses each YAML into objects
containing the fields set_name, mission_type_name, and code, validates/matches
expected keys, and returns a list/dict of drive-disk entries; then update the
GUI code that currently uses hardcoded sample data in
src/zzz_od/gui/view/devtools/intel_manage_interface.py (the function rendering
the drive-disk list around lines 784–810) to consume the loader's data instead
of the inline examples, with basic caching and error logging for missing/invalid
YAML files.
In `@src/zzz_od/gui/view/devtools/intel_manage_interface.py`:
- Around line 1097-1145: The code currently builds a partial agent_data from UI
and calls app.save_agent_data(agent_name, agent_data), which causes YAML to be
overwritten and drop fields; instead merge the existing full record in
self.agent_data[agent_name] with the partial agent_data and pass the merged full
dict to the save call: retrieve the existing record for agent_name from
self.agent_data (or an empty dict), create a merged dict that overlays the new
agent_data onto the existing record, update self.agent_data[agent_name] with the
merged dict, and then call app.save_agent_data(agent_name, merged_dict) so
YamlOperator receives the complete agent data.
- Around line 982-993: The delete handler _on_delete_clicked currently finds a
TableWidget via mode_stacked.currentWidget().findChild(TableWidget) and only
removes table rows (removeRow), which for the agent page deletes fields/weights
visually but never mutates self.agent_data or refreshes search/detail UI. Update
_on_delete_clicked to detect when current_page is self.agent_page (or contains
an agent list widget) and in that case collect selected agent IDs/indices,
remove the corresponding entries from self.agent_data, update any search options
and the details pane (trigger the same refresh method used elsewhere), and only
fall back to removing table rows for non-agent pages; reference mode_stacked,
agent_page, agent_data, TableWidget, and the UI refresh method to ensure state
and UI remain consistent.
- Around line 146-164: The save block silently swallows exceptions and still
calls self.accept(), misleading the user; update the code around weight_file /
data / self.character_name / self.weight_values to catch specific exceptions
when creating the directory or writing JSON, log the full exception (use the
module logger or processLogger) and present a user-visible error (e.g.
QMessageBox.critical or similar) when saving fails, and in that failure path do
not call self.accept() (return early) so the dialog remains open; remove the
broad bare excepts and only handle expected errors with clear logging and user
feedback.
---
Outside diff comments:
In `@src/zzz_od/gui/view/devtools/app_devtools_interface.py`:
- Around line 33-43: The method create_sub_interface currently lacks a return
type annotation; update its signature to include an explicit return type "->
None" (e.g., def create_sub_interface(self) -> None:) since it only performs
registration via add_sub_interface calls and returns nothing, ensuring
compliance with the project's Python type-hint rule for functions/methods.
---
Nitpick comments:
In `@assets/game_data/agent/_README.md`:
- Around line 8-12: Update the attribute-type mapping in the README to match the
code or explicitly note it's a simplified view: either replace entries like
"ELECTRIC → 电" with the full code values (e.g. ELECTRIC = '电属性', FIRE = '火属性',
ICE = '冰属性', PHYSICAL = '物理属性', ETHER = '以太属性') or add a clear heading stating
these are simplified mappings and the actual enum values have the "属性" suffix;
also add the missing UNKNOWN → 未知 (e.g. UNKNOWN = '未知属性') entry so the
documentation matches the code's enum values.
In `@assets/game_data/drive_disk/free_jazz.yml`:
- Line 3: The YAML 'code' field currently uses an unquoted value (code:
free_jazz); update the value to a quoted string (e.g., code: "free_jazz" or
code: 'free_jazz') to match the quoted style used elsewhere (like code:
'ellen'), ensuring consistent quoting across agent and drive disk config files
and preserving the same identifier value.
In `@src/zzz_od/application/devtools/intel_manage/intel_manage_app.py`:
- Line 2: 替换掉文件顶部对 typing.Dict 的导入并改为使用内置泛型 dict[...],并为函数 _get_enum_mapping 的参数
enum_class 补上类型注解(例如 Optional[Type[Enum]] 或更具体的枚举类型,根据实际使用场景),确保所有相关函数/方法遵循
Python 3.11+ 的内置泛型约定并补齐缺失的类型提示(参考符号:typing.Dict、_get_enum_mapping、enum_class)。
- Around line 53-61: The catch-all "except Exception as e" in the YAML loading
loop (surrounding the with open(yml_file...) block inside the intel management
code) is swallowing programming errors; remove that broad except or restrict it
to specific, recoverable exceptions only so TypeError/NameError/logic bugs
surface. Keep the existing except (IOError, yaml.YAMLError) as the only handlers
and delete the trailing generic handler (and its self.log.error(...) continue),
or replace it with a narrow exception class if there is a legitimate recoverable
case to handle.
In `@src/zzz_od/application/devtools/intel_manage/intel_manage_config.py`:
- Around line 8-13: 当前在类构造函数中直接调用 ApplicationConfig.__init__(self, ...),请改为使用
super().__init__(...) 以遵循 Python 习惯并支持未来的 mixin/继承调整:在当前类的 __init__ 方法中替换对
ApplicationConfig.__init__ 的显式调用为
super().__init__(app_id=intel_manage_const.APP_ID, instance_idx=instance_idx,
group_id=group_id) 并保留其余参数和行为不变。
In `@src/zzz_od/application/devtools/intel_manage/intel_manage_const.py`:
- Around line 1-4: Module-level constants APP_ID, APP_NAME, DEFAULT_GROUP, and
NEED_NOTIFY lack type annotations; add explicit types to improve static checking
by annotating them as APP_ID: str, APP_NAME: str, DEFAULT_GROUP: bool, and
NEED_NOTIFY: bool so linters/type-checkers (e.g., mypy) can validate usages and
catch type mistakes.
In `@src/zzz_od/gui/view/devtools/intel_manage_interface.py`:
- Line 70: Add missing type annotations across the new methods and nested
callbacks: change the constructor signature to def __init__(self,
character_name: str, parent: QWidget | None = None) -> None and annotate all
methods and nested callbacks with explicit return types (use -> None for
handlers/callbacks that don't return a value). For any validator callbacks, add
precise return type hints (e.g., -> bool for simple validators or the
appropriate Tuple/Enum signature if implementing a QValidator-style validate
method) and annotate all parameters (e.g., parent, event, value) with their
QWidget/event/value types so every function in this module conforms to the
project's type-hinting guideline.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 71138f09-1b48-475d-9dc6-fa08c1fd7cb5
📒 Files selected for processing (53)
assets/game_data/agent/Aria.ymlassets/game_data/agent/_README.mdassets/game_data/agent/anby.ymlassets/game_data/agent/anton.ymlassets/game_data/agent/ben.ymlassets/game_data/agent/billy.ymlassets/game_data/agent/corin.ymlassets/game_data/agent/ellen.ymlassets/game_data/agent/grace.ymlassets/game_data/agent/koleda.ymlassets/game_data/agent/lucy.ymlassets/game_data/agent/lycaon.ymlassets/game_data/agent/nekomata.ymlassets/game_data/agent/nicole.ymlassets/game_data/agent/piper.ymlassets/game_data/agent/rina.ymlassets/game_data/agent/soldier_11.ymlassets/game_data/agent/soukaku.ymlassets/game_data/agent/zhu_yuan.ymlassets/game_data/drive_disk/broken_branch_sword_song.ymlassets/game_data/drive_disk/canglang_song.ymlassets/game_data/drive_disk/chaos_heavy_metal.ymlassets/game_data/drive_disk/chaos_jazz.ymlassets/game_data/drive_disk/cloud_mountain_self.ymlassets/game_data/drive_disk/dawn_blossom.ymlassets/game_data/drive_disk/fang_heavy_metal.ymlassets/game_data/drive_disk/flowing_light_aria.ymlassets/game_data/drive_disk/free_blues.ymlassets/game_data/drive_disk/free_jazz.ymlassets/game_data/drive_disk/hormone_punk.ymlassets/game_data/drive_disk/inferno_heavy_metal.ymlassets/game_data/drive_disk/moonlight_knight_ode.ymlassets/game_data/drive_disk/mountain_lord.ymlassets/game_data/drive_disk/polar_heavy_metal.ymlassets/game_data/drive_disk/primitive_punk.ymlassets/game_data/drive_disk/prisoners_notebook.ymlassets/game_data/drive_disk/pufferfish_electronic.ymlassets/game_data/drive_disk/shadow_follower.ymlassets/game_data/drive_disk/shocking_disco.ymlassets/game_data/drive_disk/silent_listen_jia_yin.ymlassets/game_data/drive_disk/snow_rabbit_wonderland.ymlassets/game_data/drive_disk/song_of_phoebus.ymlassets/game_data/drive_disk/soul_rock.ymlassets/game_data/drive_disk/swing_jazz.ymlassets/game_data/drive_disk/thunder_heavy_metal.ymlassets/game_data/drive_disk/woodpecker_electronic.ymlsrc/zzz_od/application/devtools/intel_manage/__init__.pysrc/zzz_od/application/devtools/intel_manage/intel_manage_app.pysrc/zzz_od/application/devtools/intel_manage/intel_manage_app_factory.pysrc/zzz_od/application/devtools/intel_manage/intel_manage_config.pysrc/zzz_od/application/devtools/intel_manage/intel_manage_const.pysrc/zzz_od/gui/view/devtools/app_devtools_interface.pysrc/zzz_od/gui/view/devtools/intel_manage_interface.py
| ATTACK → 强攻 | ||
| STUN → 异常 | ||
| SUPPORT → 支援 | ||
| DEFENSE → 防护 | ||
| BREAK → 击破 | ||
| RUPTURE → 命破 |
There was a problem hiding this comment.
代理人类型映射存在错误
文档中的类型映射与代码实际定义不一致:
- Line 2:
STUN → 异常是错误的。根据src/zzz_od/game_data/agent.py中的AgentTypeEnum定义,STUN = '击破',而ANOMALY = '异常'。 - Line 5:
BREAK → 击破在代码中不存在BREAK枚举值,应该是STUN = '击破'。 - 文档缺少了
ANOMALY(异常)和UNKNOWN(未知)这两个枚举值。
建议的修正:
- 将 Line 2 改为
STUN → 击破 - 删除 Line 5 的
BREAK,或者如果BREAK是其他用途请补充说明 - 添加
ANOMALY → 异常和UNKNOWN → 未知
🔧 建议的修正
ATTACK → 强攻
-STUN → 异常
+STUN → 击破
+ANOMALY → 异常
SUPPORT → 支援
DEFENSE → 防护
-BREAK → 击破
RUPTURE → 命破
+UNKNOWN → 未知📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| ATTACK → 强攻 | |
| STUN → 异常 | |
| SUPPORT → 支援 | |
| DEFENSE → 防护 | |
| BREAK → 击破 | |
| RUPTURE → 命破 | |
| ATTACK → 强攻 | |
| STUN → 击破 | |
| ANOMALY → 异常 | |
| SUPPORT → 支援 | |
| DEFENSE → 防护 | |
| RUPTURE → 命破 | |
| UNKNOWN → 未知 |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@assets/game_data/agent/_README.md` around lines 1 - 6, The README mapping is
incorrect vs the AgentTypeEnum in code: update the entries to match
src/zzz_od/game_data/agent.py by changing the STUN mapping to "STUN → 击破",
removing the non-existent "BREAK → 击破" entry, and add the missing enum mappings
"ANOMALY → 异常" and "UNKNOWN → 未知"; verify the README now mirrors the
AgentTypeEnum values and names used in the AgentTypeEnum class.
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
rg -n "AgentTypeEnum|AgentType|STUN|ANOMALY|ATTACK|BREAK|RUPTURE" src/zzz_od/game_data/agent.py -A2 -B2
Length of output: 13215
@idk500,您的批评完全正确,我为此道歉。
事实层面:我的分析内容是准确的——STUN 应映射到 击破(不是 异常),BREAK 在枚举中不存在,且 ANOMALY 和 UNKNOWN 缺失。
严重性层面:将一个 README 文档文件中的映射错误标记为 🔴 Critical 是完全错误的。Critical 应保留给生产环境中可能导致安全漏洞、数据损坏或运行时崩溃的问题。一个纯文档文件(.md)的内容偏差,最多只是 minor 或 nitpick 级别。
改进方向:对于文档类文件(README.md、注释、YAML 数据文件中的说明性内容),我会严格限制使用较低的严重等级,不再将其升级为 Critical。
再次为误报的严重等级给您带来困扰致歉。
✏️ Learnings added
Learnt from: idk500
Repo: OneDragon-Anything/ZenlessZoneZero-OneDragon PR: 2186
File: assets/game_data/agent/_README.md:0-0
Timestamp: 2026-05-04T02:38:57.979Z
Learning: In the ZenlessZoneZero-OneDragon repository (Python), do NOT mark documentation-only files (README.md, .md files, YAML data files without code logic) as "Critical" severity. Documentation inconsistencies should be rated at most "minor" or "nitpick". "Critical" severity is reserved for issues with potential security vulnerabilities, data corruption, or runtime crashes in actual code.
Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
| def _on_delete_clicked(self) -> None: | ||
| """删除选中行""" | ||
| current_page = self.mode_stacked.currentWidget() | ||
| if current_page is not None: | ||
| table_widget = current_page.findChild(TableWidget) | ||
| if table_widget is not None: | ||
| selected_rows = set() | ||
| for item in table_widget.selectedItems(): | ||
| selected_rows.add(item.row()) | ||
|
|
||
| for row_idx in sorted(selected_rows, reverse=True): | ||
| table_widget.removeRow(row_idx) |
There was a problem hiding this comment.
代理人页面的删除按钮会删错对象。
在代理人页里 findChild(TableWidget) 只会拿到基础信息表或权重表,当前逻辑删除的是表格行,不会删除 self.agent_data 中的代理人,也不会更新搜索选项;用户点“删除”后可能只是把字段/权重行从界面移除了。建议对 self.agent_page 单独处理,删除当前选中的代理人数据并刷新搜索/详情区域。
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/zzz_od/gui/view/devtools/intel_manage_interface.py` around lines 982 -
993, The delete handler _on_delete_clicked currently finds a TableWidget via
mode_stacked.currentWidget().findChild(TableWidget) and only removes table rows
(removeRow), which for the agent page deletes fields/weights visually but never
mutates self.agent_data or refreshes search/detail UI. Update _on_delete_clicked
to detect when current_page is self.agent_page (or contains an agent list
widget) and in that case collect selected agent IDs/indices, remove the
corresponding entries from self.agent_data, update any search options and the
details pane (trigger the same refresh method used elsewhere), and only fall
back to removing table rows for non-agent pages; reference mode_stacked,
agent_page, agent_data, TableWidget, and the UI refresh method to ensure state
and UI remain consistent.
- 新增 slot_Mapping.json 用于属性映射管理 - 优化代理人权重配置逻辑,支持根据伤害类型动态显示属性 - 重构权重配置对话框,支持从配置文件加载权重选项 - 修复代理人数据保存时的合并逻辑问题 - 更新代理人 YAML 文件结构,添加权重配置 - 简化伤害类型枚举值显示 - 优化日志记录方式,使用全局 log 工具
There was a problem hiding this comment.
Actionable comments posted: 4
♻️ Duplicate comments (1)
src/zzz_od/gui/view/devtools/intel_manage_interface.py (1)
1098-1109:⚠️ Potential issue | 🟠 Major代理人页面删除仍只删了子表格行。
在代理人页里
findChild(TableWidget)会拿到基础信息表或权重表,removeRow()不会删除self.agent_data中的代理人,也不会刷新搜索选项。请对current_page == self.agent_page单独处理,删除当前选中的代理人数据后刷新详情与搜索框。🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/zzz_od/gui/view/devtools/intel_manage_interface.py` around lines 1098 - 1109, The delete handler _on_delete_clicked currently only removes rows from the child TableWidget; when current_page == self.agent_page you must instead remove the corresponding entries from self.agent_data for each selected agent, update any agent-detail display (e.g. refresh_agent_detail or the method that populates the detail panel) and refresh the search options/dropdown (the method that repopulates the search box). Locate _on_delete_clicked, detect current_page is self.agent_page, map selected table rows to agent identifiers in self.agent_data, delete those entries from self.agent_data, then call the existing UI refresh methods that update the agent detail view and the search box so the UI reflects the removal.
🧹 Nitpick comments (1)
src/zzz_od/application/devtools/intel_manage/intel_manage_app.py (1)
2-2: 按项目约定改用内置泛型并补齐方法类型。新增文件里还在使用
typing.Dict,且__init__/_get_enum_mapping()的签名没有完整类型标注;建议统一为 Python 3.11+ 的内置泛型写法。♻️ 建议修正
from pathlib import Path -from typing import Dict @@ - def __init__(self, ctx: ZContext): + def __init__(self, ctx: ZContext) -> None: @@ - self.agent_data: Dict[str, dict] = {} + self.agent_data: dict[str, dict] = {} @@ - def load_agent_data(self) -> Dict[str, dict]: + def load_agent_data(self) -> dict[str, dict]: @@ - def _get_enum_mapping(self, enum_class) -> Dict[str, str]: + def _get_enum_mapping(self, enum_class: type[AgentTypeEnum] | type[DmgTypeEnum]) -> dict[str, str]: @@ - def get_agent_type_mapping(self) -> Dict[str, str]: + def get_agent_type_mapping(self) -> dict[str, str]: @@ - def get_dmg_type_mapping(self) -> Dict[str, str]: + def get_dmg_type_mapping(self) -> dict[str, str]:As per coding guidelines,
**: 使用内置泛型类型(list,dict)而不是从typing模块导入的类型(List,Dict)。Also applies to: 16-32, 118-128
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/zzz_od/application/devtools/intel_manage/intel_manage_app.py` at line 2, Replace the typing.Dict import with Python 3.11+ built-in generics (use dict) and add precise type annotations to the class initializer and enum helper: update the signatures of __init__ and _get_enum_mapping in intel_manage_app.py to use built-in dict and other concrete types (e.g., dict[str, Any], list[str] or enum types as appropriate) so they are fully typed; ensure all occurrences noted (around lines 16–32 and 118–128) follow the same pattern and remove the unused typing.Dict import.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/zzz_od/application/devtools/intel_manage/intel_manage_app.py`:
- Around line 107-110: 当前在将 agent_data 写入 YAML(通过 YamlOperator(str(file_path));
yaml_op.data = agent_data; yaml_op.save())前没有移除 UI 派生字段,导致像 agent_type_cn /
dmg_type_cn 留在文件中并可能与 dmg_type 不一致;在保存前(在相同代码块里,使用 YamlOperator
之前)删除这些展示专用字段(至少移除 "agent_type_cn" 和 "dmg_type_cn",以及任何以 "_cn" 结尾或其他 UI-only
键),确保只将真实持久化字段写入 YAML,从 load_agent_data 返回的 agent_data 中清理后再调用 yaml_op.save()。
In `@src/zzz_od/gui/view/devtools/intel_manage_interface.py`:
- Around line 221-230: When loading character_weight.json into data, don't
swallow all exceptions and then continue to overwrite the file; instead catch
specific errors from json.load (e.g., json.JSONDecodeError and OSError), log the
error, and abort the save so existing weights aren't erased. In the block that
opens weight_file (referencing weight_file,
get_resource_path('config','character_weight.json'), data, self.character_name,
self.weight_values), replace the broad except Exception: pass with targeted
exception handling that logs the failure to read/parse the file and
returns/raises to prevent writing data[self.character_name] = self.weight_values
when the existing file could not be read.
- Around line 1208-1264: Validate weight entries and preserve/merge old weights
and update the index if the agent name changed: when parsing weights in the
weight_table, if any value fails float() collect that row and show an error (and
abort save) instead of silently passing; merge parsed weight_data into the
existing weights from self.agent_data[agent_name].get('weight', {}) rather than
unconditionally overwriting (assign merged weights into
merged_agent_data['weight']); after collecting basic_info_table check for a
new_name = agent_data.get('agent_name', agent_name) and if new_name !=
agent_name remove the old key and insert merged_agent_data under the new_name so
the in-memory index and the save call use the updated agent name, then call
app.save_agent_data(new_name, merged_agent_data).
---
Duplicate comments:
In `@src/zzz_od/gui/view/devtools/intel_manage_interface.py`:
- Around line 1098-1109: The delete handler _on_delete_clicked currently only
removes rows from the child TableWidget; when current_page == self.agent_page
you must instead remove the corresponding entries from self.agent_data for each
selected agent, update any agent-detail display (e.g. refresh_agent_detail or
the method that populates the detail panel) and refresh the search
options/dropdown (the method that repopulates the search box). Locate
_on_delete_clicked, detect current_page is self.agent_page, map selected table
rows to agent identifiers in self.agent_data, delete those entries from
self.agent_data, then call the existing UI refresh methods that update the agent
detail view and the search box so the UI reflects the removal.
---
Nitpick comments:
In `@src/zzz_od/application/devtools/intel_manage/intel_manage_app.py`:
- Line 2: Replace the typing.Dict import with Python 3.11+ built-in generics
(use dict) and add precise type annotations to the class initializer and enum
helper: update the signatures of __init__ and _get_enum_mapping in
intel_manage_app.py to use built-in dict and other concrete types (e.g.,
dict[str, Any], list[str] or enum types as appropriate) so they are fully typed;
ensure all occurrences noted (around lines 16–32 and 118–128) follow the same
pattern and remove the unused typing.Dict import.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: a320399e-df31-4917-aa30-9681123b4cc6
📒 Files selected for processing (13)
assets/game_data/agent/_README.mdassets/game_data/agent/corin.ymlassets/game_data/agent/nicole.ymlassets/game_data/agent/rina.ymlassets/game_data/agent/soldier_11.ymlassets/game_data/drive_disk/free_jazz.ymlsrc/zzz_od/application/devtools/intel_manage/intel_manage_app.pysrc/zzz_od/application/devtools/intel_manage/intel_manage_config.pysrc/zzz_od/application/devtools/intel_manage/intel_manage_const.pysrc/zzz_od/game_data/agent.pysrc/zzz_od/game_data/slot_Mapping.jsonsrc/zzz_od/gui/view/devtools/app_devtools_interface.pysrc/zzz_od/gui/view/devtools/intel_manage_interface.py
✅ Files skipped from review due to trivial changes (4)
- assets/game_data/drive_disk/free_jazz.yml
- src/zzz_od/game_data/slot_Mapping.json
- src/zzz_od/application/devtools/intel_manage/intel_manage_config.py
- src/zzz_od/application/devtools/intel_manage/intel_manage_const.py
🚧 Files skipped from review as they are similar to previous changes (6)
- src/zzz_od/gui/view/devtools/app_devtools_interface.py
- assets/game_data/agent/_README.md
- assets/game_data/agent/nicole.yml
- assets/game_data/agent/soldier_11.yml
- assets/game_data/agent/corin.yml
- assets/game_data/agent/rina.yml
| agent_name = self.search_combo.currentText() | ||
| if not agent_name or agent_name not in self.agent_data: | ||
| self.show_info_bar('提示', '请先选择一个代理人', icon=InfoBarIcon.WARNING) | ||
| return | ||
|
|
||
| # 读取基础信息表格数据(UI层职责:数据收集) | ||
| agent_data = {} | ||
|
|
||
| # 从下拉框获取角色类型、属性类型和稀有度(使用 currentData() 获取英文标识) | ||
| if hasattr(self, 'agent_type_combo'): | ||
| agent_data['agent_type'] = self.agent_type_combo.currentData() or '' | ||
| if hasattr(self, 'dmg_type_combo'): | ||
| agent_data['dmg_type'] = self.dmg_type_combo.currentData() or '' | ||
| if hasattr(self, 'rare_type_combo'): | ||
| agent_data['rare_type'] = self.rare_type_combo.currentData() or '' | ||
|
|
||
| # 从表格获取其他字段 | ||
| if self.basic_info_table.rowCount() > 0: | ||
| for row_idx in range(self.basic_info_table.rowCount()): | ||
| key_item = self.basic_info_table.item(row_idx, 0) | ||
| value_item = self.basic_info_table.item(row_idx, 1) | ||
| if key_item and value_item: | ||
| key = key_item.text() | ||
| value = value_item.text() | ||
| if key == '代理人名称': | ||
| agent_data['agent_name'] = value | ||
| elif key == 'code': | ||
| agent_data['code'] = value | ||
|
|
||
| # 读取权重配置表格数据 | ||
| weight_data = {} | ||
| if self.weight_table.rowCount() > 0: | ||
| for row_idx in range(self.weight_table.rowCount()): | ||
| attr_item = self.weight_table.item(row_idx, 0) | ||
| value_item = self.weight_table.item(row_idx, 1) | ||
| if attr_item and value_item: | ||
| attr_name = attr_item.text() | ||
| value = value_item.text() | ||
| if value and value != '未配置权重': | ||
| try: | ||
| weight_data[attr_name] = float(value) | ||
| except ValueError: | ||
| pass | ||
|
|
||
| if weight_data: | ||
| agent_data['weight'] = weight_data | ||
|
|
||
| # 更新内存中的代理人数据(合并完整数据) | ||
| merged_agent_data = dict(self.agent_data[agent_name]) | ||
| merged_agent_data.update(agent_data) | ||
| self.agent_data[agent_name] = merged_agent_data | ||
|
|
||
| # 调用 App 层保存数据(业务逻辑委托给 App 层) | ||
| app = self._get_intel_manage_app() | ||
| if app: | ||
| success = app.save_agent_data(agent_name, merged_agent_data) | ||
| if success: |
There was a problem hiding this comment.
保存前校验权重值,并按新代理人名更新索引。
现在非法权重值会被 pass 掉;随后 agent_data['weight'] = weight_data 会用缺项的新 dict 覆盖旧权重,导致该属性丢失。另外,如果用户修改了“代理人名称”,内存仍写在旧 key 下,save_agent_data(agent_name, ...) 也会用旧名称作为无 code 时的文件名兜底。
🐛 建议修正
# 读取权重配置表格数据
weight_data = {}
+ invalid_weight_attrs = []
if self.weight_table.rowCount() > 0:
for row_idx in range(self.weight_table.rowCount()):
attr_item = self.weight_table.item(row_idx, 0)
value_item = self.weight_table.item(row_idx, 1)
if attr_item and value_item:
@@
if value and value != '未配置权重':
try:
weight_data[attr_name] = float(value)
except ValueError:
- pass
+ invalid_weight_attrs.append(attr_name)
+
+ if invalid_weight_attrs:
+ self.show_info_bar(
+ '失败',
+ f'权重值格式错误: {", ".join(invalid_weight_attrs)}',
+ icon=InfoBarIcon.ERROR,
+ )
+ return
if weight_data:
agent_data['weight'] = weight_data
# 更新内存中的代理人数据(合并完整数据)
+ new_agent_name = agent_data.get('agent_name') or agent_name
merged_agent_data = dict(self.agent_data[agent_name])
merged_agent_data.update(agent_data)
- self.agent_data[agent_name] = merged_agent_data
+ if new_agent_name != agent_name:
+ self.agent_data.pop(agent_name, None)
+ self.agent_data[new_agent_name] = merged_agent_data
# 调用 App 层保存数据(业务逻辑委托给 App 层)
app = self._get_intel_manage_app()
if app:
- success = app.save_agent_data(agent_name, merged_agent_data)
+ success = app.save_agent_data(new_agent_name, merged_agent_data)
if success:
self.show_info_bar('成功', '代理人数据已保存', icon=InfoBarIcon.SUCCESS)
+ self._update_search_options()
+ self.search_combo.setCurrentText(new_agent_name)🧰 Tools
🪛 Ruff (0.15.10)
[warning] 1213-1213: Comment contains ambiguous ( (FULLWIDTH LEFT PARENTHESIS). Did you mean ( (LEFT PARENTHESIS)?
(RUF003)
[warning] 1213-1213: Comment contains ambiguous : (FULLWIDTH COLON). Did you mean : (COLON)?
(RUF003)
[warning] 1213-1213: Comment contains ambiguous ) (FULLWIDTH RIGHT PARENTHESIS). Did you mean ) (RIGHT PARENTHESIS)?
(RUF003)
[warning] 1216-1216: Comment contains ambiguous ( (FULLWIDTH LEFT PARENTHESIS). Did you mean ( (LEFT PARENTHESIS)?
(RUF003)
[warning] 1216-1216: Comment contains ambiguous ) (FULLWIDTH RIGHT PARENTHESIS). Did you mean ) (RIGHT PARENTHESIS)?
(RUF003)
[warning] 1255-1255: Comment contains ambiguous ( (FULLWIDTH LEFT PARENTHESIS). Did you mean ( (LEFT PARENTHESIS)?
(RUF003)
[warning] 1255-1255: Comment contains ambiguous ) (FULLWIDTH RIGHT PARENTHESIS). Did you mean ) (RIGHT PARENTHESIS)?
(RUF003)
[warning] 1260-1260: Comment contains ambiguous ( (FULLWIDTH LEFT PARENTHESIS). Did you mean ( (LEFT PARENTHESIS)?
(RUF003)
[warning] 1260-1260: Comment contains ambiguous ) (FULLWIDTH RIGHT PARENTHESIS). Did you mean ) (RIGHT PARENTHESIS)?
(RUF003)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/zzz_od/gui/view/devtools/intel_manage_interface.py` around lines 1208 -
1264, Validate weight entries and preserve/merge old weights and update the
index if the agent name changed: when parsing weights in the weight_table, if
any value fails float() collect that row and show an error (and abort save)
instead of silently passing; merge parsed weight_data into the existing weights
from self.agent_data[agent_name].get('weight', {}) rather than unconditionally
overwriting (assign merged weights into merged_agent_data['weight']); after
collecting basic_info_table check for a new_name = agent_data.get('agent_name',
agent_name) and if new_name != agent_name remove the old key and insert
merged_agent_data under the new_name so the in-memory index and the save call
use the updated agent name, then call app.save_agent_data(new_name,
merged_agent_data).
refactor: 重构信息管理应用工厂类
feat(devtools): 重构权重公式配置界面为表格形式,优化布局和交互
修复在循环中绑定信号时使用 lambda 导致的变量捕获问题,改用 functools.partial 确保正确捕获当前行和列的值
|
这个PR较大, 请添加自测运行结果。 |
refactor(数据管理): 重构权重表格逻辑,简化下拉框去重机制 feat(数据管理): 添加驱动盘和音擎数据加载功能 style(数据管理): 移除未使用的按钮和冗余代码
- 实现权重配置的原子写入机制,避免并发风险 - 添加数据缓存功能,减少重复加载开销 - 新增合并配置文件功能,支持从分离文件更新 - 重构应用层代码,引入数据封装类和线程安全机制 - 优化文件操作,使用临时文件进行原子替换
重构代理数据文件,移除冗余的中文字段(agent_type_cn/dmg_type_cn),统一使用枚举管理。新增drive_disk模块集中管理权重槽位类型配置,优化权重计算逻辑。重构intel_manage_config为更清晰的配置类结构,改进合并文件保存机制确保数据一致性。 重构代理界面权重计算逻辑,使用集中配置管理权重项顺序和属性映射。优化代理数据保存流程,确保派生字段不持久化。改进合并文件处理逻辑,增加空文件检查和分离文件回退机制。

当前功能正常运行,可投入测试检查
Summary by CodeRabbit