home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / share / sol-games / pileon.scm < prev    next >
Encoding:
Text File  |  2006-08-22  |  5.7 KB  |  181 lines

  1. ; AisleRiot - pileon.scm
  2. ; Copyright (C) 1998 Nick Lamb <njl195@zepler.org.uk>
  3. ;
  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)
  7. ; 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, write to the Free Software
  16. ; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  17. ; USA
  18.  
  19. (define (new-game)
  20.   (initialize-playing-area)
  21.   (set-ace-low)
  22.   (make-standard-deck)
  23.   (shuffle-deck)
  24.  
  25.   (add-partially-extended-slot '() right 4)
  26.   (set! HORIZPOS (+ HORIZPOS 1))
  27.   (add-partially-extended-slot '() right 4)
  28.   (set! HORIZPOS (+ HORIZPOS 1))
  29.   (add-partially-extended-slot '() right 4)
  30.   (set! HORIZPOS (+ HORIZPOS 1))
  31.   (add-partially-extended-slot '() right 4)
  32.   (add-carriage-return-slot)
  33.  
  34.   (add-partially-extended-slot '() right 4)
  35.   (set! HORIZPOS (+ HORIZPOS 1))
  36.   (add-partially-extended-slot '() right 4)
  37.   (set! HORIZPOS (+ HORIZPOS 1))
  38.   (add-partially-extended-slot '() right 4)
  39.   (set! HORIZPOS (+ HORIZPOS 1))
  40.   (add-partially-extended-slot '() right 4)
  41.   (add-carriage-return-slot)
  42.  
  43.   (add-partially-extended-slot '() right 4)
  44.   (set! HORIZPOS (+ HORIZPOS 1))
  45.   (add-partially-extended-slot '() right 4)
  46.   (set! HORIZPOS (+ HORIZPOS 1))
  47.   (add-partially-extended-slot '() right 4)
  48.   (set! HORIZPOS (+ HORIZPOS 1))
  49.   (add-partially-extended-slot '() right 4)
  50.   (add-carriage-return-slot)
  51.  
  52.   (add-partially-extended-slot '() right 4)
  53.   (set! HORIZPOS (+ HORIZPOS 1))
  54.   (add-partially-extended-slot '() right 4)
  55.   (set! HORIZPOS (+ HORIZPOS 1))
  56.   (add-partially-extended-slot '() right 4)
  57.   (add-carriage-return-slot)
  58.  
  59.   (deal-cards-face-up-from-deck DECK
  60.    '(0 0 0 0 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4 5 5 5 5 6 6 6 6 7 7 7 7 8 8 8 8 9 9 9 9 10 10 10 10 11 11 11 11 12 12 12 12))
  61.  
  62.   (list 8 4))
  63.  
  64. (define (check-same-value-list card-list)
  65.   (if (< (length card-list) 2)
  66.       #t
  67.       (if (= (get-value (car card-list)) (get-value (cadr card-list)))
  68.           (check-same-value-list (cdr card-list))
  69.           #f)))
  70.  
  71. (define (freeze-slot slot-id)
  72.    (flip-top-card slot-id)
  73.    (add-to-score! 4))
  74.  
  75. (define (button-pressed slot-id card-list)
  76.    (and (check-same-value-list card-list)
  77.         (is-visible? (car card-list))))
  78.  
  79. (define (complete-transaction start-slot card-list end-slot)
  80.   (move-n-cards! start-slot end-slot card-list)
  81.   (if (and (= (length (get-cards end-slot)) 4)
  82.            (check-same-value-list (get-cards end-slot)))
  83.                 (freeze-slot end-slot)) #t)
  84.  
  85. (define (droppable? start-slot card-list end-slot)
  86.   (and (not (= start-slot end-slot))
  87.        (or (empty-slot? end-slot)
  88.            (eq? (get-value (car (get-cards end-slot)))
  89.                 (get-value (car card-list))))
  90.        (< (+ (length (get-cards end-slot)) (length card-list)) 5)))
  91.  
  92. (define (button-released start-slot card-list end-slot)
  93.   (and (droppable? start-slot card-list end-slot)
  94.        (complete-transaction start-slot card-list end-slot)))
  95.  
  96. (define (button-clicked slot-id) #f)
  97.  
  98. (define (button-double-clicked slot) #f)
  99.  
  100. (define (game-over) 
  101.   (and (not (game-won))
  102.        (get-hint)))
  103.  
  104. (define (done-or-empty slot-id)
  105.   (or (empty-slot? slot-id)
  106.       (not (is-visible? (car (get-cards slot-id))))))
  107.  
  108. (define (game-won) 
  109.   (and (done-or-empty 0)
  110.        (done-or-empty 1)
  111.        (done-or-empty 2)
  112.        (done-or-empty 3)
  113.        (done-or-empty 4)
  114.        (done-or-empty 5)
  115.        (done-or-empty 6)
  116.        (done-or-empty 7)
  117.        (done-or-empty 8)
  118.        (done-or-empty 9)
  119.        (done-or-empty 10)
  120.        (done-or-empty 11)
  121.        (done-or-empty 12)
  122.        (done-or-empty 13)
  123.        (done-or-empty 14))
  124. )
  125.  
  126. (define (check-number slot-id)
  127.   (cond ((and (> (length (get-cards slot-id)) 1)
  128.           (not (= (get-value (get-top-card slot-id))
  129.               (get-value (cadr (get-cards slot-id))))))
  130.      1)
  131.     ((and (> (length (get-cards slot-id)) 2)
  132.           (not (= (get-value (get-top-card slot-id))
  133.               (get-value (caddr (get-cards slot-id))))))
  134.      2)
  135.     ((and (> (length (get-cards slot-id)) 3)
  136.           (not (= (get-value (get-top-card slot-id))
  137.               (get-value (cadddr (get-cards slot-id))))))
  138.      3)
  139.     (#t 1)))
  140.  
  141. (define (check-a-slot slot-id number-to-move to-slot)
  142.   (if (> to-slot 14)
  143.       #f
  144.       (if (= slot-id to-slot)
  145.       (check-a-slot slot-id number-to-move (+ 1 to-slot))
  146.       (cond ((empty-slot? slot-id)
  147.          (list 2 (_"something") (_"an empty slot")))
  148.         ((empty-slot? to-slot)
  149.          (list 2 (_"something") (_"an empty slot")))
  150.         ((= 4 (length (get-cards to-slot)))
  151.          (check-a-slot slot-id number-to-move (+ 1 to-slot)))
  152.         ((= (get-value (get-top-card to-slot))
  153.             (get-value (get-top-card slot-id)))
  154.          (if (> number-to-move (- 4 (length (get-cards to-slot))))
  155.              (check-a-slot slot-id 
  156.                    (- number-to-move 
  157.                       (- 4 (length (get-cards to-slot))))
  158.                    (+ 1 to-slot))
  159.              (list 2 (get-name (get-top-card slot-id))
  160.                (get-name (get-top-card to-slot)))))
  161.         (#t (check-a-slot slot-id number-to-move (+ 1 to-slot)))))))
  162.  
  163. (define (check-slots slot-id to-slot)
  164.   (if (> slot-id 14)
  165.       #f
  166.       (or (check-a-slot slot-id (check-number slot-id) to-slot)
  167.       (check-slots (+ 1 slot-id) 0))))
  168.  
  169. (define (get-hint)
  170.   (check-slots 0 1))
  171.  
  172. (define (get-options) #f)
  173.  
  174. (define (apply-options options) #f)
  175.  
  176. (define (timeout) #f)
  177.  
  178. (set-features droppable-feature)
  179.  
  180. (set-lambda new-game button-pressed button-released button-clicked button-double-clicked game-over game-won get-hint get-options apply-options timeout droppable?)
  181.