From bf6cace5c355441247b973dcd6ba93c70cc0fa61 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Fri, 14 Feb 2025 23:24:47 +0000 Subject: 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. --- src/main.lisp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main.lisp b/src/main.lisp index 53d9bec..e92b6ad 100644 --- a/src/main.lisp +++ b/src/main.lisp @@ -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) -- cgit v1.2.3-13-gbd6f