Пример #1
0
 public bool CanMove(FigureMoving fm)
 {
     this.fm = fm;
     return
         (CanMoveFrom() &&
          CanMoveTo() &&
          CanFigureMove() &&
          !board.IsCheckAfterMove(fm));
 }
Пример #2
0
        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);
        }
Пример #3
0
 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());
             }
         }
     }
 }
Пример #4
0
        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);
        }
Пример #5
0
 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);
             }
         }
     }
 }
Пример #6
0
        public bool IsCheckAfterMove(FigureMoving fm)
        {
            var after = Move(fm);

            return(after.CanEatKing());
        }