-
Notifications
You must be signed in to change notification settings - Fork 0
/
InventoryItems.java
114 lines (100 loc) · 2.89 KB
/
InventoryItems.java
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
/*
* -6 Simple helmet (T1);
* -5 Beef
* -4 Raw cow meat
* -3 Turkey Leg
* -2 Plastic Blade
* -1 Hides
*
*/
/* General equip slots --
* 1. Head
* 2. Body
* 3. Necklace
* 4. Weapon
*/
/*
* weird equip slots --
* -1 hpHeal raw food to be cooked
* -2 hpHeal cooked food that can be eaten for more hp
*/
public class InventoryItems {
//Marcy's cat is inventory item number 13.
public String itemName;
public boolean isEquipable;
static Player player;
public int itemNumber;
public int quantity;
public int price;
public Attributes attributes;
public static InventoryItems Turkey_Leg =
new InventoryItems(-3, "Turkey Leg", player, 3, Attributes.t_l);
public static InventoryItems Beef =
new InventoryItems(-4, "Beef", player, 3, Attributes.beef);
public static InventoryItems Hides =
new InventoryItems(-1, "Hides", player, 0, null, 4);
public static InventoryItems Raw_Beef =
new InventoryItems(-5, "Raw beef", player, 0, Attributes.rawBeef, 2);
// public static final InventoryItems HIDES = new InventoryItems(-1, "Hides", player);
public InventoryItems(int mapNumber, String itemName, Player player) {
this.itemName = itemName;
this.player = player;
this.itemNumber = mapNumber;
quantity = 1;
price = 0;
}
public InventoryItems(int mapNumber, String itemName, Player player, int price, Attributes itemAttributes) {
this.itemName = itemName;
this.player = player;
this.itemNumber = mapNumber;
quantity = 1;
this.price = price;
this.attributes = itemAttributes;
}
public InventoryItems(int mapNumber, String itemName, Player player, int price, Attributes itemAttributes,
int quantity) {
this.itemName = itemName;
this.player = player;
this.itemNumber = mapNumber;
this.quantity = quantity;
this.price = price;
this.attributes = itemAttributes;
}
public static String[] invtoString(InventoryItems[] inv) {
String[] returnString = new String[inv.length];
for(int i = 0; i < inv.length; i++) {
returnString[i] = inv[i].itemName;
}
return returnString;
}
// public static String[] itemAttributes(InventoryItems item) {
// switch(item.itemNumber) {
// case(-2): //Plastic_Blade
// String[] attributes = {"5 Attack", "5 Strength"};
// return attributes;
//
// }
//
// return null; // string
// }
public static String equipSlot(int index) {
String[] equipStrings = {"", "Head", "Body", "Necklace", "Weapon"};
return equipStrings[index];
}
public void consume() {
switch(this.attributes.equipSlot) {
case -1:
case -2:
player.health += this.attributes.hpHeal;
int excessHeal1 = 0;
if (player.health > (player.modifiers[3] + 10)) {
excessHeal1 = player.health - (player.modifiers[3] + 10);
player.health = player.modifiers[3] + 10;
}
System.out.printf("%s healed for %d Hitpoints\n",
this.itemName, this.attributes.hpHeal - excessHeal1);
player.removeItem(this, 1);
break;
}
}
}