def visit_shrine(self): """Head to the Shrine of the Unknowable Gods to make offerings.""" self.gods = godgen(2) msg = "The Shrine is mostly deserted at this time of day. " \ "Two of the altars catch your eye: one (choice 1) to " \ + self.gods[0] + ", which offers Enlightenment on a sliding " \ "tithe scale; and one (choice 2) to " + self.gods[1] + ", " \ "which promises Materialism for a single lump sum of 30,000gp." print textwrap.fill(msg), "\nChoice# Offering, or Leave" choice = get_user_input("Shrine> ", character = self.character, \ options = ["leave", "sheet", "equip", "help"]).lower() while choice != "leave": choice = choice.split() if len(choice) < 2 or (choice[0] != "1" and choice[0] != "2"): print "You need to pick both an altar number (1 or 2) " \ "and an offering amount." choice = get_user_input("Shrine> ", \ character = self.character, \ options = ["leave", "sheet", "equip", "help"]).lower() continue try: offering = int(choice[1]) except ValueError: print "You need to pick both an altar number (1 or 2) and " \ "an offering amount." choice = get_user_input("Shrine> ", \ character = self.character, \ options = ["leave", "sheet", "equip", "help"]).lower() continue self.offering(choice[0], offering) save(self) choice = get_user_input("Shrine> ", \ character = self.character, \ options = ["leave", "sheet", "equip", "help"]).lower() print "You leave the shrine and head back into the town square.", '\n'
def generate(rpg): """Wrapper for making a new character""" print "Time to make a new character! It'll be saved under this player name." rpg.character.chargen(rpg.player_name) save(rpg) msg = "In the town of North Granby, the town militia has recently " \ "discovered that the plague of monsters harrassing the townspeople " \ "originates from a nearby dungeon crammed with nasties. As the " \ "resident adventurer, the Mayor of North Granby (a retired " \ "adventurer by the name of Sir Percival) has recruited you to clear " \ "out the dungeon." print textwrap.fill(msg) return rpg
def generate(rpg): """Wrapper for making a new character""" send_to_console("Time to make a new character! It'll be saved under this player name.") rpg.character.chargen(rpg.player_name) save(rpg) msg = "In the town of North Granby, the town militia has recently " \ "discovered that the plague of monsters harrassing the townspeople " \ "originates from a nearby dungeon crammed with nasties. As the " \ "resident adventurer, the Mayor of North Granby (a retired " \ "adventurer by the name of Sir Percival) has recruited you to clear " \ "out the dungeon." send_to_console(textwrap.fill(msg)) return rpg
def town(rpg): """Maintain interactions with the town of North Granby.""" while True: if rpg.character.dead: print "You are dead!" deadchar(rpg) break print "Where would you like to go?\n", "Options: Home, " \ "Questhall, Shop, Shrine, or Dungeon [Level#] (max "+ \ str(rpg.maxdungeonlevel)+")" destinations = ["Dungeon", "Home", "Questhall", "Quest", \ "Shop", "Shrine"] + ["Dungeon "+str(i) for i in \ range(1, rpg.maxdungeonlevel+1)] goto = choose_from_list("Town> ", destinations, rand=False, character=rpg.character, allowed=["sheet", "help", "equip"]) if goto == "Home": print "You hit the sack. Once you've annoyed all " \ "the bedbugs with your ineffectual fists, "\ "you lay down and sleep." rpg.character.sleep() save(rpg) continue elif goto in ["Questhall", "Quest"]: print "You head to the Questhall." rpg.questhall() continue elif goto == "Shop": print "You head into the shop." rpg.visit_shop() continue elif goto == "Shrine": print "You head into the Shrine." rpg.visit_shrine() continue else: goto = goto.split() rpg.destination("start") if goto[0] == "Dungeon" and len(goto) == 1: rpg.dungeonlevel = 1 else: rpg.dungeonlevel = int(goto[1]) print "You head into the Dungeon, level " + str( rpg.dungeonlevel) + "." dungeon(rpg) continue
def town(rpg): """Maintain interactions with the town of North Granby.""" while True: if rpg.character.dead: send_to_console(color.BOLD + "You are dead!" + color.END) deadchar(rpg) break send_to_console("Where would you like to go?\n"+color.BOLD+"Options: Home, " \ "City-Hall, Bazaar, Temple, or Dungeon [Level#] (max "+ \ str(rpg.maxdungeonlevel)+")"+color.END) destinations = ["Dungeon", "Home", "City-Hall", "Quest", \ "Bazaar", "Temple"] + ["Dungeon "+str(i) for i in \ range(1, rpg.maxdungeonlevel+1)] goto = choose_from_list("Town> ", destinations, rand=False, character=rpg.character, allowed=["sheet", "help", "equip"]) if goto == "Home": send_to_console("You returned home," \ +color.BOLD+" game is saved "+color.END+\ "- you had a good nigth sleep.") rpg.character.sleep() save(rpg) continue elif goto in ["City-Hall", "Quest"]: send_to_console("You head to the City-Hall.") rpg.questhall() continue elif goto == "Bazaar": send_to_console("You head into the shop.") rpg.visit_shop() continue elif goto == "Temple": send_to_console("You head into the Temple.") rpg.visit_shrine() continue else: goto = goto.split() rpg.destination("start") if goto[0] == "Dungeon" and len(goto) == 1: rpg.dungeonlevel = 1 else: rpg.dungeonlevel = int(goto[1]) send_to_console("You head into the Dungeon, level " + str(rpg.dungeonlevel) + ".") dungeon(rpg) continue
def town(rpg): """Maintain interactions with the town of North Granby.""" while True: if rpg.character.dead: send_to_console("You are dead!") deadchar(rpg) break send_to_console("Where would you like to go?\n"+"Options: Home, " \ "Questhall, Shop, Shrine, or Dungeon [Level#] (max "+ \ str(rpg.maxdungeonlevel)+")") destinations = ["Dungeon", "Home", "Questhall", "Quest", \ "Shop", "Shrine"] + ["Dungeon "+str(i) for i in \ range(1, rpg.maxdungeonlevel+1)] goto = choose_from_list("Town> ", destinations, rand=False, character=rpg.character, allowed=["sheet","help","equip"]) if goto == "Home": send_to_console("You hit the sack. Once you've annoyed all " \ "the bedbugs with your ineffectual fists, "\ "you lay down and sleep.") rpg.character.sleep() save(rpg) continue elif goto in ["Questhall", "Quest"]: send_to_console("You head to the Questhall.") rpg.questhall() continue elif goto == "Shop": send_to_console("You head into the shop.") rpg.visit_shop() continue elif goto == "Shrine": send_to_console("You head into the Shrine.") rpg.visit_shrine() continue else: goto = goto.split() rpg.destination("start") if goto[0] == "Dungeon" and len(goto) == 1: rpg.dungeonlevel = 1 else: rpg.dungeonlevel = int(goto[1]) send_to_console("You head into the Dungeon, level "+str(rpg.dungeonlevel)+".") dungeon(rpg) continue