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

  1. ; AisleRiot - quatorze.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-blank-slot)
  27.   (add-normal-slot '()) 
  28.   (add-normal-slot '()) 
  29.   (add-normal-slot '()) 
  30.   (add-normal-slot '()) 
  31.   (add-normal-slot '()) 
  32.   (add-carriage-return-slot)
  33.   (add-blank-slot)
  34.   (add-blank-slot)
  35.   (add-normal-slot '()) 
  36.   (add-normal-slot '()) 
  37.   (add-normal-slot '()) 
  38.   (add-normal-slot '()) 
  39.   (add-normal-slot '()) 
  40.   (add-carriage-return-slot)
  41.   (add-blank-slot)
  42.   (add-blank-slot)
  43.   (add-normal-slot '()) 
  44.   (add-normal-slot '()) 
  45.   (add-normal-slot '()) 
  46.   (add-normal-slot '()) 
  47.   (add-normal-slot '()) 
  48.   (add-carriage-return-slot)
  49.   (add-blank-slot)
  50.   (add-blank-slot)
  51.   (add-normal-slot '()) 
  52.   (add-normal-slot '()) 
  53.   (add-normal-slot '()) 
  54.   (add-normal-slot '()) 
  55.   (add-normal-slot '()) 
  56.   (add-carriage-return-slot)
  57.   (add-blank-slot)
  58.   (add-blank-slot)
  59.   (add-normal-slot '()) 
  60.   (add-normal-slot '()) 
  61.   (add-normal-slot '()) 
  62.   (add-normal-slot '()) 
  63.   (add-normal-slot '()) 
  64.   (deal-cards-face-up 0 '(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
  65.                 19 20 21 22 23 24 25))
  66.  
  67.   (give-status-message)
  68.  
  69.   (list 7 5))
  70.  
  71. (define (give-status-message)
  72.   (set-statusbar-message (get-stock-no-string)))
  73.  
  74. (define (get-stock-no-string)
  75.   (string-append (_"Stock left:") " " 
  76.          (number->string (length (get-cards 0)))))
  77.  
  78. (define (button-pressed slot-id card-list)
  79.   (and (not (empty-slot? slot-id))
  80.        (> slot-id 0)))
  81.  
  82. (define (shift-cards slot delta)
  83.   (cond ((or (= slot 26)
  84.          (> (+ slot delta) 25))
  85.      #t)
  86.     ((empty-slot? (+ slot delta))
  87.      (shift-cards slot (+ 1 delta)))
  88.     (#t
  89.      (and (deal-cards (+ slot delta) (list slot))
  90.           (shift-cards (+ 1 slot) delta)))))
  91.  
  92. (define (fill-in start-slot end-slot)
  93.   (if (not (empty-slot? 0))
  94.       (and (deal-cards-face-up 0 (list start-slot))
  95.        (or (and (not (empty-slot? 0))
  96.             (deal-cards-face-up 0 (list end-slot)))
  97.            (shift-cards end-slot 1)))
  98.       (if (< start-slot end-slot)
  99.       (shift-cards start-slot 1)
  100.       (shift-cards end-slot 1))))
  101.  
  102. (define (droppable? start-slot card-list end-slot)
  103.   (and (not (= start-slot end-slot))
  104.        (not (empty-slot? end-slot))
  105.        (> end-slot 0)
  106.        (= 14 (+ (get-value (car card-list))
  107.         (get-value (get-top-card end-slot))))
  108.        (or (= (modulo start-slot 5)
  109.           (modulo end-slot 5))
  110.        (and (< start-slot 6)
  111.         (< end-slot 6))
  112.        (and (> start-slot 5)
  113.         (< start-slot 11)
  114.         (> end-slot 5)
  115.         (< end-slot 11))
  116.        (and (> start-slot 10)
  117.         (< start-slot 16)
  118.         (> end-slot 10)
  119.         (< end-slot 16))
  120.        (and (> start-slot 15)
  121.         (< start-slot 21)
  122.         (> end-slot 15)
  123.         (< end-slot 21))
  124.        (and (> start-slot 20)
  125.         (> end-slot 20)))))
  126.  
  127. (define (button-released start-slot card-list end-slot)
  128.   (and (droppable? start-slot card-list end-slot)
  129.        (add-to-score! 2)
  130.        (remove-card end-slot)
  131.        (fill-in start-slot end-slot)))
  132.  
  133. (define (button-clicked slot-id)
  134.   #f)
  135.  
  136. (define (button-double-clicked slot-id)
  137.   #f)
  138.  
  139. (define (game-continuable)
  140.   (give-status-message)
  141.   (and (not (game-won))
  142.        (get-hint)))
  143.  
  144. (define (game-won)
  145.   (empty-slot? 1))
  146.  
  147. (define (check-row slot1 slot2 buffer)
  148.   (cond ((= slot1 6)
  149.      #f)
  150.     ((or (empty-slot? (+ slot1 buffer))
  151.          (= slot2 6))
  152.      (check-row (+ 1 slot1) (+ 2 slot1) buffer))
  153.     ((and (not (empty-slot? (+ slot2 buffer)))
  154.           (= 14 (+ (get-value (get-top-card (+ slot1 buffer)))
  155.                (get-value (get-top-card (+ slot2 buffer))))))
  156.      (list 1 
  157.            (get-name (get-top-card (+ slot1 buffer)))
  158.            (get-name (get-top-card (+ slot2 buffer)))))
  159.     (#t (check-row slot1 (+ 1 slot2) buffer))))
  160.  
  161. (define (check-horiz)
  162.   (or (check-row 1 2 0)
  163.       (check-row 1 2 5)
  164.       (check-row 1 2 10)
  165.       (check-row 1 2 15)
  166.       (check-row 1 2 20)))
  167.  
  168. (define (check-col slot1 slot2 buffer)
  169.   (cond ((= slot1 26)
  170.      #f)
  171.     ((or (empty-slot? (+ slot1 buffer))
  172.          (= slot2 26))
  173.      (check-col (+ 5 slot1) (+ 10 slot1) buffer))
  174.     ((and (not (empty-slot? (+ slot2 buffer)))
  175.           (= 14 (+ (get-value (get-top-card (+ slot1 buffer)))
  176.                (get-value (get-top-card (+ slot2 buffer))))))
  177.      (list 1 
  178.            (get-name (get-top-card (+ slot1 buffer)))
  179.            (get-name (get-top-card (+ slot2 buffer)))))
  180.     (#t (check-col slot1 (+ 5 slot2) buffer))))
  181.  
  182. (define (check-vert)
  183.   (or (check-col 1 6 0)
  184.       (check-col 1 6 1)
  185.       (check-col 1 6 2)
  186.       (check-col 1 6 3)
  187.       (check-col 1 6 4)))
  188.  
  189. (define (get-hint)
  190.   (or (check-horiz)
  191.       (check-vert)))
  192.  
  193. (define (get-options) 
  194.   #f)
  195.  
  196. (define (apply-options options) 
  197.   #f)
  198.  
  199. (define (timeout) 
  200.   #f)
  201.  
  202. (set-features droppable-feature)
  203.  
  204. (set-lambda new-game button-pressed button-released button-clicked
  205. button-double-clicked game-continuable game-won get-hint get-options
  206. apply-options timeout droppable?)
  207.