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 Fighters.
10   * 
11   * @author Radek 'Black_Hand' Pibil
12   *
13   */
14  public enum FighterState implements IState {
15  
16  	ATTACK(JBot.STATE_FIGHTERATTACK),	
17      IN_QUEUE(JBot.STATE_FIGHTERINQUEUE);
18  	
19  	private static Map<Integer, FighterState> states = new HashMap<Integer, FighterState>();
20  	
21  	public static FighterState getState(int stateId) {
22  		return states.get(stateId);
23  	}
24  	
25  	static {
26  		for (FighterState state : FighterState.values()) {
27  			states.put(state.getStateId(), state);
28  		}
29  	}
30  	
31  	public final int id;
32  	
33  	private FighterState(int id) {
34  		this.id = id;
35  	}
36  
37  	@Override
38  	public int getStateId() {
39  		return id;
40  	}
41  	
42  	@Override
43  	public Enum<? extends IState> getEnum() {
44  		return this;
45  	}
46  
47  }