-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPlayer.java
More file actions
376 lines (285 loc) · 8.06 KB
/
Player.java
File metadata and controls
376 lines (285 loc) · 8.06 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
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
376
public class Player {
/*
@Override
public String toString() {
return "Player [name=" + name + ", experience=" + experience
+ ", level=" + level + ", strength=" + strength + ", stamina="
+ stamina + ", speed=" + speed + ", magic=" + magic
+ ", healthMax=" + healthMax + ", health=" + health
+ ", manaMax=" + manaMax + ", mana=" + mana;
}
*/
// Player attributes
protected String name;
protected int experience;
protected int level;
// protected int strength;
// protected int stamina;
// protected int speed;
// protected int magic;
protected int healthMax;
protected int health;
protected int manaMax;
protected int mana;
protected int xPos;
protected int yPos;
protected int width;
protected int height;
// Player class constructor
public Player(String name, int xPos, int yPos, int width, int heigth) {
this.name = name;
this.experience = 0;
this.level = 0;
// total starting == 150; no more than 60 in any starting value
// this.strength = 0;
// this.stamina = 0;
// this.speed = 0;
// this.magic = 0;
// total starting == 100;
this.healthMax = 0;
this.health = this.healthMax;
this.manaMax = 0;
this.mana = this.manaMax;
this.xPos = xPos;
this.yPos = yPos;
this.width = width;
this.height = height;
}
// get methods
public String getName() { return this.name; }
public int getExperience() { return this.experience; }
public int getLevel() { return this.level; }
// public int getStrength() { return this.strength; }
// public int getStamina() { return this.stamina; }
// public int getSpeed() { return this.stamina; }
// public int getMagic() { return this.magic; }
public int getHealthMax() { return this.healthMax; }
public int getHealth() { return this.health; }
public int getManaMax() { return this.manaMax; }
public int getMana() { return this.mana; }
public int getxPos() {
return xPos;
}
public int getyPos() {
return yPos;
}
public int getWidth() {
return width;
}
public int getHeight() {
return height;
}
// TODO set methods
public void setName(String name) { this.name = name; }
public void setExperience(int experience) { this.experience = experience;}
public void setLevel(int level) { this.level = level; }
// public void setStrength(int strength) { this.strength = strength; }
// public void setStamina(int stamina) { this.stamina = stamina; }
// public void setSpeed(int speed) { this.speed = speed; }
// public void setMagic(int magic) { this.magic = magic; }
public void setHealthMax(int healthMax) { this.healthMax = healthMax; }
public void setHealth(int health) { this.health = health; }
public void setManaMax(int manaMax) { this.manaMax = manaMax; }
public void setMana(int mana) { this.mana = mana; }
public void setxPos(int xPos) {
this.xPos = xPos;
}
public void setyPos(int yPos) {
this.yPos = yPos;
}
public void setWidth(int width) {
this.width = width;
}
public void setHeight(int height) {
this.height = height;
}
//General Player action methods
public void sleep() {
System.out.println("You are now asleep.");
}
}
// Character types
class Barbarian extends Player {
// Barbarian class Constructor
public Barbarian(String name, int xPos, int yPos, int width, int height) {
super(name, xPos, yPos, width, height);
this.experience = 0;
this.level = 0;
// this.strength = 60;
// this.stamina = 40;
// this.speed = 35;
// this.magic = 15;
this.healthMax = 80;
this.health = this.healthMax;
this.manaMax = 20;
this.mana = this.manaMax;
}
// Barbarian-specific actions
public void leap() {
// actions should depend on the player's stats
if(this.level >= 2) {
System.out.println("You leaped");
}
else
System.out.println("You must be at least level 2 to use Leap.");
}
}
class Sorcerer extends Player {
// Sorcerer class constructor
public Sorcerer(String name, int xPos, int yPos, int width, int height) {
super(name, xPos, yPos, width, height);
this.experience = 0;
this.level = 0;
// this.strength = 15;
// this.stamina = 40;
// this.speed = 35;
// this.magic = 60;
this.healthMax = 20;
this.health = this.healthMax;
this.manaMax = 80;
this.mana = this.manaMax;
}
// Sorcerer-specific actions
public void bolt() {
if(level >= 2) {
System.out.println("You cast bolt on your enemy.");
// damage dependent on enemy's resistance
// call a method that returns the health of the enemy
}
else
System.out.println("You must be at least level 2 to use Bolt.");
}
}
class Human extends Player {
protected String address;
protected boolean isEmployed;
protected String jobTitle;
protected boolean isMarried;
protected String gender;
protected String religion;
protected int age;
protected int weight;
// Human class constructor
public Human(String name, int xPos, int yPos, int width, int height, String gender, int age, int weight) {
super(name, xPos, yPos, width, height);
this.experience = 0;
this.level = 0;
// this.strength = 15;
// this.stamina = 10;
// this.speed = 10;
// this.magic = 0;
this.healthMax = 40;
this.health = this.healthMax;
this.manaMax = 0;
this.mana = this.manaMax;
this.gender = gender;
this.age = age;
this.height = height;
this.weight = weight;
}
public String getGender() {
return gender;
}
public int getAge() {
return age;
}
public int getWeight() {
return weight;
}
public void setGender(String gender) {
this.gender = gender;
}
public void setAge(int age) {
this.age = age;
}
public void setWeight(int weight) {
this.weight = weight;
}
// methods
public void sleep(){
System.out.println("You are sleeping.");
}
public void eat() {
System.out.println("You ate some food.");
this.weight += 1;
this.health = this.healthMax;
}
}
class Paladin extends Human {
// Paladin class constructor
public Paladin(String name, int xPos, int yPos, int width, int height, String gender, int age, int weight) {
super(name, xPos, yPos, width, height, gender, age, weight);
this.experience = 0;
this.level = 0;
// this.strength = 40;
// this.stamina = 60;
// this.speed = 15;
// this.magic = 35;
this.healthMax = 70;
this.health = this.healthMax;
this.manaMax = 30;
this.mana = this.manaMax;
}
public void heal() {
if(level >= 2) {
System.out.println("You are now healed.");
}
else
System.out.println("You must be at least level 2 to use Heal.");
}
@Override
public void sleep() {
System.out.println("You are now asleep.");
if(this.health <= this.healthMax) { this.health += 5; }
}
// TODO fix constructors and reorder
public void smash() {
if (level >= 3)
System.out.println("You smashed your enemies.");
else
System.out.println("You must be atleast level 3 to use Smash.");
}
}
class Archer extends Human {
public Archer(String name, int xPos, int yPos, int width, int height, String gender, int age, int weight){
super(name, xPos, yPos, width, height, gender, age, weight);
this.experience = 0;
this.level = 0;
// this.strength = 20;
// this.stamina = 20;
// this.speed = 10;
// this.magic = 0;
this.healthMax = 35;
this.health = this.healthMax;
this.manaMax = 0;
this.mana = this.manaMax;
}
public void rangeAttack(){
if(level >= 1){
System.out.println("You shot your bow.");
}
else
System.out.println("You must be atleast level 1 to use Range Attack.");
}
}
class Swordsman extends Human {
public Swordsman(String name, int xPos, int yPos, int width, int height, String gender, int age, int weight){
super(name, xPos, yPos, width, height, gender, age, weight);
this.experience = 0;
this.level = 0;
// this.strength = 30;
// this.stamina = 5;
// this.speed = 10;
// this.magic = 0;
this.healthMax = 50;
this.health = this.healthMax;
this.manaMax = 0;
this.mana = this.manaMax;
}
public void charge(){
if(level >= 3){
System.out.println("You used charge. ");
}
System.out.println("You must atleast level 3 to use charge.");
}
}