예제 #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();
        }
예제 #2
0
파일: Player.cs 프로젝트: lalaalal/Chess
        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);
        }
예제 #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;
                }
            }
        }