Skip to content

把「消耗热量」的判定从 fitness_band 物品 id 改成 CALORIES_SPENT 旗标 - #1252

Merged
WhiteCloud0123 merged 1 commit into
BreezeDevTeam:mainfrom
nightshame:feat/calories-spent-flag
Oct 30, 2026
Merged

WhiteCloud0123 merged 1 commit into
BreezeDevTeam:mainfrom
nightshame:feat/calories-spent-flag

Conversation

@nightshame

@nightshame nightshame commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

这个 PR 做什么

把 E(eat/consume)菜单顶部「消耗:今日/昨日 X kcal」的判定,从写死的物品 id fitness_band 改成物品旗标 CALORIES_SPENT,让模组自制的追踪器/手环也能显示这一行。

修复 #1249

改动

文件 改动
src/game_inventory.cpp 新增 json_flag_CALORIES_SPENT;has_fitness_band(you.is_wearing( itype_fitness_band ))改为 has_calories_spent_tracker(you.worn_with_flag( json_flag_CALORIES_SPENT ));删掉因此不再使用的 itype_fitness_band 声明
data/json/flags.json 新增 CALORIES_SPENT 的 json_flag 定义
data/json/items/tool_armor.json fitness_band 的 flags 加上 CALORIES_SPENT

语义等价:Character::is_wearing(itype_id) 走 worn.is_worn(),worn_with_flag(flag_id) 走 outfit::worn_with_flag(),两者都只看穿在身上的物品(不看背包/手持),所以原版手环表现不变。

效果

  • 原版 fitness_band:行为不变,「消耗」行照常显示。
  • 模组:copy-from fitness_band 的追踪器自动继承该旗标;自建物品只要加 "CALORIES_SPENT",穿戴后 E 菜单就显示「消耗」行,不必再覆盖原版 id。
  • 智能手机等只有 CALORIES_INTAKE 的物品不受影响(仍只有精确摄入数值,没有「消耗」行)。

备选方案

如果更希望不新增旗标、直接复用 CALORIES_INTAKE,把 json_flag_CALORIES_SPENT 换成 json_flag_CALORIES_INTAKE 即可(一行),代价是拿着智能手机也会多出「消耗」行。这里按 issue 描述的最小改动方案实现。

验证情况

  • 本地没有构建环境,未编译、未实机,请以 CI 编译与实机为准。
  • 实机验收步骤:
    1. 穿原版 fitness_band → E 菜单显示「消耗」行(回归);
    2. 穿带 CALORIES_SPENT 的模组手表 → 显示「消耗」行(新能力);
    3. 只带智能手机(CALORIES_INTAKE)→ 不显示「消耗」行。
  • 未加单元测试:该路径是 UI 文案拼接,没有可断言的逻辑分支;如需要,可另补一条 worn_with_flag 的数据层测试。

Summary by CodeRabbit

  • New Features
    • Calorie-spending tracking is now supported by wearable items with the appropriate flag, rather than being limited to fitness bands.
    • Calorie totals show “Spent” when a qualifying wearable is equipped.

fitness_band 的「消耗」行原来写死在 itype_fitness_band 上,模组自制的追踪器无法显示。
改为 worn_with_flag( CALORIES_SPENT ),并在 flags.json 注册旗标、给 fitness_band 补上该旗标。

修复 BreezeDevTeam#1249
@github-actions

Copy link
Copy Markdown
Contributor

🤖 微风自动审查

本次 PR 共修改 3 个文件,新增 11 行,删除 6 行。

变更范围: C++ 核心代码、本体游戏数据

自动风险提示:

  • ⚠️ 同时修改核心代码和游戏数据,建议确认 JSON 数据与代码接口、ID 和默认值保持一致。
  • ⚠️ 修改了 C++ 核心代码但没有同步修改 tests/,建议确认现有测试是否已经覆盖本次行为变化。
  • ⚠️ 修改了地图生成、世界地图、NPC、物品或 EOC 数据,建议重点确认 JSON 加载和既有存档兼容。

建议测试内容:

  • 快速检查: 检查补丁空白、变更 JSON/Python/XML/Visual Studio 项目文件、未解决合并标记,以及内置穆尔卡武器工坊关键路径。
  • Windows Tiles x64 MSVC: 编译翻译,执行完整 Release x64 MSVC 构建和 windist 打包,并验证 Windows 构件中的内置武器工坊。
  • Windows 数据加载烟雾测试: 运行打包后的 cataclysm-tiles.exe --jsonverify,确认可执行文件能够真正启动并完成核心游戏数据加载;Windows 构件会先上传,烟雾测试失败时仍可下载人工排查。
  • Android Gradle 快速检查: 使用 JDK 11 解析 Gradle 配置和依赖,提前发现 Android 构建环境或脚本问题。
  • Android arm64: 编译翻译和 arm64 Release APK,并保留 APK 构件供设备实测。

这是规则型自动审查,会依据本次 PR 的实际变更范围生成风险提示和测试建议,不假定 PR 的来源或用途,也不替代人工代码审查。每次推送后会自动更新这条摘要。

@coderabbitai

coderabbitai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Walkthrough

Calorie-spending tracking now uses the CALORIES_SPENT flag on worn items. The fitness band has this flag. Inventory hints continue to detect calorie intake through CALORIES_INTAKE on carried items.

Changes: Calorie Tracking

Layer / File(s) Summary
Register the spending flag
data/json/flags.json, data/json/items/tool_armor.json
The flag registry defines CALORIES_SPENT, and the fitness band includes it.
Detect calorie tracking in inventory
src/game_inventory.cpp
The inventory hint checks worn items for CALORIES_SPENT and carried items for CALORIES_INTAKE. It displays spending totals when a worn item has CALORIES_SPENT.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related issues

  • Issue 1249 — Changes the spending-row check from the fitness_band item ID to the CALORIES_SPENT flag on worn items, matching this change.
Merge Risk: Minimal · up to b1958

The flag registration, fitness-band configuration, and worn-item lookup are consistent, with intake tracking remaining independent.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed 标题准确概括了主要变更:将“消耗热量”的判定从固定的 fitness_band 物品 ID 改为 CALORIES_SPENT 旗标。
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 1 files. (2 skipped: 2 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

Cppcheck (2.22.0)
src/game_inventory.cpp

Cppcheck timed out; analysis of this file is incomplete

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@WhiteCloud0123
WhiteCloud0123 merged commit d07a263 into BreezeDevTeam:main Oct 30, 2026
6 checks passed
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