Ejemplo n.º 1
0
        public Input Play(IList <MarkType> state)
        {
            var isValidInput = false;
            int row          = 0;
            int col          = 0;
            //state上の位置
            int index = 0;

            do
            {
                //何か動いてるからとにかくヨシ!
                Console.Write("縦 >>");
                var colBuffer = Console.ReadLine();
                Console.Write("横 >>");
                var rowBuffer = Console.ReadLine();

                if (int.TryParse(rowBuffer, out row) && int.TryParse(colBuffer, out col))
                {
                    try
                    {
                        index = Board.CalcIndex(col, row);
                    }
                    catch
                    {
                        Console.WriteLine("無効な入力です");
                        continue;
                    }

                    isValidInput = true;
                }

                isValidInput = Input.isValidRange(col, row) && !Input.isAlreadyExistsMark(index, state);
            } while (!isValidInput);

            return(new Input(col, row));
        }