project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/Weaponset.java
branchhedgeroid
changeset 7857 2bc61f8841a1
parent 7584 7831c84cc644
equal deleted inserted replaced
7855:ddcdedd3330b 7857:2bc61f8841a1
       
     1 /*
       
     2  * Hedgewars for Android. An Android port of Hedgewars, a free turn based strategy game
       
     3  * Copyright (C) 2012 Simeon Maxein <smaxein@googlemail.com>
       
     4  *
       
     5  * This program is free software; you can redistribute it and/or
       
     6  * modify it under the terms of the GNU General Public License
       
     7  * as published by the Free Software Foundation; either version 2
       
     8  * of the License, or (at your option) any later version.
       
     9  *
       
    10  * This program is distributed in the hope that it will be useful,
       
    11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    13  * GNU General Public License for more details.
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License
       
    16  * along with this program; if not, write to the Free Software
       
    17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
       
    18  */
       
    19 
       
    20 package org.hedgewars.hedgeroid.Datastructures;
       
    21 
       
    22 import java.util.Comparator;
       
    23 
       
    24 import org.hedgewars.hedgeroid.frontlib.Flib;
       
    25 
       
    26 public final class Weaponset {
       
    27 	public static final int WEAPONS_COUNT = Flib.INSTANCE.flib_get_weapons_count();
       
    28 	
       
    29 	public final String name, loadout, crateProb, crateAmmo, delay;
       
    30 	
       
    31 	public Weaponset(String name, String loadout, String crateProb, String crateAmmo, String delay) {
       
    32 		this.name = name;
       
    33 		this.loadout = loadout;
       
    34 		this.crateProb = crateProb;
       
    35 		this.crateAmmo = crateAmmo;
       
    36 		this.delay = delay;
       
    37 	}
       
    38 
       
    39 	@Override
       
    40 	public String toString() {
       
    41 		return "Weaponset [name=" + name + ", loadout=" + loadout
       
    42 				+ ", crateProb=" + crateProb + ", crateAmmo=" + crateAmmo
       
    43 				+ ", delay=" + delay + "]";
       
    44 	}
       
    45 
       
    46 	@Override
       
    47 	public int hashCode() {
       
    48 		final int prime = 31;
       
    49 		int result = 1;
       
    50 		result = prime * result
       
    51 				+ ((crateAmmo == null) ? 0 : crateAmmo.hashCode());
       
    52 		result = prime * result
       
    53 				+ ((crateProb == null) ? 0 : crateProb.hashCode());
       
    54 		result = prime * result + ((delay == null) ? 0 : delay.hashCode());
       
    55 		result = prime * result + ((loadout == null) ? 0 : loadout.hashCode());
       
    56 		result = prime * result + ((name == null) ? 0 : name.hashCode());
       
    57 		return result;
       
    58 	}
       
    59 
       
    60 	@Override
       
    61 	public boolean equals(Object obj) {
       
    62 		if (this == obj)
       
    63 			return true;
       
    64 		if (obj == null)
       
    65 			return false;
       
    66 		if (getClass() != obj.getClass())
       
    67 			return false;
       
    68 		Weaponset other = (Weaponset) obj;
       
    69 		if (crateAmmo == null) {
       
    70 			if (other.crateAmmo != null)
       
    71 				return false;
       
    72 		} else if (!crateAmmo.equals(other.crateAmmo))
       
    73 			return false;
       
    74 		if (crateProb == null) {
       
    75 			if (other.crateProb != null)
       
    76 				return false;
       
    77 		} else if (!crateProb.equals(other.crateProb))
       
    78 			return false;
       
    79 		if (delay == null) {
       
    80 			if (other.delay != null)
       
    81 				return false;
       
    82 		} else if (!delay.equals(other.delay))
       
    83 			return false;
       
    84 		if (loadout == null) {
       
    85 			if (other.loadout != null)
       
    86 				return false;
       
    87 		} else if (!loadout.equals(other.loadout))
       
    88 			return false;
       
    89 		if (name == null) {
       
    90 			if (other.name != null)
       
    91 				return false;
       
    92 		} else if (!name.equals(other.name))
       
    93 			return false;
       
    94 		return true;
       
    95 	}
       
    96 
       
    97 	public static Comparator<Weaponset> NAME_ORDER = new Comparator<Weaponset>() {
       
    98 		public int compare(Weaponset lhs, Weaponset rhs) {
       
    99 			return String.CASE_INSENSITIVE_ORDER.compare(lhs.name, rhs.name);
       
   100 		}
       
   101 	};
       
   102 }