(CNN) President Donald Trump has reason to hope his luck is changing after a long legal losing streak.
Trump got to celebrate a big win Wednesday in an emoluments clause case relating to his Washington hotel. And there are signs that a case in Louisiana could cause yet another near death experience for Obamacare, his predecessor's top domestic achievement.
The courtroom action this week represents a potential reversal of fortune for Trump following a long list of defeats the President has tasted on cases from immigration to the 2020 census to his efforts to thwart Democratic oversight to his central campaign promise to build a border wall. For a man who bills himself as one of life's ultimate winners, Trump's legal losing record is a branding nightmare.
Yet the intimate relationship between this President and the courts actually goes beyond the win-loss calculation that normally powers Trump's life. The judicial system serves multi-dimensional roles for Trump in his personal, business and Washington life.
While the law has often frustrated Trump's political goals, he has still used it as a weapon to combat Democrats, as the glue in his conservative coalition and to postpone threatening political crises.
Often -- as in the case of Trump's national emergency declaration designed to fund his border wall or the census -- it seems as if the long odds in court do not deter the President. The law gives Trump another venue for the endless fights that sustain his politics and his personality. Even if he loses he is showing his supporters he's never giving up the battle.
Trump's judicial appointments are likely to shape the character of American life for years after he's left the White House. And it's still possible court rulings could pose an existential threat to his personal and business legacy given the flurry of cases currently open in New York.
As is often the case, Trump's wins in the courts have been outnumbered by his losses this week.
On Tuesday, an appeals court ruled that the President violated the First Amendment by blocking Twitter users.
The administration has just tumbled to defeat before different judges -- including in the Supreme Court -- on its attempts to place a citizenship question on the 2020 census.
Two significant court rulings in May upheld Congress in its battle to subvert Trump's war on oversight over Democratic lawmakers' efforts subpoena his financial records.
Trump has also tasted defeat in huge cases on immigration -- slowing or thwarting his efforts to build his border wall, and right at the start of his term on his original travel ban. The Supreme Court has since allowed parts of a rewritten plan to stand.
Research by the Center for Policy Integrity at the University of New York School of Law showed that the administration had won only three of 42 deregulatory cases, a paltry success rate of only 7%.
Yet Trump's relationship with the courts is actually far more complicated than the win-loss ratio with which he judges his own success and that of everyone around him.
In decades as a businessman Trump was the initiator and the target of thousands of lawsuits. He used the courts to try to extricate himself from dicey situations, as a weapon in negotiations and to test the legal limits of business practice.
He used lawsuits to save face, to offer a new venue to prolong a fight, to put off a reckoning or agreed out-of-court settlements to limit the costs of personal and business liabilities.
As President, Trump has also used courts to fulfill wider goals than simply winning and losing cases, especially since he's struggled to get many major bills through Congress -- apart from a big tax reform program.
With bold assertions of executive power, Trump has made the courts a constant presence in his presidency.
When he's won, he's trumpeted it. When -- more often -- he loses, the judgments become exhibits in his foundational political case that an elite establishment is out to get him and that he's being treated unfairly.
"So now the Obama appointed judge on the Census case (Are you a Citizen of the United States?) won't let the Justice Department use the lawyers that it wants to use. Could this be a first?" Trump tweeted after a reverse in the census case on Tuesday.
His frequent complaints about "Obama judges" reveal his view that the courts are simply an extension of the political game and earned him a rebuke from Chief Justice John Roberts.
Administrations often try to achieve through the courts what they cannot legislatively -- and the Trump team along with allied GOP states has been especially enthusiastic in this regard.
Just this week, in a hearing in New Orleans, two Republican-appointed appellate judges appeared to suggest in oral arguments that a fresh challenge to Obamacare could succeed.
The case also reflects the manner in which, in an era of congressional stasis and polarization, courts are being called upon to do the job lawmakers might once have done.
Judge Kurt Engelhardt questioned why, after a US district judge declared the whole ACA unconstitutional, Congress did not pass a law clarifying what provisions should stay on the books.
"Why does Congress want the ... judiciary to become the taxidermist for every legislative big-game accomplishment that Congress achieves?" Engelhardt asked.
The administration's legal gambits have often reflected the chaos and politicized arguments that rock the administration every day and have sometimes hampered its own chances of success.
Last week, for instance, a Justice Department lawyer admitted he had no idea what was in Trump's mind when he suddenly reversed course on the census case on Twitter.
Sometimes, Trump has turned to personal litigation to try to frustrate his political enemies.
In March, Trump personally sued his own accounting firm and the chairman of the House Oversight Committee to try to stop the handover of his financial records.
The President has sometimes been the target of litigation as well: Democrats are increasingly turning to the courts to enforce subpoenas.
A huge test of presidential authority is looming over Trump's sweeping claims of executive privilege that may eventually work their way up to the highest courts.
The cases could eventually lead to profound rulings about the scope of presidential power that could resonate for decades to come. And if Trump were to refuse to hand over documents or tax returns ordered by the courts, he could turn overused predictions of a looming constitutional crisis into reality.
Treasury Secretary Steven Mnuchin's refusal to hand over Trump's tax returns to a House committee under a provision of the tax code is likely to spark a long and costly court fight.
That's an example of where legal action suits Trump just fine.
In such cases there's a good chance he will fail on the merits -- but the law's slow march means that he's at least putting off a threatening political situation for another day -- possibly even beyond the 2020 election.
Each new challenge becomes a new example of the "presidential harassment" -- the term Trump and his allies use to stoke a sense of victimhood around his administration and to solidify his support with his all-important political base.
While the President may feel that he has a good chance of evading the worst possible outcome of Robert Mueller's special counsel probe -- he may not be out of the legal mire yet.
Trump is facing multiple civil and criminal investigations of his business, financial affairs, personal conduct, his foundation and inaugural committee.
The political synergy between Trump and the courts has an even deeper connection to his presidency than cases in which he is embroiled.
The President's decision to publicize a list of potential Supreme Court justices vetted by the Federalist Society was in retrospect one of the smartest moves of his 2016 campaign, embedding evangelical and judicial conservatives into his support base despite doubts about his character and ideology.
Trump has delivered on his vows to build a conservative majority on the Supreme Court with the seating of Justices Neil Gorsuch and Brett Kavanaugh. The court's new ideological balance means that rulings favorable to Trump's leanings on everything from deregulation to abortion could be handed down for years to come.
And the President's alliance with Senate Republican Majority leader Mitch McConnell has been confirming conservative judges to lower courts at an impressive clip.
According to the Heritage Foundation's Judicial Appointments Tracker, Trump has installed 127 federal judges -- more than President Barack Obama's figure of 89 at the equivalent point in his presidency.
There is no guarantee that such judges will necessarily share Trump's challenging and unique interpretations on the limits of presidential power.
But some of them could provide a more ideologically friendly judiciary for Trump's policy efforts if he wins a second term and could help break his losing streak.
And the Trump class of judges at all levels of the federal bench is likely to frustrate a future Democratic president.