public IEnumerable <FigureOnSquare> YieldMyFigureSquares() { foreach (Square square in Square.YieldBoardSquares()) { if (GetFigureAt(square).GetColor() == moveColor) { yield return(new FigureOnSquare(GetFigureAt(square), square)); } } }
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); }
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()); } } } } } }
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); }