ソースを参照

Merge branch 'master' of demetrm/Casino into working

JenniferChao4 6 年 前
コミット
4e72cf9949

+ 4
- 0
src/main/java/io/zipcoder/casino/CardGame/Solitaire/Foundation.java ファイルの表示

7
 
7
 
8
 import java.util.Stack;
8
 import java.util.Stack;
9
 
9
 
10
+import static io.zipcoder.casino.CardGame.Solitaire.Solitaire.lastStack;
11
+import static io.zipcoder.casino.CardGame.Solitaire.Solitaire.unCover;
12
+
10
 public class Foundation {
13
 public class Foundation {
11
 
14
 
12
     public static Stack<Card> clubStack = new Stack<>();
15
     public static Stack<Card> clubStack = new Stack<>();
71
                 spadeStack.push(tempStackCard.pop());
74
                 spadeStack.push(tempStackCard.pop());
72
             }
75
             }
73
         }
76
         }
77
+        if (lastStack.size() > 0) unCover(lastStack);
74
     }
78
     }
75
 
79
 
76
     public static Boolean allFoundsFull() {
80
     public static Boolean allFoundsFull() {

+ 12
- 0
src/main/java/io/zipcoder/casino/CardGame/Solitaire/Solitaire.java ファイルの表示

84
         for(Tableau tab : arrayTabs) tab.stack.peek().setCovered(false);
84
         for(Tableau tab : arrayTabs) tab.stack.peek().setCovered(false);
85
     }
85
     }
86
 
86
 
87
+    public void refillDeck(){
88
+        if (solitaireDeck.deckOfCards.size()<1){
89
+            while(wastePile.iterator().hasNext())
90
+                solitaireDeck.deckOfCards.push(wastePile.pop());
91
+        }
92
+    }
93
+
87
     public void drawCard(){
94
     public void drawCard(){
88
         wastePile.push(solitaireDeck.draw());
95
         wastePile.push(solitaireDeck.draw());
89
     }
96
     }
146
         if(wastePile.size()>0) System.out.println("\n\nDraw pile: " + wastePile.peek().toString2());
153
         if(wastePile.size()>0) System.out.println("\n\nDraw pile: " + wastePile.peek().toString2());
147
     }
154
     }
148
 
155
 
156
+    public static void unCover(Stack<Card> lastStack){
157
+        if (lastStack.size() > 0 && lastStack.peek().isCovered()) lastStack.peek().setCovered(false);
158
+    }
159
+
149
     //you've got a temp stack. so when you pull a card, show it. if it doesn't go, put it back.
160
     //you've got a temp stack. so when you pull a card, show it. if it doesn't go, put it back.
150
     //fix empty stack exceptions
161
     //fix empty stack exceptions
151
     //draw shouldn't reprint every time. only print top of wastePile
162
     //draw shouldn't reprint every time. only print top of wastePile
191
                         print();
202
                         print();
192
                         break;
203
                         break;
193
                 }
204
                 }
205
+                if (solitaireDeck.deckOfCards.size()<1) refillDeck();
194
             }
206
             }
195
     }
207
     }
196
 
208
 

+ 1
- 4
src/main/java/io/zipcoder/casino/CardGame/Solitaire/Tableau.java ファイルの表示

6
 
6
 
7
 import static io.zipcoder.casino.CardGame.Solitaire.Solitaire.lastStack;
7
 import static io.zipcoder.casino.CardGame.Solitaire.Solitaire.lastStack;
8
 import static io.zipcoder.casino.CardGame.Solitaire.Solitaire.tempStack;
8
 import static io.zipcoder.casino.CardGame.Solitaire.Solitaire.tempStack;
9
+import static io.zipcoder.casino.CardGame.Solitaire.Solitaire.unCover;
9
 
10
 
10
 public class Tableau {
11
 public class Tableau {
11
     //consider making an undo method.
12
     //consider making an undo method.
55
             if (c.getFace().getPrimaryValue() == 13) return true; //primVal of 13 is KING
56
             if (c.getFace().getPrimaryValue() == 13) return true; //primVal of 13 is KING
56
         } return false;
57
         } return false;
57
     }
58
     }
58
-
59
-    private void unCover(Stack<Card> lastStack){
60
-        if (size() > 0 && lastStack.peek().isCovered()) lastStack.peek().setCovered(false);
61
-    }
62
 }
59
 }