28
30
(set! HORIZPOS (+ HORIZPOS 0.5))
29
(add-normal-slot '()) ; Slot 0
30
(add-normal-slot '()) ; Slot 1
31
(add-normal-slot '()) ; Slot 2
32
(add-normal-slot '()) ; Slot 3
33
(add-carriage-return-slot)
36
(set! HORIZPOS (+ HORIZPOS 0.5))
37
(add-normal-slot '()) ; Slot 4
38
(add-normal-slot '()) ; Slot 5
39
(add-normal-slot '()) ; Slot 6
40
(add-normal-slot '()) ; Slot 7
41
(add-carriage-return-slot)
44
(set! HORIZPOS (+ HORIZPOS 0.5))
45
(add-normal-slot '()) ; Slot 8
46
(add-normal-slot '()) ; Slot 9
47
(add-normal-slot '()) ; Slot 10
48
(add-normal-slot '()) ; Slot 11
49
(add-carriage-return-slot)
52
(set! HORIZPOS (+ HORIZPOS 0.5))
53
(add-normal-slot '()) ; Slot 12
54
(add-normal-slot '()) ; Slot 13
55
(add-normal-slot '()) ; Slot 14
56
(add-normal-slot '()) ; Slot 15
31
(add-normal-slot '() 'corner) ; Slot 0
32
(add-normal-slot '() 'top) ; Slot 1
33
(add-normal-slot '() 'top) ; Slot 2
34
(add-normal-slot '() 'corner) ; Slot 3
35
(add-carriage-return-slot)
38
(set! HORIZPOS (+ HORIZPOS 0.5))
39
(add-normal-slot '() 'left) ; Slot 4
40
(add-normal-slot '() 'tableau) ; Slot 5
41
(add-normal-slot '() 'tableau) ; Slot 6
42
(add-normal-slot '() 'right) ; Slot 7
43
(add-carriage-return-slot)
46
(set! HORIZPOS (+ HORIZPOS 0.5))
47
(add-normal-slot '() 'left) ; Slot 8
48
(add-normal-slot '() 'tableau) ; Slot 9
49
(add-normal-slot '() 'tableau) ; Slot 10
50
(add-normal-slot '() 'right) ; Slot 11
51
(add-carriage-return-slot)
54
(set! HORIZPOS (+ HORIZPOS 0.5))
55
(add-normal-slot '() 'corner) ; Slot 12
56
(add-normal-slot '() 'bottom) ; Slot 13
57
(add-normal-slot '() 'bottom) ; Slot 14
58
(add-normal-slot '() 'corner) ; Slot 15
61
(add-normal-slot DECK) ; Slot 16
62
(add-normal-slot '()) ; Slot 17
63
(add-normal-slot DECK 'stock) ; Slot 16
64
(add-normal-slot '() 'waste) ; Slot 17
63
65
(set! add-stage #t)
64
66
(set! fill-count 0)
163
165
(empty-slot? 10)))
165
(define (list-cards slot)
168
(append (if (and (not (empty-slot? slot))
169
(< (get-value (get-top-card slot)) 11))
172
(list-cards (+ 1 slot)))))
174
(define (find-card-val-in-list? cards value)
175
(and (not (null? cards))
176
(if (= value (get-value (car cards)))
178
(find-card-val-in-list? (cdr cards) value))))
180
(define (find-match cards)
181
(and (not (null? cards))
182
(if (= 10 (get-value (car cards)))
183
(list 2 (get-name (car cards)) (_"itself")) ; yuk..
184
(let ((match (find-card-val-in-list?
186
(- 10 (get-value (car cards))))))
188
(list 1 (get-name (car cards)) (get-name match))
189
(find-match (cdr cards)))))))
167
(define (hint-remove-ten suit)
168
(cond ((eq? suit club) (_"Remove the ten of clubs."))
169
((eq? suit diamond) (_"Remove the ten of diamonds."))
170
((eq? suit heart) (_"Remove the ten of hearts."))
171
((eq? suit spade) (_"Remove the ten of spades."))))
173
(define (find-match slot1 slot2)
174
(cond ((= slot2 16) (find-match (+ 1 slot1) 0))
176
((or (empty-slot? slot2) (> (get-value (get-top-card slot2)) 10)) (find-match slot1 (+ 1 slot2)))
177
((or (empty-slot? slot1) (> (get-value (get-top-card slot1)) 10)) (find-match (+ 1 slot1) 0))
178
((= 10 (get-value (get-top-card slot2))) (list 0 (hint-remove-ten (get-suit (get-top-card slot2)))))
179
((= slot1 slot2) (find-match slot1 (+ 1 slot2)))
180
((= 10 (+ (get-value (get-top-card slot1)) (get-value (get-top-card slot2))))
181
(hint-move slot1 1 slot2))
182
(#t (find-match slot1 (+ 1 slot2)))))
191
184
(define (placeable? card)
192
185
(cond ((= (get-value card) king)
193
(and (or (empty-slot? 0)
197
(_"an empty corner slot")))
198
((= (get-value card) queen)
199
(or (and (or (empty-slot? 1)
201
(_"an empty top slot"))
202
(and (or (empty-slot? 13)
204
(_"an empty bottom slot"))))
186
(find-empty-slot '(0 3 12 15)))
187
((= (get-value card) queen)
188
(find-empty-slot '(1 2 13 14)))
205
189
((= (get-value card) jack)
206
(or (and (or (empty-slot? 4)
208
(_"an empty left slot"))
209
(and (or (empty-slot? 7)
211
(_"an empty right slot"))))
212
(#t (_"an empty slot"))))
190
(find-empty-slot '(4 8 7 11)))
192
(find-empty-slot '(5 6 9 10 0 1 2 3 4 7 8 11 12 13 14 15)))))
214
194
(define (game-over)
215
195
(give-status-message)
217
197
(and (empty-slot? 16) (empty-slot? 17)))
219
199
(set! add-stage #f)
220
(find-match (list-cards 0)))
221
201
(or (empty-slot? 17)
222
202
(placeable? (get-top-card 17)))))
224
204
(define (get-hint)
225
205
(or (if add-stage
226
206
(and (not (empty-slot? 17))
227
(list 2 (get-name (get-top-card 17))
228
(placeable? (get-top-card 17))))
229
(find-match (list-cards 0)))
207
(hint-move 17 1 (placeable? (get-top-card 17))))
230
209
(list 0 (_"Deal a new card from the deck"))))
232
211
(define (get-options) #f)