-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcharacter create.cpp
375 lines (368 loc) · 6.28 KB
/
character create.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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
//I don't think we're using this
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
#include <string>
using std::string;
#include <time.h>
class item
{
public:
enum type {pocket, hand};
item()
{
item_type = pocket;
empty = 0;
name = "initial";
}
item(type t, bool e, string n)
{
item_type = t;
empty = e;
name = n;
}
bool if_empty()
{
return empty;
}
string console_display_name()
{
return name;
}
private:
type item_type;
bool empty;
string name;
};
item empty_pocket(item::pocket, 1, "empty pocket");
item empty_hand(item::hand, 1, "empty");
item minora(item::hand, 0, "menorah");
item knife(item::hand, 0, "knife");
class character
{
public:
character()
{
hp = 0;
orthodoxy = 0;
strength = 0;
intelligence = 0;
vertical_coordinate = 0;
horizontal_coordinate = 0;
}
character(int h, int o, int s, int i)
{
max_hp = h;
orthodoxy = o;
strength = s;
intelligence = i;
vertical_coordinate = 0;
horizontal_coordinate = 0;
}
void minus_hp(int x)
{
hp -= x;
}
void plus_hp(int x)
{
if (max_hp-hp<x)
{
hp = max_hp;
}
else
{
hp += x;
}
}
void add_inventory_item(item x)
{
for (int i=0; i<4; i++)
{
if (pockets[i].if_empty())
{
pockets[i] = x;
return;
}
}
cout << "Inventory full.\n";
}
void drop_inventory_item()
{
int input;
do
{
cout << "Select an item to drop:\n";
cout << "Pockets:\n";
for (int i=0; i<4; i++)
{
cout << i << ":\t" << pockets[i].console_display_name() << endl;
}
cout << "Hands:\n";
for (int i=0; i<2; i++)
{
cout << i+4 << ":\t" << hands[i].console_display_name() << endl;
}
cout << "6:\tcancel\n";
cin >> input;
}
while (input > 6 || input < 0);
if (input==6)
{
cout << "Cancelled.\n";
return;
}
else if (input < 4)
{
pockets[input] = empty_pocket;
cout << pockets[input].console_display_name() << " dropped!\n";
}
else
{
hands[input-4] = empty_hand;
cout << hands[input-4].console_display_name() << " dropped!\n";
}
return;
}
void pocket_to_hand()
{
int input;
do
{
cout << "Select an item to hold:\n";
cout << "Pockets:\n";
for (int i=0; i<4; i++)
{
cout << i << ":\t" << pockets[i].console_display_name() << endl;
}
cout << "4:\tcancel\n";
cin >> input;
}
while (input>4 || input<0);
if(input==4)
{
cout << "Cancelled.\n";
return;
}
for (int i=0; i<2; i++)
{
if(hands[i].if_empty())
{
hands[i] = pockets[input];
return;
}
}
item temp;
temp = hands[1];
hands[1] = pockets[input];
pockets[input] = hands[1];
}
private:
int max_hp;
int hp;
int orthodoxy;
int strength;
int intelligence;
item pockets[4];
item hands[2];
int vertical_coordinate;
int horizontal_coordinate;
};
class monster
{
public:
monster()
{
}
monster(int h, int a, string n)
{
hp = h;
damage = a;
name = n;
}
void attack(character& PC)
{
int choice;
choice = rand() % 2 + 1;
if(choice==1)
{
cout << name << " attacks!\n";
PC.minus_hp(damage);
}
}
string console_display_name()
{
return name;
}
protected:
int hp;
int damage;
string name;
};
monster vampire_bunny(3, 1, "vampire bunny");
monster goat(5, 2, "goat");
class goat_master : public monster
{
public:
goat_master(int h, int a, string n)
{
hp = h;
damage = a;
name = n;
}
void attack(character& PC)
{
int choice;
choice = rand() % 2 + 1;
if(choice==1)
{
cout << name << " attacks!\n";
PC.minus_hp(damage);
}
if(choice==2)
{
cout << name << " calls a herd of goats to ram you!\n";
PC.minus_hp(damage*3);
}
}
private:
};
goat_master Annie(20, 1, "Annie");
character character_create()
{
int input;
int hp=1, orthodoxy=1, intelligence=1, strength=1;
for (int i=0; i<9; i++)
{
do
{
cout << "Question " << i << ":\n";
if (i==0)
{
cout << "Which of the following are you best at?\n";
cout << "1:\tBleeding for a week without dying\n";
cout << "2:\tLifting a lot of heavy stuff\n";
cout << "3:\tSacrificing pigeons\n";
cout << "4:\tComing up with plans\n";
}
if (i==1)
{
cout << "<Question>\n";
cout << "1:\t<hp>\n";
cout << "2:\t<strength>\n";
cout << "3:\t<orthodoxy>\n";
cout << "4:\t<intelligence>\n";
}
if (i==2)
{
cout << "<Question>\n";
cout << "1:\t<hp>\n";
cout << "2:\t<strength>\n";
cout << "3:\t<orthodoxy>\n";
cout << "4:\t<intelligence>\n";
}
if (i==3)
{
cout << "<Question>\n";
cout << "1:\t<hp>\n";
cout << "2:\t<strength>\n";
cout << "3:\t<orthodoxy>\n";
cout << "4:\t<intelligence>\n";
}
if (i==4)
{
cout << "<Question>\n";
cout << "1:\t<hp>\n";
cout << "2:\t<strength>\n";
cout << "3:\t<orthodoxy>\n";
cout << "4:\t<intelligence>\n";
}
if (i==5)
{
cout << "<Question>\n";
cout << "1:\t<hp>\n";
cout << "2:\t<strength>\n";
cout << "3:\t<orthodoxy>\n";
cout << "4:\t<intelligence>\n";
}
if (i==6)
{
cout << "<Question>\n";
cout << "1:\t<hp>\n";
cout << "2:\t<strength>\n";
cout << "3:\t<orthodoxy>\n";
cout << "4:\t<intelligence>\n";
}
if (i==7)
{
cout << "<Question>\n";
cout << "1:\t<hp>\n";
cout << "2:\t<strength>\n";
cout << "3:\t<orthodoxy>\n";
cout << "4:\t<intelligence>\n";
}
if (i==8)
{
cout << "<Question>\n";
cout << "1:\t<hp>\n";
cout << "2:\t<strength>\n";
cout << "3:\t<orthodoxy>\n";
cout << "4:\t<intelligence>\n";
}
if (i==9)
{
cout << "<Question>\n";
cout << "1:\t<hp>\n";
cout << "2:\t<strength>\n";
cout << "3:\t<orthodoxy>\n";
cout << "4:\t<intelligence>\n";
}
cin >> input;
}
while (input<1 || input>4);
if(input==1)
{
hp++;
}
if(input==2)
{
strength++;
}
if(input==3)
{
orthodoxy++;
}
if(input==4)
{
intelligence++;
}
}
character PC(hp, orthodoxy, strength, intelligence);
return PC;
}
void battle(character& PC, monster& enemy)
{
cout << "You encounter an " << enemy.console_display_name();
}
void main()
{
cout << "Welcome to game\n";
character PC = character_create();
srand(time(0));
int enemy;
enemy = rand() % 3 + 1;
if (enemy==1)
{
battle(PC, vampire_bunny);
}
if (enemy==2)
{
battle(PC, goat);
}
if (enemy==3)
{
battle(PC, Annie);
}
cout << "Exiting game\n";
system("PAUSE");
}