using System;

namespace TicTacToe.Game.Entities
{
    class HumanPlayer : Player
    {
        public HumanPlayer(char icon) : base(icon)
        {
        }

        public override GameField.Position Turn()
        {
            var cursorStartPos = GameField.Instance.WritablePositionStart;
            Console.SetCursorPosition(cursorStartPos.X, cursorStartPos.Y);
            Console.WriteLine("Where do you want to place your mark? (A:1, B:3, ..) > ");
            ConsoleHelper.ClearCurrentConsoleLine();
            try
            {
                var answer = Console.ReadLine();
                var answerSplit = answer.Split(':');
                var position = GameField.Position.GetPositionForCoordinates(answerSplit[0], answerSplit[1]);
                return position;
            }
            catch (Exception ex)
            {
                return new GameField.Position {X = -1, Y = -1};
            }
        }
    }
}
