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

  1. ; AisleRiot - fortunes.scm
  2. ; Copyright (C) 1998, 2003 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.  
  20. (define (new-game)
  21.   (initialize-playing-area)
  22.   (set-ace-high)
  23.   (make-standard-deck)
  24.   (shuffle-deck)
  25.  
  26.   (add-normal-slot DECK)
  27.  
  28.   (add-blank-slot)
  29.   (add-extended-slot '() down)
  30.   (add-extended-slot '() down)
  31.   (add-extended-slot '() down)
  32.   (add-extended-slot '() down)
  33.  
  34.   (give-status-message)
  35.  
  36.   (list 6 3)
  37. )
  38.  
  39. (define (give-status-message)
  40.   (set-statusbar-message (get-stock-no-string)))
  41.  
  42. (define (get-stock-no-string)
  43.   (string-append (_"Stock left:") " "
  44.          (number->string (length (get-cards 0)))))
  45.  
  46. (define (button-pressed slot-id card-list)
  47.   (and card-list
  48.        (> slot-id 0)
  49.        (or (empty-slot? 1)
  50.        (empty-slot? 2)
  51.        (empty-slot? 3)
  52.        (empty-slot? 4))))
  53.  
  54. (define (button-released start-slot card-list end-slot)
  55.   (if (= end-slot start-slot)
  56.       (if (= 1 (length card-list))
  57.       (begin
  58.         (move-n-cards! start-slot end-slot card-list)
  59.         (if (button-clicked start-slot)
  60.         #t
  61.         #t))
  62.       #f)
  63.       (if (empty-slot? end-slot)
  64.       (move-n-cards! start-slot end-slot card-list)
  65.       #f)))
  66.  
  67. (define (removable? slot-id reason)
  68.   (if (= slot-id reason)
  69.       (if (= reason 4)
  70.       #f
  71.       (removable? slot-id (+ reason 1)))
  72.       (if (and (not (empty-slot? reason))
  73.            (= (get-suit (get-top-card slot-id))
  74.           (get-suit (get-top-card reason)))
  75.            (< (get-value (get-top-card slot-id))
  76.           (get-value (get-top-card reason))))
  77.       (begin
  78.         (remove-card slot-id)
  79.         (add-to-score! 1))
  80.       (if (= reason 4)
  81.           #f
  82.           (removable? slot-id (+ reason 1))))))
  83.  
  84. (define (button-clicked slot-id)
  85.   (if (empty-slot? slot-id)
  86.       #f
  87.       (if (= slot-id 0)
  88.       (begin 
  89.         (deal-cards 0 '(1 2 3 4))
  90.         (flip-top-card 1)
  91.         (flip-top-card 2)
  92.         (flip-top-card 3)
  93.         (flip-top-card 4))
  94.       (removable? slot-id 1))))
  95.   
  96. (define (button-double-clicked slot)
  97.   (button-clicked slot))     
  98.       
  99. (define (game-won)
  100.   (and (empty-slot? 0)
  101.        (= 1 (length (get-cards 1)))
  102.        (= 1 (length (get-cards 2)))
  103.        (= 1 (length (get-cards 3)))
  104.        (= 1 (length (get-cards 4)))))
  105.      
  106. (define (game-over)
  107.   (give-status-message)
  108.   (not (and (empty-slot? 0)
  109.         (and (not (empty-slot? 1))
  110.              (not (empty-slot? 2))
  111.              (not (empty-slot? 3))
  112.              (not (empty-slot? 4))
  113.              (not (= (get-suit (get-top-card 1))
  114.                  (get-suit (get-top-card 2))))
  115.              (not (= (get-suit (get-top-card 1))
  116.                  (get-suit (get-top-card 3))))        
  117.              (not (= (get-suit (get-top-card 1))
  118.                  (get-suit (get-top-card 4))))
  119.              (not (= (get-suit (get-top-card 2))
  120.                  (get-suit (get-top-card 3))))
  121.              (not (= (get-suit (get-top-card 2))
  122.                  (get-suit (get-top-card 4))))
  123.              (not (= (get-suit (get-top-card 3))
  124.                  (get-suit (get-top-card 4))))))))
  125.  
  126. (define (check-hint slot1 slot2)
  127.   (if (> slot2 4)
  128.       #f
  129.       (if (and (not (empty-slot? slot1))
  130.            (not (empty-slot? slot2))
  131.            (eq? (get-suit (get-top-card slot1))
  132.             (get-suit (get-top-card slot2))))
  133.       (if (< (get-value (get-top-card slot1))
  134.          (get-value (get-top-card slot2)))
  135.           (list 0 (format (_"Move ~a off the board") 
  136.                               (get-name (get-top-card slot1))))
  137.           (list 0 (format (_"Move ~a off the board") 
  138.                               (get-name (get-top-card slot2)))))
  139.       (check-hint slot1 (+ 1 slot2)))))
  140.  
  141. (define (get-hint)
  142.   (or (check-hint 1 2)
  143.       (check-hint 2 3)
  144.       (check-hint 3 4)
  145.       (if (and (or (empty-slot? 1)
  146.            (empty-slot? 2)
  147.            (empty-slot? 3)
  148.            (empty-slot? 4))
  149.            (or (and (not (empty-slot? 1))
  150.             (> (length (get-cards 1)) 1))
  151.            (and (not (empty-slot? 2))
  152.             (> (length (get-cards 2)) 1))
  153.            (and (not (empty-slot? 3))
  154.             (> (length (get-cards 3)) 1))
  155.            (and (not (empty-slot? 4))
  156.             (> (length (get-cards 4)) 1))))
  157.       (list 0 (_"Consider moving something into an empty slot"))
  158.       #f)
  159.       (if (not (empty-slot? 0))
  160.       (list 0 (_"Deal another round"))
  161.       #f)))
  162.  
  163. (define (get-options) #f)
  164.  
  165. (define (apply-options options) #f)
  166.  
  167. (define (timeout) #f)
  168.  
  169. (set-lambda new-game button-pressed button-released button-clicked button-double-clicked game-over game-won get-hint get-options apply-options timeout)
  170.