package net.woodyfolsom.msproj.sgf;

public class SGFPlayer {
	public static final SGFPlayer BLACK = new SGFPlayer("Black");
	public static final SGFPlayer WHITE = new SGFPlayer("White");
	
	private String color;
	
	public static SGFPlayer getInstance(String color) {
		if ("B".equals(color)) {
			return BLACK;
		} else if ("W".equals(color)) {
			return WHITE;
		} else {
			throw new IllegalArgumentException(color);
		}
	}
	
	private SGFPlayer(String color) {
		this.color = color;
	}
	
	public String getColor() {
		return color;
	}
	
	@Override
	public String toString() {
		if (this == BLACK) {
			return "B";
		} else if (this == WHITE){
			return "W";
		} else {
			throw new RuntimeException("Invalid player");
		}
	}
}
