Beispiel #1
0
        public object Clone()
        {
            IChessPiece clonedChessPiece;

            if (this is Pawn)
            {
                clonedChessPiece = new Pawn(IsWhite(), false)
                {
                    DidMove = DidMove,
                    PathList = PathList.Select(path => path.ClonePath()).ToList(),
                    EatList = EatList
                };
            }
            else if (this is King)
            {
                clonedChessPiece = new King(IsWhite(), false)
                {
                    DidMove = DidMove,
                    PathList = PathList.Select(path => path.ClonePath()).ToList(),
                };
            }
            else if (this is Queen)
            {
                clonedChessPiece = new Queen(IsWhite(), false)
                {
                    DidMove = DidMove,
                    PathList = PathList.Select(path => path.ClonePath()).ToList(),
                };
            }
            else if (this is Rook)
            {
                clonedChessPiece = new Rook(IsWhite(), false)
                {
                    DidMove = DidMove,
                    PathList = PathList.Select(path => path.ClonePath()).ToList(),
                };
            }
            else if (this is Knight)
            {
                clonedChessPiece = new Knight(IsWhite(), false)
                {
                    DidMove = DidMove,
                    PathList = PathList.Select(path => path.ClonePath()).ToList(),
                };
            }
            else if (this is Bishop)
            {
                clonedChessPiece = new Bishop(IsWhite(), false)
                {
                    DidMove = DidMove,
                    PathList = PathList.Select(path => path.ClonePath()).ToList(),
                };
            }
            else
            {
                throw new NotImplementedException();
            }

            return clonedChessPiece;
        }