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

« back to all changes in this revision

Viewing changes to games/block_ten.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 - block_ten.scm
2
 
; Copyright (C) 2001, 2003 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
 
  (make-standard-deck)
20
 
  (shuffle-deck)
21
 
 
22
 
  (add-normal-slot DECK)
23
 
  (add-blank-slot)
24
 
 
25
 
  (add-normal-slot '())
26
 
  (add-normal-slot '())
27
 
  (add-normal-slot '())
28
 
  (add-carriage-return-slot)
29
 
 
30
 
  (add-blank-slot)
31
 
  (add-blank-slot)
32
 
  (add-normal-slot '())
33
 
  (add-normal-slot '())
34
 
  (add-normal-slot '())
35
 
  (add-carriage-return-slot)
36
 
 
37
 
  (add-blank-slot)
38
 
  (add-blank-slot)
39
 
  (add-normal-slot '())
40
 
  (add-normal-slot '())
41
 
  (add-normal-slot '())
42
 
 
43
 
  (deal-cards-face-up 0 '(1 2 3 4 5 6 7 8 9))
44
 
  (give-status-message)
45
 
 
46
 
  (list 5 3))
47
 
 
48
 
(define (give-status-message)
49
 
  (set-statusbar-message (get-stock-no-string)))
50
 
 
51
 
(define (get-stock-no-string)
52
 
  (string-append (_"Stock left:") " "
53
 
                 (number->string (length (get-cards 0)))))
54
 
 
55
 
(define (button-pressed slot-id card-list)
56
 
  (and (not (empty-slot? slot-id))
57
 
       (not (= 0 slot-id))))
58
 
 
59
 
(define (check-for-deal start-slot end-slot)
60
 
  (or (empty-slot? 0)
61
 
      (and (deal-cards-face-up 0 (list start-slot))
62
 
           (or (empty-slot? 0)
63
 
               (deal-cards-face-up 0 (list end-slot))))))
64
 
 
65
 
(define (button-released start-slot card-list end-slot)
66
 
  (and (droppable? start-slot card-list end-slot)
67
 
       (remove-card end-slot)
68
 
       (check-for-deal start-slot end-slot)
69
 
       (add-to-score! 2)))
70
 
 
71
 
(define (droppable? start-slot card-list end-slot)
72
 
  (and (not (= end-slot 0))
73
 
       (not (empty-slot? end-slot))
74
 
       (or (= 10 (+ (get-value (car card-list))
75
 
                    (get-value (get-top-card end-slot))
76
 
                 )
77
 
           )
78
 
           (and (> (get-value (car card-list)) 10)
79
 
                (= (get-value (get-top-card end-slot))
80
 
                   (get-value (car card-list))
81
 
                )
82
 
           )
83
 
       )
84
 
   )
85
 
)
86
 
(define (button-clicked slot-id)
87
 
  #f)
88
 
 
89
 
(define (button-double-clicked slot-id)
90
 
  #f)
91
 
 
92
 
(define (game-continuable)
93
 
  (give-status-message)
94
 
  (and (not (game-won))
95
 
       (get-hint)))
96
 
 
97
 
(define (game-won)
98
 
  (and (or (empty-slot? 1)
99
 
           (= (get-value (get-top-card 1)) 10))
100
 
       (or (empty-slot? 2)
101
 
           (= (get-value (get-top-card 2)) 10))
102
 
       (or (empty-slot? 3)
103
 
           (= (get-value (get-top-card 3)) 10))
104
 
       (or (empty-slot? 4)
105
 
           (= (get-value (get-top-card 4)) 10))
106
 
       (or (empty-slot? 5)
107
 
           (= (get-value (get-top-card 5)) 10))
108
 
       (or (empty-slot? 6)
109
 
           (= (get-value (get-top-card 6)) 10))
110
 
       (or (empty-slot? 7)
111
 
           (= (get-value (get-top-card 7)) 10))
112
 
       (or (empty-slot? 8)
113
 
           (= (get-value (get-top-card 8)) 10))
114
 
       (or (empty-slot? 9)
115
 
           (= (get-value (get-top-card 9)) 10))))
116
 
 
117
 
(define (avail-pair? slot1 slot2)
118
 
  (cond ((= slot1 9)
119
 
         #f)
120
 
        ((or (empty-slot? slot1)
121
 
             (= slot2 10))
122
 
         (avail-pair? (+ 1 slot1) (+ 2 slot1)))
123
 
        ((and (not (empty-slot? slot2))
124
 
              (or (= 10 (+ (get-value (get-top-card slot1))
125
 
                           (get-value (get-top-card slot2))))
126
 
                  (and (> (get-value (get-top-card slot1)) 10)
127
 
                       (= (get-value (get-top-card slot1))
128
 
                          (get-value (get-top-card slot2))))))
129
 
         (list 1 
130
 
               (get-name (get-top-card slot1)) 
131
 
               (get-name (get-top-card slot2))))
132
 
        (#t (avail-pair? slot1 (+ 1 slot2)))))
133
 
 
134
 
(define (get-hint)
135
 
  (avail-pair? 1 2))
136
 
 
137
 
(define (get-options) 
138
 
  #f)
139
 
 
140
 
(define (apply-options options) 
141
 
  #f)
142
 
 
143
 
(define (timeout) 
144
 
  #f)
145
 
 
146
 
(set-features droppable-feature)
147
 
 
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?)