Skip to content

[#6708] Add makeChange option to getActorCurrencyUpdates#6762

Merged
Fyorl merged 4 commits into
foundryvtt:5.3.xfrom
Sayshal:make-change
Feb 26, 2026
Merged

[#6708] Add makeChange option to getActorCurrencyUpdates#6762
Fyorl merged 4 commits into
foundryvtt:5.3.xfrom
Sayshal:make-change

Conversation

@Sayshal

@Sayshal Sayshal commented Feb 25, 2026

Copy link
Copy Markdown
Contributor
  • Break higher-denomination coins when the target denomination is unavailable
  • Respects existing priority parameter for coin selection order

Closes #6708


// Test 1: GP-only actor, deduct CP**
// Actor: { pp: 0, gp: 100, ep: 0, sp: 0, cp: 0 }

const result = dnd5e.applications.CurrencyManager.getActorCurrencyUpdates(actor, 20, "cp", { makeChange: true });
// Result: remainder=0, gp=99, cp=80

// Test 2: PP-only actor, deduct SP
// Actor: { pp: 5, gp: 0, ep: 0, sp: 0, cp: 0 }

const result = dnd5e.applications.CurrencyManager.getActorCurrencyUpdates(actor, 30, "sp", { makeChange: true });
// Result: remainder=0, pp=4, sp=70

// Test 3: Without makeChange (unchanged behavior)
// Actor: { pp: 0, gp: 100, ep: 0, sp: 0, cp: 0 }

const result = dnd5e.applications.CurrencyManager.getActorCurrencyUpdates(actor, 20, "cp");
// Result: remainder=20, no coins changed

- Break higher-denomination coins when the target denomination is unavailable
- Respects existing `priority` parameter for coin selection order

Closes foundryvtt#6708
@arbron arbron added the api label Feb 25, 2026
@Sayshal Sayshal changed the title Add makeChange option to getActorCurrencyUpdates [#6708] Add makeChange option to getActorCurrencyUpdates Feb 25, 2026
Comment thread module/applications/currency-manager.mjs Outdated
Comment thread module/applications/currency-manager.mjs Outdated
- Extract `CurrencyUpdateOption`s typedef to `_types.mjs`
- Replace inline option JSDoc with typedef on both `deductActorCurrency` and `getActorCurrencyUpdates`
- Default `makeChange` to true
@Sayshal
Sayshal requested a review from arbron February 25, 2026 19:21
Comment thread module/applications/_types.mjs
Comment thread module/applications/currency-manager.mjs Outdated
Sayshal and others added 2 commits February 25, 2026 13:20
@Sayshal
Sayshal requested a review from Fyorl February 25, 2026 20:24

@Fyorl Fyorl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Don't feel strongly about whether this should be breaking or not. Means we don't need any code change for bastion deduction at least.

@Fyorl Fyorl added the breaking Breaking changes label Feb 25, 2026
@Fyorl Fyorl added this to the D&D5E 5.3.0 milestone Feb 25, 2026
@Fyorl
Fyorl merged commit 474348c into foundryvtt:5.3.x Feb 26, 2026
@Sayshal
Sayshal deleted the make-change branch March 1, 2026 02:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api breaking Breaking changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add makeChange option to getActorCurrencyUpdates

3 participants