|
5 | 5 |
|
6 | 6 | import rescuecore2.standard.entities.Human; |
7 | 7 |
|
| 8 | +import java.util.Random; |
| 9 | + |
8 | 10 | /** |
9 | | - Class for holding information about humans. |
10 | | -*/ |
| 11 | + Class for holding information about humans. |
| 12 | + */ |
11 | 13 | public class HumanAttributes { |
12 | 14 | private Human human; |
13 | 15 | private EntityID id; |
14 | 16 | private DamageType damageFire; |
15 | 17 | private DamageType damageCollapse; |
16 | 18 | private DamageType damageBury; |
| 19 | + private Random random; |
17 | 20 |
|
18 | 21 | /** |
19 | | - Construct a HumanAttributes object that wraps a Human. |
20 | | - @param h The Human to wrap. |
21 | | - @param config The system configuration. |
22 | | - */ |
| 22 | + Construct a HumanAttributes object that wraps a Human. |
| 23 | + @param h The Human to wrap. |
| 24 | + @param config The system configuration. |
| 25 | + */ |
23 | 26 | public HumanAttributes(Human h, Config config) { |
24 | 27 | this.human = h; |
25 | 28 | this.id = h.getID(); |
26 | | - damageFire = new DamageType("fire", config); |
27 | | - damageCollapse = new DamageType("collapse", config); |
28 | | - damageBury = new DamageType("bury", config); |
| 29 | + // Generate Random for each Human |
| 30 | + this.random = new Random(config.getRandom().nextLong()); |
| 31 | + damageFire = new DamageType("fire", config, random); |
| 32 | + damageCollapse = new DamageType("collapse", config, random); |
| 33 | + damageBury = new DamageType("bury", config, random); |
29 | 34 | } |
30 | 35 |
|
31 | 36 | /** |
32 | | - Get the ID of the wrapped human. |
33 | | - @return The human ID. |
34 | | - */ |
| 37 | + Get the ID of the wrapped human. |
| 38 | + @return The human ID. |
| 39 | + */ |
35 | 40 | public EntityID getID() { |
36 | 41 | return id; |
37 | 42 | } |
38 | 43 |
|
39 | 44 | /** |
40 | | - Get the wrapped human. |
41 | | - @return The wrapped human. |
42 | | - */ |
| 45 | + Get the wrapped human. |
| 46 | + @return The wrapped human. |
| 47 | + */ |
43 | 48 | public Human getHuman() { |
44 | 49 | return human; |
45 | 50 | } |
46 | 51 |
|
47 | 52 | /** |
48 | | - Add some collapse damage. |
49 | | - @param d The amount of damage to add. |
50 | | - */ |
| 53 | + Get the random sequence of the wrapped human. |
| 54 | + @return The random sequence. |
| 55 | + */ |
| 56 | + public Random getRandom(){ |
| 57 | + return random; |
| 58 | + } |
| 59 | + /** |
| 60 | + Add some collapse damage. |
| 61 | + @param d The amount of damage to add. |
| 62 | + */ |
51 | 63 | public void addCollapseDamage(double d) { |
52 | 64 | damageCollapse.addDamage(d); |
53 | 65 | } |
54 | 66 |
|
55 | 67 | /** |
56 | | - Get the amount of collapse damage this human has. |
57 | | - @return The amount of collapse damage. |
58 | | - */ |
| 68 | + Get the amount of collapse damage this human has. |
| 69 | + @return The amount of collapse damage. |
| 70 | + */ |
59 | 71 | public double getCollapseDamage() { |
60 | 72 | return damageCollapse.getDamage(); |
61 | 73 | } |
62 | 74 |
|
63 | 75 | /** |
64 | | - Set the amount of collapse damage this human has. |
65 | | - @param d The new collapse damage. |
66 | | - */ |
| 76 | + Set the amount of collapse damage this human has. |
| 77 | + @param d The new collapse damage. |
| 78 | + */ |
67 | 79 | public void setCollapseDamage(double d) { |
68 | 80 | damageCollapse.setDamage(d); |
69 | 81 | } |
70 | 82 |
|
71 | 83 | /** |
72 | | - Add some buriedness damage. |
73 | | - @param d The amount of damage to add. |
74 | | - */ |
| 84 | + Add some buriedness damage. |
| 85 | + @param d The amount of damage to add. |
| 86 | + */ |
75 | 87 | public void addBuriednessDamage(double d) { |
76 | 88 | damageBury.addDamage(d); |
77 | 89 | } |
78 | 90 |
|
79 | 91 | /** |
80 | | - Get the amount of buriedness damage this human has. |
81 | | - @return The amount of buriedness damage. |
82 | | - */ |
| 92 | + Get the amount of buriedness damage this human has. |
| 93 | + @return The amount of buriedness damage. |
| 94 | + */ |
83 | 95 | public double getBuriednessDamage() { |
84 | 96 | return damageBury.getDamage(); |
85 | 97 | } |
86 | 98 |
|
87 | 99 | /** |
88 | | - Set the amount of buriedness damage this human has. |
89 | | - @param d The new buriedness damage. |
90 | | - */ |
| 100 | + Set the amount of buriedness damage this human has. |
| 101 | + @param d The new buriedness damage. |
| 102 | + */ |
91 | 103 | public void setBuriednessDamage(double d) { |
92 | 104 | damageBury.setDamage(d); |
93 | 105 | } |
94 | 106 |
|
95 | 107 | /** |
96 | | - Add some fire damage. |
97 | | - @param d The amount of damage to add. |
98 | | - */ |
| 108 | + Add some fire damage. |
| 109 | + @param d The amount of damage to add. |
| 110 | + */ |
99 | 111 | public void addFireDamage(double d) { |
100 | 112 | damageFire.addDamage(d); |
101 | 113 | } |
102 | 114 |
|
103 | 115 | /** |
104 | | - Get the amount of fire damage this human has. |
105 | | - @return The amount of fire damage. |
106 | | - */ |
| 116 | + Get the amount of fire damage this human has. |
| 117 | + @return The amount of fire damage. |
| 118 | + */ |
107 | 119 | public double getFireDamage() { |
108 | 120 | return damageFire.getDamage(); |
109 | 121 | } |
110 | 122 |
|
111 | 123 | /** |
112 | | - Set the amount of fire damage this human has. |
113 | | - @param d The new fire damage. |
114 | | - */ |
| 124 | + Set the amount of fire damage this human has. |
| 125 | + @param d The new fire damage. |
| 126 | + */ |
115 | 127 | public void setFireDamage(double d) { |
116 | 128 | damageFire.setDamage(d); |
117 | 129 | } |
118 | 130 |
|
119 | 131 | /** |
120 | | - Get the total damage of this human, rounded to the nearest integer. |
121 | | - @return The total damage. |
| 132 | + Get the total damage of this human, rounded to the nearest integer. |
| 133 | + @return The total damage. |
122 | 134 | */ |
123 | 135 | public int getTotalDamage() { |
124 | 136 | return (int)Math.round(damageCollapse.getDamage() + damageFire.getDamage() + damageBury.getDamage()); |
125 | 137 | } |
126 | 138 |
|
127 | 139 | /** |
128 | | - Progress all damage types. |
129 | | - */ |
| 140 | + Progress all damage types. |
| 141 | + */ |
130 | 142 | public void progressDamage() { |
131 | 143 | damageCollapse.progress(); |
132 | 144 | damageFire.progress(); |
133 | 145 | damageBury.progress(); |
134 | 146 | } |
135 | 147 |
|
136 | 148 | /** |
137 | | - Clear all damage. |
138 | | - */ |
| 149 | + Clear all damage. |
| 150 | + */ |
139 | 151 | public void clearDamage() { |
140 | 152 | damageCollapse.setDamage(0); |
141 | 153 | damageBury.setDamage(0); |
|
0 commit comments