Conversation
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
Fyorl
left a comment
There was a problem hiding this comment.
Not sure if this PR is intended to fix all or just some of the issues in #6627. It doesn't handle the the case of deducting 1gp from an actor with 1pp (Math.floor(1 * 0.1) = 0). We would need to generate change for that, and I'm not sure if this method is intending to do that.
This fix is focused on fixing the behavior that broke at some point in the past. I added another issue (#6708) to add a |
There was a problem hiding this comment.
This fix is focused on fixing the behavior that broke at some point in the past. I added another issue (#6708) to add a
makeChangeoption that would allow the system to go one step further.
Probably shouldn't be marked as closing #6627 then (and maybe #6627 should be a feature request, not bug), but otherwise this looks good, thank you.
Modifies how
getActorCurrencyUpdatesworks 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
0or has used each currency denomination as its first entry.Closed #6627