feat: added integer conversion to StoneType enum

This commit is contained in:
Yannik Bretschneider 2021-05-11 21:00:33 +02:00
parent f4123481bc
commit 1cb2c145d1

View File

@ -1,11 +1,36 @@
package uulm.teamname.marvelous.gamelibrary.entities; package uulm.teamname.marvelous.gamelibrary.entities;
import java.util.HashMap;
import java.util.Map;
/** Specifies the type of an {@link InfinityStone}. */ /** Specifies the type of an {@link InfinityStone}. */
public enum StoneType { public enum StoneType {
SpaceStone, SpaceStone(0),
MindStone, MindStone(1),
RealityStone, RealityStone(2),
PowerStone, PowerStone(3),
TimeStone, TimeStone(4),
SoulStone SoulStone(5);
private final int id;
private final static HashMap<Integer, StoneType> map;
private StoneType(int id) {
this.id = id;
}
static {
map = new HashMap<>();
for (StoneType stoneType : StoneType.values()) {
map.put(stoneType.id, stoneType);
}
}
public static StoneType valueOf (int stoneType) {
return map.get(stoneType);
}
public int getID() {
return id;
}
} }