(defun %game ()
"Try test-run instead, or step through manually
; currently (round-active) never 'finishes'
by itself, and (score-game) is unimplemented"
(loop while (no-winner)
do (setup-game)
do (loop while (game-active)
do (setup-round)
do (loop while (round-active)
do (get-action))
do (reveal-shared))
do (score-game)))
(defun test-run ()
"Step through likely usage relevant to 'game'
;;Setup
(setf *players* nil)
(dotimes (n 3) (add-player))
;;Tournament game loop condition
(format t "No-winner: ~a is t~%" (no-winner))
;;Generate deck, deal hands.
(setup-game)
;;Check players (hands, for examples)
(format t "~{~a~%~}~%" *players*)
;;Check game-active
;;- more than one player has money,
;;- and the river has not been played yet
(format t "game-active: ~a is t~%" (game-active))
;;Setup round - bid blinds, set up action ..
(setup-round)
;;Check players bids, who is active next
(format t "~{~a~%~}~%" *players*)
;;round-active - there is more action in this round
(format t "round-active: ~a is t%" (round-active))
;bug in (round-active)
;;get-action - test calling works.
(with-input-from-string (*standard-input* "call")
(get-action))
;;Check players bids, who is active next
(format t "~{~a~%~}~%" *players*)
;;Repeat that a bunch for standard gameplay
;;reveal-shared - advance *community-cards*
(format t "~{~a~^ ~}~%" *community-cards*)
(reveal-shared)
(format t "~{~a~^ ~}~%" *community-cards*)
;; ... advances properly
(defun fresh-deck ()
(let ((deck nil)
(suits '(clubs spades diamonds hearts))
(ranks '(two three four five six seven
eight nine ten jack queen king
ace)))
(loop for suit in suits
do (loop for rank in ranks
do (push (cons rank suit) deck)))
(alexandria:shuffle deck)))
(defun no-winner ()
"Checks if one person has won the tournament;
prints who in that case or else t"
(let ((+ve-balances-on
(mapcan (lambda (x) (and (< 0 (cdr (assoc 'balance x)))
(list x)))
*players*)))
(case (length +ve-balances-on)
(1 (format t "The winner is ~a~%"
(cdr (assoc 'name (car +ve-balances-on))))
(values))
(t (values t)))))