View Javadoc

1   package cz.cuni.amis.pogamut.defcon.consts.state;
2   
3   import java.util.HashMap;
4   import java.util.Map;
5   
6   import javabot.JBot;
7   
8   /**
9    * Contains all states for Battleships.
10   * 
11   * @author Radek 'Black_Hand' Pibil
12   *
13   */
14  public enum BattleshipState implements IState {
15  	
16  	ATTACK(JBot.STATE_BATTLESHIPATTACK);
17  
18  	private static Map<Integer, BattleshipState> states = new HashMap<Integer, BattleshipState>();
19  	
20  	public static BattleshipState getState(int stateId) {
21  		return states.get(stateId);
22  	}
23  	
24  	static {
25  		for (BattleshipState state : BattleshipState.values()) {
26  			states.put(state.getStateId(), state);
27  		}
28  	}
29  	
30  	public final int id;
31  	
32  	private BattleshipState(int id) {
33  		this.id = id;
34  	}
35  
36  	@Override
37  	public int getStateId() {
38  		return id;
39  	}
40  
41  	@Override
42  	public Enum<? extends IState> getEnum() {
43  		return this;
44  	}
45  
46  }