2
; Copyright (C) 2000 Matthew Wilcox <willy@linuxcare.com>
4
; This program is free software: you can redistribute it and/or modify
5
; it under the terms of the GNU General Public License as published by
6
; the Free Software Foundation, either version 3 of the License, or
7
; (at your option) any later version.
9
; This program is distributed in the hope that it will be useful,
10
; but WITHOUT ANY WARRANTY; without even the implied warranty of
11
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
; GNU General Public License for more details.
14
; You should have received a copy of the GNU General Public License
15
; along with this program. If not, see <http://www.gnu.org/licenses/>.
32
(initialize-playing-area)
37
(add-normal-slot DECK)
46
(add-carriage-return-slot)
49
(add-carriage-return-slot)
51
(add-carriage-return-slot)
53
(add-carriage-return-slot)
55
(add-carriage-return-slot)
58
(deal-cards-face-up 0 '(1 2 3 4 5 6 7 9 10 11 12 13 14 15 16 18 19
59
20 21 22 23 24 25 26 27 28 29 30 31 32 33
60
34 35 36 37 38 39 40 41 42 43 44 45 46 47
63
(make-visible-top-card 0)
70
(define (eliminate-kings slot)
71
(and (not (empty-slot? slot))
72
(= (get-value (get-top-card slot)) king)
75
(eliminate-kings (- slot 1))))
77
(define (button-pressed slot-id card-list)
80
(define (suit-next? first second)
81
(and (= (get-suit first)
83
(= (+ 1 (get-value first))
86
(define (card-next? lower higher)
87
(or (and (= ace (get-value higher))
88
(= queen (get-value lower)))
89
(suit-next? lower higher)))
91
(define (button-released start-slot card-list end-slot)
92
(and (droppable? start-slot card-list end-slot)
93
(add-card! end-slot (car card-list))))
95
(define (droppable? start-slot card-list end-slot)
96
(set! card (car card-list))
97
(and (not (= start-slot end-slot))
98
(empty-slot? end-slot)
99
(or (if (= end-slot 0)
100
(= ace (get-value card))
101
(and (not (empty-slot? (- end-slot 1)))
102
(card-next? (get-top-card (1- end-slot)) card)))
104
(= queen (get-value card))
105
(and (not (empty-slot? (1+ end-slot)))
106
(card-next? card (get-top-card (1+ end-slot))))))))
108
(define (button-clicked slot-id)
111
(define (button-double-clicked slot-id)
114
(define (get-full-card slot)
115
(if (empty-slot? slot)
116
(get-full-card (1+ slot))
117
(get-top-card slot)))
119
(define (calculate-score)
120
(set! card (get-full-card 0))
121
(if (= (get-value card) ace)
124
(calculate-score-helper 1 card)
125
(= (get-score) 48) ; 48 cards in the pack
128
(define (calculate-score-helper slot prev)
130
(and (empty-slot? slot)
131
(calculate-score-helper (1+ slot) prev))
132
(and (set! card (get-top-card slot))
133
(card-next? prev card)
136
(calculate-score-helper (1+ slot) card)))
145
(list 0 (_"Aim to place the suits in the order which fits the current layout most naturally.")))
147
(define (get-options)
150
(define (apply-options options)
156
(set-features droppable-feature)
158
(set-lambda new-game button-pressed button-released button-clicked
159
button-double-clicked game-over game-won get-hint get-options
160
apply-options timeout droppable?)