-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreature.java
More file actions
73 lines (66 loc) · 2.37 KB
/
Creature.java
File metadata and controls
73 lines (66 loc) · 2.37 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
package game;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class Creature {
private static Random randWeight = new Random();
public String name;
public int health;
public int atk;
public Armor HEAD_ARMOR;
public Armor CHEST_ARMOR;
public Armor LEG_ARMOR;
public Armor FEET_ARMOR;
public Item ON_HAND;
public Item OFF_HAND;
public List<Armor> isWearing(Creature creature) {
List<Armor> wearing = new ArrayList<Armor>();
wearing.add(HEAD_ARMOR);
wearing.add(CHEST_ARMOR);
wearing.add(LEG_ARMOR);
wearing.add(FEET_ARMOR);
return wearing;
}
public int getIntProtectValue(Creature creature) {
int totalProtectValue = HEAD_ARMOR.protection_value + CHEST_ARMOR.protection_value + LEG_ARMOR.protection_value + FEET_ARMOR.protection_value;
return totalProtectValue;
}
public static Creature generateRandomCreature() {
int wearingArmor = randWeight.nextInt(2);
int somethingInOnHand = randWeight.nextInt(2);
int somethingInOffHand = randWeight.nextInt(2);
int baseHealth = 10;
int baseAtk = 2;
Creature randomCreature = new Creature("Goblin", baseHealth, baseAtk, null, null, null, null, null, null);
if (wearingArmor == 1) {
randomCreature.HEAD_ARMOR = validIDs.iron_helm;
randomCreature.CHEST_ARMOR = validIDs.iron_chest;
randomCreature.LEG_ARMOR = validIDs.iron_leg;
randomCreature.FEET_ARMOR = validIDs.iron_boots;
}
if (somethingInOnHand == 1) {
int weaponListSize = Weapon.weaponList.size();
//int randomWeapon = randWeight.nextInt(weaponListSize + 1);
Weapon randomWeapon = Weapon.weaponList.get(randWeight.nextInt(weaponListSize));
randomCreature.ON_HAND = randomWeapon;
randomCreature.atk = baseAtk + randomWeapon.atkInfluence;
}
if (somethingInOffHand == 1) {
int shieldListSize = Shield.shieldList.size();
int randomShield = randWeight.nextInt(shieldListSize);
randomCreature.OFF_HAND = Shield.shieldList.get(randomShield);
}
return randomCreature;
}
public Creature(String name, int health, int atk, Armor Head, Armor Chest, Armor Leg, Armor Feet, Item ON_HAND, Item OFF_HAND) {
this.name = name;
this.health = health;
this.atk = atk;
this.HEAD_ARMOR = Head;
this.CHEST_ARMOR = Chest;
this.LEG_ARMOR = Leg;
this.FEET_ARMOR = Feet;
this.ON_HAND = ON_HAND;
this.OFF_HAND = OFF_HAND;
}
}