1
; AisleRiot - hopscotch.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/>.
18
(initialize-playing-area)
20
(set! DECK (make-deck-list-ace-low 1 5 club))
23
(add-normal-slot DECK)
31
(add-carriage-return-slot)
35
(add-extended-slot '() down)
36
(add-extended-slot '() down)
37
(add-extended-slot '() down)
38
(add-extended-slot '() down)
40
(add-card! 2 (make-visible (make-card ace club)))
41
(add-card! 3 (make-visible (make-card 2 club)))
42
(add-card! 4 (make-visible (make-card 3 club)))
43
(add-card! 5 (make-visible (make-card 4 club)))
49
(define (give-status-message)
50
(set-statusbar-message (get-stock-no-string)))
52
(define (get-stock-no-string)
53
(string-append (_"Stock left:") " "
54
(number->string (length (get-cards 0)))))
56
(define (button-pressed slot-id card-list)
57
(and (not (empty-slot? slot-id))
58
(= (length card-list) 1)
62
(define (droppable? start-slot card-list end-slot)
63
(cond ((and (> end-slot 1)
65
(= (modulo (get-value (car card-list)) 13)
66
(modulo (+ (- end-slot 1) (get-value (get-top-card end-slot))) 13)))
67
((and (= start-slot 1)
72
(define (button-released start-slot card-list end-slot)
73
(if (droppable? start-slot card-list end-slot)
75
(move-n-cards! start-slot end-slot card-list)
76
(if (and (> end-slot 1) (< end-slot 6))
81
(define (button-clicked slot-id)
86
(define (button-double-clicked slot-id)
89
(define (game-continuable)
102
(define (check-to-foundation slot-id foundation-id)
103
(cond ((or (> slot-id 9)
108
(check-to-foundation (+ 1 slot-id) 2))
109
((or (empty-slot? slot-id)
110
(and (not (empty-slot? foundation-id))
111
(= (get-value (get-top-card foundation-id)) 13))
112
(not (= (modulo (get-value (get-top-card slot-id)) 13)
113
(modulo (+ (- foundation-id 1)
114
(get-value (get-top-card foundation-id)))
116
(check-to-foundation slot-id (+ 1 foundation-id)))
118
(get-name (get-top-card slot-id))
119
(get-name (get-top-card foundation-id))))))
121
(define (check-waste)
122
(cond ((empty-slot? 1)
124
((check-to-foundation 1 2)
125
(check-to-foundation 1 2))
126
(#t (list 0 (_"Move card from waste")))))
129
(and (not (empty-slot? 0))
130
(list 0 (_"Deal another card"))))
133
(or (check-to-foundation 6 2)
137
(define (get-options)
140
(define (apply-options options)
146
(set-features droppable-feature)
148
(set-lambda new-game button-pressed button-released button-clicked
149
button-double-clicked game-continuable game-won get-hint get-options
150
apply-options timeout droppable?)