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
        private Square FindBadKing()
        {
            Figure 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.º 3
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);
                 }
             }
         }
     }
 }