Example #1
0
        public ChessArr(int a)
        {
            Chess chess;

            black = new Dictionary <int, Chess>();
            white = new Dictionary <int, Chess>();
            Pole  = new Dictionary <int, Dictionary <int, Chess> >();
            FileStream   fstream = new FileStream("Save.txt", FileMode.Open, FileAccess.Read);
            StreamReader reader  = new StreamReader(fstream);
            string       s       = reader.ReadLine();

            colornow = Convert.ToInt32(s);
            s        = reader.ReadLine();
            while (s != "q")
            {
                char c         = s[0];
                int  _type     = Convert.ToInt32(c) - 48;
                int  stpoint   = 2;
                int  pozitionX = Convert.ToInt32(s[stpoint++]) - 48;
                int  pozitionY = Convert.ToInt32(s[stpoint]) - 48;
                switch (_type)
                {
                case 1:
                    chess = new Pawn(pozitionX, pozitionY);
                    white.Add(chess.ReturnPozition(), chess);
                    break;

                case 2:
                    chess = new Rook(pozitionX, pozitionY);
                    white.Add(chess.ReturnPozition(), chess);
                    break;

                case 3:
                    chess = new Horse(pozitionX, pozitionY);
                    white.Add(chess.ReturnPozition(), chess);
                    break;

                case 4:
                    chess = new Elephant(pozitionX, pozitionY);
                    white.Add(chess.ReturnPozition(), chess);
                    break;

                case 5:
                    chess = new Queen(pozitionX, pozitionY);
                    white.Add(chess.ReturnPozition(), chess);
                    break;

                case 6:
                    chess = new King(pozitionX, pozitionY);
                    white.Add(chess.ReturnPozition(), chess);
                    break;
                }
                s = reader.ReadLine();
            }
            s = reader.ReadLine();
            while (s != "q")
            {
                char c         = s[0];
                int  _type     = Convert.ToInt32(c) - 48;
                int  stpoint   = 2;
                int  pozitionX = Convert.ToInt32(s[stpoint++]) - 48;
                int  pozitionY = Convert.ToInt32(s[stpoint]) - 48;
                switch (_type)
                {
                case 1:
                    chess = new Pawn(pozitionX, pozitionY);
                    black.Add(chess.ReturnPozition(), chess);
                    break;

                case 2:
                    chess = new Rook(pozitionX, pozitionY);
                    black.Add(chess.ReturnPozition(), chess);
                    break;

                case 3:
                    chess = new Horse(pozitionX, pozitionY);
                    black.Add(chess.ReturnPozition(), chess);
                    break;

                case 4:
                    chess = new Elephant(pozitionX, pozitionY);
                    black.Add(chess.ReturnPozition(), chess);
                    break;

                case 5:
                    chess = new Queen(pozitionX, pozitionY);
                    black.Add(chess.ReturnPozition(), chess);
                    break;

                case 6:
                    chess = new King(pozitionX, pozitionY);
                    black.Add(chess.ReturnPozition(), chess);
                    break;
                }
                s = reader.ReadLine();
            }
            reader.Close();
            fstream.Close();
            Pole.Add(1, black);
            Pole.Add(0, white);
            AllEvents = new Dictionary <int, ThreeElemEvent>
            {
                { 1, this.Pawn },
                { 2, this.Rook },
                { 3, this.Horse },
                { 4, this.Elephant },
                { 5, this.Queen },
                { 6, this.King },
            };
        }
Example #2
0
        public ChessArr()
        {
            colornow = 0;//0-белые,1-черные
            Chess chess;

            black = new Dictionary <int, Chess>();
            white = new Dictionary <int, Chess>();
            Pole  = new Dictionary <int, Dictionary <int, Chess> >();
            //Расставляем пешки
            for (int i = 1; i < 9; i++)
            {
                chess = new Pawn(2, i);
                white.Add(chess.ReturnPozition(), chess);
                chess = new Pawn(7, i);
                black.Add(chess.ReturnPozition(), chess);
            }
            //Белые фигуры
            chess = new Rook(1, 1);
            white.Add(chess.ReturnPozition(), chess);
            chess = new Rook(1, 8);
            white.Add(chess.ReturnPozition(), chess);
            chess = new Horse(1, 2);
            white.Add(chess.ReturnPozition(), chess);
            chess = new Horse(1, 7);
            white.Add(chess.ReturnPozition(), chess);
            chess = new Elephant(1, 3);
            white.Add(chess.ReturnPozition(), chess);
            chess = new Elephant(1, 6);
            white.Add(chess.ReturnPozition(), chess);
            chess = new Queen(1, 4);
            white.Add(chess.ReturnPozition(), chess);
            chess = new King(1, 5);
            white.Add(chess.ReturnPozition(), chess);
            //Черные фигуры
            chess = new Rook(8, 1);
            black.Add(chess.ReturnPozition(), chess);
            chess = new Rook(8, 8);
            black.Add(chess.ReturnPozition(), chess);
            chess = new Horse(8, 2);
            black.Add(chess.ReturnPozition(), chess);
            chess = new Horse(8, 7);
            black.Add(chess.ReturnPozition(), chess);
            chess = new Elephant(8, 3);
            black.Add(chess.ReturnPozition(), chess);
            chess = new Elephant(8, 6);
            black.Add(chess.ReturnPozition(), chess);
            chess = new Queen(8, 4);
            black.Add(chess.ReturnPozition(), chess);
            chess = new King(8, 5);
            black.Add(chess.ReturnPozition(), chess);
            Pole.Add(1, black);
            Pole.Add(0, white);
            AllEvents = new Dictionary <int, ThreeElemEvent>
            {
                { 1, this.Pawn },
                { 2, this.Rook },
                { 3, this.Horse },
                { 4, this.Elephant },
                { 5, this.Queen },
                { 6, this.King },
            };
        }