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

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