feat: make items consumable #73
No reviewers
Labels
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Blocks
Reference
Athemis/ds4!73
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feature/consume-items"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR makes items consumable.
Fixes #51
503244eb695dcfd7ec135dcfd7ec1397de41c15f035de17343597764ab3bReview summary
usable+consumedOnUse+uses+consumeEffect) incl. UI + chat feedback.expireOnCombatEnd).pnpm format:check,pnpm lint,pnpm test✅Blockers
Major
For future work, consider splitting into 2–3 PRs to make review and bisecting easier.
I’d suggest adding 2–3 sentences to the PR description/docs clarifying:
floorwhen converting remaining seconds to rounds).Minor / nit
src/apps/actor/base-sheet.js: the consume flow is now quite large; long-term it might be worth extracting into a helper (e.g.src/utils/consume.ts) to keep the sheet lean.roll/heal/damageconsume effects, an empty formula currently results in “no effect” (sincehasEffectdepends onformula). That’s fine, but a small UI warning could prevent confusion whentypeis set butformulais empty.Questions
expireOnCombatEndmeant to apply only to consume item effects, or more broadly to actor effects in general? (It’s currently wired viaflags.ds4.consumeEffect.)quantity=0anduses.spent=usesMax(not0). Is that intentional as an “empty/depleted” signal? Looks consistent, just confirming.Suggested tests
uses.max=3,quantity=2,consumedOnUse=true: consume repeatedly → uses decrements, when uses reach max then qty-- and uses reset; final unit ends at qty=0 / depleted.durationFormula(rounds/seconds) +expireOnCombatEnd=true: apply effect → start combat → end combat → verify expire/reconversion behavior.Areas reviewed
src/apps/actor/base-sheet.js(consume flow + target prompt + ActiveEffect application)src/hooks/pre-update-item.js(prevent qty=0 while uses remain)src/hooks/effect-expiry.js(queue + combat reconciliation)spec/hooks/effect-expiry.spec.ts,spec/hooks/pre-update-item.spec.ts(test coverage)WIP: feat: make items consumableto feat: make items consumable@claw-bot review
Ack — ich schaue mir das an.
Quick review (claw-bot)
✅ CI: Success (ci/woodpecker/pr/checks)
Highlights
Nits / things to double-check
Overall: LGTM for merge; main risk area is the expiry engine complexity, but tests + GM-only gating help.
Full review (claw-bot)
✅ CI: Success (ci/woodpecker/pr/checks)
Overall
Highlights
src/apps/actor/consume-flow.js)src/hooks/effect-expiry.js)Issues / suggestions
src/utils/enrich-description.jsforcessecrets: false.secrets: this.item.isOwner(so owners could see secret blocks). With the new helper, owners will no longer see them.Suggestion: make
enrichItemDescription(item, { secrets })configurable, or default tosecrets: item.isOwner.{{item.usesRemaining}}(computed in_prepareContext).data-data-path="system.usesRemaining".Unless
system.usesRemainingexists, sorting by remaining uses won’t work.Suggestion: either
usesRemaining, ORitem.system.usesRemainingfor display-only sorting.item.system?.uses?.labelis interpolated into HTML without escaping in the chat message.Suggestion: wrap with
foundry.utils.escapeHTML(...).buildSecondsToRoundsUpdateusesMath.floor(secondsRemaining / roundTime)and setsturns=1when rounds=0.This is probably fine (avoids giving extra time), but it can shorten effects near boundaries.
Suggestion: confirm expected semantics for “< 1 round remaining” and add/adjust a test if needed.
rollable-image.hbsoverlay alt text remains “dice overlay” even when using the hand icon.Suggestion: allow passing overlayAlt (optional).
src/hooks/init.jssetsCONFIG.time.roundTime = 5.If DS4 intends 5s rounds: great. If not, this will affect any time/round conversions across the system.
Suggested test scenarios (manual)
uses.max=3,quantity=2,consumedOnUse=true: consume repeatedly → uses decrement, then qty-- and uses reset; last unit ends at qty=0/spent=max.Verdict
Addendum (claw-bot)
One additional critical issue found by the subagent:
⚠️ High: Consume formula rolls have no roll data
src/apps/actor/consume-flow.js:new Roll(resolvedFormula)and duration formula roll are evaluated without actor/item roll data.@-references (e.g.,@abilities.str.value,@item.level) will not resolve correctly.Suggestion:
Same applies to the durationFormula evaluation when applying ActiveEffects.
d1b77c89949838b39accView command line instructions
Checkout
From your project repository, check out a new branch and test the changes.