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

  1. ; AisleRiot - fourteen.scm
  2. ; Copyright (C) 1999 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.   (make-standard-deck)
  23.   (shuffle-deck)
  24.  
  25.   (add-extended-slot '() down)
  26.   (add-extended-slot '() down)
  27.   (add-extended-slot '() down)
  28.   (add-extended-slot '() down)
  29.   (add-extended-slot '() down)
  30.   (add-extended-slot '() down)
  31.  
  32.   (add-carriage-return-slot)
  33.   (set! VERTPOS (+ VERTPOS 0.75))
  34.  
  35.   (add-extended-slot '() down)
  36.   (add-extended-slot '() down)
  37.   (add-extended-slot '() down)
  38.   (add-extended-slot '() down)
  39.   (add-extended-slot '() down)
  40.   (add-extended-slot '() down)
  41.  
  42.   (set! HORIZPOS (+ HORIZPOS 3000))
  43.   (add-normal-slot DECK)
  44.  
  45.   (deal-cards-face-up 12 '(0 1 2 3 4 5 6 7 8 9 10 11))
  46.   (deal-cards-face-up 12 '(0 1 2 3 4 5 6 7 8 9 10 11))
  47.   (deal-cards-face-up 12 '(0 1 2 3 4 5 6 7 8 9 10 11))
  48.   (deal-cards-face-up 12 '(0 1 2 3 4 5 6 7 8 9 10 11))
  49.   (deal-cards-face-up 12 '(0 1 2 3))
  50.  
  51.   (list 6 3)
  52. )
  53.  
  54. (define (button-pressed slot-id card-list)
  55.   (if (and (not (empty-slot? slot-id))
  56.        (= (length card-list) 1))
  57.       #t
  58.       #f))
  59.  
  60. (define (droppable? start-slot card-list end-slot)
  61.   (and (not (empty-slot? end-slot))
  62.        (not (= start-slot end-slot))
  63.        (= 14 (+ (get-value (get-top-card end-slot))
  64.         (get-value (car card-list))))))
  65.  
  66. (define (button-released start-slot card-list end-slot)
  67.   (and (droppable? start-slot card-list end-slot)
  68.        (add-to-score! 2)
  69.        (remove-card end-slot)))
  70.  
  71. (define (button-clicked slot-id)
  72.   #f)
  73.  
  74. (define (button-double-clicked slot-id)
  75.   #f)
  76.  
  77. (define (game-continuable)
  78.   (and (not (game-won))
  79.        (get-hint)))
  80.  
  81. (define (game-won)
  82.   (and (empty-slot? 0)
  83.        (empty-slot? 1)
  84.        (empty-slot? 2)
  85.        (empty-slot? 3)
  86.        (empty-slot? 4)
  87.        (empty-slot? 5)
  88.        (empty-slot? 6)
  89.        (empty-slot? 7)
  90.        (empty-slot? 8)
  91.        (empty-slot? 9)
  92.        (empty-slot? 10)
  93.        (empty-slot? 11)))
  94.  
  95. (define (check-slot slot1 slot2)
  96.   (if (empty-slot? slot1)
  97.       (if (< slot1 10)
  98.       (check-slot (+ 1 slot1) (+ 2 slot1))
  99.       #f)
  100.       (if (or (empty-slot? slot2)
  101.           (not (= 14 (+ (get-value (get-top-card slot1))
  102.                 (get-value (get-top-card slot2))))))
  103.       (if (< slot2 11)
  104.           (check-slot slot1 (+ 1 slot2))
  105.           (if (< slot1 10)
  106.           (check-slot (+ 1 slot1) (+ 2 slot1))
  107.           #f))
  108.       (list 1 
  109.         (get-name (get-top-card slot1)) 
  110.         (get-name (get-top-card slot2))))))
  111.           
  112. (define (get-hint)
  113.   (check-slot 0 1))
  114.  
  115. (define (get-options) 
  116.   #f)
  117.  
  118. (define (apply-options options) 
  119.   #f)
  120.  
  121. (define (timeout) 
  122.   #f)
  123.  
  124. (set-features droppable-feature)
  125.  
  126. (set-lambda new-game button-pressed button-released button-clicked
  127. button-double-clicked game-continuable game-won get-hint get-options
  128. apply-options timeout droppable?)
  129.