View Javadoc

1   package cz.cuni.amis.pogamut.defcon.consts;
2   
3   import java.util.HashMap;
4   import java.util.Map;
5   
6   /**
7    * One of the game options. Might be accessed through {@link GameInfo#GetOptionValue()},
8    * {@link GameOption} and {@link GameInfo#getGameSpeed()}.
9    * 
10   * @author Radek 'Black_Hand' Pibil
11   *
12   */
13  public enum GameSpeed {
14  	
15  	PAUSED(0),
16  	REALTIME(1),
17  	SLOW(5),
18  	MEDIUM(10),
19  	FAST(20);
20  	
21  	private static Map<Integer, GameSpeed> enums = new HashMap<Integer, GameSpeed>();
22  	
23  	public static GameSpeed getEnum(int factor) {
24  		return enums.get(factor);
25  	}
26  	
27  	static {
28  		for (GameSpeed item : GameSpeed.values()) {
29  			enums.put(item.factor, item);
30  		}
31  	}
32  	
33  	public final int factor;
34  	
35  	private GameSpeed(int factor) {
36  		this.factor = factor;
37  	}
38  
39  }