Skip to content

hex loss from barter stall#12

Open
KascadeKyle wants to merge 1 commit intoclockworklabs:masterfrom
KascadeKyle:fix-barter-stall
Open

hex loss from barter stall#12
KascadeKyle wants to merge 1 commit intoclockworklabs:masterfrom
KascadeKyle:fix-barter-stall

Conversation

@KascadeKyle
Copy link

Summary

Fix an issue where barter stall transactions could incorrectly deduct too many coins from the claim treasury when both the stall inventory and treasury contained coins.

Previously, the code calculated how many coins should come from the treasury (removed_from_treasury), but the validation and deduction logic mistakenly used the full payout amount (removed_coins). This caused the treasury to be charged for the entire payout instead of only the shortfall after stall inventory coins were used.

Changes

  • Ensures the treasury only covers the portion of the payout not available in the stall inventory.
  • Clarified the calculation of removed_from_treasury by using removed_coins directly instead of coin_item[0].quantity.
  • claim_local.treasury < removed_from_treasury checks that the treasury has the amount needed after stall reduction, rather than claim_local.treasury < removed_coins which checks against the full payout value

Bug Replication

  • Barter stall offers 100 coins
  • Stall inventory contains 60 coins
  • Claim treasury contains 200 coins

Expected:

  • Player receives 100 coins
  • Stall inventory provides 60 coins
  • Treasury provides 40 coins

Actual:

  • Player receives 100 coins
  • Stall inventory provides 60 coins
  • Treasury provides 100 coins
  • 60 coins are permanently lost

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant