public bool CanMove(FigureMoving fm) { this.fm = fm; return (CanMoveFrom() && CanMoveTo() && CanFigureMove() && !board.IsCheckAfterMove(fm)); }
public Chess Move(string move) { var fm = new FigureMoving(move); //if (!moves.CanMove(fm)) // return this; // Cannot move exceptions TODO var nextBoard = _board.Move(fm); var nextChess = new Chess(nextBoard); return(nextChess); }
public IEnumerable <string> YieldValidMoves() { foreach (FigureOnSquare fs in _board.YieldFigures()) { foreach (Square to in Square.YieldSquares()) { FigureMoving fm = new FigureMoving(fs, to); if (moves.CanMove(fm)) { yield return(fm.ToString()); } } } }
public Board Move(FigureMoving figure) { var newBoard = new Board(Fen); newBoard.SetFigureAt(figure.From, Figure.none); newBoard.SetFigureAt(figure.To, figure.Promotion == Figure.none ? figure.Figure : figure.Promotion); if (moveColor == Color.black) { newBoard.MoveNumber++; } newBoard.moveColor = moveColor.FlipColor(); newBoard.GenerateFen(); return(newBoard); }
private void FindAllMoves() { 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)) { continue; } if (!_board.IsCheckAfterMove(fm)) { allMoves.Add(fm); } } } }
public bool IsCheckAfterMove(FigureMoving fm) { var after = Move(fm); return(after.CanEatKing()); }