[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-bugs-dist
Subject:    [Bug 91317] Klondike (draw 3) incorrect unwinnable game message
From:       Inge Wallin <inge () lysator ! liu ! se>
Date:       2005-01-07 17:54:28
Message-ID: 20050107175428.3473.qmail () ktown ! kde ! org
[Download RAW message or body]

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
        
http://bugs.kde.org/show_bug.cgi?id=91317        
inge lysator liu se changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED



------- Additional Comments From inge lysator liu se  2005-01-07 18:54 -------
CVS commit by ingwa: 

Fix bug 91317: Klondike (draw 3) incorrect unwinnable game message

BUG: 91317


  M +6 -1      CHANGES   1.18
  M +15 -15    klondike.cpp   1.48


--- kdegames/kpat/CHANGES  #1.17:1.18
 @ -1,6 +1,11  @
 2005-01-07 Inge Wallin <inge lysator liu se>
 
+        Fix bug 91317: Klondike (draw 3) incorrect unwinnable game message
+        - Fix criteria for lost game in klondike.
+
+        ---- CVS commit here ----
+
         Fix bug 96531: KPat: Mod3 incorrect unwinnable game message
-        - mod3.cpp(isGameLost): Fix criteria for lost game.
+        - Fix criteria for lost game in mod3.
 
 2004-11-10 Inge Wallin <inge lysator liu se>

--- kdegames/kpat/klondike.cpp  #1.47:1.48
 @ -351,13 +352,10  @ bool Klondike::isGameLost() const
     kdDebug( 1111 ) << "Is the game lost?" << endl;
 
-    // If we did not even redeal once, and the deck is not empty yet, we cannot
-    // tell what the source pile contains, so we cannot tell whether the game
-    // is lost or not.
-    if ( !redealt && !deck->isEmpty() ) {
-        kdDebug( 1111 ) << "No, we don't know all cards in the pile yet." << endl;
+    if (!deck->isEmpty()) {
+        kdDebug( 1111 ) << "We should only check this when the deck is exhausted." \
<< endl;  return false;
     }
 
-    // Check whether top of the pile can be added to any of the target piles
+    // Check whether top of the pile can be added to any of the target piles.
     if ( !pile->isEmpty() ) {
         for ( int i = 0; i < 4; ++i ) {
 @ -373,18 +371,20  @ bool Klondike::isGameLost() const
     }
 
+    // Create a card list - srcPileCards - that contains all accessible
+    // cards in the pile and the deck.
     CardList srcPileCards;
     if ( EasyRules ) {
         srcPileCards = pile->cards();
-        srcPileCards += deck->cards();
     } else {
-        /* In the draw3 mode, not every card in the source pile is accessible,
-         * but only third one. For the cards in the deck, start from the back
-         * since the cards are in reverse order.
+        /* In the draw3 mode, not every card in the source pile is
+         * accessible, but only every third one.
          */
-        for ( int i = deck->cards().count() - 3; i > 2; i -= 3 ) {
-            srcPileCards += deck->cards()[ i ];
+        for ( unsigned int i = 2; i < pile->cards().count(); i += 3 ) {
+            kdDebug( 1111 ) << "Found card "<< pile->cards()[i]->name()<< endl;
+            srcPileCards += pile->cards()[ i ];
         }
-        if ( !deck->cards().isEmpty() && deck->cards().count() % 3 != 0 ) {
-            srcPileCards += deck->cards()[ 0 ];
+        if ( !pile->cards().isEmpty() && pile->cards().count() % 3 != 0 ) {
+            kdDebug( 1111 ) << "Found last card "<< \
pile->cards()[pile->cards().count() - 1]->name()<< endl; +            srcPileCards += \
pile->cards()[ pile->cards().count() - 1 ];  }
     }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic