Forcecage is exactly what you are searching.
But taking an offensive spell first is not always a good choice, especially when a spell like Limited Wish (great versatility) is available.

(Dungeons & Dragons)
Rulebook featuring "high magic" options, including a host of new spells.