Sfoglia il codice sorgente

Merge branch 'master' of demetrm/Casino into working

JenniferChao4 6 anni fa
parent
commit
4e72cf9949

+ 4
- 0
src/main/java/io/zipcoder/casino/CardGame/Solitaire/Foundation.java Vedi File

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

+ 12
- 0
src/main/java/io/zipcoder/casino/CardGame/Solitaire/Solitaire.java Vedi File

@@ -84,6 +84,13 @@ public class Solitaire extends CardGame {
84 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 94
     public void drawCard(){
88 95
         wastePile.push(solitaireDeck.draw());
89 96
     }
@@ -146,6 +153,10 @@ public class Solitaire extends CardGame {
146 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 160
     //you've got a temp stack. so when you pull a card, show it. if it doesn't go, put it back.
150 161
     //fix empty stack exceptions
151 162
     //draw shouldn't reprint every time. only print top of wastePile
@@ -191,6 +202,7 @@ public class Solitaire extends CardGame {
191 202
                         print();
192 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 Vedi File

@@ -6,6 +6,7 @@ import java.util.Stack;
6 6
 
7 7
 import static io.zipcoder.casino.CardGame.Solitaire.Solitaire.lastStack;
8 8
 import static io.zipcoder.casino.CardGame.Solitaire.Solitaire.tempStack;
9
+import static io.zipcoder.casino.CardGame.Solitaire.Solitaire.unCover;
9 10
 
10 11
 public class Tableau {
11 12
     //consider making an undo method.
@@ -55,8 +56,4 @@ public class Tableau {
55 56
             if (c.getFace().getPrimaryValue() == 13) return true; //primVal of 13 is KING
56 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
 }