-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathTeam.java
More file actions
55 lines (52 loc) · 1.24 KB
/
Team.java
File metadata and controls
55 lines (52 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package battlecode.common;
/**
* This enum represents the team of a robot. A robot is on exactly one team.
* Player robots are on either team A or team B.
* <p>
* Since Team is a Java 1.5 enum, you can use it in <code>switch</code>
* statements, it has all the standard enum methods (<code>valueOf</code>,
* <code>values</code>, etc.), and you can safely use <code>==</code> for
* equality tests.
*/
public enum Team {
/**
* Team A.
*/
A,
/**
* Team B.
*/
B,
/**
* Neutral robots.
*/
NEUTRAL;
/**
* Determines the team that is the opponent of this team.
*
* @return the opponent of this team.
*
* @battlecode.doc.costlymethod
*/
public Team opponent() {
switch (this) {
case A:
return B;
case B:
return A;
default:
return NEUTRAL;
}
}
/**
* Returns whether a robot of this team is a player-controlled entity
* (team A or team B).
*
* @return true a robot of this team is player-controlled; false otherwise.
*
* @battlecode.doc.costlymethod
*/
public boolean isPlayer() {
return this == A || this == B;
}
}