Ejemplo n.º 1
0
 public IEnumerable <FigureOnSquare> YieldFigures()                         //?
 {
     foreach (Square square in Square.YieldSquares())                       //перебор клеток, куда может пойти фигура
     {
         if (GetFigureAt(square).GetColor() == moveColor)                   //если на клетке фигура нашего цвета(кто ходит)
         {
             yield return(new FigureOnSquare(GetFigureAt(square), square)); //возвращаем фигуру
         }
     }
 }
Ejemplo n.º 2
0
 public IEnumerable <FigureOnSquare> YieldFigures()
 {
     foreach (Square square in Square.YieldSquares())
     {
         if (GetFigureAt(square).GetColor() == MoveColor)
         {
             yield return(new FigureOnSquare(GetFigureAt(square), square));
         }
     }
 }
Ejemplo n.º 3
0
 private Square FindCheckedKing(Figure checkedKing)
 {
     foreach (Square square in Square.YieldSquares())
     {
         if (GetFigureAt(square) == checkedKing)
         {
             return(square);
         }
     }
     return(Square.none);
 }
Ejemplo n.º 4
0
        private Square FindBadKing()
        {
            Figure badKing = moveColor == Color.black ? Figure.whiteKing : Figure.blackKing;

            foreach (Square square in Square.YieldSquares())
            {
                if (GetFigureAt(square) == badKing)
                {
                    return(square);
                }
            }
            return(Square.none);
        }
Ejemplo n.º 5
0
        private Square FindBadKing()
        {
            var badKing = MoveColor == Color.Black ? Figure.WhiteKing : Figure.BlackKing;

            foreach (var square in Square.YieldSquares())
            {
                if (GetFigureAt(square) == badKing)
                {
                    return(square);
                }
            }
            return(Square.None);
        }
Ejemplo n.º 6
0
        private Square FindBadKing()
        {
            //ищем короля, которого нужно съесть
            Figure badKing = moveColor == Color.black ? Figure.whiteKing : Figure.blackKing;

            foreach (Square square in Square.YieldSquares())
            {
                if (GetFigureAt(square) == badKing)
                {
                    return(square);
                }
            }
            return(Square.none);
        }
Ejemplo n.º 7
0
        bool CanKingGo(Square fl, Board board)
        {
            Moves          moves = new Moves(board);
            FigureOnSquare fs    = new FigureOnSquare(moveColor == Color.white ? Figure.whiteKing : Figure.blackKing, fl);

            foreach (Square to in Square.YieldSquares())
            {
                FigureMoving fm = new FigureMoving(fs, to);
                if (moves.CanMove(fm))
                {
                    return(true);
                }
            }
            return(false);
        }
 void FindAllMoves()
 {
     allMoves = new List <FigureMoving>();
     foreach (FigureOnSquare fs in board.YieldFigures())
     {
         foreach (Square to in Square.YieldSquares())
         {
             FigureMoving fm = new FigureMoving(fs, to);
             if (moves.CanMove(fm))
             {
                 allMoves.Add(fm);
             }
         }
     }
 }
Ejemplo n.º 9
0
 void FindAllMoves()
 {
     this.allMoves = new List <FigureMoving>();
     foreach (FigureOnSquare fs in this.board.YieldFigures())
     {
         foreach (Square to in Square.YieldSquares())
         {
             FigureMoving fm = new FigureMoving(fs, to);
             if (this.moves.CanMove(fm))
             {
                 if (!this.board.IsCheckAfterMove(fm))
                 {
                     this.allMoves.Add(fm);
                 }
             }
         }
     }
 }
Ejemplo n.º 10
0
 void FindAllMoves()
 {
     allMoves = new List <FigureMoving>();
     foreach (FigureOnSquare fs in board.YieldFigures()) //перебор фигур того цвета, которые щас ходят
     {
         foreach (Square to in Square.YieldSquares())    //перебор клеток, куда может пойти фигура
         {
             FigureMoving fm = new FigureMoving(fs, to);
             if (moves.CanMove(fm))
             {
                 if (!board.IsCheckAfterMove(fm))
                 {
                     allMoves.Add(fm);
                 }
             }
         }
     }
 }
Ejemplo n.º 11
0
 private void FindAllMoves()
 {
     _figureMovings = new List <FigureMoving>();
     foreach (FigureOnSquare fs in _board.YieldFigures())
     {
         foreach (Square to in Square.YieldSquares())
         {
             var fm = new FigureMoving(fs, to);
             if (_moves.CanMove(fm) == true)
             {
                 if (_board.IsCheckAfterMove(fm) == false)
                 {
                     _figureMovings.Add(fm);
                 }
             }
         }
     }
 }
Ejemplo n.º 12
0
 public void FindAllMoves()
 {
     allMoves = new List <FigureMoving>();
     foreach (FigureOnSquare fs in board.YieldFigures())
     {
         foreach (Square to in Square.YieldSquares())
         {
             var fm = new FigureMoving(fs, to);
             if (moves.CanMove(fm))
             {
                 if (!board.IsCheckAfterMove(fm))
                 {
                     allMoves.Add(fm);
                 }
             }
         }
     }
 }
Ejemplo n.º 13
0
        void FindAllMoves()
        {
            var allMoves = new List <FigureMoving>();

            foreach (var fs in Board.YieldFigures())
            {
                foreach (var to in Square.YieldSquares())
                {
                    var fm = new FigureMoving(fs, to);
                    if (Moves.CanMove(fm))
                    {
                        if (!Board.IsCheckAfterMove(fm))
                        {
                            allMoves.Add(fm);
                        }
                    }
                }
            }

            AllMoves = allMoves;
        }