
import java.io.Console;
import java.util.List;

public class Human extends Player{

    /**
     * This class is an extends of the class Player, this allows the player to choose his move.
     */

    //------------------Methods--------------------------
    /**
    * Return the coordinate of the move played by the player.
    * @param Board The actual Gomoku board.
    * @return The coordinate of the move played.
    */
    public Coordinate chooseMove(GomokuBoard board){
        
        Console cons = System.console();

        int x=0,y=0;
        boolean pass = false;

        do{

            do{
                try {
                    System.out.println("Veuillez saisir le X");
                    x = Integer.parseInt( cons.readLine());
                    pass=true;
                    
                } catch (NumberFormatException e) {
                    System.out.println("Ce n'est pas un nombre !");
                    pass=false;
                }
            }
            while(!pass);
                
            do{
                try {
                    System.out.println("Veuillez saisir le Y");
                    y = Integer.parseInt( cons.readLine());
                    pass=true;
                    
                } catch (NumberFormatException e) {
                    System.out.println("Ce n'est pas un nombre !");
                    pass=false;
                }
            }
            while(!pass);


            pass =board.getCell(x,y).isPlayable();
            if(!pass)
            {
                System.out.println("Cette case n'est pas jouable !");
            }
        }
        while(!pass);
        
        System.out.println("Vous avez saisi : "+ x+", "+ y);

        
        return new Coordinate(x,y);
    }
}