package de.rico.adventure.conversation;

import java.util.LinkedList;
import java.util.List;

/**
 * A branch encapsulates the series of sentences that get spoken
 * after the player chose a question from the conversation list menu.
 * @author Frank Bruns
 */
public class Branch
{
	private String id = null;
	private String title = null;
	private boolean isAvailable = false;
	private boolean hasBeenSaid = false;

	private LinkedList<Sentence> sentences = null;

	/**
	 * Creates a new conversation branch with the specified parameters.
	 * @param id internal id of the branch
	 * @param title tile of the branch (, will be display in the list menu)
	 * @param available is branch initially available? --> true=yes, false=no
	 */
	public Branch(String id, String title, boolean available)
	{
		this.id = id;
		this.title = title;
		this.isAvailable = available;

		this.sentences = new LinkedList<Sentence>();
	}

	/**
	 * Adds a Sentence object to the branch.
	 * @param sent Sentence object
	 */
	public void addSentence(Sentence sent)
	{
		this.sentences.add(sent);
	}

	/**
	 * Returns the list of sentences of this branch.
	 * @return list of sentences
	 */
	public List<Sentence> getSentences()
	{
		return this.sentences;
	}

	/**
	 * Returns the id of the branch.
	 * @return branch id
	 */
	public String getId()
	{
		return this.id;
	}

	/**
	 * Returns the title of the branch which is the text that gets
	 * displayed in the conversation's dialog list menu for choosing
	 * the branch.
	 * @return title of the branch
	 */
	public String getTitle()
	{
		return this.title;
	}

	/**
	 * Determines whether or not this branch is (already) available
	 * for a conversation.
	 * @return is available? --> true=yes, false=no
	 */
	public boolean isAvailable()
	{
		return this.isAvailable;
	}

	/**
	 * Determines whether or not this branch has been marked to have
	 * been said before.
	 * @return has branch been said before? --> true=yes, false=no
	 */
	public boolean hasBeenSaid()
	{
		return this.hasBeenSaid;
	}

	/**
	 * Marks this branch as been said.
	 *
	 */
	public void markAsSaid()
	{
		this.hasBeenSaid = true;
	}

	/**
	 * Sets whethter or not this branch is available for
	 * a conversation.
	 * @param available set available? --> true=yes, false=no
	 */
	public void setAvailable(boolean available)
	{
		this.isAvailable = available;
	}
}
