Skip to content

fix(SellProduct): 修复设置优先售卖柑实罐头会选择优质柑实罐头导致卖不了柑实罐头的问题#1790

Merged
MistEO merged 4 commits intov2from
fix/sell-product-item
Mar 31, 2026
Merged

fix(SellProduct): 修复设置优先售卖柑实罐头会选择优质柑实罐头导致卖不了柑实罐头的问题#1790
MistEO merged 4 commits intov2from
fix/sell-product-item

Conversation

@he0119
Copy link
Copy Markdown
Contributor

@he0119 he0119 commented Mar 31, 2026

同时修复据点内优先物品列表不正确的问题。

不过还需要等 Joe-Bao/MAA-pipeline-generate#1 实现才能直接生成 task 文件。

fixed #1793

Summary by Sourcery

修复 SellProduct 任务的物品选择逻辑,使用自动生成的物品/前哨站配置,并添加用于自动任务生成的支持数据和工具。

新功能:

  • 引入基于定居点贸易前哨站数据的数据驱动 SellProduct 配置生成器。

缺陷修复:

  • 修正 SellProduct 物品选择逻辑,使罐头食品和其他前哨站商品能够映射到预期的变体,并能在各定居点正确出售。

优化改进:

  • 新增结构化的物品元数据与定居点映射层,用于在不同繁荣等级间统一 SellProduct 配置。

文档:

  • tools/pipeline-generate/SellProduct 目录下新增 README,记录 SellProduct 管线生成工具的使用方法及其数据来源。

日常维护:

  • 提交 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:

  • Introduce a data-driven SellProduct configuration generator based on settlement trade outpost data.

Bug Fixes:

  • Correct SellProduct item selection so canned goods and other outpost items map to the intended variants and can be sold correctly at each settlement.

Enhancements:

  • Add a structured item metadata and settlement mapping layer to unify SellProduct configuration across prosperity levels.

Documentation:

  • Document the SellProduct pipeline-generate usage and data source in a new README under tools/pipeline-generate/SellProduct.

Chores:

  • Check in source data, config, and template files required by the SellProduct pipeline generation tooling.

Copilot AI review requested due to automatic review settings March 31, 2026 13:44
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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

Hey - I've left some high level feedback:

  • 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.
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.

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.

@he0119 he0119 requested a review from Joe-Bao March 31, 2026 13:45
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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}$`,
],
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里把物品名称直接拼到正则里(^${item.name.*}$),但英文名里包含 [ ](如 "Buck Capsule [A]"、"Canned Citrome [B]"),在正则语义下会被当作字符类而不是字面量方括号,导致 OCR 匹配失败或误匹配。建议在生成 expected 前对名称做正则转义(至少转义 [](){}.*+?^$|\\ 等元字符),或不要用锚点/正则而改为生成字面量匹配模式。

Copilot uses AI. Check for mistakes.
@MistEO MistEO merged commit 293aac2 into v2 Mar 31, 2026
18 checks passed
@MistEO MistEO deleted the fix/sell-product-item branch March 31, 2026 15:54
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.

售卖产品的识别问题

3 participants