Exemple #1
0
 public bool CanMove(FigureMoving fm)
 {
     this.fm = fm;
     return
         (CanMoveForm() &&
          CanMoveTo() &&
          CanFigureMove());
 }
Exemple #2
0
        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);
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        public Chess Move(string move)
        {
            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);
        }
Exemple #5
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);
                 }
             }
         }
     }
 }
Exemple #6
0
        public bool IsCheckAfterMove(FigureMoving fm)
        {
            Board after = Move(fm);

            return(after.CanEatKing());
        }