1
; AisleRiot - scorpion.scm
2
; Copyright (C) 1999 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/>.
16
; winning game seed: 2036201447
19
(initialize-playing-area)
24
(add-normal-slot DECK)
28
(add-extended-slot '() down)
29
(add-extended-slot '() down)
30
(add-extended-slot '() down)
31
(add-extended-slot '() down)
32
(add-extended-slot '() down)
33
(add-extended-slot '() down)
34
(add-extended-slot '() down)
36
(deal-cards 0 '(1 2 3 4))
37
(deal-cards-face-up 0 '(5 6 7))
38
(deal-cards 0 '(1 2 3 4))
39
(deal-cards-face-up 0 '(5 6 7))
40
(deal-cards 0 '(1 2 3 4))
41
(deal-cards-face-up 0 '(5 6 7))
42
(deal-cards-face-up 0 '(1 2 3 4 5 6 7))
43
(deal-cards-face-up 0 '(1 2 3 4 5 6 7))
44
(deal-cards-face-up 0 '(1 2 3 4 5 6 7))
45
(deal-cards-face-up 0 '(1 2 3 4 5 6 7))
47
(begin-score (reverse (get-cards 1)))
48
(begin-score (reverse (get-cards 2)))
49
(begin-score (reverse (get-cards 3)))
50
(begin-score (reverse (get-cards 4)))
51
(begin-score (reverse (get-cards 5)))
52
(begin-score (reverse (get-cards 6)))
53
(begin-score (reverse (get-cards 7)))
57
(define (begin-score card-list)
58
(if (not (is-visible? (car card-list)))
59
(begin-score (cdr card-list))
61
(if (and (= (get-suit (car card-list))
62
(get-suit (cadr card-list)))
63
(= (get-value (car card-list))
64
(+ (get-value (cadr card-list)) 1)))
66
(if (> (length card-list) 2)
67
(begin-score (cdr card-list))
70
(define (button-pressed slot-id card-list)
71
(and (not (empty-slot? slot-id))
72
(is-visible? (car (reverse card-list)))))
74
(define (correct-sequence card-list)
75
(or (= (length card-list) 1)
76
(and (is-visible? (cadr card-list))
77
(eq? (get-suit (car card-list))
78
(get-suit (cadr card-list)))
79
(= (+ 1 (get-value (car card-list)))
80
(get-value (cadr card-list)))
81
(correct-sequence (cdr card-list)))))
83
(define (droppable? start-slot card-list end-slot)
84
(and (not (= start-slot end-slot))
86
(or (and (empty-slot? end-slot)
87
(= (get-value (car (reverse card-list))) king))
88
(and (not (empty-slot? end-slot))
89
(eq? (get-suit (get-top-card end-slot))
90
(get-suit (car (reverse card-list))))
91
(= (get-value (get-top-card end-slot))
92
(+ 1 (get-value (car (reverse card-list)))))))))
94
(define (button-released start-slot card-list end-slot)
95
(and (droppable? start-slot card-list end-slot)
96
(or (empty-slot? end-slot)
98
(move-n-cards! start-slot end-slot card-list)
99
(or (empty-slot? start-slot)
100
(is-visible? (get-top-card start-slot))
101
(and (make-visible-top-card start-slot)
103
(or (not (= (length (get-cards end-slot)) 13))
104
(not (correct-sequence (get-cards end-slot)))
105
(and (= (length card-list) 13)
106
(empty-slot? start-slot))
108
(or (not (= (length (get-cards start-slot)) 13))
109
(not (correct-sequence (get-cards start-slot)))
112
(define (check-for-points slot-id)
114
(give-status-message)
116
(if (and (> (length (get-cards slot-id)) 1)
117
(eq? (get-suit (get-top-card slot-id))
118
(get-suit (cadr (get-cards slot-id))))
119
(= (+ 1 (get-value (get-top-card slot-id)))
120
(get-value (cadr (get-cards slot-id)))))
123
(check-for-points (+ 1 slot-id)))))
125
(define (button-clicked slot-id)
127
(not (empty-slot? 0))
128
(deal-cards-face-up 0 '(1 2 3))
129
(check-for-points 1)))
131
(define (button-double-clicked slot-id)
134
(define (game-continuable)
138
(eq? (get-score) 100))
141
(and (not (empty-slot? 0))
142
(list 0 (_"Deal the cards"))))
144
(define (check-slot-cards card card-list)
145
(cond ((or (= (length card-list) 0)
146
(not (is-visible? (car card-list))))
148
((and (eq? (get-suit card)
149
(get-suit (car card-list)))
151
(+ 1 (get-value (car card-list)))))
153
(#t (check-slot-cards card (cdr card-list)))))
155
(define (check-a-slot slot1 slot2)
158
((and (not (= slot1 slot2))
159
(not (empty-slot? slot2))
160
(check-slot-cards (get-top-card slot1) (get-cards slot2)))
162
(#t (check-a-slot slot1 (+ 1 slot2)))))
164
(define (check-slot slot-id)
167
((and (not (empty-slot? slot-id))
168
(check-a-slot slot-id 1))
170
(get-name (make-card (- (get-value (get-top-card slot-id)) 1)
171
(get-suit (get-top-card slot-id))))
172
(get-name (get-top-card slot-id))))
173
(#t (check-slot (+ 1 slot-id)))))
175
(define (here-kingy-kingy card-list)
176
(cond ((or (= (length card-list) 0)
177
(= (length card-list) 1)
178
(not (is-visible? (car card-list))))
180
((= (get-value (car card-list)) king)
181
(list 2 (get-name (car card-list)) (_"an empty slot")))
182
(#t (here-kingy-kingy (cdr card-list)))))
184
(define (king-avail? slot-id)
187
((and (not (empty-slot? slot-id))
188
(here-kingy-kingy (get-cards slot-id)))
189
(here-kingy-kingy (get-cards slot-id)))
190
(#t (king-avail? (+ 1 slot-id)))))
192
(define (check-for-empty)
193
(and (or (empty-slot? 1)
207
(define (get-options)
210
(define (apply-options options)
216
(set-features droppable-feature)
218
(set-lambda new-game button-pressed button-released button-clicked
219
button-double-clicked game-continuable game-won get-hint get-options
220
apply-options timeout droppable?)