コード例 #1
0
ファイル: Program.cs プロジェクト: jcoliz/Minesweeper
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to Minesweeper!");

            Playfield = new Game(new Size(PlayfieldSize, PlayfieldSize));

            bool done = false;

            while (!done)
            {
                try
                {
                    PrettyRender(Playfield.GameBoard);

                    Console.Write("Enter col,row to play or q to quit> ");

                    var input = Console.ReadLine();

                    if (input == "q")
                    {
                        break;
                    }

                    var values = input.Split(",");

                    var position = new Point(int.Parse(values[0]) - 1, int.Parse(values[1]) - 1);

                    var result = Playfield.PlayAt(position);

                    Console.WriteLine(result.ToString());

                    if (result == Game.PlayResult.GameOver || result == Game.PlayResult.Victory)
                    {
                        done = true;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }

            PrettyRender(Playfield.GameBoard);

            Console.Write("Press enter:");
            Console.ReadLine();
        }