
// GameDemo.java

import java.util.*;
import java.io.*;

/******************************************************************************
/ GameDemo.java använder Gameklassen.
/
/*****************************************************************************/

public class GameDemo
{

    public static void main(String[] args) throws IOException
    {
		Scanner    in = new Scanner (System.in);
		Game    g = new Game ();
		
		System.out.println (g);
		
		while (true)
		{
			System.out.print ("Ditt spelar#? : ");
			int    me = in.nextInt ();
			
			if ( me == 0)
				break;

			System.out.print ("(U)tmana, (F)lytta? : ");
			int action = System.in.read ();
			empty (System.in);
			
			switch (action)
			{
				case 'U':
				case 'u':
					System.out.print ("Vem vill du utmana? : ");
					int    challenged = in.nextInt ();
					empty (System.in);
					
					g.doHit (me, challenged);

					break;
					
				case 'F':
				case 'f':
					System.out.print ("Flytta till rad # ?");
					int    newRow = in.nextInt ();
					System.out.print ("Flytta till kolumn # ?");
					int    newColumn = in.nextInt ();
					
					g.moveEntity (me, newRow, newColumn);
					
					break;
			}


			System.out.println (g); 
		}
		
	
    }
	
	// "Empty" the input buffer by skipping past all data in buffer
	private static void empty (InputStream is) throws IOException
	{
		int    available = is.available ();
		is.skip (available);
	}

}    
    
	
    