Example #1
0
 public IEnumerable <FigureOnSquare> YieldMyFigureSquares()
 {
     foreach (Square square in Square.YieldBoardSquares())
     {
         if (GetFigureAt(square).GetColor() == moveColor)
         {
             yield return(new FigureOnSquare(GetFigureAt(square), square));
         }
     }
 }
Example #2
0
        private Square FindBadKing()
        {
            Figure badKing = moveColor == Color.white ? Figure.blackKing : Figure.whiteKing;

            foreach (Square square in Square.YieldBoardSquares())
            {
                if (GetFigureAt(square) == badKing)
                {
                    return(square);
                }
            }
            return(Square.none);
        }
Example #3
0
 public IEnumerable <string> YieldValidMoves()
 {
     foreach (FigureOnSquare fs in board.YieldMyFigureOnSquares())
     {
         foreach (Square to in Square.YieldBoardSquares())
         {
             foreach (Figure promotion in fs.figure.YieldPromotions(to))
             {
                 FigureMoving fm = new FigureMoving(fs, to, promotion);
                 if (moves.CanMove(fm))
                 {
                     if (!board.IsCheckAfter(fm))
                     {
                         yield return(fm.ToString());
                     }
                 }
             }
         }
     }
 }
Example #4
0
        public bool IsDrawSet()
        {
            int countFigures = 0;

            IsDraw = false;
            foreach (Square square in Square.YieldBoardSquares())
            {
                if (countFigures > 2)
                {
                    return(false);
                }
                Figure figure = board.GetFigureAt(square);
                if (figure != Figure.none)
                {
                    countFigures++;
                }
            }
            if (countFigures == 2)
            {
                IsDraw = true;
                return(true);
            }
            return(false);
        }