public Board(string fen, MoveController mc) : base(fen)
 {
     this.mc = mc;
     DropEnpassant();
     SetEnpassant();
     MoveFigures();
     ChangeCurrentMoveColor();
     MoveCastlingRook();
     UpdateCastlingFlags();
     ChangeMoveNumber();
     CreateNewFen();
 }
Example #2
0
        public Chess Move(string move)
        {
            if (!isValidMove(move))
            {
                return(this);
            }
            MoveController  moveController = new MoveController(move);
            BoardController newBC          = boardController.Move(moveController);
            Chess           newChessEngine = new Chess(newBC);

            return(newChessEngine);
        }
Example #3
0
        public bool isValidMove(string move)
        {
            MoveController moveController = new MoveController(move);

            if (!moves.CanMove(moveController))
            {
                return(false);
            }
            if (boardController.isCheckAfter(moveController))
            {
                return(false);
            }
            return(true);
        }
Example #4
0
 public IEnumerable <string> YieldValidMoves()
 {
     foreach (FigureOnCell fc in boardController.YieldFiguresOnCell())
     {
         foreach (Cell cell in Cell.YieldBoardCells())
         {
             foreach (Figure transformation in fc.figure.YieldTransformations(cell))
             {
                 MoveController mc = new MoveController(fc, cell, transformation);
                 if (moves.CanMove(mc))
                 {
                     if (!boardController.isCheckAfter(mc))
                     {
                         yield return(mc.ToString());
                     }
                 }
             }
         }
     }
 }
Example #5
0
 public bool CanMove(MoveController mc)
 {
     this.moveController = mc;
     return(CanMoveCurrent() && CanMoveNew() && CanFigureMove());
 }
        public bool isCheckAfter(MoveController mc)
        {
            BoardController after = Move(mc);

            return(after.CanEatKing());
        }
 public BoardController Move(MoveController moveController)
 {
     return(new Board(Fen, moveController));
 }