Skip to content

fix: 关闭同类型宝藏限制后同步扫描结果到 profiles.json - #194

Closed
yuelu-lan wants to merge 1 commit into
Logical-Byte:devfrom
yuelu-lan:fix/sync-treasure-matrix-when-limit-disabled
Closed

fix: 关闭同类型宝藏限制后同步扫描结果到 profiles.json#194
yuelu-lan wants to merge 1 commit into
Logical-Byte:devfrom
yuelu-lan:fix/sync-treasure-matrix-when-limit-disabled

Conversation

@yuelu-lan

@yuelu-lan yuelu-lan commented Aug 1, 2026

Copy link
Copy Markdown

修复内容

关闭「同类型宝藏限制」功能(same_type_treasure_limit_enabled 设为 false)后,扫描基质不会更新 profiles.json 中的宝藏基质配置。

关联 Issue: #195

根因

_apply_same_type_treasure_limit() 在限制关闭时直接返回,只将武器 ID 加入 _updated_this_scan,但未同步等级数据到 _same_type_best_levels。引擎的同步循环读取到 None 等级,导致 _weapon_essence_levels 为空,_on_scan_complete 发现 0 把武器后不会调用 _sync_to_treasure_matrix(),最终 profiles.json 未更新。

修改

  • 限制关闭时也更新 _same_type_best_levels[weapon_id],使用 _level_cmp 对比保留最高等级
  • 同时累计 _same_type_treasure_counts[weapon_id]

测试

新增两个测试用例验证:

  1. 限制关闭时 _same_type_best_levels_same_type_treasure_counts 正确更新
  2. 同一武器多次扫描时保留最高等级
335 passed, 1 skipped

…is disabled

When same_type_treasure_limit_enabled is False, the
_apply_same_type_treasure_limit() function returned early without
populating _same_type_best_levels, causing the engine's sync loop to
receive None levels. This left _weapon_essence_levels empty, so
_on_scan_complete found 0 weapons and never called
_sync_to_treasure_matrix(), meaning profiles.json was never updated.

Now also updates _same_type_best_levels (with _level_cmp comparison to
keep the highest) and _same_type_treasure_counts when limit is disabled.

Co-Authored-By: Claude <noreply@anthropic.com>
@yuelu-lan yuelu-lan changed the title fix: sync scanned weapon levels to profiles.json when treasure limit is disabled fix: 关闭同类型宝藏限制后同步扫描结果到 profiles.json Aug 1, 2026
@jiubook

jiubook commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

感谢pr,但我准备先关了

理由:根因分析是对的、测试也是对的,但"全量写入"违背单武器分配语义,会导致profiles污染,改动后续会合入 #191

如果想接着讨论可以继续在 issue #195

jiubook added a commit to jiubook/EER-Ai that referenced this pull request Aug 7, 2026
修复 issue Logical-Byte#195:关闭「同类型宝藏数量上限」后,扫描结果不再同步到
profiles.json。

根因:限制关闭时 _apply_same_type_treasure_limit 提前返回,只把匹配武器
加入 _updated_this_scan,但未写入 _same_type_best_levels,引擎同步循环
读到 None 等级,导致扫描后不落盘。原 PR Logical-Byte#194 的「全量写入」方案会为每把
匹配武器写入同一份数据,违背单武器分配语义,故改为复用按武器分配逻辑:

- _apply_same_type_treasure_limit 限制关闭时改走 _apply_weapon_group_limit
  (每把武器上限 1 枚),套用用户设置的非降级原则过滤与留大弃小
- 留大弃小仅应用留大(更优替换并同步落盘),不应用弃小:认领耗尽或非降级
  过滤后无可用武器时,通过新增的 exhausted_policy="keep" 保留原判定结果
  (不标记养成材料、不落盘),修复日志先报「养成材料」再改口「保留」的矛盾
- keep_best 关闭时无等级比较,按武器优先级首枚锁定

前端设置页同步调整:
- 非降级原则过滤、留大弃小、等级比较方式解除对「数量上限」总开关的禁用
  依赖(等级比较方式仍依赖留大弃小开关),使关闭限制时用户可预设这些规则
- 更新相关提示文案,说明关闭限制后的分配与落盘行为

新增 7 个测试用例覆盖:单武器认领、多武器按优先级分配、留大升级与更差
保留、首枚锁定、认领耗尽保留、非降级过滤拦截/通过。
@jiubook jiubook closed this Aug 7, 2026
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