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

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