Warner Bros. makes a big gamble, and after a trial held last year, gets a deal for a new project to be produced by Roy Lee ('The Lego Movie').

Nearly a year after a six-day trial was held on the past and future of the Dungeons & Dragons franchise, Warner Bros., Hasbro and Sweetpea Entertainment have worked out a deal that will usher in a new film and avoid a judge's intervention.

The upcoming Warner Bros motion picture will be based on a script by David Leslie Johnson (Wrath of the Titans) and produced by Roy Lee (The Lego Movie, How To Train Your Dragon) with the involvement of Hasbro chief executive Brian Goldner and chief content officer Stephen Davis. It will take place in the popular D&D campaign setting of the Forgotten Realms.

"We are so excited about bringing the world of Dungeons & Dragons to life on the big screen," said Greg Silverman, president of creative development and worldwide production at Warner Bros. Pictures. "This is far and away the most well-known brand in fantasy, which is the genre that drives the most passionate film followings. D&D has endless creative possibilities, giving our filmmakers immense opportunities to delight and thrill both fans and moviegoers new to the property."

An announcement was made after parties filed papers in California federal court dismissing a lawsuit with prejudice.

Four years ago, Warner Bros. Pictures rolled the dice by commissioning a screenplay based on the fantasy game first published in 1974. This was a particular risk because the studio didn't have rights lined up. When Johnson delivered Chainmail, based on board game from D&D designer Gary Gygax, Warners began investigating the possibility of acquiring rights from Hasbro.

Warners offered $5 million to purchase rights and 5 percent gross, but Hasbro made a deal with Universal Pictures instead.

This didn't end the matter, however, because Warners was quite enthusiastic about Johnson's script and D&D rights turned out to be complicated.

In 1994, Courtney Solomon's Sweetpea optioned D&D from a company later acquired by Hasbro for a mere $15,000 and eventually produced a film released in 2000 that was both a commercial and critical flop.

Sweetpea deal — actually an amendment to the contract to resolve prior litigation — gave Sweetpea sequel rights so long as it produced one in a timely fashion. And so, two more D&D films came out. The first, Dungeons & Dragons: Wrath of the Dragon God, premiered on the SyFy Channel in 2005 and the second, Dungeons & Dragons: The Book of Vile Darkness, aired on the SyFy Channel in 2012.

After Universal beat Warner Bros. to a deal with Hasbro for a new film, Warners began investigating the possibility of getting rights through Sweetpea.

Hasbro contended that Sweetpea's rights had reverted, and that its TV films didn't constitute proper sequels. The issue was brought to trial last September in a proxy war of sorts between two big studios. Before trial, Warners invested $5 million acquiring Sweetpea rights and covering legal costs. In October, the parties delivered post-trial arguments.

Since then, U.S. District Judge Dolly Gee has held back on issuing a ruling. Instead, she has urged the two sides to settle.

On Monday, after months of negotiation, the parties were finally able to reveal they had come to an undisclosed arrangement to end the lawsuit, but one that will give Warner Bros. confidence in moving forward with its film. It's unclear whether Universal has signed off on this deal.

Maura Wogan and Jeremy Goldman of Frankfurt Kurnit Klein & Selz acted as lead counsel for Hasbro and Wizards of the Coast, and issued a statement: "This settlement accomplished our overarching goal of unifying all Dungeons & Dragons rights under Hasbro's control, paving the way to make a blockbuster film. It's a great outcome for those involved — especially Dungeons & Dragons fans who will now get to see D&D on the big screen.

Patty Glaser and Jill Basinger of Glaser Weil Fink Howard Avchen & Shapiro acted as lead counsel for Sweetpea and tried the case with Chris Caldwell of Caldwell Leslie & Proctor. As part of the agreement, Sweetpea's Solomon and Allan Zeman are also attached as producers of the new film.