-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAttributes.java
90 lines (82 loc) · 2.93 KB
/
Attributes.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
public class Attributes {
// public InventoryItems associatedItem;
public int attack = 0;
public int strength = 0;
public int defence = 0;
public int hpModifier = 0;
public int hpHeal = 0;
public int equipSlot = 0;
public int quantitySold = 0;
public boolean isEquipable = false;
public int[] attributesArray = new int[6];
public String[] attributesString = {"Attack", "Strength", "Defence", "hpModifier",
"hpHeal"};
public static Attributes t_l = new Attributes(0, 0, 0, 0, 3, -1, 2, false);
public static Attributes rawBeef = new Attributes(0, 0, 0, 0, 1, -2, 1, false);
public static Attributes beef = new Attributes(0, 0, 0, 0, 5, -1, 1, false);
public Attributes(int attack, int strength, int defence,
int hpModifier, int hpHeal, int equipSlot, int quantitySold, boolean isEquip) {
this.attack = attack;
this.strength = strength;
this.defence = defence;
this.hpModifier = hpModifier;
this.hpHeal = hpHeal;
this.equipSlot = equipSlot;
this.quantitySold = quantitySold;
this.isEquipable = isEquip;
this.attributesArray = assignArray(this);
}
public static void printAttributes(Attributes a) {
if(a == null) {
System.out.println("This item has no attributes");
return;
}
if(!(a.attack == 0)) {
System.out.println("Attack Bonus: " + a.attack);
}
if (!(a.strength == 0)) {
System.out.println("Strength Bonus: " + a.strength);
}
if(!(a.defence == 0)) {
System.out.println("Defence Bonus: " + a.defence);
}
if (!(a.hpModifier == 0)) {
System.out.println("Hitpoints Boost: " + a.hpModifier);
}
if (!(a.hpHeal == 0)) {
System.out.println("Heals: " + a.hpHeal);
}
if (!(a.equipSlot == 0)) {
System.out.println("Eqipment Slot: " + InventoryItems.equipSlot(a.equipSlot));
}
}
public static String[] modifierStrings(InventoryItems[] equipment) {
String[] equipmentString = new String[equipment.length];
for (int i = 0; i < equipment.length; i++) {
if(!(equipment[i] == null)) {
equipmentString[i] = "";
if(!(equipment[i].attributes.attack == 0)) {
equipmentString[i] += ("\nAttack Bonus: " + equipment[i].attributes.attack);
}
if (!(equipment[i].attributes.strength == 0)) {
equipmentString[i] += ("\nStrength Bonus: " + equipment[i].attributes.strength);
}
if(!(equipment[i].attributes.defence == 0)) {
equipmentString[i] += ("\nDefence Bonus: " + equipment[i].attributes.defence);
}
if (!(equipment[i].attributes.hpModifier == 0)) {
equipmentString[i] += ("\nHitpoints Boost: " + equipment[i].attributes.hpModifier);
}
if (!(equipment[i].attributes.hpHeal == 0)) {
equipmentString[i] += ("\nHeals: " + equipment[i].attributes.hpHeal);
}
}
}
return equipmentString;
}
public int[] assignArray(Attributes array) {
int[] returnArray = {array.attack, array.strength, array.hpModifier, array.hpHeal,
array.equipSlot, array.quantitySold};
return returnArray;
}
}