WIP: Making a simple re-deal program.
Gives a hand from a shuffled deck to the user, asks them to provide indices for cards they wish to re-deal then does so.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
(asdf:defsystem :cantedraw
|
||||
:depends-on (:alexandria)
|
||||
:components ((:file "packages")
|
||||
(:file "lib.macros")
|
||||
(:file "lib.functions")
|
||||
|
||||
27
main.lisp
27
main.lisp
@@ -32,7 +32,8 @@
|
||||
(remove-if #'null)))
|
||||
|
||||
(fn read-integers () (-> nil list)
|
||||
(->> (read-input "Enter numbers: ")
|
||||
(->> "Enter numbers: "
|
||||
read-input
|
||||
parse-integers))
|
||||
|
||||
(fn read-until-integers () (-> nil list)
|
||||
@@ -43,8 +44,24 @@
|
||||
(setq inp (read-integers)))
|
||||
inp))
|
||||
|
||||
(fn is-valid-hand-index (n) (-> (fixnum) boolean)
|
||||
(and (< n 5)
|
||||
(>= n 0)))
|
||||
|
||||
(fn read-until-valid-integers () (-> nil list)
|
||||
(let ((inp (remove-duplicates (read-integers))))
|
||||
(while (not (every #'is-valid-hand-index inp))
|
||||
(format t "Need at most 5 integers between 0 and 4...~%")
|
||||
(force-output)
|
||||
(setq inp (remove-duplicates (read-integers))))))
|
||||
|
||||
(defun generate-hand ()
|
||||
(->> (make-deck)
|
||||
alexandria:shuffle
|
||||
(split 5)))
|
||||
|
||||
(defun start ()
|
||||
(--> var
|
||||
(read-until-integers)
|
||||
(cons '+ var)
|
||||
(format t "~a = ~a~%" var (eval var))))
|
||||
(destructuring-bind (hand . rest) (generate-hand)
|
||||
(declare (ignore rest))
|
||||
(->> hand cardset->str (format t "Hand=[~a]~%"))
|
||||
(force-output)))
|
||||
|
||||
@@ -48,5 +48,7 @@
|
||||
:make-joker :make-deck))
|
||||
|
||||
(defpackage cantedraw.main
|
||||
(:use :cl :cantedraw.lib.macros :cantedraw.lib.functions)
|
||||
(:use :cl
|
||||
:cantedraw.lib.macros :cantedraw.lib.functions
|
||||
:cantedraw.model)
|
||||
(:export :start))
|
||||
|
||||
Reference in New Issue
Block a user