public bool CanMove(FigureMoving fm) { this.fm = fm; return(CanMoveFrom() && CanMoveTo() && CanFigureMove()); }
public Chess Move(string move) { FigureMoving fm = new FigureMoving(move); if (!moves.CanMove(fm)) { return(this); } Board nextBoard = board.Move(fm); return(new Chess(nextBoard)); }
public Board Move(FigureMoving fm) { Board next = new Board(Fen); next.SetFigureAt(fm.From, Figure.none); next.SetFigureAt(fm.To, fm.Promotion == Figure.none ? fm.Figure : fm.Promotion); if (MoveColor == Color.black) { next.MoveNumber++; } next.MoveColor = MoveColor.FlipColor(); next.GenerateFen(); return(next); }
private bool CanEatKing() { Square badKing = FindBadKing(); Moves moves = new Moves(this); foreach (FigureOnSquare fs in YieldFigures()) { FigureMoving fm = new FigureMoving(fs, badKing); if (moves.CanMove(fm)) { return(true); } } return(false); }
public Board Move(FigureMoving fm) { Board next = new Board(fen); next.SetFigureAt(fm.from, Figure.none); next.SetFigureAt(fm.to, fm.promotion == Figure.none ? fm.figure : fm.promotion); if (moveColor == Color.black) { next.moveNumber++; } next.moveColor = moveColor.FlipColor(); next.GenerateFEN(); return(next); }
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)) { allMoves.Add(fm); } } } }
public Chess Move(string move) // Pe2e4 Pe7e8Q { FigureMoving fm = new FigureMoving(move); if (!moves.CanMove(fm)) { return(this); } if (board.isCheckAfterMove(fm)) { return(this); } Board nextBoard = board.Move(fm); Chess nextChess = new Chess(nextBoard); return(nextChess); }
public bool isCheckAfterMove(FigureMoving fm) { Board after = Move(fm); return(after.CanEatKing()); }