package common.entity.npc;

import java.util.Map;

import common.collect.Maps;
import common.color.TextColor;

public enum Alignment {
	LAWFUL_GOOD("lgood", "Rechtsch. gut", 1, 1, TextColor.NEON), 
	GOOD("good", "Gut", 0, 1, TextColor.BLUE), 
	CHAOTIC_GOOD("cgood", "Chaotisch gut", -1, 1, TextColor.CYAN),
	LAWFUL("lawful", "Rechtschaffen", 1, 0, TextColor.WHITE), 
	NEUTRAL("neutral", "Neutral", 0, 0, TextColor.LGRAY), 
	CHAOTIC("chaotic", "Chaotisch", -1, 0, TextColor.GRAY),
	LAWFUL_EVIL("levil", "Rechtsch. böse", 1, -1, TextColor.ORANGE), 
	EVIL("evil", "Böse", 0, -1, TextColor.RED), 
	CHAOTIC_EVIL("cevil", "Chaotisch böse", -1, -1, TextColor.DRED);
	
	private static final Map<String, Alignment> LOOKUP = Maps.newHashMap();

	public final boolean lawful;
	public final boolean chaotic;
	public final boolean good;
	public final boolean evil;
	public final TextColor color;
	public final String name;
	public final String prefix;
	public final String display;
	
	private Alignment(String name, String display, int temper, int morale, TextColor color) {
		this.lawful = temper == 1;
		this.chaotic = temper == -1;
		this.good = morale == 1;
		this.evil = morale == -1;
		this.color = color;
		this.name = name;
		this.display = display;
		this.prefix = TextColor.GRAY + "[" + (temper == 0 && morale == 0 ? TextColor.LGRAY + "~" : "") + 
				(this.good ? TextColor.BLUE + "*" : (this.evil ? TextColor.RED + "!" : "")) + 
				(this.lawful ? TextColor.GREEN + "+" : (this.chaotic ? TextColor.DMAGENTA + "-" : "")) + 
				TextColor.GRAY + "]";
	}
	
	public static Alignment getByName(String name) {
		Alignment type = LOOKUP.get(name.toLowerCase());
		return type == null ? NEUTRAL : type;
	}
	
	static {
		for(Alignment type : values()) {
			LOOKUP.put(type.name, type);
		}
	}
}
