1 package org.hedgewars.hedgeroid.Datastructures; |
1 package org.hedgewars.hedgeroid.Datastructures; |
|
2 |
|
3 import java.util.Comparator; |
2 |
4 |
3 import org.hedgewars.hedgeroid.frontlib.Flib; |
5 import org.hedgewars.hedgeroid.frontlib.Flib; |
4 |
6 |
5 public final class Weaponset { |
7 public final class Weaponset { |
6 public static final int WEAPONS_COUNT = Flib.INSTANCE.flib_get_weapons_count(); |
8 public static final int WEAPONS_COUNT = Flib.INSTANCE.flib_get_weapons_count(); |
15 this.delay = delay; |
17 this.delay = delay; |
16 } |
18 } |
17 |
19 |
18 @Override |
20 @Override |
19 public String toString() { |
21 public String toString() { |
20 return name; // TODO use the generated one once StartGameActivity doesn't need this anymore |
22 return "Weaponset [name=" + name + ", loadout=" + loadout |
|
23 + ", crateProb=" + crateProb + ", crateAmmo=" + crateAmmo |
|
24 + ", delay=" + delay + "]"; |
21 } |
25 } |
|
26 |
|
27 @Override |
|
28 public int hashCode() { |
|
29 final int prime = 31; |
|
30 int result = 1; |
|
31 result = prime * result |
|
32 + ((crateAmmo == null) ? 0 : crateAmmo.hashCode()); |
|
33 result = prime * result |
|
34 + ((crateProb == null) ? 0 : crateProb.hashCode()); |
|
35 result = prime * result + ((delay == null) ? 0 : delay.hashCode()); |
|
36 result = prime * result + ((loadout == null) ? 0 : loadout.hashCode()); |
|
37 result = prime * result + ((name == null) ? 0 : name.hashCode()); |
|
38 return result; |
|
39 } |
|
40 |
|
41 @Override |
|
42 public boolean equals(Object obj) { |
|
43 if (this == obj) |
|
44 return true; |
|
45 if (obj == null) |
|
46 return false; |
|
47 if (getClass() != obj.getClass()) |
|
48 return false; |
|
49 Weaponset other = (Weaponset) obj; |
|
50 if (crateAmmo == null) { |
|
51 if (other.crateAmmo != null) |
|
52 return false; |
|
53 } else if (!crateAmmo.equals(other.crateAmmo)) |
|
54 return false; |
|
55 if (crateProb == null) { |
|
56 if (other.crateProb != null) |
|
57 return false; |
|
58 } else if (!crateProb.equals(other.crateProb)) |
|
59 return false; |
|
60 if (delay == null) { |
|
61 if (other.delay != null) |
|
62 return false; |
|
63 } else if (!delay.equals(other.delay)) |
|
64 return false; |
|
65 if (loadout == null) { |
|
66 if (other.loadout != null) |
|
67 return false; |
|
68 } else if (!loadout.equals(other.loadout)) |
|
69 return false; |
|
70 if (name == null) { |
|
71 if (other.name != null) |
|
72 return false; |
|
73 } else if (!name.equals(other.name)) |
|
74 return false; |
|
75 return true; |
|
76 } |
|
77 |
|
78 public static Comparator<Weaponset> NAME_ORDER = new Comparator<Weaponset>() { |
|
79 public int compare(Weaponset lhs, Weaponset rhs) { |
|
80 return String.CASE_INSENSITIVE_ORDER.compare(lhs.name, rhs.name); |
|
81 } |
|
82 }; |
22 } |
83 } |