
import java.util.Scanner;
import java.util.Random;

/**
 * This class implements a simple version of Connect Four, called NibbleNabble.
 * @author Your name here
 * @version 1.0
 * @since 1.8
 */
public class NibbleNabble {

	private Player currentPlayer;
	private Player computer;
	private Player user;
	private Board board;
	private Scanner input;
	
	/** Outputs a welcome message. Prompts the user for their name, and instantiates a new Player with the name.
	 *  Initializes the Scanner, Board, user and computer variables.
	 */
	public NibbleNabble() {
		

	}
	
	public boolean playGame() {
		
		while (true) {
			board.display();
			int column = 0;
			currentPlayer = togglePlayer();
			
			System.out.print(currentPlayer.getName() + " > ");
			
			while (column == 0) {
				
				if (currentPlayer == computer) {
					column = new Random().nextInt(7) + 1;
					System.out.println(column);
				} else {
					String move = input.next();
					if (move.toUpperCase().charAt(0) == 'Q')
						return false;
					
					column = Integer.parseInt(move);
				}
				
				if (!board.makeMove(column, currentPlayer.getToken())) {
					column = 0;
				}
				
			}
			
			if (currentPlayer == computer && board.checkVictory()) {
				System.out.println("Oh no! The computer won!");	
				board.display();
				break;
			} else if (currentPlayer == user && board.isFull()) {
				System.out.println("You are victorious!!!");
				board.display();
				break;
			}
		}	
		
		return true;
	}
	
	/**
	 * Re-initializes the board variable with a new Board object.
	 * Outputs prompt to user: Enter Q to quit, or any key to keep playing:
	 * If the user enters any variation of Q, q, Quit, quit, quits the game.
	 * @return True if the user wants to quit, false otherwise.
	 */
	public boolean quit() {
		
	}

	/**
	 * If the currentPlayer is the user, returns computer. Otherwise, returns the user.
	 *
	 * @return computer if currentPlayer is user, otherwise user.
	 */
	private Player togglePlayer() {
		
	}
}
