1
; AisleRiot - scuffle.scm
2
; Copyright (C) 2001 Rosanna Yuen <zana@webwynk.net>
4
; This game 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 2, or (at your option)
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, write to the Free Software
16
; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20
(initialize-playing-area)
22
(set! DECK (make-deck-list-ace-low 2 2 club))
25
(add-normal-slot DECK)
31
(add-carriage-return-slot)
39
(add-card! 1 (make-visible (make-card ace club)))
40
(add-card! 2 (make-visible (make-card ace diamond)))
41
(add-card! 3 (make-visible (make-card ace heart)))
42
(add-card! 4 (make-visible (make-card ace spade)))
49
(define (give-status-message)
50
(set-statusbar-message (string-append (get-stock-no-string)
52
(get-redeals-string))))
54
(define (get-redeals-string)
55
(string-append "Redeals left: "
56
(number->string (- 2 FLIP-COUNTER))))
58
(define (get-stock-no-string)
59
(string-append "Stock left: "
60
(number->string (length (get-cards 0)))))
62
(define (button-pressed slot-id card-list)
63
(and (not (empty-slot? slot-id))
66
(define (button-released start-slot card-list end-slot)
69
(= (get-value (car card-list))
70
(+ 1 (get-value (get-top-card end-slot))))
71
(move-n-cards! start-slot end-slot card-list)
74
(define (deal-cards-out slot)
76
(not (empty-slot? 0)))
77
(and (deal-cards-face-up 0 (list slot))
78
(deal-cards-out (+ 1 slot)))
81
(define (button-clicked slot-id)
83
(or (and (not (empty-slot? 0))
85
(and (< FLIP-COUNTER 2)
86
(set! FLIP-COUNTER (+ 1 FLIP-COUNTER))
93
(define (check-end-slot? slot1 slot2)
94
(if (and (not (empty-slot? slot1))
95
(= (get-value (get-top-card slot1))
96
(+ 1 (get-value (get-top-card slot2)))))
98
(deal-cards slot1 (list slot2))
101
(check-end-slot? slot1 (+ 1 slot2))
104
(define (button-double-clicked slot-id)
106
(check-end-slot? slot-id 1)))
108
(define (game-continuable)
109
(give-status-message)
110
(and (not (game-won))
120
(define (movable? slot1 slot2)
125
(movable? (+ 1 slot1) 1)
126
(if (= (get-value (get-top-card slot1))
127
(+ 1 (get-value (get-top-card slot2))))
129
(get-name (get-top-card slot1))
130
(get-name (get-top-card slot2)))
131
(movable? slot1 (+ 1 slot2))))))
134
(or (and (not (empty-slot? 0))
135
(list 0 "Deal another round"))
136
(and (< FLIP-COUNTER 2)
137
(list 0 "Reshuffle cards"))))
143
(define (get-options)
146
(define (apply-options options)
152
(set-lambda new-game button-pressed button-released button-clicked
153
button-double-clicked game-continuable game-won get-hint get-options
154
apply-options timeout)