Skip to content

Comments

[#6627] Fix getActorCurrencyUpdates not working in some instances#6707

Open
arbron wants to merge 1 commit into5.3.xfrom
fix/6627
Open

[#6627] Fix getActorCurrencyUpdates not working in some instances#6707
arbron wants to merge 1 commit into5.3.xfrom
fix/6627

Conversation

@arbron
Copy link
Collaborator

@arbron arbron commented Feb 9, 2026

Modifies how getActorCurrencyUpdates works to now perform additional passes in an attempt to find the correct currency to deduce without resulting in a remainder. Previously, if you had a character with 100 gp, 5 sp, and 20 cp, and you asked to deduce 100 cp, it would return a remainder of 30 despite having enough currency to complete the request. This is because the loop would start at the lowest currency (100 - 20 = 80), then go to the next currency up (80 - (5 * 10) = 30), and then continue up through the denominations not finding any more that would be able to be deducted.

This change causes it to instead perform several loops over the list of currencies. If on the first pass ends with a remainder, then it will move the first entry in the currencies list to the end and re-perform the calculation. It will continue until it ends up with a remainder of 0 or has used each currency denomination as its first entry.

Closes #6627

Modifies how `getActorCurrencyUpdates` works to now perform
additional passes in an attempt to find the correct currency to
deduce without resulting in a remainder. Previously, if you had a
character with 100 gp, 5 sp, and 20 cp, and you asked to deduce
100 cp, it would return a remainder of 30 despite having enough
currency to complete the request. This is because the loop would
start at the lowest currency (100 - 20 = 80), then go to the next
currency up (80 - (5 * 10) = 30), and then continue up through the
denominations not finding any more that would be able to be
deducted.

This change causes it to instead perform several loops over the
list of currencies. If on the first pass ends with a remainder,
then it will move the first entry in the currencies list to the end
and re-perform the calculation. It will continue until it ends up
with a remainder of `0` or has used each currency denomination as
its first entry.

Closes #6627
@arbron arbron added this to the D&D5E 5.3.0 milestone Feb 9, 2026
@arbron arbron self-assigned this Feb 9, 2026
@arbron arbron added the api label Feb 9, 2026
@arbron arbron requested a review from Fyorl February 21, 2026 00:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

deductActorCurrency doesn't look at higher currencies

1 participant