Made calculateMaxAffordable, calculateCost, and cost requirements interface a bit cleaner #17

Merged
thepaperpilot merged 6 commits from feature/requirements-refactor into main 2023-05-17 23:52:28 +00:00
thepaperpilot commented 2023-05-07 16:27:39 +00:00 (Migrated from github.com)

This is a breaking change, and will require updating the docs.

  • Removes challenge.maximize
  • Removes repeatable.maximize
  • Rename spendResources to cumulativeCost
  • Rename summedPurchases to directSum
  • calculateMaxAffordable now takes maxBulkAmount, and will support non-invertible formulas when maxBulkAmount < directSum
  • Adds maxBulkAmount to cost requirements, defaulting to 1
  • Adds directSum to cost requirements, which gets passed to calculateCost and calculateMaxAffordable
  • Updates and adds tests for all these changes

So where previously you would set maximize: true on a repeatable or challenge, you'd now set maxBulkAmount on the cost requirement, such as Decimal.dInf.

This is a breaking change, and will require updating the docs. - Removes challenge.maximize - Removes repeatable.maximize - Rename spendResources to cumulativeCost - Rename summedPurchases to directSum - calculateMaxAffordable now takes maxBulkAmount, and will support non-invertible formulas when maxBulkAmount < directSum - Adds maxBulkAmount to cost requirements, defaulting to 1 - Adds directSum to cost requirements, which gets passed to calculateCost and calculateMaxAffordable - Updates and adds tests for all these changes So where previously you would set `maximize: true` on a repeatable or challenge, you'd now set `maxBulkAmount` on the cost requirement, such as `Decimal.dInf`.
Sign in to join this conversation.
No description provided.