benknoble / frosthaven-manager

GUI Frosthaven Scenario Manager
https://benknoble.github.io/frosthaven-manager
Other
5 stars 0 forks source link

`loot-picker` and `loot-picker-updater` can add the same card more than once #1

Closed benknoble closed 1 year ago

benknoble commented 1 year ago

The loot-picker always calls on-card with the full deck, and loot-picker-updater takes (car (shuffle deck)). Since the loot-picker doesn't know which card has been removed and the deck is unchanged, subsequent calls will pass the same deck and there is a chance for (car (shuffle deck)) to return the same card as it did previously.

One way to fix this is for loot-picker to maintain copies of the decks as local state. It can pass individual cards to on-card for addition, and update its local copies of the deck to remove the card. Going the opposite direction is harder, so removing a card has to be more fine-grained as well (remove a specific card), which requires knowing which cards have been put in the deck. Changes to the interface of on-card (which probably becomes (or/c (list/c 'add loot-card?) (list/c 'remove loot-card?))) need documented, as well.