Bug 131587 - "cannot win this game" message just after start of mod3 game
Summary: "cannot win this game" message just after start of mod3 game
Status: RESOLVED FIXED
Alias: None
Product: kpat
Classification: Applications
Component: general (show other bugs)
Version: 2.2.2
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Stephan Kulow
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-07-31 14:39 UTC by Miroslav Maiksnar
Modified: 2006-09-07 23:04 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
The file linked in the last comment (745.83 KB, image/png)
2006-08-16 13:24 UTC, Inge Wallin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Miroslav Maiksnar 2006-07-31 14:39:38 UTC
Version:           2.2.2 (using KDE 3.5.3, Debian Package 4:3.5.3-1 (testing/unstable))
Compiler:          Target: i486-linux-gnu
OS:                Linux (i686) release 2.6.17-vaio32-1

When i start Mod3 game # 458119981, i imediately got message that i can't win this game, even when i was able to win this particular game.
Comment 1 Inge Wallin 2006-07-31 16:18:52 UTC
It would be great if you could have taken a screenshot. It's kind of difficult to search for which types of moves that it forgets when doing the "cannot win" calculations.
Comment 2 Miroslav Maiksnar 2006-08-01 00:26:57 UTC
Here's actual screenshot of the game: http://download.mixi.cz/mod3-bug.png
Sorry for czech localization, dialog window is just saying that you cannot win this game (showed up imediately after start of game #458119981).
Comment 3 Inge Wallin 2006-08-16 13:24:44 UTC
Created attachment 17390 [details]
The file linked in the last comment
Comment 4 Inge Wallin 2006-08-16 13:26:36 UTC
I can see that it forgets to check for aces in the row below the playing field.
Comment 5 Inge Wallin 2006-09-07 22:58:46 UTC
SVN commit 581887 by ingwa:

Fix bug 131587: "cannot win this game" message just after start of mod3 game

 - Check for aces in the store and not only for empty places.

BUGS: 131587



 M  +6 -0      CHANGES  
 M  +3 -2      mod3.cpp  


--- branches/KDE/3.5/kdegames/kpat/CHANGES #581886:581887
@@ -1,5 +1,11 @@
 2005-06-25 Inge Wallin <inge@lysator.liu.se>
 
+        Fix bug 131587: "cannot win this game" message just after
+                         start of mod3 game
+        - Check for ace at the store in addition to empty
+
+2005-06-25 Inge Wallin <inge@lysator.liu.se>
+
         Code cleaning
         - Rename Card::Value  --> Card::Rank
         - Rename Card::Suites --> Card::Suit
--- branches/KDE/3.5/kdegames/kpat/mod3.cpp #581886:581887
@@ -187,9 +187,10 @@
 
     bool nextTest=false;
 
-    // If there is an empty stack below, the game is not lost.
+    // If there is an empty stack or an ace below, the game is not lost.
     for (col=0; col < 8; col++){
-        if (stack[3][col]->isEmpty())
+        if (stack[3][col]->isEmpty()
+	    || stack[3][col]->at(0)->rank() == Card::Ace)
             return false;
     }
 
Comment 6 Inge Wallin 2006-09-07 23:04:11 UTC
SVN commit 581889 by ingwa:

Fix bug 131587: "cannot win this game" message just after start of mod3 game

Forward port of fix for 3.5 branch.

CCBUGS: 131587



 M  +6 -0      CHANGES  
 M  +9 -3      mod3.cpp  


--- trunk/KDE/kdegames/kpat/CHANGES #581888:581889
@@ -1,5 +1,11 @@
 2005-06-25 Inge Wallin <inge@lysator.liu.se>
 
+        Fix bug 131587: "cannot win this game" message just after
+                         start of mod3 game
+        - Check for ace at the store in addition to empty
+
+2005-06-25 Inge Wallin <inge@lysator.liu.se>
+
         Code cleaning
         - Rename Card::Value  --> Card::Rank
         - Rename Card::Suites --> Card::Suit
--- trunk/KDE/kdegames/kpat/mod3.cpp #581888:581889
@@ -73,6 +73,7 @@
 bool Mod3::checkAdd( int checkIndex, const Pile *c1, const CardList& cl) const
 {
     // kDebug(11111) << "checkAdd " << checkIndex << " " << c1->top()->name() << " " << c1->index() << " " << c1->index() / 10 << endl;
+
     if (checkIndex == 0) {
         Card *c2 = cl.first();
 
@@ -95,11 +96,15 @@
         kDebug(11111) << "+1\n";
 
         return true;
+
     } else if (checkIndex == 1) {
         return c1->isEmpty();
+
     } else if (checkIndex == 2) {
         return cl.first()->rank() == Card::Ace;
-    } else return false;
+
+    } else
+	return false;
 }
 
 
@@ -187,9 +192,10 @@
 
     bool nextTest=false;
 
-    // If there is an empty stack below, the game is not lost.
+    // If there is an empty stack or an ace below, the game is not lost.
     for (col=0; col < 8; col++){
-        if (stack[3][col]->isEmpty())
+        if (stack[3][col]->isEmpty()
+	    || stack[3][col]->at(0)->rank() == Card::Ace)
             return false;
     }