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.
The
loot-picker
always callson-card
with the full deck, andloot-picker-updater
takes(car (shuffle deck))
. Since theloot-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 toon-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 ofon-card
(which probably becomes(or/c (list/c 'add loot-card?) (list/c 'remove loot-card?))
) need documented, as well.