author | unc0rr |
Sat, 14 Nov 2015 22:19:05 +0300 | |
changeset 11381 | 437a60995fe1 |
parent 7691 | 55c0a856ecd0 |
permissions | -rw-r--r-- |
7584
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7508
diff
changeset
|
1 |
/* |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7508
diff
changeset
|
2 |
* Hedgewars for Android. An Android port of Hedgewars, a free turn based strategy game |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7508
diff
changeset
|
3 |
* Copyright (C) 2012 Simeon Maxein <smaxein@googlemail.com> |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7508
diff
changeset
|
4 |
* |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7508
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7508
diff
changeset
|
6 |
* modify it under the terms of the GNU General Public License |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7508
diff
changeset
|
7 |
* as published by the Free Software Foundation; either version 2 |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7508
diff
changeset
|
8 |
* of the License, or (at your option) any later version. |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7508
diff
changeset
|
9 |
* |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7508
diff
changeset
|
10 |
* This program is distributed in the hope that it will be useful, |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7508
diff
changeset
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7508
diff
changeset
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7508
diff
changeset
|
13 |
* GNU General Public License for more details. |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7508
diff
changeset
|
14 |
* |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7508
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7508
diff
changeset
|
16 |
* along with this program; if not, write to the Free Software |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7508
diff
changeset
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7508
diff
changeset
|
18 |
*/ |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7508
diff
changeset
|
19 |
|
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
20 |
package org.hedgewars.hedgeroid.Datastructures; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
21 |
|
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7476
diff
changeset
|
22 |
import java.util.Comparator; |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7476
diff
changeset
|
23 |
|
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7476
diff
changeset
|
24 |
/** |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7476
diff
changeset
|
25 |
* Basic information about a player on a server. |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7476
diff
changeset
|
26 |
*/ |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
27 |
public final class Player { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
28 |
public final String name; |
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7476
diff
changeset
|
29 |
public final boolean registered, admin; |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
30 |
|
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7476
diff
changeset
|
31 |
public Player(String name, boolean registered, boolean admin) { |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
32 |
this.name = name; |
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7476
diff
changeset
|
33 |
this.registered = registered; |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7476
diff
changeset
|
34 |
this.admin = admin; |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
35 |
} |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
36 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
37 |
@Override |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
38 |
public String toString() { |
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7476
diff
changeset
|
39 |
return "Player [name=" + name + ", registered=" + registered |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7476
diff
changeset
|
40 |
+ ", admin=" + admin + "]"; |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
41 |
} |
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7476
diff
changeset
|
42 |
|
7691
55c0a856ecd0
frontlib+Hedgeroid: Added support for the new client flags (chief, admin, reg)
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
43 |
public static Comparator<Player> ADMIN_NAME_ORDER = new Comparator<Player>() { |
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7476
diff
changeset
|
44 |
public int compare(Player lhs, Player rhs) { |
7691
55c0a856ecd0
frontlib+Hedgeroid: Added support for the new client flags (chief, admin, reg)
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
45 |
if(lhs.admin != rhs.admin) { |
55c0a856ecd0
frontlib+Hedgeroid: Added support for the new client flags (chief, admin, reg)
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
46 |
return lhs.admin ? -1 : 1; |
55c0a856ecd0
frontlib+Hedgeroid: Added support for the new client flags (chief, admin, reg)
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
47 |
} else { |
55c0a856ecd0
frontlib+Hedgeroid: Added support for the new client flags (chief, admin, reg)
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
48 |
return lhs.name.compareToIgnoreCase(rhs.name); |
55c0a856ecd0
frontlib+Hedgeroid: Added support for the new client flags (chief, admin, reg)
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
49 |
} |
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7476
diff
changeset
|
50 |
} |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7476
diff
changeset
|
51 |
}; |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
52 |
} |