-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayer.java
More file actions
89 lines (71 loc) · 1.81 KB
/
Player.java
File metadata and controls
89 lines (71 loc) · 1.81 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
import java.util.ArrayList;
public class Player
{
int currentHealth;
int maxHealth;
int speed;
int strength;
ArrayList<Item> inventory;
public Player()
{
maxHealth = 15;
currentHealth = maxHealth;
strength = 1;
inventory = new ArrayList<Item>();
inventory.add(new Weapon("Shortsword", 1, 88));
inventory.add(new Potion("Basic Medicine", 3, 0, 0));
inventory.add(new Potion("Basic Medicine", 3, 0, 0));
}
public ArrayList<Item> getInventory()
{
return inventory;
}
public Item getItem(int x)
{
return inventory.get(x);
}
public void addItem(Item i)//0 means duplicate, 1 means successful
{
inventory.add(i);
}
public boolean isInventoryEmpty()
{
return inventory.isEmpty();
}
public void setHealth(int h)
{
currentHealth = h;
}
public void decrementHealth(int x) //0 means player is dead, 1 means they successfully lost health
{
currentHealth-=x;
}
public void incrementHealth(int x) //0 means player is at max health, 1 means they successfully gained health
{
currentHealth+=x;
}
public int getCurrentHealth()
{
return currentHealth;
}
public int getMaxHealth()
{
return maxHealth;
}
public int getStrength()
{
return strength;
}
public void setStrength(int s)
{
strength = s;
}
public void increaseStrength(int s)
{
strength+=s;
}
public String toString()
{
return "You have " + currentHealth + " out of " + maxHealth + " hearts";
}
}