1
; AisleRiot - treize.scm
2
; Copyright (C) 2001, 2003 Rosanna Yuen <zana@webwynk.net>
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)
23
(add-normal-slot DECK)
25
(set! HORIZPOS (- HORIZPOS (/ 2 3)))
26
(add-extended-slot '() right)
28
(add-carriage-return-slot)
35
(add-carriage-return-slot)
36
(set! VERTPOS (- VERTPOS (/ 2 3)))
37
(set! HORIZPOS (+ HORIZPOS 0.5))
43
(add-carriage-return-slot)
44
(set! VERTPOS (- VERTPOS (/ 2 3)))
51
(add-carriage-return-slot)
52
(set! VERTPOS (- VERTPOS (/ 2 3)))
53
(set! HORIZPOS (+ HORIZPOS 0.5))
60
(add-carriage-return-slot)
61
(set! VERTPOS (- VERTPOS (/ 2 3)))
69
(add-carriage-return-slot)
70
(set! VERTPOS (- VERTPOS (/ 2 3)))
71
(set! HORIZPOS (+ HORIZPOS 0.5))
79
(add-carriage-return-slot)
80
(set! VERTPOS (- VERTPOS (/ 2 3)))
89
(deal-cards-face-up 0 ' (3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
90
20 21 22 23 24 25 26 27 28 29 30))
96
(define (give-status-message)
97
(set-statusbar-message (get-stock-no-string)))
99
(define (get-stock-no-string)
100
(string-append (_"Stock left:") " "
101
(number->string (length (get-cards 0)))))
103
(define (button-pressed slot-id card-list)
104
(and (not (empty-slot? slot-id))
105
(not (= (get-value (car card-list)) king))
106
(available? slot-id 0)
107
(= (length card-list) 1)))
109
(define (available? slot-id r-slot)
110
(cond ((or (= slot-id 1)
116
(and (empty-slot? 29)
119
(not (= r-slot 30))))
121
(and (empty-slot? 28)
124
(not (= r-slot 29))))
126
(and (empty-slot? 27)
129
(not (= r-slot 28))))
131
(and (empty-slot? 26)
134
(not (= r-slot 27))))
136
(and (empty-slot? 25)
139
(not (= r-slot 26))))
141
(and (empty-slot? 24)
144
(not (= r-slot 25))))
146
(and (empty-slot? 22)
149
(not (= r-slot 23))))
151
(and (empty-slot? 21)
154
(not (= r-slot 22))))
156
(and (empty-slot? 20)
159
(not (= r-slot 21))))
161
(and (empty-slot? 19)
164
(not (= r-slot 20))))
166
(and (empty-slot? 18)
169
(not (= r-slot 19))))
171
(and (empty-slot? 16)
174
(not (= r-slot 17))))
176
(and (empty-slot? 15)
179
(not (= r-slot 16))))
181
(and (empty-slot? 14)
184
(not (= r-slot 15))))
186
(and (empty-slot? 13)
189
(not (= r-slot 14))))
191
(and (empty-slot? 11)
194
(not (= r-slot 12))))
196
(and (empty-slot? 10)
199
(not (= r-slot 11))))
204
(not (= r-slot 10))))
219
(not (= r-slot 5))))))
221
(define (droppable? start-slot card-list end-slot)
222
(and (not (empty-slot? end-slot))
223
(available? end-slot start-slot)
224
(= 13 (+ (get-value (car card-list))
225
(get-value (get-top-card end-slot))))))
227
(define (button-released start-slot card-list end-slot)
228
(and (droppable? start-slot card-list end-slot)
230
(remove-card end-slot)
231
(if (or (= start-slot 1)
233
(if (not (empty-slot? 2))
235
(let ((new-contents (get-cards 2)))
236
(let ((moving-back (car (reverse new-contents))))
237
(set-cards! 1 (list moving-back)))
238
(set-cards! 2 (reverse (cdr (reverse new-contents))))))
242
(define (button-clicked slot-id)
245
(and (not (empty-slot? 0))
246
(deal-cards-face-up 0 '(1)))
247
(and (not (empty-slot? 0))
248
(deal-cards-face-up 0 '(2))))
249
(and (not (empty-slot? slot-id))
250
(available? slot-id 0)
251
(= (get-value (get-top-card slot-id))
253
(remove-card slot-id)
255
(if (not (empty-slot? 2))
257
(let ((new-contents (get-cards 2)))
258
(let ((moving-back (car (reverse new-contents))))
259
(set-cards! 1 (list moving-back)))
260
(set-cards! 2 (reverse (cdr (reverse new-contents))))))))
263
(define (button-double-clicked slot-id)
266
(define (game-continuable)
267
(give-status-message)
268
(and (not (game-won))
276
(define (check-move slot1 slot2)
277
(if (or (empty-slot? slot1)
278
(not (available? slot1 0)))
280
(check-move (+ 1 slot1) (+ 2 slot1))
282
(if (= king (get-value (get-top-card slot1)))
283
(list 2 (get-name (get-top-card slot1)) (_"itself"))
284
(if (or (empty-slot? slot2)
285
(not (available? slot2 0))
286
(not (= 13 (+ (get-value (get-top-card slot1))
287
(get-value (get-top-card slot2))))))
289
(check-move slot1 (+ 1 slot2))
291
(check-move (+ 1 slot1) (+ 2 slot1))
294
(get-name (get-top-card slot1))
295
(get-name (get-top-card slot2)))))))
298
(if (not (empty-slot? 0))
299
(list 0 (_"Deal a card"))
302
(define (check-waste)
303
(and (not (empty-slot? 2))
304
(> (length (get-cards 2)) 1)
305
(= 13 (+ (get-value (get-top-card 2))
306
(get-value (cadr (get-cards 2)))))
308
(get-name (get-top-card 2))
309
(get-name (cadr (get-cards 2))))))
316
(define (get-options)
319
(define (apply-options options)
325
(set-features droppable-feature)
327
(set-lambda new-game button-pressed button-released button-clicked
328
button-double-clicked game-continuable game-won get-hint get-options
329
apply-options timeout droppable?)