Star Trek: The Squire of Gothos

On stardate 2124.5, the starship USS Enterprise, under the command of Captain James T. Kirk, is on an 8-day supply mission to Colony Beta VI. Along the journey, the ship encounters a rogue planet drifting through space. Without the time to really stop and investigate it, Kirk orders the planet to be recorded for a future exploration mission and to continue with their original heading. Suddenly, Kirk and Lt. Sulu are teleported from the bridge.
Spock believes that the two must have been taken to the mysterious planet below even though sensor readings indicate the planet's atmosphere is lethal to most forms of life. The Enterprise then receives a strange message on a viewscreen in blackletter writing, "Greetings and Felicitations!" followed by "Hip hip hoorah. Tallyho!" Spock orders Dr. McCoy, along with Lt. DeSalle and geophysicist Karl Jaeger, to form a landing party and conduct a search.
The landing party beams down and finds the area to be a lush and breathable environment, contradicting Jager's original scans that the world was barren and couldn't support life. They also come to what appears to be a medieval castle constructed in the middle of nowhere. They soon find Captain Kirk and Lt. Sulu, along with a brash and impetuous being who identifies himself as "General Trelane, Retired". McCoy's medical tricorder does not get any readings from Trelane and according to the scanner nothing is there. Trelane invites everyone to stay as his guests on his world he calls Gothos and discuss his favorite subject: the military history of Earth.
Spock, meanwhile, manages to locate the landing party in a minute zone of breathable atmosphere, and beams everyone, except Trelane, back to the ship by locking onto every detectable lifeform in the area. Unwilling to let his guests leave, Trelane makes an appearance on the Enterprise's bridge. He then brings the entire bridge crew back down to the planet. This time he includes Spock, Uhura and Yeoman Teresa Ross.
Kirk's patience begins to wear thin, especially when Trelane dances with Yeoman Ross and changes her uniform into a flowing formal ball gown. Kirk and Spock both notice that their host never strays far from a particular wall mirror; They surmise that the mirror may be the source of his powers. To test this theory, Kirk provokes Trelane into a duel and during the fight he destroys the mirror and damages some strange machinery inside. It is discovered that Trelane uses this machine to manipulate matter for his amusement. The bridge crew manages to beam back to the Enterprise but, as the ship warps away, Gothos keeps appearing in its path. Kirk orders the Enterprise into orbit and is going to beam down. As he enters the turbolift, he suddenly finds himself in a witness stand in a courtroom back on Gothos where the angry Trelane confronts him dressed in the white wig and robes of a magistrate. Trelane tells Kirk he must face a trial for "treason". Over Kirk's protests, Trelane condemns Kirk to death by hanging. However, Kirk, to stall the execution, plays off of Trelane's childish whims by presenting him with a better idea.
In order to have his ship released, Kirk offers himself as the prey for a royal hunt. Trelane gleefully accepts and the hunt begins. This scene is quite reminiscent of Richard Connell's classic tale, "The Most Dangerous Game". Just as Trelane is about to kill Kirk, two energy beings appear and put a stop to his fun. It is revealed that Trelane is the "child" of the two beings. After apologizing to Kirk for their child's misbehavior, the beings disappear along with the whining Trelane, and Kirk is allowed to return to the ship.