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

  1. ; AisleRiot - auld_lang_syne.scm
  2. ; Copyright (C) 1999, 2003 Rosanna Yuen <rwsy@mit.edu>
  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.   (set! DECK (make-deck-list-ace-low 2 2 club))
  23.   (shuffle-deck)
  24.  
  25.   (add-normal-slot DECK)
  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-normal-slot '())
  35.   (add-normal-slot '())
  36.   (add-normal-slot '())
  37.   (add-normal-slot '())
  38.   
  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)))
  43.  
  44.   (give-status-message)
  45.  
  46.   (list 6 2)
  47. )
  48.  
  49. (define (give-status-message)
  50.   (set-statusbar-message (get-stock-no-string)))
  51.  
  52. (define (get-stock-no-string)
  53.   (string-append (_"Stock left:") " "
  54.          (number->string (length (get-cards 0)))))
  55.  
  56. (define (button-pressed slot-id card-list)
  57.   (and (not (empty-slot? slot-id))
  58.        (> slot-id 4)))
  59.  
  60. (define (droppable? start-slot card-list end-slot)
  61.   (and (< end-slot 5)
  62.        (> end-slot 0)
  63.        (= (get-value (car card-list))
  64.           (+ 1 (get-value (get-top-card end-slot))))))
  65.  
  66. (define (button-released start-slot card-list end-slot)
  67.   (and (droppable? start-slot card-list end-slot)
  68.        (move-n-cards! start-slot end-slot card-list)
  69.        (add-to-score! 1)))
  70.  
  71. (define (button-clicked slot-id)
  72.   (and (= slot-id 0)
  73.        (not (empty-slot? 0))
  74.        (deal-cards-face-up 0 '(5 6 7 8))))
  75.  
  76. (define (check-end-slot? slot1 slot2)
  77.   (if (and (not (empty-slot? slot1))
  78.        (= (get-value (get-top-card slot1))
  79.           (+ 1 (get-value (get-top-card slot2)))))
  80.       (begin
  81.     (deal-cards slot1 (list slot2))
  82.     (add-to-score! 1))
  83.       (if (< slot2 4)
  84.       (check-end-slot? slot1 (+ 1 slot2))
  85.       #f)))
  86.  
  87. (define (button-double-clicked slot-id)
  88.   (and (> slot-id 4)
  89.        (check-end-slot? slot-id 1)))
  90.  
  91. (define (game-continuable)
  92.   (and (not (game-won))
  93.        (get-hint)))
  94.  
  95. (define (game-won)
  96.   (give-status-message)
  97.   (and (empty-slot? 0)
  98.        (empty-slot? 5)
  99.        (empty-slot? 6)
  100.        (empty-slot? 7)
  101.        (empty-slot? 8)))
  102.  
  103. (define (movable? slot1 slot2)
  104.   (if (= slot1 9)
  105.       #f
  106.       (if (or (= slot2 5)
  107.           (empty-slot? slot1))
  108.       (movable? (+ 1 slot1) 1)
  109.       (if (= (get-value (get-top-card slot1))
  110.          (+ 1 (get-value (get-top-card slot2))))
  111.           (list 1
  112.             (get-name (get-top-card slot1)) 
  113.             (get-name (get-top-card slot2)))
  114.           (movable? slot1 (+ 1 slot2))))))
  115.  
  116. (define (dealable?)
  117.   (and (not (empty-slot? 0))
  118.        (list 0 (_"Deal another round"))))
  119.  
  120. (define (get-hint)
  121.   (or (movable? 5 1)
  122.       (dealable?)))
  123.  
  124. (define (get-options) 
  125.   #f)
  126.  
  127. (define (apply-options options) 
  128.   #f)
  129.  
  130. (define (timeout) 
  131.   #f)
  132.  
  133. (set-features droppable-feature)
  134.  
  135. (set-lambda new-game button-pressed button-released button-clicked
  136. button-double-clicked game-continuable game-won get-hint get-options
  137. apply-options timeout droppable?)
  138.