package game;

import exception.InputInvalidException;
import minesweeper.Minesweeper;
import othello.Othello;
import tictactoe.TicTacToe;
import tictactoe.TicTacToeSinglePlayer;

/**
 * This class runs the games that are in this game pack.
 */
public class GameDriver {
	private static CustomScanner console = new CustomScanner();

	public static void main(String[] args) {
		int selection;
		while (true) {
			System.out.println("1. TicTacToe\n2. Minesweeper\n3. Othello\n4. Help\n5. Exit");
			System.out.print("Please enter the number of the game you want " + "to play: ");

			try {
				selection = console.getBoundInt(1, 5);
				switch (selection) {
				case 1:
					startTicTacToe();
					break;
				case 2:
					System.out.print("Enter a board size between 3 and 20: ");
					new Minesweeper(console.getBoundInt(3, 20)).startGame();
					break;
				case 3:
					System.out.println("Not yet implemented");
					new Othello();
					break;
				case 4:
					displayHelp();
					break;
				case 5:
					System.exit(0);
				default:
					System.out.println("Try again");
					break;
				}

				console.pressToContinue();
				
			} catch (InputInvalidException e) {
				System.out.println("Try again.");
			}
		}
	}
	
	private static void startTicTacToe() {
		System.out.println("1. Play against another human\n" + "2. Play against the AI as X\n"
				+ "3. Play agaist the AI as O");
		System.out.print("Please enter the number of the game mode you want to play: ");
		switch (console.getBoundInt(1, 3)) {
		case 1:
			new TicTacToe().startGame();
			break;
		case 2:
			new TicTacToeSinglePlayer(PieceType.X).startGame();
			break;
		case 3:
			new TicTacToeSinglePlayer(PieceType.O).startGame();
			break;
		default:
			System.out.println("No Tic Tac Toe game started.");
			break;
		}
	}

	/**
	 * This method gives basic, general instructions about the key phrases the
	 * user can use and how the user can input square coordinates.
	 */
	public static void displayHelp() {
		System.out.println("\n Using the phrase \"Exit\" will completely close the program at any time.\n"
				+ " When a game is active, using the phrase \"Back\" or \"Menu\" will take you back to the main menu\n"
				+ " When indicating a square, the only accepted format is single letter then single number \"a1\".\n"
				+ " I hope you have fun.\n");
	}

}
@@ -744,126 +744,24 @@
 %09%09%09%09
-System.out.print(%22Enter a board size between 3 and 20: %22);%0D%0A%09%09%09%09%09new Minesweeper(console.getBoundInt(3, 20)).startGame
+startMinesweeper
 ();%0D
@@ -1063,14 +1063,10 @@
 );%0D%0A
-%09%09%09%09
 %0D%0A
+
 %09%09%09%7D
@@ -1159,11 +1159,10 @@
 %09%7D%0D%0A
-%09
 %0D%0A
+
 %09pri
@@ -1215,24 +1215,30 @@
 out.println(
+%0D%0A%09%09%09%09
 %221. Play aga
@@ -1292,22 +1292,17 @@
  as X%5Cn%22
-%0D%0A%09%09%09%09
+ 
 + %223. Pl
@@ -1741,16 +1741,16 @@
 break;%0D%0A
-
 %09%09%7D%0D%0A%09%7D%0D
@@ -1752,16 +1752,187 @@
 %0D%0A%09%7D%0D%0A%0D%0A
+%09private static void startMinesweeper() %7B%0D%0A%09%09System.out.print(%22Enter a board size between 3 and 20: %22);%0D%0A%09%09new Minesweeper(console.getBoundInt(3, 20)).startGame();%0D%0A%09%7D%0D%0A%0D%0A
 %09/**%0D%0A%09 

add startMinesweeper()