[aisleriot] Revert "Define new hint functions and deprecate (get-name)."



commit 7e506ea9559a66b6babb6a3087f3b002d26d67c7
Author: Vincent Povirk <madewokherd gmail com>
Date:   Wed Sep 28 04:21:10 2011 -0500

    Revert "Define new hint functions and deprecate (get-name)."
    
    This reverts commit 6a94bec9fa0527f543339d5609d8056a8f4fe88f.
    
    Whoops, we're in a freeze. Sorry about that.

 games/Rules.HOWTO  |    4 +-
 games/klondike.scm |   19 +++++------
 games/sol.scm      |   87 +---------------------------------------------------
 3 files changed, 11 insertions(+), 99 deletions(-)
---
diff --git a/games/Rules.HOWTO b/games/Rules.HOWTO
index 4aa9458..ece4335 100644
--- a/games/Rules.HOWTO
+++ b/games/Rules.HOWTO
@@ -201,7 +201,7 @@ I'll deal with (new-game) later.
 
 (game-continuable) Asks if the game is not stuck (and therefore not lost).
 
-(get-hint) is called when the user requests a hint. It should be created like (list 0 (_"Hint string.")), or (hint-move from-slot card-count to-slot).
+(get-hint) is called when the user requests a hint. The return from hint is in the form of a list.  It seems to be used in two ways. (get-name a-card) is a very useful library function.
 
 Method 0:
 (list 0 "A single sentence.") Perhaps something like _"Deal the next row".
@@ -359,7 +359,7 @@ Quite a few are self explanatory:
 (check-alternating-color-list card-list)
 (check-straight-descending-list card-list) 
 (length card-list)
-(hint-move from-slot card-count to-slot) ; creates a hint for moving cards
+(get-name card)           ; card description as a string
 (set-cards! slot-id card-list) ; puts card-list into the slot "slot-id"
 (make-card value suit)   ; turn a value and a suit into a card
 
diff --git a/games/klondike.scm b/games/klondike.scm
index 64724f9..fdffb4a 100644
--- a/games/klondike.scm
+++ b/games/klondike.scm
@@ -174,7 +174,6 @@
 
 ; Global variables used in searching (keeping it simple):
 
