def enter_dungeon(self, index): try: index = int(index) - 1 if index >= len(self.dungeon_definitions): raise ValueError except ValueError: return ['%s searches the map thoroughly, but can\'t find such a location.' % self.player.name] self.dungeon = Dungeon(self.player, self.dungeon_definitions[index], self.enemy_definitions) self.state = S_DUNGEON return ['%s cautiously entered %s!' % (self.player.name, self.dungeon.name)] + self.new_encounter()