fix(RichMan): handle sold-out medal shop items gracefully - #1799
Conversation
- add sold-out OCR detection to count 'sold out' labels in medal shop page - buy item only when its card template is detected; record undetected items - after processing, verify undetected items are all sold out via OCR count, so a fully/partially sold-out shop finishes normally instead of hitting GameStuckError from blindly clicking back button - add timeout guard to enter-medal click and back_mall to avoid infinite loops
There was a problem hiding this comment.
您好——我发现了 1 个问题
给 AI Agent 的提示
请处理本次代码审查中的评论:
## 单条评论
### 评论 1
<location path="tasks/RichMan/mall/medal.py" line_range="100-101" />
<code_context>
+ # 注意:页面上的售罄标签可能包含未配置购买的商品,因此用 >= 而非 ==,避免误报。
+ if not_found:
+ self.screenshot()
+ soldout_count = self.count_soldout()
+ if soldout_count >= len(not_found):
+ logger.info(f'Medal: {len(not_found)} item(s) not detected, sold out count is {soldout_count}, '\
+ f'the not-detected items are sold out, skip normally')
</code_context>
<issue_to_address>
**issue (bug_risk):** 聚合 OCR 计数无法验证具体未检测到的已配置商品是否确实已售罄。如果页面异常导致某个模板识别失败,但另一个未配置的商品已售罄,或者本次运行中较早购买的商品在最终计数前变为售罄,那么 `soldout_count >= len(not_found)` 就会错误地将缺失的已配置商品判定为正常,并跳过异常页面处理。
**触发条件:** 至少有一个已配置商品未被检测到,且商店中存在另一个售罄标签,包括本次运行中成功购买后产生的标签。
**建议修复:** 将 OCR 识别出的售罄标签与对应的商品卡片区域关联起来,或者在购买前获取售罄状态快照,并将每个未检测到的商品与其自身区域进行比较。
</issue_to_address>Sourcery 评估
等待批准。 请先处理 1 个发现的问题。
阻塞性发现:tasks/RichMan/mall/medal.py:101
Original comment in English
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="tasks/RichMan/mall/medal.py" line_range="100-101" />
<code_context>
+ # 注意:页面上的售罄标签可能包含未配置购买的商品,因此用 >= 而非 ==,避免误报。
+ if not_found:
+ self.screenshot()
+ soldout_count = self.count_soldout()
+ if soldout_count >= len(not_found):
+ logger.info(f'Medal: {len(not_found)} item(s) not detected, sold out count is {soldout_count}, '
+ f'the not-detected items are sold out, skip normally')
</code_context>
<issue_to_address>
**issue (bug_risk):** The aggregate OCR count does not verify that the specific not-detected configured items are sold out. A template can fail for an abnormal page while another unconfigured item is sold out, or an item bought earlier in the same run can become sold out before this final count; `soldout_count >= len(not_found)` then incorrectly classifies the missing configured item(s) as normal and skips abnormal-page handling.
**Triggers:** When at least one configured item is not detected and the shop contains another sold-out label, including a label created by a successful purchase earlier in this run.
**Suggested fix:** Associate OCR sold-out labels with the corresponding item card regions, or take the sold-out snapshot before purchases and compare each not-detected item against its own region.
</issue_to_address>Sourcery assessment
Approval pending. 1 finding to address first.
Blocking findings: tasks/RichMan/mall/medal.py:101
Findings
Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
To allow these domains, add them to the network:
allowed:
- defaults
- "ab.chatgpt.com"See Network Configuration for more information.
|
Change Summary
Reconstructed Intent点击此处展开- 这次改动最可能是为了把“商品已售罄导致模板消失”从页面异常处理为可接受的正常分支,避免继续错误导航并触发游戏重启。 - 同时希望在页面确实异常或 UI 无响应时,避免无限点击循环。Observed Constraints点击此处展开- 每个配置商品的模板识别失败只能说明“未识别到”,不能单独证明“该商品售罄”。 - `O_SOLD_OUT` 覆盖的是整个商品区域,最终只比较总数;它没有把 OCR 结果绑定到具体商品卡片。 - 购买流程会按配置顺序执行,成功购买的商品可能在最终 OCR 前改变页面状态,因此最终计数并非购买前的状态快照。 - `_enter_medal()` 与 `back_mall()` 的超时返回值在调用方没有被检查;超时后流程仍会继续执行后续购买或整体退出流程。Intent Alignment
Release Risk
Validation Gaps点击此处展开- 未看到针对“具体卡片售罄 vs 其他卡片售罄”的隔离验证;至少应覆盖未配置商品售罄、已购买商品变售罄、模板异常缺失三种组合。 - 未看到 `_enter_medal` / `back_mall` 超时返回 `False` 后的流程验证,需明确是否应中止当前商城任务并回退/报错。 - PR 描述提到 py_compile、导入和 OCR 截图验证,但未看到自动化测试或导航异常场景的可重复验证记录。Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
To allow these domains, add them to the network:
allowed:
- defaults
- "ab.chatgpt.com"See Network Configuration for more information.
|
|
关于 C5(O_SOLD_OUT 未同步 ocr.json):这条是误报,无需修改。 核实依据:
结论:O_SOLD_OUT 不需要在 ocr.json 中注册,当前 PR 无需为此修改。另补充说明合并策略:本 PR base 为 dev 分支,建议先在 dev 长期测试、确认稳定后再合入 master。 |
|
“# 售罄 OCR:统计勋章商店页面中"售"字(售罄标签)数量,用于核对识别失败的商品是否均为售罄 |
Problem
When items in the medal shop are sold out, their card templates no longer match (sold-out labels / greyed out), so all configured items fail detection. The script then blindly clicks the back button from the main screen and triggers GameStuckError -> game restart. Reproduced twice with identical stack (RichMan medal shop).
Root cause: no sold-out recognition; sold out (normal state) is treated as not found (abnormal), then wrong exit flow is taken.
Fix
Verification
Sourcery 总结
妥善处理奖牌商店中已售罄的商品,并在界面无响应时保护商店导航流程。
错误修复:
功能增强:
Original summary in English
Sourcery 摘要
优雅地处理奖牌商店中的售罄商品,防止商店导航无响应而陷入无限交互循环。
错误修复:
功能增强:
Original summary in English
Sourcery 总结
妥善处理奖牌商店中已售罄的商品,防止无响应的商店导航无限期停滞。
错误修复:
功能增强:
Original summary in English
Summary by Sourcery
Handle sold-out medal shop items gracefully and prevent unresponsive shop navigation from stalling indefinitely.
Bug Fixes:
Enhancements: