Exemple #1
0
        public List <string> GetValidCaptures()
        {
            var figuresOnSquares = Board.GetFigureOnSquares();
            var squares          = Square.GetBoardSquares();
            var validMoves       = new List <string>();

            var opponentCollor = MoveColor == Color.black ? Color.white : Color.black;

            foreach (var figuresOnSquare in figuresOnSquares)
            {
                foreach (var to in squares)
                {
                    foreach (Figure promotion in figuresOnSquare.Figure.YieldPromotions(to))
                    {
                        FigureMoving fm = new FigureMoving(figuresOnSquare, to, promotion);

                        if (IsValidMove(fm) &&
                            Board.GetFigureAt(to).GetFigureColor() == opponentCollor)
                        {
                            validMoves.Add(fm.ToString());
                        }
                    }
                }
            }

            return(validMoves);
        }
Exemple #2
0
        public IEnumerable <string> YieldValidMoves()
        {
            var figuresOnSquares = Board.GetFigureOnSquares();
            var squares          = Square.GetBoardSquares();

            foreach (var figuresOnSquare in figuresOnSquares)
            {
                foreach (var to in squares)
                {
                    foreach (Figure promotion in figuresOnSquare.Figure.YieldPromotions(to))
                    {
                        FigureMoving fm = new FigureMoving(figuresOnSquare, to, promotion);

                        if (IsValidMove(fm))
                        {
                            yield return(fm.ToString());
                        }
                    }
                }
            }
        }
Exemple #3
0
        public List <string> GetValidMoves()
        {
            var figuresOnSquares = Board.GetFigureOnSquares();
            var squares          = Square.GetBoardSquares();
            var validMoves       = new List <string>();

            foreach (var figuresOnSquare in figuresOnSquares)
            {
                foreach (var to in squares)
                {
                    foreach (Figure promotion in figuresOnSquare.Figure.YieldPromotions(to))
                    {
                        FigureMoving fm = new FigureMoving(figuresOnSquare, to, promotion);

                        if (IsValidMove(fm))
                        {
                            validMoves.Add(fm.ToString());
                        }
                    }
                }
            }

            return(validMoves);
        }