001package squidpony.squidgrid.mapping;
002
003import squidpony.annotation.Beta;
004
005/**
006 * A base class for cell level features common to roguelike dungeons.
007 *
008 *
009 * @author Eben Howard - http://squidpony.com - howard@squidpony.com
010 */
011@Beta
012public class Terrain {
013
014    public static final Terrain FLOOR = new Terrain('.', 0),
015            WALL = new Terrain('#', 1),
016            CLOSED_DOOR = new Terrain('+', 2),
017            OPEN_DOOR = new Terrain('/', 2),
018            EMPTY_SPACE = new Terrain('_', 30),
019            LIQUID = new Terrain('~', 26),
020            ENTRANCE = new Terrain('<', 34),
021            EXIT = new Terrain('>', 38);
022    private final char symbol;
023    private final int color;
024
025    private Terrain(char symbol, int colorIndex) {
026        this.symbol = symbol;
027        color = colorIndex;
028    }
029
030    /**
031     * Returns the character representation for this terrain. This is meant to
032     * be for display purposes and should not be used to check for equality
033     * since multiple different terrains may return the same symbol.
034     *
035     * @return
036     */
037    public char symbol() {
038        return symbol;
039    }
040
041    /**
042     * Returns the color for this terrain.
043     *
044     * @return
045     */
046    public int colorIndex() {
047        return color;
048    }
049
050    @Override
051    public int hashCode() {
052        int hash = 7;
053        hash = 83 * hash + symbol;
054        return hash;
055    }
056
057    @Override
058    public boolean equals(Object obj) {
059        if (obj == null) {
060            return false;
061        }
062        if (getClass() != obj.getClass()) {
063            return false;
064        }
065        final Terrain other = (Terrain) obj;
066        return symbol == other.symbol;
067    }
068}