Hell Yeah! I love Enums.
Here’s an example:
enum HexType {
SEA (Resource.NONE, new Color(0.5f, 0.7f, 0.9f)),
PASTURE (Resource.WOOL, new Color(0.5f, 0.8f, 0.3f)),
FIELD (Resource.GRAIN, new Color(0.9f, 0.9f, 0.5f)),
MOUNTAIN (Resource.ORE, new Color(0.5f, 0.5f, 0.6f)),
HILLS (Resource.BRICK, new Color(0.7f, 0.4f, 0.3f)),
FOREST (Resource.LUMBER, new Color(0.1f, 0.5f, 0.1f)),
DESERT (Resource.NONE, new Color(0.8f, 0.7f, 0.6f));
public final Resource resource;
public final Color color;
HexType(Resource r, Color c){
resource = r;
color = c;
}
}
That allows me to have a collections of hex objects where each hex can tell me what resource type it produces and what color it should be on the map. If I were using constants, I’d need associated lists or maps containing hex->resource mappings and hex-> color mappings. It’s much tidier this way because it keeps all the hex-related info in one place.