~ubuntu-branches/ubuntu/oneiric/gnome-games/oneiric

« back to all changes in this revision

Viewing changes to aisleriot/rules/maze.scm

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2011-07-21 04:22:50 UTC
  • mfrom: (1.1.93)
  • Revision ID: package-import@ubuntu.com-20110721042250-far722bxogjk1rhi
Tags: 1:3.1.3-0ubuntu1
* New upstream release
  - Aisleriot was split out of gnome-games into its own module.
  - Gnotravex was ported to GSettings.
  - Sudoku was ported to PyGObject/GTK3 by John Stowers.
* debian/aisleriot*: Dropped
* debian/control
  - Drop aisleriot package
  - Recommend aisleriot
  - Disable lightsoff & swell-foop as they're not ready yet
  - Re-enable gnome-sudoku
  - Use python-gobject instead of python-gtk2
  - Don't use python-launchpad-integration as it doesn't work with pygi yet
  - Switch to dh_python2 (LP: #788514)
  - Drop old pre-Lucid conflicts with gnome-cards-data & gnome-games-data
  - Drop obsolete build-depends: check, dpkg-dev, guile-1.8, lsb-release,
    rarian-compat, & scrollkeeper
  - Use ${gir:Depends}
* debian/copyright: Drop aisleriot & blackjack entries
* debian/glchess.install: Drop gnome-gnuchess
* debian/gnome-games-common.install: Drop aisleriot entries
* debian/gnome-sudoku.install: Install gconf schema
* debian/gnotravex.install: Install GSettings schema
* debian/rules
  - Clean up configure flags
  - Switch to dh_python2
* debian/watch: Watch for .bz2
* debian/patches/01_lpi.patch: Refreshed
* debian/patches/02_desktop-path.patch: Removed aisleriot references
* debian/patches/03_add-appinstall-keywords.patch
  - Add keywords to make searching for the games easier in Software Center

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
; AisleRiot - maze.scm
2
 
; Copyright (C) 2000 Matthew Wilcox <willy@linuxcare.com>
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 card '())
18
 
 
19
 
(define (add-line)
20
 
  (add-normal-slot '())
21
 
  (add-normal-slot '())
22
 
  (add-normal-slot '())
23
 
  (add-normal-slot '())
24
 
  (add-normal-slot '())
25
 
  (add-normal-slot '())
26
 
  (add-normal-slot '())
27
 
  (add-normal-slot '())
28
 
  (add-normal-slot '())
29
 
)
30
 
 
31
 
(define (new-game)
32
 
  (initialize-playing-area)
33
 
  (set-ace-low)
34
 
  (make-standard-deck)
35
 
  (shuffle-deck)
36
 
 
37
 
  (add-normal-slot DECK)
38
 
  (add-normal-slot '())
39
 
  (add-normal-slot '())
40
 
  (add-normal-slot '())
41
 
  (add-normal-slot '())
42
 
  (add-normal-slot '())
43
 
  (add-normal-slot '())
44
 
  (add-normal-slot '())
45
 
  (add-normal-slot '())
46
 
  (add-carriage-return-slot)
47
 
 
48
 
  (add-line)
49
 
  (add-carriage-return-slot)
50
 
  (add-line)
51
 
  (add-carriage-return-slot)
52
 
  (add-line)
53
 
  (add-carriage-return-slot)
54
 
  (add-line)
55
 
  (add-carriage-return-slot)
56
 
  (add-line)
57
 
 
58
 
  (deal-cards-face-up 0 '(1 2 3 4 5 6 7 9 10 11 12 13 14 15 16 18 19
59
 
                            20 21 22 23 24 25 26 27 28 29 30 31 32 33 
60
 
                            34 35 36 37 38 39 40 41 42 43 44 45 46 47 
61
 
                            48 49 50 51 52 53))
62
 
 
63
 
  (make-visible-top-card 0)
64
 
  (eliminate-kings 53)
65
 
 
66
 
  (calculate-score)
67
 
 
68
 
  (list 9 6))
69
 
 
70
 
(define (eliminate-kings slot)
71
 
  (and (not (empty-slot? slot))
72
 
       (= (get-value (get-top-card slot)) king)
73
 
       (remove-card slot))
74
 
  (and (> slot 0)
75
 
       (eliminate-kings (- slot 1))))
76
 
 
77
 
(define (button-pressed slot-id card-list)
78
 
  #t)
79
 
 
80
 
(define (suit-next? first second)
81
 
  (and (= (get-suit first)
82
 
          (get-suit second))
83
 
       (= (+ 1 (get-value first))
84
 
          (get-value second))))
85
 
 
86
 
(define (card-next? lower higher)
87
 
  (or (and (= ace (get-value higher))
88
 
           (= queen (get-value lower)))
89
 
      (suit-next? lower higher)))
90
 
 
91
 
(define (button-released start-slot card-list end-slot)
92
 
  (and (droppable? start-slot card-list end-slot)
93
 
       (add-card! end-slot (car card-list))))
94
 
 
95
 
(define (droppable? start-slot card-list end-slot)
96
 
  (set! card (car card-list))
97
 
  (and (not (= start-slot end-slot))
98
 
       (empty-slot? end-slot)
99
 
       (or (if (= end-slot 0)
100
 
               (= ace (get-value card))
101
 
               (and (not (empty-slot? (- end-slot 1)))
102
 
                    (card-next? (get-top-card (1- end-slot)) card)))
103
 
           (if (= end-slot 53)
104
 
               (= queen (get-value card))
105
 
               (and (not (empty-slot? (1+ end-slot)))
106
 
                    (card-next? card (get-top-card (1+ end-slot))))))))
107
 
 
108
 
(define (button-clicked slot-id)
109
 
  #f)
110
 
 
111
 
(define (button-double-clicked slot-id)
112
 
  #f)
113
 
 
114
 
(define (get-full-card slot)
115
 
  (if (empty-slot? slot)
116
 
      (get-full-card (1+ slot))
117
 
      (get-top-card slot)))
118
 
 
119
 
(define (calculate-score)
120
 
  (set! card (get-full-card 0))
121
 
  (if (= (get-value card) ace)
122
 
      (set-score! 1)
123
 
      (set-score! 0))
124
 
  (calculate-score-helper 1 card)
125
 
  (= (get-score) 48) ; 48 cards in the pack
126
 
)
127
 
 
128
 
(define (calculate-score-helper slot prev)
129
 
  (or (= slot 54)
130
 
      (and (empty-slot? slot)
131
 
           (calculate-score-helper (1+ slot) prev))
132
 
      (and (set! card (get-top-card slot))
133
 
           (card-next? prev card)
134
 
           (add-to-score! 1)
135
 
           #f)
136
 
      (calculate-score-helper (1+ slot) card)))
137
 
 
138
 
(define (game-won)
139
 
  (calculate-score))
140
 
 
141
 
(define (game-over)
142
 
  (not (game-won)))
143
 
 
144
 
(define (get-hint)
145
 
  (list 0 (_"Aim to place the suits in the order which fits the current layout most naturally.")))
146
 
 
147
 
(define (get-options) 
148
 
  #f)
149
 
 
150
 
(define (apply-options options) 
151
 
  #f)
152
 
 
153
 
(define (timeout) 
154
 
  #f)
155
 
 
156
 
(set-features droppable-feature)
157
 
 
158
 
(set-lambda new-game button-pressed button-released button-clicked
159
 
button-double-clicked game-over game-won get-hint get-options
160
 
apply-options timeout droppable?)