Rework read-until-valid-integers to work better for redeal inputs

A player may:
- not redeal any cards
- redeal all their cards

Therefore the indices must be between 0,5 and there can be at most 5
inputs.
This commit is contained in:
2025-02-14 23:24:47 +00:00
parent 8f23358d3e
commit bf6cace5c3

View File

@@ -50,10 +50,13 @@
(fn read-until-valid-integers () (-> nil list)
(let ((inp (remove-duplicates (read-integers))))
(while (not (every #'is-valid-hand-index inp))
(while (not (and (every #'is-valid-hand-index inp)
(< (length inp) 5)
(>= (length inp) 0)))
(format t "Need at most 5 integers between 0 and 4...~%")
(force-output)
(setq inp (remove-duplicates (read-integers))))))
(setq inp (remove-duplicates (read-integers))))
inp))
(defun generate-hand ()
(->> (make-deck)