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

  1. ; AisleRiot - helsinki.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-normal-slot DECK)
  26.  
  27.   (add-carriage-return-slot)
  28.  
  29.   (add-normal-slot '())
  30.   (add-normal-slot '())
  31.   (add-normal-slot '())
  32.   (add-normal-slot '())
  33.   (add-normal-slot '())
  34.  
  35.   (add-carriage-return-slot)
  36.  
  37.   (add-normal-slot '())
  38.   (add-normal-slot '())
  39.   (add-normal-slot '())
  40.   (add-normal-slot '())
  41.   (add-normal-slot '())
  42.  
  43.   (deal-cards-face-up 0 '(1 2 3 4 5 6 7 8 9 10))
  44.  
  45.   (give-status-message)
  46.  
  47.   (list 5 3))
  48.  
  49. (define (give-status-message)
  50.   (set-statusbar-message (string-append (get-stock-no-string))))
  51.  
  52. (define (get-stock-no-string)
  53.   (string-append (_"Stock left:") " " 
  54.          (number->string (length (get-cards 0)))))
  55.  
  56. (define (button-pressed slot-id card-list)
  57.   (and (> slot-id 0)
  58.        (not (empty-slot? slot-id))
  59.        (= (length card-list) 1)
  60.        (not (= (get-value (get-top-card slot-id)) king))))
  61.  
  62. (define (droppable? start-slot card-list end-slot)
  63.   (and (not (empty-slot? end-slot))
  64.        (> end-slot 0)
  65.        (= 13 (+ (get-value (car card-list))
  66.         (get-value (get-top-card end-slot))))))
  67.  
  68. (define (button-released start-slot card-list end-slot)
  69.   (and (droppable? start-slot card-list end-slot)
  70.        (remove-card end-slot)
  71.        (add-to-score! 2)
  72.        (or (empty-slot? 0)
  73.        (deal-cards-face-up 0 (list start-slot)))
  74.        (or (empty-slot? 0)
  75.        (deal-cards-face-up 0 (list end-slot)))))
  76.  
  77. (define (button-clicked slot-id)
  78.   (and (not (empty-slot? slot-id))
  79.        (> slot-id 0)
  80.        (= (get-value (get-top-card slot-id)) king)
  81.        (remove-card slot-id)
  82.        (add-to-score! 1)
  83.        ; This is slightly odd, but the return value is important
  84.        (and (or (empty-slot? 0)
  85.         (deal-cards-face-up 0 (list slot-id)))
  86.         #t)))
  87.  
  88. (define (button-double-clicked slot-id)
  89.   #f)
  90.  
  91. (define (game-continuable)
  92.   (give-status-message)
  93.   (and (not (game-won))
  94.        (get-hint)))
  95.  
  96. (define (game-won)
  97.   (and (empty-slot? 1)
  98.        (empty-slot? 2)
  99.        (empty-slot? 3)
  100.        (empty-slot? 4)
  101.        (empty-slot? 5)
  102.        (empty-slot? 6)
  103.        (empty-slot? 7)
  104.        (empty-slot? 8)
  105.        (empty-slot? 9)
  106.        (empty-slot? 10)))
  107.  
  108. (define (check-for-moves slot1 slot2)
  109.   (cond ((= slot1 11)
  110.      #f)
  111.     ((or (empty-slot? slot1)
  112.          (= slot2 11))
  113.      (check-for-moves (+ 1 slot1) (+ 2 slot1)))
  114.     ((= (get-value (get-top-card slot1)) king)
  115.      (list 2
  116.            (get-name (get-top-card slot1))
  117.            (_"itself")))
  118.     ((and (not (empty-slot? slot2))
  119.           (= 13 (+ (get-value (get-top-card slot1))
  120.                (get-value (get-top-card slot2)))))
  121.      (list 1
  122.            (get-name (get-top-card slot1))
  123.            (get-name (get-top-card slot2))))
  124.     (#t (check-for-moves slot1 (+ 1 slot2)))))
  125.  
  126. (define (get-hint)
  127.   (check-for-moves 1 2))
  128.  
  129. (define (get-options) 
  130.   #f)
  131.  
  132. (define (apply-options options) 
  133.   #f)
  134.  
  135. (define (timeout) 
  136.   #f)
  137.  
  138. (set-features droppable-feature)
  139.  
  140. (set-lambda new-game button-pressed button-released button-clicked
  141. button-double-clicked game-continuable game-won get-hint get-options
  142. apply-options timeout droppable?)
  143.