project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/Weaponset.java
author Medo <smaxein@googlemail.com>
Sat, 18 Aug 2012 00:47:51 +0200
changeset 7508 763d3961400b
parent 7485 0481bd74267c
child 7584 7831c84cc644
permissions -rw-r--r--
Hedgeroid: Frantic scrabbling toward the deadline - Added activities for weapon/scheme editors (unfinished) - Completed tablet version of netroom activity - Added map preview - Fixed default team files having the wrong names - Restructuring - Updated frontlib JNA bindings to respect the latest frontlib changes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7485
0481bd74267c Hedgeroid:
Medo <smaxein@googlemail.com>
parents:
diff changeset
     1
package org.hedgewars.hedgeroid.Datastructures;
0481bd74267c Hedgeroid:
Medo <smaxein@googlemail.com>
parents:
diff changeset
     2
7508
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
     3
import java.util.Comparator;
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
     4
7485
0481bd74267c Hedgeroid:
Medo <smaxein@googlemail.com>
parents:
diff changeset
     5
import org.hedgewars.hedgeroid.frontlib.Flib;
0481bd74267c Hedgeroid:
Medo <smaxein@googlemail.com>
parents:
diff changeset
     6
0481bd74267c Hedgeroid:
Medo <smaxein@googlemail.com>
parents:
diff changeset
     7
public final class Weaponset {
0481bd74267c Hedgeroid:
Medo <smaxein@googlemail.com>
parents:
diff changeset
     8
	public static final int WEAPONS_COUNT = Flib.INSTANCE.flib_get_weapons_count();
0481bd74267c Hedgeroid:
Medo <smaxein@googlemail.com>
parents:
diff changeset
     9
	
0481bd74267c Hedgeroid:
Medo <smaxein@googlemail.com>
parents:
diff changeset
    10
	public final String name, loadout, crateProb, crateAmmo, delay;
0481bd74267c Hedgeroid:
Medo <smaxein@googlemail.com>
parents:
diff changeset
    11
	
0481bd74267c Hedgeroid:
Medo <smaxein@googlemail.com>
parents:
diff changeset
    12
	public Weaponset(String name, String loadout, String crateProb, String crateAmmo, String delay) {
0481bd74267c Hedgeroid:
Medo <smaxein@googlemail.com>
parents:
diff changeset
    13
		this.name = name;
0481bd74267c Hedgeroid:
Medo <smaxein@googlemail.com>
parents:
diff changeset
    14
		this.loadout = loadout;
0481bd74267c Hedgeroid:
Medo <smaxein@googlemail.com>
parents:
diff changeset
    15
		this.crateProb = crateProb;
0481bd74267c Hedgeroid:
Medo <smaxein@googlemail.com>
parents:
diff changeset
    16
		this.crateAmmo = crateAmmo;
0481bd74267c Hedgeroid:
Medo <smaxein@googlemail.com>
parents:
diff changeset
    17
		this.delay = delay;
0481bd74267c Hedgeroid:
Medo <smaxein@googlemail.com>
parents:
diff changeset
    18
	}
0481bd74267c Hedgeroid:
Medo <smaxein@googlemail.com>
parents:
diff changeset
    19
0481bd74267c Hedgeroid:
Medo <smaxein@googlemail.com>
parents:
diff changeset
    20
	@Override
0481bd74267c Hedgeroid:
Medo <smaxein@googlemail.com>
parents:
diff changeset
    21
	public String toString() {
7508
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    22
		return "Weaponset [name=" + name + ", loadout=" + loadout
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    23
				+ ", crateProb=" + crateProb + ", crateAmmo=" + crateAmmo
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    24
				+ ", delay=" + delay + "]";
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    25
	}
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    26
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    27
	@Override
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    28
	public int hashCode() {
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    29
		final int prime = 31;
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    30
		int result = 1;
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    31
		result = prime * result
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    32
				+ ((crateAmmo == null) ? 0 : crateAmmo.hashCode());
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    33
		result = prime * result
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    34
				+ ((crateProb == null) ? 0 : crateProb.hashCode());
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    35
		result = prime * result + ((delay == null) ? 0 : delay.hashCode());
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    36
		result = prime * result + ((loadout == null) ? 0 : loadout.hashCode());
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    37
		result = prime * result + ((name == null) ? 0 : name.hashCode());
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    38
		return result;
7485
0481bd74267c Hedgeroid:
Medo <smaxein@googlemail.com>
parents:
diff changeset
    39
	}
7508
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    40
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    41
	@Override
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    42
	public boolean equals(Object obj) {
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    43
		if (this == obj)
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    44
			return true;
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    45
		if (obj == null)
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    46
			return false;
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    47
		if (getClass() != obj.getClass())
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    48
			return false;
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    49
		Weaponset other = (Weaponset) obj;
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    50
		if (crateAmmo == null) {
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    51
			if (other.crateAmmo != null)
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    52
				return false;
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    53
		} else if (!crateAmmo.equals(other.crateAmmo))
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    54
			return false;
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    55
		if (crateProb == null) {
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    56
			if (other.crateProb != null)
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    57
				return false;
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    58
		} else if (!crateProb.equals(other.crateProb))
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    59
			return false;
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    60
		if (delay == null) {
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    61
			if (other.delay != null)
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    62
				return false;
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    63
		} else if (!delay.equals(other.delay))
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    64
			return false;
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    65
		if (loadout == null) {
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    66
			if (other.loadout != null)
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    67
				return false;
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    68
		} else if (!loadout.equals(other.loadout))
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    69
			return false;
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    70
		if (name == null) {
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    71
			if (other.name != null)
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    72
				return false;
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    73
		} else if (!name.equals(other.name))
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    74
			return false;
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    75
		return true;
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    76
	}
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    77
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    78
	public static Comparator<Weaponset> NAME_ORDER = new Comparator<Weaponset>() {
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    79
		public int compare(Weaponset lhs, Weaponset rhs) {
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    80
			return String.CASE_INSENSITIVE_ORDER.compare(lhs.name, rhs.name);
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    81
		}
763d3961400b Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents: 7485
diff changeset
    82
	};
7485
0481bd74267c Hedgeroid:
Medo <smaxein@googlemail.com>
parents:
diff changeset
    83
}