package net.woodyfolsom.msproj.policy;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import net.woodyfolsom.msproj.GameConfig;
import net.woodyfolsom.msproj.GameState;

public abstract class GameTreeNode {
	private GameConfig gameConfig;
	private GameState gameState;
	private GameTreeNode parent;
	private Map<String, GameTreeNode> children = new HashMap<String, GameTreeNode>();
	private String player;

	public GameTreeNode(GameConfig gameConfig, GameState gameState,
			String player) {
		this.gameConfig = gameConfig;
		this.gameState = gameState;
		this.player = player;
	}
	
	public void addChild(String action, GameTreeNode child) {
		children.put(action, child);
		child.parent = this;
	}

	public Set<String> getActions() {
		return children.keySet();
	}
	
	public GameTreeNode getChild(String action) {
		return children.get(action);
	}
	
	public int getChildrenSize() {
		return children.size();
	}
	
	public GameConfig getGameConfig() {
		return gameConfig;
	}

	public GameState getGameState() {
		return gameState;
	}

	public GameTreeNode getParent() {
		return parent;
	}

	public String getPlayer() {
		return player;
	}

	public boolean isRoot() {
		return parent == null;
	}
}