import java.util.Scanner;

public class NimDriver
{
	/*********************************************************************
	    The main methods prompts for the player name, 
	    makes a Nim object using the command line arguments and 
		 then calls the playGame method to start the game.
		 
		 @param args Command line arguments.  Arg 1 contains the
		             long seed value used to start the Random generator
	**********************************************************************/
	public static void main (String [] args)
	{
		int 		seed;
		Scanner 	kb;
		String 	name;
		Nim		game;
		Toolkit	tools;
		
		tools = new Toolkit();
		
		seed = -1;
		kb = new Scanner(System.in);
		
		// Introduce the game
		System.out.print("Welcome to the game of Nim\n\n");
 
		// This step gets the user name from the keyboard
		System.out.print("Who are you? ");
		name = kb.nextLine();
		System.out.println();
		
		// This step gets the seed value from the user
		while(seed <= -1)
		{
			seed = tools.getInteger(kb, "Enter an positive integer to use as a seed: ",
			 "This is not an integer, try again.");
			if(!(tools.isInRange(seed, 1, Integer.MAX_VALUE, true)))
			 System.out.println(seed + " is not a positive integer, try again.");
		}
				
		// Instantiate a Nim game 
		game = new Nim(kb, seed, name);
		game.playGame();
	}
}