[aisleriot] yield: Use hint-move instead of get-name.



commit 2a92a524ffc258654065344c0a54719e113e198f
Author: Vincent Povirk <madewokherd gmail com>
Date:   Fri Jun 29 15:04:38 2012 -0500

    yield: Use hint-move instead of get-name.
    
    For bug 551859.

 games/api.scm   |   10 ++++++----
 games/yield.scm |   16 +++++++++-------
 2 files changed, 15 insertions(+), 11 deletions(-)
---
diff --git a/games/api.scm b/games/api.scm
index 6abcdad..ac21c90 100644
--- a/games/api.scm
+++ b/games/api.scm
@@ -468,8 +468,8 @@
                      (#t (_"the unknown card"))))
               (#t (_"the unknown card"))))))
 
-(define-public (hint-get-dest-format to-slot)
-  (if (empty-slot? to-slot)
+(define (hint-get-dest-format to-slot cards)
+  (if (null? cards)
       (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.")))
             ((member to-slot RESERVE-SLOTS) (if (= (length RESERVE-SLOTS) 1) (_"Move ~a onto the reserve.") (_"Move ~a onto an empty reserve slot.")))
@@ -480,7 +480,7 @@
             ((member to-slot LEFT-SLOTS) (_"Move ~a onto an empty left slot."))
             ((member to-slot RIGHT-SLOTS) (_"Move ~a onto an empty right slot."))
             (else (_"Move ~a onto an empty slot.")))
-      (let* ((card (get-top-card to-slot)) (value (get-value card)) (suit (get-suit card)))
+      (let* ((card (car cards)) (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) 
@@ -546,7 +546,9 @@
                    (#t (_"Move ~a onto the unknown card."))))))
 
 (define-public (hint-move from-slot from-slot-count to-slot)
-  (list 0 (format #f (hint-get-dest-format to-slot) (get-name (get-nth-card from-slot from-slot-count)))))
+  (if (= from-slot to-slot)
+      (list 0 (format #f (hint-get-dest-format to-slot (list-tail (get-cards to-slot) from-slot-count)) (get-name (get-nth-card from-slot from-slot-count))))
+      (list 0 (format #f (hint-get-dest-format to-slot (get-cards to-slot)) (get-name (get-nth-card from-slot from-slot-count))))))
 
 (define-public (hint-click slot-id hint-string)
   (list 0 hint-string))
diff --git a/games/yield.scm b/games/yield.scm
index 8f59ff1..08fa9ed 100644
--- a/games/yield.scm
+++ b/games/yield.scm
@@ -291,6 +291,12 @@
        (empty-slot? 8)
        (empty-slot? 9)))
 
+(define (hint-remove-king suit)
+  (cond ((eq? suit club) (_"Remove the king of clubs."))
+        ((eq? suit diamond) (_"Remove the king of diamonds."))
+        ((eq? suit heart) (_"Remove the king of hearts."))
+        ((eq? suit spade) (_"Remove the king of spades."))))
+
 (define (check-move slot1 slot2)
   (if (or (empty-slot? slot1)
 	  (not (available? slot1 0)))
@@ -298,7 +304,7 @@
 	  (check-move (+ 1 slot1) (+ 2 slot1))
 	  #f)
       (if (= king (get-value (get-top-card slot1)))
-	  (list 2 (get-name (get-top-card slot1)) (_"itself"))
+	  (hint-click slot1 (hint-remove-king (get-suit (get-top-card slot1))))
 	  (if (or (empty-slot? slot2)
 		  (not (available? slot2 0))
 		  (not (= 13 (+ (get-value (get-top-card slot1))
@@ -308,9 +314,7 @@
 		  (if (< slot1 29)
 		      (check-move (+ 1 slot1) (+ 2 slot1))
 		      #f))
-	      (list 1 
-		    (get-name (get-top-card slot1)) 
-		    (get-name (get-top-card slot2)))))))
+	      (hint-move slot1 1 slot2)))))
 
 (define (dealable?)
   (if (not (empty-slot? 0))
@@ -322,9 +326,7 @@
        (> (length (get-cards 2)) 1)
        (= 13 (+ (get-value (get-top-card 2))
 		(get-value (cadr (get-cards 2)))))
-       (list 1
-	     (get-name (get-top-card 2))
-	     (get-name (cadr (get-cards 2))))))
+       (hint-move 2 1 2)))
 
 (define (get-hint)
   (or (check-move 1 2)



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