package net.woodyfolsom.msproj.sgf;

import java.util.ArrayList;
import java.util.List;

import net.woodyfolsom.msproj.Action;
import net.woodyfolsom.msproj.GameConfig;

public class SGFNodeCollection {
	private List<SGFGameTree> gameTrees = new ArrayList<SGFGameTree>();

	public void add(SGFGameTree gameTree) {
		gameTrees.add(gameTree);
	}

	public SGFGameTree getGameTree(int index) {
		return gameTrees.get(index);
	}

	public GameConfig getGameConfig() {
		SGFGameTree gameTree = gameTrees.get(0);
		int boardSize = gameTree.getBoardSize();
		double komi = gameTree.getKomi();
		
		return new GameConfig(boardSize,komi);
	}
	
	public int getGameTreeCount() {
		return gameTrees.size();
	}

	public List<Action> getMoves(int boardSize) {
		SGFGameTree gameTree = gameTrees.get(0);
		return gameTree.getMoves(boardSize);
	}

	/**
	 * This method is an alias for toString().
	 * @return
	 */
	public String toSGF() {
		return toString();
	}

	@Override
	public String toString() {
		StringBuilder sbuilder = new StringBuilder();
		for (SGFGameTree gameTree : gameTrees) {
			sbuilder.append(gameTree.toString());
		}
		return sbuilder.toString();
	}
}
