(define (reset-flowers flowers)
[when (method-in-interface?
'snap-back-after-regions? card<%>)
(broadcast flowers snap-back-after-regions? #t)]
(broadcast* flowers
(face-down)
(dim #f)
(user-can-flip #f)
(snap-back-after-move #t)
(user-can-move #f))
flowers)
(define (wiggle-flower-in-garden flower garden)
(let* ((table (send garden get-table))
(layout (send garden get-layout))
(x-offset (send layout get-flower-wiggle-x-offset flower))
(y-offset (send layout get-flower-wiggle-y-offset flower)))
(let-values (([x y] (send table card-location flower)))
(send table move-card flower
(- x x-offset) (+ y y-offset))
(send table move-card flower
(+ x x-offset) (- y y-offset))
(send table move-card flower x y)) ))
(define (flower-save-state flower)
(list (send flower face-down?)
(send flower user-can-flip)
(send flower snap-back-after-move)
(send flower user-can-move)
(send flower home-region)))
(define (flower-restore-state flower state)
(if (first state)
(send flower face-down)
(send flower face-up))
(send flower user-can-flip (second state))
(send flower snap-back-after-move (third state))
(send flower user-can-move (fourth state))
(send flower home-region (fifth state)))
(define (make-flowers flowers)
(reset-flowers flowers))
(define (card-sort-smaller? first-card second-card)
"Return true if the first card has a lower rank than the second card."
(< (send first-card get-value) (send second-card get-value)))
(define (card-sort-by-rank cards)
(sort cards card-sort-smaller?))