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

  1. ; AisleRiot - valentine.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.   (add-normal-slot '())
  27.  
  28.   (add-carriage-return-slot)
  29.  
  30.   (add-normal-slot '())
  31.   (add-normal-slot '())
  32.   (add-normal-slot '())
  33.   (add-normal-slot '())
  34.  
  35.   (deal-cards-face-up 0 '(2 3 4 5))
  36.  
  37.   (list 4 2))
  38.  
  39. (define (button-pressed slot-id card-list)
  40.   (and (> slot-id 0)
  41.        (not (empty-slot? slot-id))))
  42.  
  43. (define (droppable? start-slot card-list end-slot)
  44.   (and (not (empty-slot? end-slot))
  45.        (= (get-suit (get-top-card end-slot))
  46.       (get-suit (car card-list)))
  47.        (= (get-value (get-top-card end-slot))
  48.       (+ 1 (get-value (car card-list))))))
  49.  
  50. (define (button-released start-slot card-list end-slot)
  51.   (and (droppable? start-slot card-list end-slot)
  52.        (move-n-cards! start-slot end-slot card-list)))
  53.  
  54. (define (flip-each-card card-list)
  55.   (if (= (length card-list) 1)
  56.       (list (flip-card (car card-list)))
  57.       (cons (flip-card (car card-list)) (flip-each-card (cdr card-list)))))
  58.  
  59. (define (make-all-cards-invisible slot-id)
  60.   (if (< slot-id 6)
  61.       (begin    
  62.     (set-cards! slot-id (flip-each-card (get-cards slot-id)))
  63.     (make-all-cards-invisible (+ 1 slot-id)))
  64.       #t))
  65.  
  66. (define (button-clicked slot-id)
  67.   (cond ((or (> slot-id 0)
  68.          (and (empty-slot? 0)
  69.           (empty-slot? 1)))
  70.      #f)
  71.     ((or (empty-slot? 2)
  72.          (empty-slot? 3)
  73.          (empty-slot? 4)
  74.          (empty-slot? 5))
  75.      (and (or (not (empty-slot? 2))
  76.           (and (not (empty-slot? 1))
  77.                (deal-cards 1 '(2)))
  78.           (deal-cards-face-up 0 '(2)))
  79.           (or (not (empty-slot? 3))
  80.           (and (not (empty-slot? 1))
  81.                (deal-cards 1 '(3)))
  82.           (deal-cards-face-up 0 '(3)))
  83.           (or (not (empty-slot? 4))
  84.           (and (not (empty-slot? 1))
  85.                (deal-cards 1 '(4)))
  86.           (deal-cards-face-up 0 '(4)))
  87.           (or (not (empty-slot? 5))
  88.           (and (not (empty-slot? 1))
  89.                (deal-cards 1 '(5)))
  90.           (deal-cards-face-up 0 '(5)))))
  91.     ((empty-slot? 1)
  92.      (deal-cards-face-up 0 '(1)))
  93.     (#t
  94.      (and (make-all-cards-invisible 2)      
  95.           (set-cards! 0 (append (get-cards slot-id) 
  96.                     (reverse (get-cards 5))
  97.                     (reverse (get-cards 4))
  98.                     (reverse (get-cards 3))
  99.                     (reverse (get-cards 2))))
  100.           (set-cards! 2 '())
  101.           (set-cards! 3 '())
  102.           (set-cards! 4 '())
  103.           (set-cards! 5 '())          
  104.           (deal-cards 1 '(2))
  105.           (deal-cards-face-up 0 '(3 4 5))))))
  106.  
  107. (define (button-double-clicked slot-id)
  108.   #f)
  109.  
  110. (define (game-continuable)
  111.   (not (game-won)))
  112.  
  113. (define (game-won)
  114.   (and (empty-slot? 1)
  115.        (empty-slot? 0)))
  116.  
  117. (define (tableau-move? slot1 slot2)
  118.   (cond ((= slot1 6)
  119.      #f)
  120.     ((or (= slot2 6)
  121.          (empty-slot? slot1))
  122.      (tableau-move? (+ 1 slot1) 2))
  123.     ((and (not (empty-slot? slot2))
  124.           (= (get-suit (get-top-card slot1))
  125.          (get-suit (get-top-card slot2)))
  126.           (= (+ 1 (get-value (get-top-card slot1)))
  127.          (get-value (get-top-card slot2))))
  128.      (list 1 
  129.            (get-name (get-top-card slot1))
  130.            (get-name (get-top-card slot2))))
  131.     (#t (tableau-move? slot1 (+ 1 slot2)))))
  132.  
  133.  
  134. (define (get-hint)
  135.   (or (tableau-move? 1 2)
  136.       (list 0 (_"Deal more cards"))))
  137.  
  138.  
  139.  
  140. (define (get-options) 
  141.   #f)
  142.  
  143. (define (apply-options options) 
  144.   #f)
  145.  
  146. (define (timeout) 
  147.   #f)
  148.  
  149. (set-features droppable-feature scores-disabled)
  150.  
  151. (set-lambda new-game button-pressed button-released button-clicked
  152. button-double-clicked game-continuable game-won get-hint get-options
  153. apply-options timeout droppable?)
  154.