Пример #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("-------- CHECKERS --------");
            Console.WriteLine();
            bool running = true;

            GameBoard Board = null;


            //Restart:
            while (running == true)
            {
                DisplayMenu();
                char menuchoice = Console.ReadLine().ToCharArray()[0];
                switch (menuchoice)
                {
                case '1':
                    var blackpieces = Pieces.BlackPlacements();
                    var whitepieces = Pieces.WhitePlacements();
                    Board = new GameBoard(8, blackpieces, whitepieces);
                    Start1PGame(Board);
                    break;

                case '2':
                    var blackpieces2 = Pieces.BlackPlacements();
                    var whitepieces2 = Pieces.WhitePlacements();
                    Board = new GameBoard(8, blackpieces2, whitepieces2);
                    Start2PGame(Board);
                    break;

                case '4':
                    var TestBlacks = Pieces.JumpedBlack();
                    var TestWhites = Pieces.JumpingWhite();
                    Board = new GameBoard(8, TestBlacks, TestWhites);
                    Start1PGame(Board);
                    break;

                case '3':
                    var retry = true;
                    while (retry)
                    {
                        try
                        {
                            string tempExeName = Path.Combine(Directory.GetCurrentDirectory(), "GUI.exe");
                            using (FileStream fsDst = new FileStream(tempExeName, FileMode.CreateNew, FileAccess.Write))
                            {
                                byte[] bytes = Resources.GetGUI();

                                fsDst.Write(bytes, 0, bytes.Length);
                            }
                            Process.Start(tempExeName);
                            retry = false;
                        }
                        catch (Exception)
                        {
                            File.Delete(Path.Combine(Directory.GetCurrentDirectory(), "GUI.exe"));
                        }
                    }
                    running = false;
                    Application.Exit();
                    break;

                case '0':
                    running = false;
                    break;

                default:
                    Console.WriteLine("Invalid Menu Choice");
                    break;
                }
            }
        }