package org.vostan.banvor;

import android.app.Application;
import android.content.SharedPreferences;

import org.vostan.banvor.game.State;
import org.vostan.banvor.game.PuzzleContainer;

public class App extends Application
{	
	public static final String TAG = "Sokoban";
	public static final String PREFS = "org.dyndns.vahagn.sokoban.prefs";
	public static final int MIN_LEVEL = 1;

	private static App mApp = null;
	protected State gameState;
	protected SharedPreferences prefs;

	/*
	 *
	 */
	@Override
	public void onCreate()
	{
	    super.onCreate();
	    mApp = this;

	    PuzzleContainer pc = new PuzzleContainer();
		gameState = new State(pc);
		prefs = getSharedPreferences(PREFS, MODE_PRIVATE);

		gameState.loadState(prefs);
	}

	public void storeGameState(){
		 gameState.storeState(prefs.edit());
	}

	//
	//	This is a singleton object.
	//
	public static App theApp() {
	    return mApp;
	}

	public State state(){
		return gameState;
	}
}
