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
|
(asdf:defsystem :cantedraw
|
||||||
|
:depends-on (:alexandria)
|
||||||
:components ((:file "packages")
|
:components ((:file "packages")
|
||||||
(:file "lib.macros")
|
(:file "lib.macros")
|
||||||
(:file "lib.functions")
|
(:file "lib.functions")
|
||||||
|
|||||||
27
main.lisp
27
main.lisp
@@ -32,7 +32,8 @@
|
|||||||
(remove-if #'null)))
|
(remove-if #'null)))
|
||||||
|
|
||||||
(fn read-integers () (-> nil list)
|
(fn read-integers () (-> nil list)
|
||||||
(->> (read-input "Enter numbers: ")
|
(->> "Enter numbers: "
|
||||||
|
read-input
|
||||||
parse-integers))
|
parse-integers))
|
||||||
|
|
||||||
(fn read-until-integers () (-> nil list)
|
(fn read-until-integers () (-> nil list)
|
||||||
@@ -43,8 +44,24 @@
|
|||||||
(setq inp (read-integers)))
|
(setq inp (read-integers)))
|
||||||
inp))
|
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 ()
|
(defun start ()
|
||||||
(--> var
|
(destructuring-bind (hand . rest) (generate-hand)
|
||||||
(read-until-integers)
|
(declare (ignore rest))
|
||||||
(cons '+ var)
|
(->> hand cardset->str (format t "Hand=[~a]~%"))
|
||||||
(format t "~a = ~a~%" var (eval var))))
|
(force-output)))
|
||||||
|
|||||||
@@ -48,5 +48,7 @@
|
|||||||
:make-joker :make-deck))
|
:make-joker :make-deck))
|
||||||
|
|
||||||
(defpackage cantedraw.main
|
(defpackage cantedraw.main
|
||||||
(:use :cl :cantedraw.lib.macros :cantedraw.lib.functions)
|
(:use :cl
|
||||||
|
:cantedraw.lib.macros :cantedraw.lib.functions
|
||||||
|
:cantedraw.model)
|
||||||
(:export :start))
|
(:export :start))
|
||||||
|
|||||||
Reference in New Issue
Block a user