-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayer.java
More file actions
171 lines (123 loc) · 3.08 KB
/
Player.java
File metadata and controls
171 lines (123 loc) · 3.08 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
import java.util.ArrayList;
import java.util.Scanner;
public class Player extends CharacterCreation{
String name;
int health = 100;
int gold = 0;
int attack;
Item equippedItem;
classes classes;
race race;
ArrayList<Item> inventory = new ArrayList<Item>() ; //Inventory of Items
boolean equipped = false;
boolean isDead = false;
public enum classes {
WARRIOR,
MAGE,
THIEF
}
public enum race{
HUMAN,
ELF,
ORC,
DWARF
}
public Player() {
}
public Player(String name) {
super();
this.name = name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void setRace(race race) {
this.race = race;
}
public Player.race getRace() {
return race;
}
public classes getClasses() {
return classes;
}
public void setClasses(classes classes) {
this.classes = classes;
}
public void getInventory() {
System.out.println("+++++++++++++++Inventory+++++++++++++++");
for (int i = 0; i< inventory.size(); i++) {
System.out.println(i +". |"+ inventory.get(i).name + "| Cost: " + inventory.get(i).cost + " Qunatity: " + inventory.get(i).quantity+ " Damage: " + inventory.get(i).damage);
}
}
public void setInventory(ArrayList<Item> inventory) {
this.inventory = inventory;
}
public void Pickup(Places place) {
if (place.item == null) {
System.out.println("No items here!");
}
else {
if(place.item.itemType == place.item.itemType.GOLD) {
this.setGold(place.item.quantity);
}
inventory.add(place.item);
System.out.println("You picked up " + place.item.name);
place.setItem(null);
}
}
/*
* Equip method
*/
public void Equip(Scanner scan, Player player) {
System.out.println("What do you want to equip?");
player.getInventory();
var pick = scan.nextInt();
if (pick <0 |pick>= player.inventory.size()) {
System.out.println("Invalid Option!");
}else {
var e = player.inventory.get(pick);
if (!equipped) {
equippedItem = e;
this.setAttack(equippedItem.damage);
equipped = true;
System.out.println("You equipped " + e.name + " Damage: " + e.damage + "+");
}else if(equipped) {
System.out.println("Item Already Equipped!");
}
}
}
public Item getEquippedItem() {
return equippedItem;
}
public void setEquippedItem(Item equippedItem) {
this.equippedItem = equippedItem;
}
public int getHealth() {
return health;
}
public void Damage (int Damage) {
this.health = health-Damage;
}
public int getAttack() {
return attack;
}
public void setAttack(int attack) {
this.attack = attack;
}
public int getGold() {
return gold;
}
public void setGold(int gold) {
this.gold = gold;
}
public void setHealth(int health) {
this.health = health;
}
@Override
public String toString() {
return "Player [name=" + name + ", classes=" + classes + ", race=" + race + ", inventory=" + inventory + "]";
}
};