|
@@ -3,6 +3,7 @@ package io.zipcoder.casino.CardGame.Solitaire;
|
3
|
3
|
import io.zipcoder.casino.CardGame.Card;
|
4
|
4
|
import io.zipcoder.casino.CardGame.CardGame;
|
5
|
5
|
import io.zipcoder.casino.CardGame.Deck;
|
|
6
|
+import io.zipcoder.casino.Casino;
|
6
|
7
|
import io.zipcoder.casino.Console;
|
7
|
8
|
import io.zipcoder.casino.Player;
|
8
|
9
|
|
|
@@ -11,9 +12,7 @@ import java.util.Scanner;
|
11
|
12
|
import java.util.Stack;
|
12
|
13
|
|
13
|
14
|
import static io.zipcoder.casino.CardGame.Card.toCard;
|
14
|
|
-import static io.zipcoder.casino.CardGame.Solitaire.Foundation.allFoundsFull;
|
15
|
|
-import static io.zipcoder.casino.CardGame.Solitaire.Foundation.cheatFoundations;
|
16
|
|
-import static io.zipcoder.casino.CardGame.Solitaire.Foundation.whichSuit;
|
|
15
|
+import static io.zipcoder.casino.CardGame.Solitaire.Foundation.*;
|
17
|
16
|
|
18
|
17
|
public class Solitaire extends CardGame {
|
19
|
18
|
|
|
@@ -21,6 +20,7 @@ public class Solitaire extends CardGame {
|
21
|
20
|
// Solitaire s = new Solitaire(new Player("Bill"));
|
22
|
21
|
// s.start();
|
23
|
22
|
// }
|
|
23
|
+ Casino casino = Casino.getInstance();
|
24
|
24
|
Console console = new Console(System.in, System.out);
|
25
|
25
|
|
26
|
26
|
Scanner in = new Scanner(System.in);
|
|
@@ -33,7 +33,6 @@ public class Solitaire extends CardGame {
|
33
|
33
|
public Tableau[] arrayTabs;
|
34
|
34
|
public static Stack<Card> tempStack = new Stack<>();
|
35
|
35
|
public static Stack<Card> lastStack = null;
|
36
|
|
- public Boolean ifFromWaste = false;
|
37
|
36
|
|
38
|
37
|
public Solitaire(Player player) {
|
39
|
38
|
this.player = player;
|
|
@@ -53,15 +52,24 @@ public class Solitaire extends CardGame {
|
53
|
52
|
|
54
|
53
|
public void start(){
|
55
|
54
|
System.out.println("Welcome");
|
|
55
|
+ help();
|
56
|
56
|
resetDeck();
|
57
|
57
|
wastePile.removeAllElements();
|
58
|
58
|
tempStack.removeAllElements();
|
|
59
|
+ clubStack.removeAllElements();
|
|
60
|
+ diamondStack.removeAllElements();
|
|
61
|
+ spadeStack.removeAllElements();
|
|
62
|
+ heartStack.removeAllElements();
|
59
|
63
|
shuffle();
|
60
|
64
|
deal();
|
61
|
65
|
print();
|
62
|
66
|
takeATurn();
|
63
|
67
|
}
|
64
|
68
|
|
|
69
|
+ public void help(){
|
|
70
|
+ console.println("\n\nInstructions:\n%s\n%s\n%s\n%s\n%s\n%s\n\n","To draw a card, enter \'DRAW\'","To pick up card from draw pile, enter \'P\'","To place card on column, enter column number. If card goes into foundation, enter \'8\'","To pull card down, type in card code (i.e. \'7H\' for Seven of Hearts","To quit, enter \'QUIT\'", "If you need help, just enter 'HELP'");
|
|
71
|
+ }
|
|
72
|
+
|
65
|
73
|
public void shuffle(){
|
66
|
74
|
solitaireDeck.shuffle();
|
67
|
75
|
}
|
|
@@ -113,7 +121,7 @@ public class Solitaire extends CardGame {
|
113
|
121
|
whichSuit(tempStack);
|
114
|
122
|
break;
|
115
|
123
|
default:
|
116
|
|
- System.out.println("Not a valid entry. Try again or press \'E\'");
|
|
124
|
+ System.out.println("Not a valid entry. Try again");
|
117
|
125
|
dropToTab(in.next().charAt(0));
|
118
|
126
|
}
|
119
|
127
|
}
|
|
@@ -164,6 +172,9 @@ public class Solitaire extends CardGame {
|
164
|
172
|
console.println("\nCan't pull from an empty draw pile");
|
165
|
173
|
break;
|
166
|
174
|
}
|
|
175
|
+ case "HELP":
|
|
176
|
+ help();
|
|
177
|
+ break;
|
167
|
178
|
case "QUIT":
|
168
|
179
|
gameOver();
|
169
|
180
|
// case "FOO":
|
|
@@ -219,12 +230,12 @@ public class Solitaire extends CardGame {
|
219
|
230
|
if (Foundation.heartStack.size() == 0){
|
220
|
231
|
System.out.print(" -- \t\t");
|
221
|
232
|
} else {
|
222
|
|
- System.out.print(" " + Foundation.heartStack.peek().toString2() + " \t");
|
|
233
|
+ System.out.print(" " + Foundation.heartStack.peek().toString2() + " \t\t");
|
223
|
234
|
}
|
224
|
235
|
if (Foundation.spadeStack.size() == 0){
|
225
|
236
|
System.out.println(" -- \t\t");
|
226
|
237
|
} else {
|
227
|
|
- System.out.print(" " + Foundation.spadeStack.peek().toString2() + " \t\n");
|
|
238
|
+ System.out.print(" " + Foundation.spadeStack.peek().toString2() + " \t\t\n");
|
228
|
239
|
}
|
229
|
240
|
|
230
|
241
|
int i = 1;
|
|
@@ -236,7 +247,8 @@ public class Solitaire extends CardGame {
|
236
|
247
|
}
|
237
|
248
|
|
238
|
249
|
public Boolean gameOver(){
|
239
|
|
- if(console.getInputString("Are you sure you want to quit?\nEnter Y to quit").equals("Y")) return true;
|
|
250
|
+ casino.chooseGame();
|
|
251
|
+ //if(console.getInputString("Are you sure you want to quit?\nEnter Y to quit").equals("Y")) return true;
|
240
|
252
|
return false;
|
241
|
253
|
}
|
242
|
254
|
|