In a hilarious turn of the screw, adult film star Stormy Daniels — who says she had an affair with Donald Trump in 2006, signed a non-disclosure agreement to stay silent about said affair then sued to break that agreement earlier this year, then broke that agreement anyway by speaking out about the alleged one-night stand, then sued Trump again for defamation when he tweeted a response to her speaking out — was ordered by a judge Tuesday to pay nearly $300K in legal fees racked up while Trump’s lawyers fought the defamation case.

Got all that? 

“The U.S. District Court today ordered Stormy Daniels (real name Stephanie Clifford) to pay President Trump $293,052.33 to reimburse his attorneys’ fees (75% of his total legal bill), plus an additional $1,000 in sanctions to punish Daniels for having filed a meritless lawsuit against the President designed to chill his free speech rights,” Charles J. Harder, the president’s legal counsel, said in a statement.

Attorneys for President Trump had asked a court earlier this month for nearly $800,000 in lawyers’ fees and penalties from Daniels for the failed defamation lawsuit against him. Harder defended more than 500 hours his firm spent that rang up a nearly $390,000 legal bill for the president and asked for an equal amount in sanctions as a deterrent against a “repeat filer or frivolous defamation cases.”

And if you thought this would all go down without Daniels’ lawyer Michael Avenatti getting involved, you live in a very pretty world.

“Charles Harder and Trump deserve each other because they are both dishonest,” Avenatti tweeted. “If Stormy has to pay $300k to Trump in the defamation case (which will never hold up on appeal) and Trump has to pay Stormy $1,500,000 in the NDA case (net $1,200,000 to Stormy), how is this a Trump win?”

Daniels’ defamation suit was thrown out of court in October because it was decided that Trump’s tweet about Daniels’ violation of the non-disclosure agreement was protected speech.

The ruling also apparently entitled Trump to attorney and legal fees, which led many to speculate that the GoFundMe account set up to help Stormy Daniels would in fact ultimately be going to pay Trump.

Regardless of the source of the money, Daniels is on the hook; at least if and until she manages to successfully appeal the ruling.

For what it’s worth, Trump has denied the affair ever took place.