package dk.itu.mario.level.matcher;

import dk.itu.mario.MarioInterface.LevelInterface;

public class LevelArchetype {
	public static final int MAX_DIFFICULTY_LEVEL = 10;

	// The canonical Super Mario level types.
	public enum TYPE {
		OVERGROUND, UNDERGROUND, CASTLE
	}

	private int difficultyLevel;
	private TYPE type;

	public LevelArchetype(TYPE type, int difficultyLevel) {
		if (difficultyLevel < 1 || difficultyLevel > MAX_DIFFICULTY_LEVEL) {
			throw new IllegalArgumentException(
					"DifficultyLevel must be in the range [1.."
							+ MAX_DIFFICULTY_LEVEL + "]");
		}
		this.difficultyLevel = difficultyLevel;
		this.type = type;
	}

	public int getDifficultyLevel() {
		return difficultyLevel;
	}

	public TYPE getType() {
		return type;
	}

	public int getTypeInt() {
		switch (type) {
		case CASTLE:
			return LevelInterface.TYPE_CASTLE;
		case OVERGROUND:
			return LevelInterface.TYPE_OVERGROUND;
		case UNDERGROUND:
			return LevelInterface.TYPE_UNDERGROUND;
		default:
			throw new UnsupportedOperationException("LevelArchetype.TYPE "
					+ type + " does not have a known integer value");
		}
	}

	@Override
	public String toString() {
		return type + " (Difficulty " + difficultyLevel + "/"
				+ MAX_DIFFICULTY_LEVEL + ")";
	}
}
