(define-test ankan-hand :parent hands ;; Normal (let ((hand (hand-from-tile-string "N N N E S S W W 1m 2m 3m 4m N/3s")) (meld (make-list 4 :initial-element "N"))) (is equal meld (mapcar #'notation (ankan-tile hand "N"))) (is equal meld (mapcar #'notation (elt (slot-value hand 'open-part) 0)))) ;; Open hand OK (let ((hand (hand-from-tile-string "1m 2m 3m/Z Z Z E S S W W 4m Z/3s")) (meld (make-list 4 :initial-element "Z"))) (is equal meld (mapcar #'notation (ankan-tile hand "Z"))) (is equal meld (mapcar #'notation (elt (slot-value hand 'open-part) 1)))) ;; All tiles must be in hand (let ((hand (hand-from-tile-string "1m 2m 3m/as as as E S S W W 4m Z/ft"))) (fail (ankan-tile hand "as"))) ;; And not in an open hand (let ((hand (hand-from-tile-string "bs bs bs/bs as as E S S W W 4m Z/ft"))) (fail (ankan-tile hand "bs"))) (let ((hand (hand-from-tile-string "xs bs ds/bs bs bs E S S W W 4m Z/ft"))) (fail (ankan-tile hand "bs"))) ;; But in tsumo is okay (let ((hand (hand-from-tile-string "am am am bs as as E S S W W 4m Z/am")) (meld (make-list 4 :initial-element "am"))) (is equal meld (mapcar #'notation (ankan-tile hand "am"))) (is equal meld (mapcar #'notation (elt (slot-value hand 'open-part) 0)))) ;; Must have tsumo (let ((hand (hand-from-tile-string "am am am xs xs xs xs S S W W 4m Z/"))) (fail (ankan-tile hand "xs"))) ;; Must have all four tiles (let ((hand (hand-from-tile-string "cm am am bs as as E S S W W 4m Z/am"))) (fail (ankan-tile hand "am"))))