-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWoo.java
More file actions
221 lines (152 loc) · 6.44 KB
/
Copy pathWoo.java
File metadata and controls
221 lines (152 loc) · 6.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
public class Woo {
public static int level = 1;
public static int numGames = 0;
public static int pointCtr = 1;
private static Display foo;
private static Values boo;
private static boolean flippedTopher = false;
private static int totalPoints;
//NOTE: display method has methods to find x and y of a letter in the display grid
//flip method
public static void flip(String letter) {
//find the coordinatyes of the letter;
int letterR = foo.findR(letter);
int letterC = foo.findC(letter);
//get new number from boo (values)
int newNumVal = boo.gridVal[letterR][letterC];
pointCtr = newNumVal * pointCtr;
//check to see if you flipped a topher!
if (newNumVal == 0) {
foo.gridDis[letterR][letterC] = "" + newNumVal;
flipAll();
flippedTopher = true;
}
else {
//put the regular newNumVal where the letter was (and thats it)
foo.gridDis[letterR][letterC] = "" + newNumVal;
}
//checks to see if you won
if (pointCtr == boo.product){
flipAll();
foo.printAll(boo.tophersVal, boo.pointsVal);
totalPoints += pointCtr;
System.out.println("you flipped all the 2s and 3s! play another game!");
flippedTopher = true;
}
}
//occurs when you flip a topher or win
//basically just set the gridDis to gridVal
public static void flipAll() {
for (int r = 0; r < 5; r ++){
for (int c = 0; c < 5; c ++){
foo.gridDis[r][c] = "" + boo.gridVal[r][c];
}
}
}
public static void playTurn(){
System.out.println(boo.allNotes);
System.out.println("===================");
System.out.println("Select a letter... Don't run into a topher! ");
String letter = Keyboard.readString().toUpperCase();
System.out.println("===================");
System.out.println("I want to ..... ");
System.out.println("1. Flipppp it!");
System.out.println("2. Take notes!");
System.out.println("3. Break!");
int choice = Keyboard.readInt();
if (choice == 1){
flip(letter);
//flips a 1, 2, or 3
if (flippedTopher == false) {
System.out.println("Here's what your grid looks like after you flipped " + letter + ":\n");
System.out.println("You have " + pointCtr + " point(s) out of " + boo.product + "!");
foo.printAll(boo.tophersVal, boo.pointsVal);
}
else {
if (pointCtr != boo.product){
System.out.println("Oh no! Looks like you flipped a Topher! DX");
System.out.println("STUDY the grid below and be SMARTER next time! :)");
}
System.out.println("total points:" + totalPoints);
foo.printAll(boo.tophersVal, boo.pointsVal);
}
}
else if (choice == 2){
takeNotes(letter);
foo.printAll(boo.tophersVal, boo.pointsVal);
}
else{
flippedTopher = true;
System.out.println("No problem! See ya! Thanks for playing!");
}
}
//====================
public static void takeNotes(String letter){
System.out.println("Please enter your notes for " + letter);
String notes = Keyboard.readString();
boo.allNotes += "\n" + letter + ": " + notes;
}
//====================
public static void instructions() {
String info = "\n{ HOW TO PLAY: }\n";
info += "\nEach turn you will be prompted to have the choice to either flip a tile, make notes on it, or break the game (aka stop playing). Select an option by inputting the corresponding number and pressing ENTER. \n";
info += "\n\n[FLIPPING:]\n";
info += "\t 1) Flipping will reveal the value of that tile. This value can either be a point value or a Topher. \n";
info += "\t HOW TO FLIP: After selecting the option to flip, you will be asked to select the letter of the tile you want to flip. Input this letter and press ENTER. \n";
info += "\n\n[TAKING NOTES:]\n";
info += "\t 2) You can take notes on the tile, meaning you can write whatever you want about it. Most use this section to keep track of which tiles have which potential values. \n";
info += "\t\t Remember: indicate which tile letter you're taking notes for! (Its up to you how you want to go about this.) \n";
info += "\t HOW TO TAKE NOTES: After selecting the option to take notes, you will be asked to take them. Type in whatever note you would like to take on the tile and press ENTER. \n";
info += "\n\n[BREAKING:]\n";
info += "\t 3) If you ever feel like you don't want to play anymore (but let't be real, why would you??), you always have the option of breaking the game to stop playing.";
info += "\t HOW TO BREAK: Simply selecting the option to break the game will cause the game to terminate, so be careful! \n";
System.out.print(info);
}
//===================
public static void newGame() {
String intro = "\n \n *** WELCOME TO TOPHER FLIP! *** \n";
intro += "In this game you will be tested in your skills to see how long you can last without discovering a Topher!\n";
System.out.println(intro);
}
// =========================
public static void main(String[] args){
int wannaPlay = 2;
newGame();
while (wannaPlay != 1) {
//ask if they wanna play
System.out.println("\n\nAre you ready to play??");
System.out.println("1. OH YEAH BRING IT ON!!!");
System.out.println("2. Read the instructions.");
System.out.println("3. Uhh not yet...?");
wannaPlay = Keyboard.readInt();
if (wannaPlay == 2) {
instructions();
}
if (wannaPlay == 3) {
System.out.println("No problem, don't sweat it! Maybe next time when you feel ready to face THE TOPHER.");
break;
}
}
if (wannaPlay == 1) {
System.out.println("how difficult would you like this to be? (1-3)");
int difficulty = Keyboard.readInt();
level = difficulty;
//Display
foo = new Display();
String allNotes = "";
//Value
boo = new Values();
boo.popLineVal(level);
boo.popGridVal();
boo.popTophers();
boo.popPoints();
//================
foo.populate();
foo.printAll(boo.tophersVal, boo.pointsVal);
//================
while (flippedTopher == false) {
playTurn();
}
}
}
}