-(define build '())
 (define card #f)
 (define color 0)
 (define suit 0)
@@ -185,29 +184,28 @@
   (and (not (empty-slot? slot-id2))
        (= suit (get-suit (get-top-card slot-id2)))
        (= value (get-value (get-top-card slot-id2)))
-       (hint-move slot-id2 1 slot-id1)))
+       (list 1 (get-name (get-top-card slot-id2)) (get-name card))))
 
 (define (ploppable? slot-id)
   (and (not (empty-slot? slot-id))
        (set! card (get-top-card slot-id))
        (set! suit (get-suit card))
        (set! value (+ (get-value card) 1))
-       (set! slot-id1 slot-id)
        (or-map match? (cons waste tableau))))
 
 (define (is-ace? slot-id)
   (and (not (empty-slot? slot-id))
        (= ace (get-value (get-top-card slot-id)))
-       (hint-move slot-id 1 (find-empty-slot foundation))))
+       (list 2 (get-name (get-top-card slot-id)) (_"an empty slot" ))))
 
 (define (shiftable? slot-id2)
   (and (not (= slot-id2 slot-id1))
        (if (empty-slot? slot-id2)
 	   (and (= value king)
-		(hint-move slot-id1 (length build) slot-id2))
+		(list 2 (get-name card) (_"an empty slot")))
 	   (and (= (get-value (get-top-card slot-id2)) (+ 1 value))
 		(not (= (get-color (get-top-card slot-id2)) color))
-		(hint-move slot-id1 (length build) slot-id2)))))
+		(list 1 (get-name card) (get-name (get-top-card slot-id2)))))))
 
 (define (get-top-build card-list acc)
   (if (or (null? card-list)
@@ -223,8 +221,7 @@
 (define (shiftable-iter slot-id)
   (and (not (empty-slot? slot-id))
        (begin
-         (set! build (get-top-build (get-cards slot-id) '()))
-	 (set! card (car build))
+	 (set! card (car (get-top-build (get-cards slot-id) '())))
 	 (set! color (get-color card))	
 	 (set! value (get-value card))
 	 (set! slot-id1 slot-id)
@@ -235,10 +232,10 @@
 (define (addable? slot-id)
   (if (empty-slot? slot-id)
       (and (= (get-value card) king)
-	   (hint-move waste 1 slot-id))
+	   (list 2 (get-name card) (_"an empty slot" )))
       (and (= (get-value (get-top-card slot-id)) (+ 1 (get-value card)))
 	   (not (= (get-color (get-top-card slot-id)) (get-color card)))
-	   (hint-move waste 1 slot-id))))
+	   (list 1 (get-name card) (get-name (get-top-card slot-id))))))
 
 (define (any-slot-nonempty? slots)
   (if (eq? slots '())
@@ -261,7 +258,7 @@
 			(< FLIP-COUNTER max-redeal))
 		    (not (empty-slot? waste)))
 	       (not (empty-slot? stock))) 
-	   (hint-click stock (_"Deal a new card from the deck")))
+	   (list 0 (_"Deal a new card from the deck")))
 ; FIXME: need to give proper hints for this case too ...
       (and (not (and-map empty-slot? foundation))
            (list 0 (_"Try moving cards down from the foundation")))
diff --git a/games/sol.scm b/games/sol.scm
index 0ccb915..3ae6fd9 100644
--- a/games/sol.scm
+++ b/games/sol.scm
@@ -67,9 +67,7 @@
   (set! IN-GAME #f)
   (set! MOVE '())
   (set-statusbar-message " ")
-  (set! HISTORY '())
-  (set! FOUNDATION-SLOTS '())
-  (set! TABLEAU-SLOTS '()))
+  (set! HISTORY '()))
 
 ; Use this instead of define for variables which determine the state of
 ; the game. i.e. anything that isn't a constant. This is so undo/redo
@@ -373,8 +371,6 @@
   (if (is-black? card) (_"black joker") (_"red joker")))
 
 (define (get-name card)
-  ; Do not use this function directly. To create a hint for moving a card or
-  ; stack of cards, use (hint-move).
   (let ((value (get-value card)) (suit (get-suit card)))
     (if (is-joker? card)
         (get-joker-name card)
@@ -440,82 +436,6 @@
                      (#t (_"the unknown card"))))
               (#t (_"the unknown card"))))))
 
-(define (hint-get-dest-format to-slot)
-  (if (empty-slot? to-slot)
-      (cond ((member to-slot FOUNDATION-SLOTS) (if (= (length FOUNDATION-SLOTS) 1) (_"Move ~a onto the foundation.") (_"Move ~a onto an empty foundation slot.")))
-            ((member to-slot TABLEAU-SLOTS) (if (= (length TABLEAU-SLOTS) 1) (_"Move ~a onto the tableau.") (_"Move ~a onto an empty tableau slot.")))
-            (else (_"Move ~a onto an empty slot.")))
-      (let* ((card (get-top-card to-slot)) (value (get-value card)) (suit (get-suit card)))
-             (cond ((is-joker? card)
-                    (if (is-black? card) (_"Move ~a onto the black joker.") (_"Move ~a onto the red joker.")))
-                   ((eq? suit club) 
-                    (cond ((eq? value ace) (_"Move ~a onto the ace of clubs."))
-                          ((eq? value 2) (_"Move ~a onto the two of clubs."))
-                          ((eq? value 3) (_"Move ~a onto the three of clubs."))
-                          ((eq? value 4) (_"Move ~a onto the four of clubs."))
-                          ((eq? value 5) (_"Move ~a onto the five of clubs."))
-                          ((eq? value 6) (_"Move ~a onto the six of clubs."))
-                          ((eq? value 7) (_"Move ~a onto the seven of clubs."))
-                          ((eq? value 8) (_"Move ~a onto the eight of clubs."))
-                          ((eq? value 9) (_"Move ~a onto the nine of clubs."))
-                          ((eq? value 10) (_"Move ~a onto the ten of clubs."))
-                          ((eq? value jack) (_"Move ~a onto the jack of clubs."))
-                          ((eq? value queen) (_"Move ~a onto the queen of clubs."))
-                          ((eq? value king) (_"Move ~a onto the king of clubs."))
-                          (#t (_"Move ~a onto the unknown card."))))
-                   ((eq? suit spade) 
-                    (cond ((eq? value ace) (_"Move ~a onto the ace of spades."))
-                          ((eq? value 2) (_"Move ~a onto the two of spades."))
-                          ((eq? value 3) (_"Move ~a onto the three of spades."))
-                          ((eq? value 4) (_"Move ~a onto the four of spades."))
-                          ((eq? value 5) (_"Move ~a onto the five of spades."))
-                          ((eq? value 6) (_"Move ~a onto the six of spades."))
-                          ((eq? value 7) (_"Move ~a onto the seven of spades."))
-                          ((eq? value 8) (_"Move ~a onto the eight of spades."))
-                          ((eq? value 9) (_"Move ~a onto the nine of spades."))
-                          ((eq? value 10) (_"Move ~a onto the ten of spades."))
-                          ((eq? value jack) (_"Move ~a onto the jack of spades."))
-                          ((eq? value queen) (_"Move ~a onto the queen of spades."))
-                          ((eq? value king) (_"Move ~a onto the king of spades."))
-                          (#t (_"Move ~a onto the unknown card."))))
-                   ((eq? suit heart) 
-                    (cond ((eq? value ace) (_"Move ~a onto the ace of hearts."))
-                          ((eq? value 2) (_"Move ~a onto the two of hearts."))
-                          ((eq? value 3) (_"Move ~a onto the three of hearts."))
-                          ((eq? value 4) (_"Move ~a onto the four of hearts."))
-                          ((eq? value 5) (_"Move ~a onto the five of hearts."))
-                          ((eq? value 6) (_"Move ~a onto the six of hearts."))
-                          ((eq? value 7) (_"Move ~a onto the seven of hearts."))
-                          ((eq? value 8) (_"Move ~a onto the eight of hearts."))
-                          ((eq? value 9) (_"Move ~a onto the nine of hearts."))
-                          ((eq? value 10) (_"Move ~a onto the ten of hearts."))
-                          ((eq? value jack) (_"Move ~a onto the jack of hearts."))
-                          ((eq? value queen) (_"Move ~a onto the queen of hearts."))
-                          ((eq? value king) (_"Move ~a onto the king of hearts."))
-                          (#t (_"Move ~a onto the unknown card."))))
-                   ((eq? suit diamond) 
-                    (cond ((eq? value ace) (_"Move ~a onto the ace of diamonds."))
-                          ((eq? value 2) (_"Move ~a onto the two of diamonds."))
-                          ((eq? value 3) (_"Move ~a onto the three of diamonds."))
-                          ((eq? value 4) (_"Move ~a onto the four of diamonds."))
-                          ((eq? value 5) (_"Move ~a onto the five of diamonds."))
-                          ((eq? value 6) (_"Move ~a onto the six of diamonds."))
-                          ((eq? value 7) (_"Move ~a onto the seven of diamonds."))
-                          ((eq? value 8) (_"Move ~a onto the eight of diamonds."))
-                          ((eq? value 9) (_"Move ~a onto the nine of diamonds."))
-                          ((eq? value 10) (_"Move ~a onto the ten of diamonds."))
-                          ((eq? value jack) (_"Move ~a onto the jack of diamonds."))
-                          ((eq? value queen) (_"Move ~a onto the queen of diamonds."))
-                          ((eq? value king) (_"Move ~a onto the king of diamonds."))
-                          (#t (_"Move ~a onto the unknown card."))))
-                   (#t (_"Move ~a onto the unknown card."))))))
-
-(define (hint-move from-slot from-slot-count to-slot)
-  (list 0 (format (hint-get-dest-format to-slot) (get-name (get-nth-card from-slot from-slot-count)))))
-
-(define (hint-click slot-id hint-string)
-  (list 0 hint-string))
-
 (define (move-n-cards! start-slot end-slot cards)
   (add-cards! end-slot cards))
 
@@ -571,9 +491,6 @@
   (list #f deck placement (if (null? type) 'unknown (car type))))
 
 (define (set-tag! slot)
-  (case (cadddr slot)
-    ((tableau) (set! TABLEAU-SLOTS (cons SLOTS TABLEAU-SLOTS)))
-    ((foundation) (set! FOUNDATION-SLOTS (cons SLOTS FOUNDATION-SLOTS))))
   (set! SLOTS (+ 1 SLOTS))
   (cons (- SLOTS 1) (cdr slot)))
 
@@ -610,8 +527,6 @@
 (define HISTORY '())
 (define FUTURE '())
 (define IN-GAME #f)
-(define FOUNDATION-SLOTS '())
-(define TABLEAU-SLOTS '())
 
 ; called from C:
 (define (start-game)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]