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

  1. ; AisleRiot - jamestown.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.   (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 (droppable? start-slot card-list end-slot)
  68.   (and (not (= end-slot 0))
  69.        (not (empty-slot? end-slot))
  70.        (= (get-value (car card-list))
  71.       (get-value (get-top-card end-slot)))))
  72.  
  73. (define (button-released start-slot card-list end-slot)
  74.   (and (droppable? start-slot card-list end-slot)
  75.        (remove-card end-slot)
  76.        (check-for-deal start-slot end-slot)
  77.        (add-to-score! 2)))
  78.  
  79. (define (button-clicked slot-id)
  80.   #f)
  81.  
  82. (define (button-double-clicked slot-id)
  83.   #f)
  84.  
  85. (define (game-continuable)
  86.   (give-status-message)
  87.   (and (not (game-won))
  88.        (get-hint)))
  89.  
  90. (define (game-won)
  91.   (and (empty-slot? 1)
  92.        (empty-slot? 2)
  93.        (empty-slot? 3)
  94.        (empty-slot? 4)
  95.        (empty-slot? 5)
  96.        (empty-slot? 6)
  97.        (empty-slot? 7)
  98.        (empty-slot? 8)
  99.        (empty-slot? 9)))
  100.  
  101. (define (avail-pair? slot1 slot2)
  102.   (cond ((= slot1 9)
  103.      #f)
  104.     ((or (empty-slot? slot1)
  105.          (= slot2 10))
  106.      (avail-pair? (+ 1 slot1) (+ 2 slot1)))
  107.     ((and (not (empty-slot? slot2))
  108.           (= (get-value (get-top-card slot1))
  109.          (get-value (get-top-card slot2))))
  110.      (list 1 
  111.            (get-name (get-top-card slot1)) 
  112.            (get-name (get-top-card slot2))))
  113.     (#t (avail-pair? slot1 (+ 1 slot2)))))
  114.  
  115. (define (get-hint)
  116.   (avail-pair? 1 2))
  117.  
  118. (define (get-options) 
  119.   #f)
  120.  
  121. (define (apply-options options) 
  122.   #f)
  123.  
  124. (define (timeout) 
  125.   #f)
  126.  
  127. (set-features droppable-feature)
  128.  
  129. (set-lambda new-game button-pressed button-released button-clicked
  130. button-double-clicked game-continuable game-won get-hint get-options
  131. apply-options timeout droppable?)
  132.