package de.rico.adventure.structure;

import de.rico.adventure.enums.State;

/**
 * This is a class that reflects the current game state.
 * It implements the singleton pattern.
 * @author Frank Bruns
 *
 */
public class StateManager
{
	private State currentState = State.MENU;

	private static StateManager instance = new StateManager();

	/**
	 * Private singleton constructor.
	 *
	 */
	private StateManager()
	{

	}

	/**
	 * Returns the singleton instance of the state manager
	 * @return the state manager instance
	 */
	public static StateManager getInstance()
	{
		return instance;
	}

	/**
	 * Sets the current game state to the specified state from the
	 * State enumeration
	 * @param state new game state
	 */
	public void setState(State state)
	{
		this.currentState = state;
	}

	/**
	 * Returns the current game state
	 * @return current game state that is set
	 */
	public State getState()
	{
		return this.currentState;
	}

	/**
	 * Determins whether the current gamestate is equal to the specified one
	 * @param state the state to compare for equality
	 * @return is state equal to current state? --> true=yes, false=no
	 */
	public boolean equals(State state)
	{
		return this.currentState.equals(state);
	}
}
