1
; AisleRiot - zebra.scm
2
; Copyright (C) 1999, 2003 Rosanna Yuen <rwsy@mit.edu>
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/>.
18
(initialize-playing-area)
20
(set! DECK (append (make-deck-list-ace-low 2 2 club)
21
(make-deck-list-ace-low 2 2 club)))
24
(add-normal-slot DECK)
27
(set! HORIZPOS (+ HORIZPOS (/ 1 3)))
29
(add-normal-slot (list (make-visible (make-card ace club))))
30
(add-normal-slot (list (make-visible (make-card ace diamond))))
31
(add-normal-slot (list (make-visible (make-card ace heart))))
32
(add-normal-slot (list (make-visible (make-card ace spade))))
33
(add-normal-slot (list (make-visible (make-card ace club))))
34
(add-normal-slot (list (make-visible (make-card ace diamond))))
35
(add-normal-slot (list (make-visible (make-card ace heart))))
36
(add-normal-slot (list (make-visible (make-card ace spade))))
38
(add-carriage-return-slot)
40
(add-extended-slot '() down)
41
(set! HORIZPOS (+ HORIZPOS (/ 7 21)))
42
(add-extended-slot '() down) 7 21
43
(set! HORIZPOS (+ HORIZPOS (/ 7 21)))
44
(add-extended-slot '() down) 7 21
45
(set! HORIZPOS (+ HORIZPOS (/ 7 21)))
46
(add-extended-slot '() down) 7 21
47
(set! HORIZPOS (+ HORIZPOS (/ 7 21)))
48
(add-extended-slot '() down) 7 21
49
(set! HORIZPOS (+ HORIZPOS (/ 7 21)))
50
(add-extended-slot '() down) 7 21
51
(set! HORIZPOS (+ HORIZPOS (/ 7 21)))
52
(add-extended-slot '() down) 7 21
53
(set! HORIZPOS (+ HORIZPOS (/ 7 21)))
54
(add-extended-slot '() down)
56
(deal-cards-face-up 0 '(10 11 12 13 14 15 16 17))
60
(list (+ 10 (/ 1 3)) 3)
63
(define (give-status-message)
64
(set-statusbar-message (string-append (get-stock-no-string)
66
(get-redeals-string))))
68
(define (get-stock-no-string)
69
(string-append (_"Stock left:") " "
70
(number->string (length (get-cards 0)))))
72
(define (get-redeals-string)
73
(string-append (_"Redeals left:") " "
74
(number->string (- 1 FLIP-COUNTER))))
76
(define (button-pressed slot-id card-list)
77
(and (not (empty-slot? slot-id))
81
(define (empty-tableau slot)
82
(or (not (empty-slot? slot))
84
(and (not (empty-slot? 1))
85
(deal-cards-face-up 1 (list slot)))
86
(and (not (empty-slot? 0))
87
(deal-cards-face-up 0 (list slot)))
90
(define (droppable? start-slot card-list end-slot)
91
(cond ((= start-slot end-slot) #f)
93
(and (= (length card-list) 1)
94
(not (empty-slot? end-slot))
95
(not (eq? (is-red? (car card-list))
96
(is-red? (get-top-card end-slot))))
97
(= (get-value (get-top-card end-slot))
98
(+ 1 (get-value (car card-list))))))
100
(and (not (eq? (is-red? (get-top-card end-slot))
101
(is-red? (car card-list))))
102
(= (+ 1 (get-value (get-top-card end-slot)))
103
(get-value (car card-list)))))
106
(define (button-released start-slot card-list end-slot)
107
(and (droppable? start-slot card-list end-slot)
109
(move-n-cards! start-slot end-slot card-list)
111
(move-n-cards! start-slot end-slot (reverse card-list))
112
(add-to-score! (length card-list))))
113
(empty-tableau start-slot)))
115
(define (do-deal-next-cards)
121
(define (button-clicked slot-id)
123
(do-deal-next-cards)))
125
(define (move-to-foundation slot-id foundation-id)
126
(cond ((= foundation-id 10)
128
((and (not (eq? (is-red? (get-top-card slot-id))
129
(is-red? (get-top-card foundation-id))))
130
(= (+ 1 (get-value (get-top-card foundation-id)))
131
(get-value (get-top-card slot-id))))
132
(and (move-n-cards! slot-id
134
(list (get-top-card slot-id)))
135
(remove-card slot-id)
136
(empty-tableau slot-id)))
137
(#t (move-to-foundation slot-id (+ 1 foundation-id)))))
139
(define (button-double-clicked slot-id)
140
(and (not (empty-slot? slot-id))
143
(move-to-foundation slot-id 2)
146
(define (game-continuable)
147
(give-status-message)
151
(and (= (length (get-cards 2)) 13)
152
(= (length (get-cards 3)) 13)
153
(= (length (get-cards 4)) 13)
154
(= (length (get-cards 5)) 13)
155
(= (length (get-cards 6)) 13)
156
(= (length (get-cards 7)) 13)
157
(= (length (get-cards 8)) 13)
158
(= (length (get-cards 9)) 13)))
160
(define (check-a-foundation slot-id foundation-id)
161
(cond ((= foundation-id 10)
163
((and (not (eq? (is-red? (get-top-card slot-id))
164
(is-red? (get-top-card foundation-id))))
165
(= (+ 1 (get-value (get-top-card foundation-id)))
166
(get-value (get-top-card slot-id))))
169
(check-a-foundation slot-id (+ 1 foundation-id)))))
171
(define (check-to-foundations slot-id)
172
(cond ((= slot-id 18)
175
(check-to-foundations 10))
176
((and (not (empty-slot? slot-id))
177
(check-a-foundation slot-id 2))
179
(get-name (get-top-card slot-id))
180
(_"the appropriate Foundation pile")))
182
(check-to-foundations (+ 1 slot-id)))))
184
(define (check-a-tableau slot1 card-list slot2)
187
((and (not (= slot1 slot2))
188
(not (eq? (is-red? (car card-list))
189
(is-red? (get-top-card slot2))))
190
(= (+ 1 (get-value (car card-list)))
191
(get-value (get-top-card slot2)))
193
(= (length card-list) 1)
194
(check-a-tableau slot1 (cdr card-list) 10)))
196
(get-name (car card-list))
197
(get-name (get-top-card slot2))))
199
(check-a-tableau slot1 card-list (+ 1 slot2)))))
201
(define (check-to-tableaus slot-id)
202
(cond ((= slot-id 18)
205
(check-to-tableaus 10))
206
((and (not (empty-slot? slot-id))
207
(check-a-tableau slot-id (get-cards slot-id) 10))
208
(check-a-tableau slot-id (get-cards slot-id) 10))
209
(#t (check-to-tableaus (+ 1 slot-id)))))
212
(or (check-to-foundations 1)
213
(check-to-tableaus 1)
214
(or (and (not (empty-slot? 0))
215
(list 0 (_"Deal another round")))
216
(and (not (empty-slot? 1))
218
(list 0 (_"Move waste back to stock"))))))
220
(define (get-options)
223
(define (apply-options options)
229
(set-features droppable-feature dealable-feature)
231
(set-lambda new-game button-pressed button-released button-clicked
232
button-double-clicked game-continuable game-won get-hint get-options
233
apply-options timeout droppable? dealable?)