Crapette: choose how many cards of a run to drop onto an empty house

* cg-crapette.el (cg-crap--house-move): honour an optional WANT count on
an empty-house destination.  (cg-crap--do-move): thread it through.
(cg-crap--hold-adjust, cg-crap-hold-less, cg-crap-hold-more): [ and ] set
the held count.  (cg-crap--holding-line): show the run with the held
cards marked.  (cg-crap-act): default the held count to the run length.
Bind [ and ]; update the legend and help.
* test/card-games-tests.el: add cgt-crap-sequence-partial, cgt-crap-partial-space.
* NEWS: note choosing the group size.
This commit is contained in:
Corwin Brust 2026-07-01 03:33:45 -05:00
parent f7932047ce
commit 5060835731
3 changed files with 90 additions and 17 deletions

View file

@ -800,6 +800,27 @@
(should (cg-crap--stop g))
(should (string-match-p "STOP" (cg-get g :message))))))
(ert-deftest cgt-crap-sequence-partial ()
(let ((g (cg-crap--deal (cg-crapette-game))))
(aset (cg-get g :houses) 0 (list '(2 . 8) '(0 . 7) '(3 . 6))) ; 9D 8S 7H
(aset (cg-get g :houses) 1 nil) ; empty destination
(dotimes (i 6) (aset (cg-get g :houses) (+ 2 i) nil)) ; plenty of space
(should (eq t (cg-crap--house-move g 0 1 2))) ; move only the top 2
(should (equal '(2 . 8) (cg-crap--top (cg-crap--house g 0)))) ; 9D stays behind
(should (= 2 (length (cg-crap--house g 1))))
(should (equal '(0 . 7) (car (cg-crap--house g 1)))) ; 8S is the moved bottom
(should (equal '(3 . 6) (cg-crap--top (cg-crap--house g 1)))))) ; 7H the top
(ert-deftest cgt-crap-partial-space ()
(let ((g (cg-crap--deal (cg-crapette-game))))
(aset (cg-get g :houses) 0 (list '(2 . 8) '(0 . 7) '(3 . 6))) ; run of 3
(aset (cg-get g :houses) 1 nil) ; the only empty house
(dotimes (i 6) (aset (cg-get g :houses) (+ 2 i) (list '(0 . 0))))
(should (eq 'space (cg-crap--house-move g 0 1 3))) ; 3 needs more space
(should (eq t (cg-crap--house-move g 0 1 1))) ; but 1 fits
(should (= 2 (length (cg-crap--house g 0))))
(should (= 1 (length (cg-crap--house g 1))))))
(ert-deftest cgt-pat-golf-deal ()
(let ((g (cg-pat--deal (cg-golf-game))))
(should (= 35 (length (cg-get g :cards))))