def explore(self): """Explore the dungeon!""" room = random.choice([random.randint(1, 20) for i in range(6)]) self.whereareyou = "dungeon" if room <= 2: send_to_console("You find a flight of stairs, leading down! " \ +color.BOLD+"Go down, or Stay?"+color.END) choice = choose_from_list("Stairs> ", \ ["down", "go down", "stay"], rand=False, \ character=self.character, allowed=['sheet', 'help', 'equip']) if choice != "stay": self.godownstairs() else: send_to_console("You decide to stick around on level " + \ str(self.dungeonlevel) + " a little while longer.") return elif room > 2 and room <= 5: msg = color.BOLD + "You found a chest! " + color.END chest = pq_treasuregen(self.dungeonlevel) self.character.defeat_enemy(0, chest) loot = [] for i in chest.keys(): if chest[i]: if i == 'gp': loot.append(str(chest[i]) + " gp") elif i == 'ring': loot.append("a Ring of " + chest[i]) else: loot.append("a " + chest[i]) if not loot: msg += "Sadly, it was empty." else: msg += "Inside, you find " + color.BOLD + ", ".join( loot) + "." + color.END send_to_console(msg) return elif room > 5 and room <= 8: msg = "The room echoes with a hollow emptiness, and you " \ "reflect on the vagaries of living life alone... Then " \ "you eat" + sandgen() + ", and get ready to kill more things." send_to_console(textwrap.fill(msg), "\nYou regain " + \ str(self.dungeonlevel) + " hp and sp!") self.character.sammich(self.dungeonlevel) return elif room > 8 and room <= 10: self.whereareyou = "puzzle" self.puzzle = PQ_Puzzle(self.dungeonlevel, self.character) self.puzzle.puzzleinit() #elif room > 10 and room <= 12: # self.whereareyou = "trap" # #elif room > 12: elif room > 10: msg = "You've stumbled on an enemy! It seems to be... " questcheck = self.maxdungeonlevel - self.questlevel cutoff = float(1 + questcheck) / float(10 + 2 * questcheck) if self.dungeonlevel == self.questlevel and self.quest and \ self.character.queststatus == "active" and random.random() \ < cutoff: self.combat = PQ_Combat(self.dungeonlevel, self.character, \ self.quest) msg += color.BOLD + self.quest.name + color.END + '!' else: self.combat = PQ_Combat(self.dungeonlevel, \ self.character, None) if self.dungeonlevel >= 10: msg += color.RED + self.combat.enemy.name + color.END + '!' else: msg += 'a ' + color.BOLD + self.combat.enemy.name + color.END + '!' if self.combat.turnorder[0] == 'player': msg += ' You get the jump on it.' else: msg += ' It gets the jump on you.' send_to_console(msg) self.whereareyou = "combat" self.combat.advance_turn() self.combat = None