-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMonster.java
More file actions
58 lines (46 loc) · 1.29 KB
/
Monster.java
File metadata and controls
58 lines (46 loc) · 1.29 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
public class Monster implements BattleReady{
private String name;
private int health;
private int level;
public Monster(String name, int level) {
this.name = name;
this.health = 100*level;
this.level = level;
}
public int getLevel() {
return this.level;
}
@Override
public int getHealth() {
return this.health;
}
@Override
public String getName() {
return this.name;
}
public void setHealth(int health) {
this.health = health;
}
@Override
public boolean takeDamage(int amount) {
health -= amount;
if (health < 1) {
return false;
}
return true;
}
@Override
public int attack() {
return (int)((Math.random() * 100 * this.level)/3);
}
public int rewardExperience(){
return this.level*25;
}
public Inventory rewardPotions(){
int smallPotions = (int)(this.level-Math.random()*this.level/6);
int mediumPotions = (int)(this.level-Math.random()*this.level/2);
int largePotions = (int)((this.level-this.level/2)-Math.random()*(this.level-this.level/2));
Inventory inventory = new Inventory(smallPotions, mediumPotions, largePotions);
return inventory;
}
}