I tried writing a similar script and everything in mine works fine except I can't fight the Goblin King. The relavant line is
adventure(1, $location[The King's Chamber]);
same as in your script but mafia tells me no such location exists. Anyone know why?