-
Notifications
You must be signed in to change notification settings - Fork 0
/
class.game.cpp
299 lines (267 loc) · 5.77 KB
/
class.game.cpp
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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
#include "class.game.hpp"
#include "class.display.hpp"
Game::Game()
{
PlayerLL p;
Wheel w;
Puzzle z;
Display d;
players = p;
display = d;
wheel = w;
puzzle = z;
}
Game::Game(PlayerLL p, Wheel w)
{
Puzzle z;
Display d;
puzzle = z;
display = d;
players = p;
wheel = w;
}
Game::Game(PlayerLL p, Wheel w, Puzzle z)
{
Display d;
display = d;
players = p;
wheel = w;
puzzle = z;
}
int Game::spin()
{
return wheel.spin();
}
void Game::solvePuzzle()
{
string answer = puzzle.getAnswer();
char buffer[100];
display.text("YOU HAVE 30 SECONDS TO SOLVE THE PUZZLE!");
display.text(puzzle.display() + "\n");
display.pause(30);
cin >> buffer;
string attempt = buffer;
if(puzzle.toUpper(attempt) == answer)
{
display.text("Correct");
}
else
{
display.text("Incorrect");
display.text(puzzle.toUpper(attempt));
display.text(answer);
}
display.pause(60);
display.text(attempt);
display.text(answer);
// if()
}
int Game::end()
{
display.clear();
display.pause(1);
display.banner(4);
display.pause(1);
return 0;
}
int Game::start()
{
//Displaying Game Banner;
display.banner(1);
display.millipause(2);
display.banner(6);
display.wait();
//Inserting Cards into Wheel
wheel.insertCardAtHead(MONEY,900);
wheel.insertCardAtHead(MONEY,500);
wheel.insertCardAtHead(MONEY,650);
wheel.insertCardAtHead(MONEY,500);
wheel.insertCardAtHead(MONEY,800);
wheel.insertCardAtHead(SKIP);
wheel.insertCardAtHead(MONEY, 700);
wheel.insertCardAtHead(MONEY, 850);
wheel.insertCardAtHead(MONEY, 650);
wheel.insertCardAtHead(BANKRUPT);
wheel.insertCardAtHead(MONEY, 600);
wheel.insertCardAtHead(MONEY, 500);
wheel.insertCardAtHead(MONEY, 550);
wheel.insertCardAtHead(MONEY, 600);
wheel.insertCardAtHead(BANKRUPT);
wheel.insertCardAtHead(MONEY, 700);
wheel.insertCardAtHead(MONEY, 500);
wheel.insertCardAtHead(MONEY, 650);
wheel.insertCardAtHead(MONEY, 600);
wheel.insertCardAtHead(MONEY, 700);
wheel.insertCardAtHead(MONEY, 600);
wheel.insertCardAtHead(SKIP);
wheel.insertCardAtHead(MONEY, 2500);
wheel.insertCardAtHead(BANKRUPT);
wheel.circular();
// wheel.display();
players.insertPlayerAtHead("Patrick");
players.insertPlayerAtHead("Dymond");
players.insertPlayerAtHead("Michael");
players.insertPlayerAtHead("Brianna");
players.circular();
// players.display();
puzzle.setPuzzle("question","answer");
// cout << puzzle.display() << " " << puzzle.getQuestion() << " " << puzzle.getAnswer() << endl;
return 0;
}
void Game::pickConsonant()
{
string a;
cin >> a;
if(puzzle.isConsonant(a.at(0)))
{
if(!puzzle.inCache(a.at(0)))
{
puzzle.enterLetter(a.at(0));
players.player()->deposit(wheel.card()->getValue() * puzzle.letterCount(a.at(0)));
}
else {
display.text("Letter Has already been entered; Enter another vowel");
pickConsonant();
}
}
else
{
display.text("Letter is not a Consonant. Enter a Consonant");
pickConsonant();
}
}
/*
This function is reliant on int Game::options(Player*) for input to decide what actions a player can and cannot do
*/
int Game::action(int choice)
{
cout << "Choice: " << choice << endl;
bool loop = true;
while(loop)
{
loop = false;
switch(choice)
{
case 1: // 1. Buy Vowel
if(players.player()->balance() >= 250)
{
buyVowel();
}
else
{
display.text("Unavailable Option, please enter again");
display.text("1");
cin >> choice;
loop = true;
}
break;
case 2: // 2. Pick Consonant
if (wheel.getSpun())
{
pickConsonant();
}
else
{
display.text("Unavailable Option, please enter again");
display.text("2");
cin >> choice;
loop = true;
}
break;
case 3: // 3. Solve
if(!(puzzle.getCache()==""))
{
solvePuzzle();
}
else
{
display.text("Unavailable Option, please enter again");
display.text("3");
cin >> choice;
loop = true;
}
break;
case 4: // 4. Spin Wheel
if(true)
{
wheel.spin();
display.spinning();
display.card(wheel.card());
display.text("Hit Enter to continue");
// display.pause(3);
display.wait();
// game.decide();
}
else
{
display.text("Unavailable Option, please enter again");
display.text("4");
cin >> choice;
loop = true;
}
break;
default:
display.text("Unavailable Option, please enter again");
display.text("default");
cin >> choice;
loop = true;
break;
}
}
return 0;
}
void Game::buyVowel()
{
string a;
cin >> a;
if(puzzle.isVowel(a.at(0)))
{
if(!puzzle.inCache(a.at(0)))
{
puzzle.enterLetter(a.at(0));
players.player()->setMoney(players.player()->balance() - 250);
}
else {
display.text("Letter Has already been entered; Enter another vowel");
buyVowel();
}
}
else
{
display.text("Letter is not a Vowel. Enter a vowel");
buyVowel();
}
}
int Game::options(Player* p)
{
int choice;
display.text("OPTIONS: [✓ = Available, x = Not Available]");
(p->balance() >= 250) ? (display.text("✓ 1. Buy Vowel [$250]")):(display.text("x 1. Buy Vowel [$250]"));
(wheel.getSpun()) ? (display.text("✓ 2. Pick Consonant")): (display.text("x 2. Pick Consonant"));
(!(puzzle.getCache()=="")) ? (display.text("✓ 3. Solve")) : (display.text("x 3. Solve"));
(1)/*You can always spin*/ ? (display.text("✓ 4. Spin Wheel\n")) : (display.text("x 4. Spin Wheel\n"));
display.text("ENTER AN OPTION: ");
cin >> choice;
return choice;
}
int Game::round(int round)
{
display.clear();
display.displayRound(round);
display.pause(3);
// display.clear();
display.player(players.player());
display.card(wheel.card());
display.puzzle(puzzle);
action(options(players.player()));
// puzzle.enterLetter();
return 0;
}
#ifdef UNIT_TEST_GAME
int main()
{
Game game;
game.start();
return 0;
}
#endif