1
; AisleRiot - eagle_wing.scm
2
; Copyright (C) 1998, 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/>.
20
(initialize-playing-area)
25
(add-normal-slot DECK)
26
(add-normal-slot '()) ;waste
34
(add-carriage-return-slot)
35
(set! VERTPOS (+ VERTPOS 0.2))
36
(add-extended-slot '() down) ;tableau (slot 6)
37
(set! VERTPOS (- VERTPOS 0.1))
38
(add-extended-slot '() down) ;tableau (slot 7)
39
(set! VERTPOS (- VERTPOS 0.1))
40
(add-extended-slot '() down) ;tableau (slot 8)
41
(set! VERTPOS (+ VERTPOS 0.1))
42
(add-extended-slot '() down) ;tableau (slot 9)
43
(set! VERTPOS (+ VERTPOS 0.25))
44
(add-normal-slot '()) ;reserve (slot 10)
45
(set! VERTPOS (- VERTPOS 0.25))
46
(add-extended-slot '() down) ;tableau (slot 11)
47
(set! VERTPOS (- VERTPOS 0.1))
48
(add-extended-slot '() down) ;tableau (slot 12)
49
(set! VERTPOS (+ VERTPOS 0.1))
50
(add-extended-slot '() down) ;tableau (slot 13)
51
(set! VERTPOS (+ VERTPOS 0.1))
52
(add-extended-slot '() down) ;tableau (slot 14)
54
(deal-cards-face-up 0 '(10))
55
(deal-cards 0 '(10 10 10 10 10 10 10 10 10 10 10 10 6 7 8 9 11 12 13 14 2))
68
(set! BASE-VAL (get-value (get-top-card 2)))
74
(define (give-status-message)
75
(set-statusbar-message (string-append (get-stock-no-string)
77
(get-reserve-no-string)
81
(get-redeals-string))))
83
(define (get-stock-no-string)
84
(string-append (_"Stock left:") " "
85
(number->string (length (get-cards 0)))))
87
(define (get-reserve-no-string)
88
(string-append (_"Reserve left:") " "
89
(number->string (length (get-cards 10)))))
91
(define (get-base-string)
92
(cond ((and (> BASE-VAL 1)
94
(string-append (_"Base Card: ") (number->string BASE-VAL)))
100
(_"Base Card: Queen"))
102
(_"Base Card: King"))
105
(define (get-redeals-string)
106
(string-append (_"Redeals left:") " "
107
(number->string (- 2 FLIP-COUNTER))))
109
(define (button-pressed slot-id card-list)
111
(not (member slot-id '(2 3 4 5)))
112
(is-visible? (car card-list))))
114
(define (fill-tableau-slot slot)
118
(not (empty-slot? 10))
119
(deal-cards-face-up 10 (cons slot '())))
122
(define (complete-transaction start-slot card-list end-slot)
123
(if (member end-slot '(2 3 4 5))
124
(add-to-score! (length card-list)))
125
(move-n-cards! start-slot end-slot card-list)
126
(fill-tableau-slot start-slot))
128
(define (droppable? start-slot card-list end-slot)
129
(and (not (= start-slot end-slot))
130
(or (and (member end-slot '(2 3 4 5))
131
(if (empty-slot? end-slot)
132
(= (get-value (car card-list)) BASE-VAL)
133
(and (eq? (get-suit (car card-list))
134
(get-suit (get-top-card end-slot)))
135
(or (= (get-value (car card-list))
136
(+ (get-value (get-top-card end-slot)) 1))
137
(and (= (get-value (car card-list)) ace)
138
(= (get-value (get-top-card end-slot))
140
(and (member end-slot '(6 7 8 9 11 12 13 14))
141
(= (length card-list) 1)
142
(or (empty-slot? end-slot)
143
(and (< (length (get-cards end-slot)) 3)
144
(eq? (get-suit (car card-list))
145
(get-suit (get-top-card end-slot)))
146
(or (= (get-value (car card-list))
147
(- (get-value (get-top-card end-slot)) 1))
148
(and (= (get-value (car card-list)) king)
149
(= (get-value (get-top-card end-slot))
152
(define (button-released start-slot card-list end-slot)
153
(and (droppable? start-slot card-list end-slot)
154
(complete-transaction start-slot (reverse card-list) end-slot)))
159
(define (do-deal-next-cards)
162
(define (button-clicked slot-id)
167
(define (button-double-clicked slot)
168
(if (and (not (empty-slot? slot))
169
(is-visible? (get-top-card slot))
174
(cond ((and (= BASE-VAL (get-value (get-top-card slot))))
175
(cond ((empty-slot? 2)
176
(deal-cards slot '(2)))
178
(deal-cards slot '(3)))
180
(deal-cards slot '(4)))
182
(deal-cards slot '(5))))
184
(fill-tableau-slot slot))
185
((and (not (empty-slot? 2))
186
(= (get-suit (get-top-card slot))
187
(get-suit (get-top-card 2))))
188
(if (or (and (= (get-value (get-top-card slot)) ace)
189
(= (get-value (get-top-card 2)) king))
190
(= (get-value (get-top-card slot))
191
(+ 1 (get-value (get-top-card 2)))))
193
(deal-cards slot '(2))
195
(fill-tableau-slot slot))
197
((and (not (empty-slot? 3))
198
(= (get-suit (get-top-card slot))
199
(get-suit (get-top-card 3))))
200
(if (or (and (= (get-value (get-top-card slot)) ace)
201
(= (get-value (get-top-card 3)) king))
202
(= (get-value (get-top-card slot))
203
(+ 1 (get-value (get-top-card 3)))))
205
(deal-cards slot '(3))
207
(fill-tableau-slot slot))
209
((and (not (empty-slot? 4))
210
(= (get-suit (get-top-card slot))
211
(get-suit (get-top-card 4))))
212
(if (or (and (= (get-value (get-top-card slot)) ace)
213
(= (get-value (get-top-card 4)) king))
214
(= (get-value (get-top-card slot))
215
(+ 1 (get-value (get-top-card 4)))))
217
(deal-cards slot '(4))
219
(fill-tableau-slot slot))
221
((and (not (empty-slot? 5))
222
(= (get-suit (get-top-card slot))
223
(get-suit (get-top-card 5))))
224
(if (or (and (= (get-value (get-top-card slot)) ace)
225
(= (get-value (get-top-card 5)) king))
226
(= (get-value (get-top-card slot))
227
(+ 1 (get-value (get-top-card 5)))))
229
(deal-cards slot '(5))
231
(fill-tableau-slot slot))
237
(give-status-message)
238
(and (not (game-won))
254
(define (check-a-foundation slot1 slot2)
255
(and (not (empty-slot? slot2))
256
(= (get-suit (get-top-card slot1))
257
(get-suit (get-top-card slot2)))
258
(or (= (get-value (get-top-card slot1))
259
(+ 1 (get-value (get-top-card slot2))))
260
(and (= (get-value (get-top-card slot1)) ace)
261
(= (get-value (get-top-card slot2)) king)))))
263
(define (check-to-foundation slot)
264
(if (and (not (empty-slot? slot))
265
(is-visible? (get-top-card slot)))
266
(cond ((= (get-value (get-top-card slot)) BASE-VAL)
267
(list 0 (format #f (_"Move ~a to an empty foundation") (get-name (get-top-card slot)))))
268
((check-a-foundation slot 2)
270
(get-name (get-top-card slot))
271
(get-name (get-top-card 2))))
272
((check-a-foundation slot 3)
274
(get-name (get-top-card slot))
275
(get-name (get-top-card 3))))
276
((check-a-foundation slot 4)
278
(get-name (get-top-card slot))
279
(get-name (get-top-card 4))))
280
((check-a-foundation slot 5)
282
(get-name (get-top-card slot))
283
(get-name (get-top-card 5))))
285
(check-to-foundation 6))
287
(check-to-foundation (+ 1 slot)))
290
(check-to-foundation 6)
292
(check-to-foundation (+ 1 slot))
295
(define (check-empty-slot slot)
296
(if (and (empty-slot? slot)
300
(list 2 (get-name (get-top-card 1)) (_"an empty slot on tableau")))
302
(check-empty-slot (+ 1 slot))
305
(define (check-to-tableau slot card check-slot)
306
(if (and (not (= slot check-slot))
307
(not (= check-slot 10))
308
(not (empty-slot? check-slot))
309
(< (length (get-cards check-slot)) 3)
311
(get-suit (get-top-card check-slot)))
312
(or (= (+ 1 (get-value card))
313
(get-value (get-top-card check-slot)))
314
(and (= (get-value card) king)
315
(= (get-value (get-top-card check-slot)) ace))))
316
(list 1 (get-name card) (get-name (get-top-card check-slot)))
317
(if (< check-slot 14)
318
(check-to-tableau slot card (+ 1 check-slot))
321
(define (check-tableau slot)
322
(if (and (not (empty-slot? slot))
325
(is-visible? (get-top-card slot))
326
(= 1 (length (get-cards slot))))))
327
(check-to-tableau slot (get-top-card slot) 6)
331
(if (not (empty-slot? 0))
332
(list 0 (_"Deal a card"))
333
(if (and (not (empty-slot? 1))
335
(list 0 (_"Move waste back to stock"))
339
(or (check-to-foundation 1)
353
(define (get-options) #f)
355
(define (apply-options options) #f)
357
(define (timeout) #f)
359
(set-features droppable-feature dealable-feature)
361
(set-lambda new-game button-pressed button-released button-clicked button-double-clicked game-over game-won get-hint get-options apply-options timeout droppable? dealable?)