Ejemplo n.º 1
0
        public void Display(BoardView board)
        {
            Console.Clear();
            Console.WriteLine("  a b c d e f g h ");
            for (int y = 7; y >= 0; y--)
            {
                Console.Write(y + 1 + " ");
                for (int x = 0; x < 8; x++)
                {
                    Point          point = new Point(x, y);
                    ImmutablePiece piece = board[point];

                    SetColor(point, piece);

                    if (board.IsEmpty(point))
                    {
                        Console.Write("  ");
                    }
                    else
                    {
                        Console.Write(board[point].Identifier + " ");
                    }
                }
                SetDefaultColor();
                Console.WriteLine();
            }
            Console.WriteLine();
        }
Ejemplo n.º 2
0
        private bool _IsCheck(int[] dx, int[] dy, Board.PieceGetter GetPiece)
        {
            for (int i = 0; i < dx.Length; i++)
            {
                Point          delta = new Point(dx[i], dy[i]);
                ImmutablePiece piece = GetPiece(king.CurrentPoint, delta);

                if (piece == null || king.IsFriendly(piece))
                {
                    continue;
                }

                if (piece.CanMoveTo(king.CurrentPoint, board))
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 3
0
        private void SetColor(Point point, ImmutablePiece piece)
        {
            if ((point.x + point.y) % 2 == 0)
            {
                Console.BackgroundColor = ConsoleColor.DarkGray;
            }
            else
            {
                Console.BackgroundColor = ConsoleColor.Gray;
            }

            if (piece != null)
            {
                if (piece.Team == Team.White)
                {
                    Console.ForegroundColor = ConsoleColor.White;
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Black;
                }
            }
        }