fix(SellProduct): 修复设置优先售卖柑实罐头会选择优质柑实罐头导致卖不了柑实罐头的问题#1790
Merged
Conversation
Contributor
There was a problem hiding this comment.
Hey - 我给出了一些高层次的反馈:
- 当前的生成逻辑假设
SETTLEMENT_MAP中的所有settlementId键都一定存在于settlementData.settlements中;建议增加一个保护(或显式错误),这样当缺少某个 settlement 条目时,可以快速失败,而不是在执行Object.values(settlement.byProsperityLevel)时抛异常。 - 在构建
ITEMS.expected时,代码直接访问item.name.TC/CN/JP/EN;如果源 JSON 中缺少某个语言环境的字符串,就会生成^undefined$这样的匹配模式——可以加一个小的过滤或回退逻辑来跳过undefined的名称,从而让匹配更加健壮。
给 AI Agent 的提示
Please address the comments from this code review:
## Overall Comments
- The generation logic assumes all `settlementId` keys in `SETTLEMENT_MAP` exist in `settlementData.settlements`; consider adding a guard (or a clear error) so a missing settlement entry fails fast rather than throwing on `Object.values(settlement.byProsperityLevel)`.
- When assembling `ITEMS.expected`, the code directly accesses `item.name.TC/CN/JP/EN`; if any locale string is missing in the source JSON this will produce `^undefined$` patterns—adding a small filter or fallback to skip undefined names would make the matching more robust.帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续的评审。
Original comment in English
Hey - I've left some high level feedback:
- The generation logic assumes all
settlementIdkeys inSETTLEMENT_MAPexist insettlementData.settlements; consider adding a guard (or a clear error) so a missing settlement entry fails fast rather than throwing onObject.values(settlement.byProsperityLevel). - When assembling
ITEMS.expected, the code directly accessesitem.name.TC/CN/JP/EN; if any locale string is missing in the source JSON this will produce^undefined$patterns—adding a small filter or fallback to skip undefined names would make the matching more robust.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The generation logic assumes all `settlementId` keys in `SETTLEMENT_MAP` exist in `settlementData.settlements`; consider adding a guard (or a clear error) so a missing settlement entry fails fast rather than throwing on `Object.values(settlement.byProsperityLevel)`.
- When assembling `ITEMS.expected`, the code directly accesses `item.name.TC/CN/JP/EN`; if any locale string is missing in the source JSON this will produce `^undefined$` patterns—adding a small filter or fallback to skip undefined names would make the matching more robust.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Contributor
There was a problem hiding this comment.
Pull request overview
该 PR 旨在修复 SellProduct 任务中“设置优先售卖柑实罐头却会选到优质柑实罐头导致无法售卖”的配置错误,并补充/整理据点售卖物品数据与生成模板,方便后续通过 pipeline-generate 维护 SellProduct 的选项与物品列表。
Changes:
- 修正
assets/tasks/SellProduct.json中部分物品的名称/label/expected 对应关系,并新增武陵区域开关选项。 - 新增
tools/pipeline-generate/SellProduct/*:包含模板、数据构建脚本与据点交易数据源,用于自动生成/维护 SellProduct 配置。 - 将部分 OCR
expected由纯文本改为带^...$的模式(正则)。
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/pipeline-generate/SellProduct/template.jsonc | SellProduct 选项结构模板(售卖点开关、尝试开关、优先物品选择 1-4)。 |
| tools/pipeline-generate/SellProduct/settlement_trade_outposts.json | 据点交易物品数据源(含多语言名称)。 |
| tools/pipeline-generate/SellProduct/data.mjs | 基于数据源构建各据点可选物品列表与每个 select 的 cases(含 expected/label)。 |
| tools/pipeline-generate/SellProduct/config.json | pipeline-generate 配置(模板/数据/格式化/合并策略)。 |
| tools/pipeline-generate/SellProduct/README.md | 生成方式与数据来源致谢说明。 |
| assets/tasks/SellProduct.json | 修复 SellProduct 物品映射错误、补充武陵区域开关,并更新多处 expected。 |
Comment on lines
+45
to
+50
| expected: [ | ||
| `^${item.name.TC}$`, | ||
| `^${item.name.CN}$`, | ||
| `^${item.name.JP}$`, | ||
| `^${item.name.EN}$`, | ||
| ], |
There was a problem hiding this comment.
这里把物品名称直接拼到正则里(^${item.name.*}$),但英文名里包含 [ ](如 "Buck Capsule [A]"、"Canned Citrome [B]"),在正则语义下会被当作字符类而不是字面量方括号,导致 OCR 匹配失败或误匹配。建议在生成 expected 前对名称做正则转义(至少转义 [](){}.*+?^$|\\ 等元字符),或不要用锚点/正则而改为生成字面量匹配模式。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
同时修复据点内优先物品列表不正确的问题。
不过还需要等 Joe-Bao/MAA-pipeline-generate#1 实现才能直接生成 task 文件。
fixed #1793
Summary by Sourcery
修复 SellProduct 任务的物品选择逻辑,使用自动生成的物品/前哨站配置,并添加用于自动任务生成的支持数据和工具。
新功能:
缺陷修复:
优化改进:
文档:
tools/pipeline-generate/SellProduct目录下新增 README,记录 SellProduct 管线生成工具的使用方法及其数据来源。日常维护:
Original summary in English
Summary by Sourcery
Fix SellProduct task item selection using a generated item/outpost configuration and add supporting data and tooling for automatic task generation.
New Features:
Bug Fixes:
Enhancements:
Documentation:
Chores: