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

  1. ; AisleRiot - fortress.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.   (set-ace-low)
  22.   (make-standard-deck)
  23.   (shuffle-deck)
  24.  
  25.   (add-extended-slot '() right)
  26.  
  27.   (add-blank-slot)
  28.   (add-blank-slot)
  29.   (add-blank-slot)
  30.   (add-blank-slot)
  31.   (add-blank-slot)
  32.   (add-extended-slot '() right)
  33.  
  34.   (add-carriage-return-slot)
  35.  
  36.   (add-extended-slot '() right)
  37.   (add-blank-slot)
  38.   (add-blank-slot)
  39.   (add-blank-slot)
  40.   (add-normal-slot DECK)
  41.   (add-blank-slot)
  42.   (add-extended-slot '() right)
  43.  
  44.   (add-carriage-return-slot)
  45.  
  46.   (add-extended-slot '() right)
  47.   (add-blank-slot)
  48.   (add-blank-slot)
  49.   (add-blank-slot)
  50.   (add-normal-slot '())
  51.   (add-blank-slot)
  52.   (add-extended-slot '() right)
  53.  
  54.   (add-carriage-return-slot)
  55.  
  56.   (add-extended-slot '() right)
  57.   (add-blank-slot)
  58.   (add-blank-slot)
  59.   (add-blank-slot)
  60.   (add-normal-slot '())
  61.   (add-blank-slot)
  62.   (add-extended-slot '() right)
  63.   (add-carriage-return-slot)
  64.  
  65.   (add-extended-slot '() right)
  66.   (add-blank-slot)
  67.   (add-blank-slot)
  68.   (add-blank-slot)
  69.   (add-normal-slot '())
  70.   (add-blank-slot)
  71.   (add-extended-slot '() right)
  72.  
  73.   (deal-cards-face-up 3 '(0 2 5 8 11 1 4 7 10 13 0 2 5 8 11 1 4 7 10 13 0 2 5 8 11 1 4 7 10 13 0 2 5 8 11 1 4 7 10 13 0 2 5 8 11 1 4 7 10 13 0 1))
  74.  
  75.   (list 10 5))
  76.  
  77. (define (button-pressed slot-id card-list)
  78.   (and (not (empty-slot? slot-id))
  79.        (not (= slot-id 3))
  80.        (not (= slot-id 6))
  81.        (not (= slot-id 9))
  82.        (not (= slot-id 12))
  83.        (= (length card-list) 1)))
  84.  
  85. (define (droppable? start-slot card-list end-slot)
  86.   (cond ((= start-slot end-slot) #f)
  87.         ((member end-slot '(3 6 9 12))
  88.      (and (or (and (empty-slot? end-slot)
  89.                (= (get-value (car card-list)) ace))
  90.           (and (not (empty-slot? end-slot))
  91.                (= (get-suit (get-top-card end-slot))
  92.               (get-suit (car card-list)))
  93.                (= (get-value (car card-list))
  94.               (+ 1 (get-value (get-top-card end-slot))))))))
  95.     (#t
  96.      (or (empty-slot? end-slot)
  97.          (and (= (get-suit (get-top-card end-slot))
  98.              (get-suit (car card-list)))
  99.           (or (= (get-value (get-top-card end-slot))
  100.              (+ 1 (get-value (car card-list))))
  101.               (= (+ 1 (get-value (get-top-card end-slot)))
  102.              (get-value (car card-list)))))))))
  103.  
  104. (define (button-released start-slot card-list end-slot)
  105.   (and (droppable? start-slot card-list end-slot)
  106.        (move-n-cards! start-slot end-slot card-list)
  107.        (or (not (member end-slot '(3 6 9 12)))
  108.            (add-to-score! 1))))
  109.  
  110. (define (button-clicked slot-id)
  111.   #f)
  112.  
  113. (define (move-to-foundation slot f-slot)
  114.   (cond ((= f-slot 15)
  115.      #f)
  116.     ((and (empty-slot? f-slot)
  117.           (= (get-value (get-top-card slot)) ace))
  118.      (and (deal-cards slot (list f-slot))
  119.           (add-to-score! 1)))
  120.     ((and (not (empty-slot? f-slot))
  121.           (= (get-suit (get-top-card f-slot))
  122.          (get-suit (get-top-card slot)))
  123.           (= (+ 1 (get-value (get-top-card f-slot)))
  124.          (get-value (get-top-card slot))))
  125.      (and (deal-cards slot (list f-slot))
  126.           (add-to-score! 1)))
  127.     (#t (move-to-foundation slot (+ 3 f-slot)))))
  128.  
  129. (define (button-double-clicked slot-id)
  130.   (and (not (empty-slot? slot-id))
  131.        (or (= slot-id 0)
  132.        (not (= (modulo slot-id 3) 0)))
  133.        (move-to-foundation slot-id 3)))
  134.  
  135. (define (game-continuable)
  136.   (and (not (game-won))
  137.        (get-hint)))
  138.  
  139. (define (game-won)
  140.   (and (empty-slot? 0)
  141.        (empty-slot? 1)
  142.        (empty-slot? 2)
  143.        (empty-slot? 4)
  144.        (empty-slot? 5)
  145.        (empty-slot? 7)
  146.        (empty-slot? 8)
  147.        (empty-slot? 10)
  148.        (empty-slot? 11)
  149.        (empty-slot? 13)))
  150.  
  151. (define (to-foundations? slot f-slot)
  152.   (cond ((= slot 14)
  153.      #f)
  154.     ((or (empty-slot? slot)
  155.          (= slot 3)
  156.          (= slot 6)
  157.          (= slot 9)
  158.          (= slot 12)
  159.          (= f-slot 15))
  160.      (to-foundations? (+ 1 slot) 3))
  161.     ((and (empty-slot? f-slot)
  162.           (= (get-value (get-top-card slot))
  163.          ace))
  164.      (list 2
  165.            (get-name (get-top-card slot))
  166.            (_"an empty foundation")))
  167.     ((and (not (empty-slot? f-slot))
  168.           (= (get-suit (get-top-card f-slot))
  169.          (get-suit (get-top-card slot)))
  170.           (= (get-value (get-top-card slot))
  171.          (+ 1 (get-value (get-top-card f-slot)))))
  172.      (list 1
  173.            (get-name (get-top-card slot))
  174.            (get-name (get-top-card f-slot))))
  175.     (#t (to-foundations? slot (+ 3 f-slot)))))
  176.  
  177. (define (to-tableau? slot1 slot2)
  178.   (cond ((= slot1 14)
  179.      #f)
  180.     ((or (empty-slot? slot1)
  181.          (= slot2 14)
  182.          (= slot1 3)
  183.          (= slot1 6)
  184.          (= slot1 9)
  185.          (= slot1 12))
  186.      (to-tableau? (+ 1 slot1) (+ 2 slot1)))
  187.     ((and (not (or (= slot2 3)
  188.                (= slot2 6)
  189.                (= slot2 9)
  190.                (= slot2 12)))
  191.           (not (empty-slot? slot2))
  192.           (= (get-suit (get-top-card slot1))
  193.          (get-suit (get-top-card slot2)))
  194.           (or (= (get-value (get-top-card slot1))
  195.              (+ 1 (get-value (get-top-card slot2))))
  196.           (= (get-value (get-top-card slot2))
  197.              (+ 1 (get-value (get-top-card slot1))))))
  198.      (list 1
  199.            (get-name (get-top-card slot1))
  200.            (get-name (get-top-card slot2))))
  201.     (#t
  202.      (to-tableau? slot1 (+ 1 slot2)))))
  203.  
  204. (define (empties?)
  205.   (and (or (empty-slot? 0)
  206.        (empty-slot? 1)
  207.        (empty-slot? 2)
  208.        (empty-slot? 4)
  209.        (empty-slot? 5)
  210.        (empty-slot? 7)
  211.        (empty-slot? 8)
  212.        (empty-slot? 10)
  213.        (empty-slot? 11)
  214.        (empty-slot? 13))
  215.        (list 0 (_"Move something into the empty Tableau slot"))))
  216.  
  217. (define (get-hint)
  218.   (or (to-foundations? 0 3)
  219.       (to-tableau? 0 1)
  220.       (empties?)))
  221.  
  222. (define (get-options) 
  223.   #f)
  224.  
  225. (define (apply-options options) 
  226.   #f)
  227.  
  228. (define (timeout) 
  229.   #f)
  230.  
  231. (set-features droppable-feature)
  232.  
  233. (set-lambda new-game button-pressed button-released button-clicked
  234. button-double-clicked game-continuable game-won get-hint get-options
  235. apply-options timeout droppable?)
  236.