import javafx.application.Application;
import javafx.scene.Scene;
import javafx.stage.Stage;

/**
 * Creates and connects the objects for each screen, and switches between
 * screens. No game logic, no drawing.
 */
public class KlondikeApp extends Application implements ScreenSwitcher {
	private Scene scene_;
	private StartView startView_;
	private NavigationController navigation_; // one for the whole app

	@Override
	public void start ( Stage stage ) {
		navigation_ = new NavigationController(this);
		startView_ = new StartView();
		startView_.setNavigation(navigation_);

		scene_ = new Scene(startView_,600,380);
		stage.setScene(scene_);
		stage.setTitle("Klondike");
		stage.setResizable(false);
		stage.show();
	}

	@Override
	public void showStart () {
		scene_.setRoot(startView_);
	}

	/**
	 * Builds one game's model, view and move controller, connects them, and shows
	 * the view.
	 */
	@Override
	public void showGame ( int seed ) {
		KlondikeGame game = new KlondikeGame(seed);
		GameView view = new GameView();
		KlondikeController controller = new KlondikeController(game,view);

		game.addListener(view); // model -> view
		view.setController(controller); // view -> controllers
		view.setNavigation(navigation_);

		view.refresh(game); // first drawing
		scene_.setRoot(view);
	}

	public static void main ( String[] args ) {
		launch(args);
	}
}
