aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2025-02-14 23:24:47 +0000
committerAryadev Chavali <aryadev@aryadevchavali.com>2025-02-14 23:24:47 +0000
commitbf6cace5c355441247b973dcd6ba93c70cc0fa61 (patch)
treecc8e7be766b04d7b58a1f259534f5bbdd3516492 /src
parent8f23358d3e26f0d4463964f41104b20d96b05bd5 (diff)
downloadcantedraw-bf6cace5c355441247b973dcd6ba93c70cc0fa61.tar.gz
cantedraw-bf6cace5c355441247b973dcd6ba93c70cc0fa61.tar.bz2
cantedraw-bf6cace5c355441247b973dcd6ba93c70cc0fa61.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/main.lisp7
1 files 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)