-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathPlayer.java
More file actions
160 lines (142 loc) · 4.01 KB
/
Player.java
File metadata and controls
160 lines (142 loc) · 4.01 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
public class Player
{
public static String playerName;
public static int healthPoints = 200;
public static int attackPoints = 10;
public static int defensePoints = 10;
public static int speedPoints = 10;
public Item equWeapon;
public Item armor1;
public Item armor2;
public Player(String name)
{
super();
this.playerName = name;
this.healthPoints = 200;
this.attackPoints = 10;
this.defensePoints = 10;
this.speedPoints = 10;
this.equWeapon = null;
this.armor1 = null;
this.armor2 = null;
}
public static int getHealthPoints() {
return healthPoints;
}
public void setHealthPoints(int healthPoints)
{
this.healthPoints = healthPoints;
}
public static int getAttackPoints() {
return attackPoints;
}
public void setAttackPoints(int attackPoints) {
this.attackPoints = attackPoints;
}
public static int getDefensePoints() {
return defensePoints;
}
public void setDefensePoints(int defensePoints) {
this.defensePoints = defensePoints;
}
public static int getSpeedPoints() {
return speedPoints;
}
public void setSpeedPoints(int speed) {
this.speedPoints = speed;
}
public static String getPlayername() {
return playerName;
}
public void setPlayername(String playerName) {
this.playerName = playerName;
}
public void equipweapon(Item w)
{
if (this.equWeapon == null)
{
this.equWeapon = w;
this.setAttackPoints(this.attackPoints + w.getItemAtk());
this.setSpeedPoints(this.speedPoints + w.getItemSpeed());
}
else
{
System.out.println("This slot is full. Please swap weapon with the new one");
}
}
public void equiparmor1(Item a)
{
if (this.armor1 == null)
{
this.armor1 = a;
this.healthPoints = healthPoints + a.getItemHP();
this.defensePoints = defensePoints + a.getItemDef();
}
else
{
System.out.println("This slot is full. Please swap armor1 with the new one");
}
}
public void equiparmor2(Item b)
{
if (this.armor1 == null)
{
this.armor2 = b;
this.healthPoints = healthPoints + b.getItemHP();
this.defensePoints = defensePoints + b.getItemDef();
}
else
{
System.out.println("This slot is full. Please swap armor2 with the new one");
}
}
public void addItem(Item i)
{
this.addItem(i);
}
public void swapWeapon(Item w)
{
if (this.equWeapon != null && w.weapon == true) //must look later
{
this.attackPoints = this.attackPoints - this.equWeapon.getItemAtk();
this.speedPoints = this.getSpeedPoints() - this.equWeapon.getItemSpeed();
this.equWeapon = w;
this.setAttackPoints(this.attackPoints + this.equWeapon.getItemAtk());
this.setSpeedPoints(this.speedPoints + this.equWeapon.getItemSpeed());
}
else
{
System.out.println("There is no weapon equipped in this slot");
}
}
public void swapArmor1(Item i)
{
if (this.armor1 != null && i.armor == true) //must look later
{
this.defensePoints = defensePoints - this.armor1.getItemDef();
this.healthPoints = healthPoints - this.armor1.getItemHP();
this.armor1 = i;
this.setDefensePoints(this.defensePoints + this.armor1.getItemDef());
this.setHealthPoints(this.healthPoints + this.armor1.getItemHP());
}
else
{
System.out.println("There is no armor equipped in this slot");
}
}
public void swapArmor2(Item i)
{
if (this.armor2 != null && i.armor == true) //must look later
{
this.defensePoints = defensePoints - this.armor2.getItemDef();
this.healthPoints = healthPoints - this.armor2.getItemHP();
this.armor2 = i;
this.setDefensePoints(this.defensePoints + this.armor2.getItemDef());
this.setHealthPoints(this.healthPoints + this.armor2.getItemHP());
}
else
{
System.out.println("There is no armor equipped in this slot");
}
}
}