~ubuntu-branches/debian/jessie/aisleriot/jessie

« back to all changes in this revision

Viewing changes to games/sir_tommy.scm

  • Committer: Package Import Robot
  • Author(s): Jordi Mallach, Jeremy Bicha, Jordi Mallach
  • Date: 2012-04-22 12:49:26 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20120422124926-gmr0thwstl91jt1n
Tags: 1:3.4.1-1
[ Jeremy Bicha ]
* New upstream release
* debian/control.in: (Build)-depend on guile-2.0
* debian/*.install: Cards files are now stored as zipped .svg's
* debian/patches/99_format-security.patch: Dropped, applied upstream

[ Jordi Mallach ]
* New upstream release.
* Update copyright to final version of the machine-readable 1.0 spec.
* Bump Standards Version to 3.9.3.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
; AisleRiot - sir_tommy.scm
2
 
; Copyright (C) 2001 Rosanna Yuen <zana@webwynk.net>
3
 
;
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.
8
 
;
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.
13
 
;
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
 
 
17
 
(define (new-game)
18
 
  (initialize-playing-area)
19
 
  (set-ace-low)
20
 
  (make-standard-deck)
21
 
  (shuffle-deck)
22
 
 
23
 
  (add-normal-slot DECK)
24
 
  (add-normal-slot '())
25
 
 
26
 
  (add-blank-slot)
27
 
  (add-normal-slot '())
28
 
  (add-normal-slot '())
29
 
  (add-normal-slot '())
30
 
  (add-normal-slot '())
31
 
  (add-carriage-return-slot)
32
 
  (add-blank-slot)
33
 
  (add-blank-slot)
34
 
  (add-blank-slot)
35
 
  (add-extended-slot '() down)
36
 
  (add-extended-slot '() down)
37
 
  (add-extended-slot '() down)
38
 
  (add-extended-slot '() down)
39
 
 
40
 
  (give-status-message)
41
 
  (list 7 4))
42
 
 
43
 
(define (give-status-message)
44
 
  (set-statusbar-message (get-stock-no-string)))
45
 
 
46
 
(define (get-stock-no-string)
47
 
  (string-append (_"Stock left:") " " 
48
 
                 (number->string (length (get-cards 0)))))
49
 
 
50
 
(define (button-pressed slot-id card-list)
51
 
  (and (not (empty-slot? slot-id))
52
 
       (= (length card-list) 1)
53
 
       (or (= slot-id 1)
54
 
           (> slot-id 5))))
55
 
 
56
 
(define (droppable? start-slot card-list end-slot)
57
 
  (cond ((> end-slot 5)
58
 
         (= start-slot 1))
59
 
        ((> end-slot 1)
60
 
         (or (and (= (get-value (car card-list)) ace)
61
 
                  (empty-slot? end-slot))
62
 
             (and (not (empty-slot? end-slot))
63
 
                  (= (get-value (car card-list))
64
 
                     (+ 1 (get-value (get-top-card end-slot)))))))
65
 
        (#t #f)))
66
 
 
67
 
(define (button-released start-slot card-list end-slot)
68
 
  (and (droppable? start-slot card-list end-slot)
69
 
       (cond ((> end-slot 5)
70
 
              (move-n-cards! start-slot end-slot card-list))
71
 
             ((> end-slot 1)
72
 
              (begin
73
 
                (move-n-cards! start-slot end-slot card-list)
74
 
                (add-to-score! 1)))
75
 
             (#t #f))))
76
 
 
77
 
(define (button-clicked slot-id)
78
 
  (and (= slot-id 0)
79
 
       (not (empty-slot? 0))
80
 
       (empty-slot? 1)
81
 
       (deal-cards-face-up 0 '(1))))
82
 
 
83
 
(define (check-top-card slot f-slot)
84
 
  (cond ((= f-slot 6)
85
 
         #f)
86
 
        ((and (not (empty-slot? f-slot))
87
 
              (= (get-value (get-top-card slot))
88
 
                 (+ 1 (get-value (get-top-card f-slot)))))
89
 
         (list f-slot))
90
 
        ((and (= (get-value (get-top-card slot)) 
91
 
                 ace)
92
 
              (empty-slot? f-slot))
93
 
         (list f-slot))
94
 
        (#t (check-top-card slot (+ 1 f-slot)))))
95
 
 
96
 
(define (button-double-clicked slot-id)
97
 
  (and (not (empty-slot? slot-id))
98
 
       (or (= slot-id 1)
99
 
           (> slot-id 5))
100
 
       (check-top-card slot-id 2)
101
 
       (deal-cards slot-id (check-top-card slot-id 2))
102
 
       (add-to-score! 1)))
103
 
 
104
 
(define (game-continuable)
105
 
  (give-status-message)
106
 
  (and (not (game-won))
107
 
       (get-hint)))
108
 
 
109
 
(define (game-won)
110
 
  (and (= (length (get-cards 2)) 13)
111
 
       (= (length (get-cards 3)) 13)
112
 
       (= (length (get-cards 4)) 13)
113
 
       (= (length (get-cards 5)) 13)))
114
 
 
115
 
(define (check-to-foundation slot)
116
 
  (cond ((= slot 10)
117
 
         #f)
118
 
        ((= slot 2)
119
 
         (check-to-foundation 6))
120
 
        ((and (not (empty-slot? slot))
121
 
              (check-top-card slot 2))
122
 
         (or (and (= (get-value (get-top-card slot)) ace)
123
 
                  (list 2 (get-name (get-top-card slot)) (_"empty foundation")))
124
 
             (list 1 
125
 
                   (get-name (get-top-card slot))
126
 
                   (get-name (get-top-card (car (check-top-card slot 2)))))))
127
 
        (#t (check-to-foundation (+ 1 slot)))))
128
 
 
129
 
(define (move-waste)
130
 
  (and (not (empty-slot? 1))
131
 
       (not (empty-slot? 0))
132
 
       (list 0 (_"Move waste on to a reserve slot"))))
133
 
 
134
 
(define (dealable?)
135
 
  (and (not (empty-slot? 0))
136
 
       (list 0 (_"Deal another card"))))
137
 
 
138
 
(define (get-hint)
139
 
  (or (check-to-foundation 1)
140
 
      (move-waste)
141
 
      (dealable?)))
142
 
 
143
 
(define (get-options) 
144
 
  #f)
145
 
 
146
 
(define (apply-options options) 
147
 
  #f)
148
 
 
149
 
(define (timeout) 
150
 
  #f)
151
 
 
152
 
(set-features droppable-feature)
153
 
 
154
 
(set-lambda new-game button-pressed button-released button-clicked
155
 
button-double-clicked game-continuable game-won get-hint get-options
156
 
apply-options timeout droppable?)