def main(ctx, arg1, arg2, arg3, arg4): # /|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|/ # Names # /|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|/ if arg1 == "randomname" or arg1 == "rname": openoutput = randomnamegenerator.main() elif arg1 == "malename" or arg1 == "mname": openoutput = np.random.choice(malenamelist) elif arg1 == "femalename" or arg1 == "fname": openoutput = np.random.choice(femalenamelist) elif arg1 == "surname" or arg1 == "sname": openoutput = np.random.choice(surnamelist) # /|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|/ # NPCS # /|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|/ elif arg1 == "fantasyNPC" or arg1 == "fNPC": #Generates a fantasy NPC. if arg2 == "nothing was entered0": NPC = fantasyNPCgenerator.main() else: NPC = fantasyNPCgenerator.main(arg2) output = "Name: " + NPC["name"] + "\nGender: " + NPC["gender"] + "\nAge: " + str(int(NPC["age"])) \ + "\nOccupation: " + str(NPC["occupation"]) + "\nCharacteristic: " + NPC["characteristic"] openoutput = output output += "\nTrait: " + NPC["trait"] dummy = NPC["secret"] if str(dummy) != str("Has no secret"): output += "\nSecret: " + dummy secretoutput = output # /|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|/ # Inns # /|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|/ elif arg1 == "fantasyinn" or arg1 == "finn" or arg1 == "inn": inn = fantasyinngenerator.main() output = "__**Inn**__\nName: " + inn["name"] + "\nOddity: " + inn["oddity"] \ + "\nSpeciality: " + inn["specialty"] openoutput = output output += "\nSecret: " + inn["secret"] secretoutput = output owner = fantasyNPCgenerator.main("Innkeeper") waiter = fantasyNPCgenerator.main("Waiter") openoutput += "\n\n**Owner**\nName: " + owner["name"] + "\nGender: " + owner["gender"] + "\nAge: " \ + str(int(owner["age"])) + "\nOccupation: " + str(owner["occupation"]) + "\nCharacteristic: " \ + owner["characteristic"] openoutput += "\n\n**Waiter**\nName: " + waiter["name"] + "\nGender: " + waiter["gender"] + "\nAge: " \ + str(int(waiter["age"])) + "\nOccupation: " + str(waiter["occupation"]) + "\nCharacteristic: " \ + waiter["characteristic"] secretoutput += "\n\n**Owner**\nName: " + owner["name"] + "\nGender: " + owner["gender"] + "\nAge: " \ + str(int(owner["age"])) + "\nOccupation: " + str(owner["occupation"]) + "\nCharacteristic: " \ + owner["characteristic"] + "\nTrait: " + owner["trait"] + "\nSecret: " + owner["secret"] secretoutput += "\n\n**Waiter**\nName: " + waiter["name"] + "\nGender: " + waiter["gender"] + "\nAge: " \ + str(int(waiter["age"])) + "\nOccupation: " + str(waiter["occupation"]) + "\nCharacteristic: " \ + waiter["characteristic"]+ "\nTrait: " + waiter["trait"] + "\nSecret: " + waiter["secret"] # /|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|/ # Missions # /|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|/ elif arg1 == "mission" or arg1 == "mis" or arg1 == "m": #Generates a mission. if arg2 == "nothing was entered0": mission = missiongenerator.main() else: mission = missiongenerator.main(int(arg2)) output = "Difficulty: " + str( mission["difficulty"]) + "\nObjective: \n" i = 1 while i < len(mission["objectives"]): output += " * " + mission["objectives"][i - 1] + "\n" i += 1 output += "Reward: " + str(mission["reward"]) if len(mission["opencomplications"]) > 0: output += "\nComplications: \n" i = 0 while i < len(mission["opencomplications"]): output += " * " + mission["opencomplications"][i] + "\n" i += 1 openoutput = output if len(mission["secretcomplications"]) > 0: output += "Secret complications: \n" i = 1 while i < len(mission["secretcomplications"]): output += " * " + mission["secretcomplications"][i - 1] + "\n" i += 1 secretoutput = output elif arg1 == "jobboard" or arg1 == "jb": if arg2 == "nothing was entered0": arg2 = 5 openoutput = "__Job Board__\n\n" secretoutput = "__Job Board__\n\n" k = 0 while k < int(arg2): k += 1 mission = missiongenerator.main() output = "\n__Job: " + str(k) + "/" + str( arg2) + "__\nDifficulty: " + str( mission["difficulty"]) + "\nObjective: \n" i = 0 while i < len(mission["objectives"]): output += " * " + mission["objectives"][i] + "\n" i += 1 output += "Reward: " + str(mission["reward"]) if len(mission["opencomplications"]) > 0: output += "\nComplications: \n" i = 0 while i < len(mission["opencomplications"]): output += " * " + mission["opencomplications"][i] + "\n" i += 1 openoutput += output if len(mission["secretcomplications"]) > 0: output += "Secret complications: \n" i = 0 while i < len(mission["secretcomplications"]): output += " * " + mission["secretcomplications"][i] + "\n" i += 1 secretoutput += output output = "" # /|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|/ # Settlements # /|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|/ elif arg1 == "fantasysettlement" or arg1 == "fsettlement" or arg1 == "fset": #fantasy settlement if arg2 == "nothing was entered0": arg2 = 0 openoutput, secretoutput = fantasysettlementformat( fantasysettlementgenerator.main(arg2)) elif arg1 == "fantasyoutpost" or arg1 == "foutpost": #fantasy outpost openoutput, secretoutput = fantasysettlementformat( fantasysettlementgenerator.main(1)) elif arg1 == "fantasyhamlet" or arg1 == "fhamlet": #fantasy hamlet openoutput, secretoutput = fantasysettlementformat( fantasysettlementgenerator.main(2)) elif arg1 == "fantasyvillage" or arg1 == "fvillage": #fantasy village openoutput, secretoutput = fantasysettlementformat( fantasysettlementgenerator.main(3)) elif arg1 == "fantasytown" or arg1 == "ftown": #fantasy town openoutput, secretoutput = fantasysettlementformat( fantasysettlementgenerator.main(4)) elif arg1 == "fantasyvcity" or arg1 == "fcity": #fantasy city openoutput, secretoutput = fantasysettlementformat( fantasysettlementgenerator.main(5)) # end of generator # /|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|/ # Book keeping # /|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|/ elif arg1 == "nothing was entered0": openoutput = "There must be an argument after gen, use !itemlist to get a list" else: openoutput = arg1 + " is not a valid generator argument, use !itemlist to get a list" try: secretoutput except NameError: secretoutput = openoutput return (openoutput, secretoutput)
def fantasysettlementformat(settlement): # general settlement stuff output = "__**" + settlement["size"] + "**__\n" output += "Name: " + settlement["name"] + "\n" output += "Population: " + str(settlement["population"]) + "\n" openoutput = output output += "Age: " + str(settlement["age"]) + "\n" secretoutput = output output = "Asset: " + settlement["asset"] + "\n" output += "Oddity: " + settlement["oddity"] + "\n" openoutput += output + "\n" output += "Problem: " + settlement["problem"] + "\n" secretoutput += output + "\n" # Ruler stuff output = "**Ruler**\n" if settlement["ruler"]["individual"]: output += "Name: " + settlement["ruler"]["name"] + "\n" output += "Gendre: " + settlement["ruler"]["gender"] + "\n" output += "Title: " + settlement["ruler"]["occupation"] + "\n" openoutput += output + "\n" output += "Age: " + str(settlement["ruler"]["age"]) + "\n" output += "Characteristic: " + settlement["ruler"][ "characteristic"] + "\n" output += "Trait: " + settlement["ruler"]["trait"] + "\n" if str(settlement["ruler"]["secret"]) != str("Has no secret"): output += "Secret: " + settlement["ruler"]["secret"] + "\n" secretoutput += output + "\n" else: output += settlement["ruler"]["adjective"] + " " + settlement["ruler"][ "title"] output += "\nNumber of membres: " + str(settlement["ruler"]["number"]) openoutput += output + "\n\n" secretoutput += output + "\n\n" # Institutions output = "**Institutions**" for institution in settlement["institutions"]: output += "\n\n**" + institution["discriptor"] + "**\n" output += "Name: " + institution["name"] openoutput += output + "\n" secretoutput += output output = "" if institution["identifier"] == 1 or institution[ "identifier"] == 2: #inn/tavern output += "\nOddity: " + institution["oddity"] \ + "\nSpeciality: " + institution["specialty"] output += "\nSecret: " + institution["secret"] secretoutput += output output = "" owner = fantasyNPCgenerator.main("Owner") waiter = fantasyNPCgenerator.main("Waiter") secretoutput += "\n\n**Owner**\n" + secretcharaformat(owner) secretoutput += "\n\n**Waiter**\n" + secretcharaformat(waiter) elif institution["identifier"] == 3: #trading post secretoutput += "\nFood vendors:\n" for vendor in institution["food"]: secretoutput += " " + vendor + "\n" secretoutput += "Smell: " + institution["smell"] elif institution["identifier"] == 4: #Temple secretoutput += "\nPrincipal succour: " + institution[ "succour"] + "\n" highpriest = fantasyNPCgenerator.main("High priest") secretoutput += "\n**High priest**\n" + secretcharaformat( highpriest) elif institution["identifier"] == 5: #Library secretoutput += "\nAreas of focus:\n" for discipline in institution["disciplines"]: secretoutput += " " + discipline + "\n" librarian = fantasyNPCgenerator.main("Librarian") secretoutput += "\n**Librarian**\n" + secretcharaformat(librarian) elif institution["identifier"] == 6: #University secretoutput += "\nClasses taught:\n" for discipline in institution["disciplines"]: secretoutput += " " + discipline + "\n" dean = fantasyNPCgenerator.main("Dean") secretoutput += "\n**Dean**\n" + secretcharaformat(dean) elif institution["identifier"] == 7: #Park secretoutput += "\nCentre piece: " + institution[ "centrepiece"] + "\n" return (openoutput, secretoutput)
def main(races=[], race=None, ethnicity="eng", size=0): # Generates a random settlement from tables and RNGs, the output is an object #The input selects the size 0: Random, 1:Outpost, 2: Hamlet, 3:Village, 4:Town, 5:City output = {} size = int(size) output["ethnicity"] = "eng" if races == []: output["race"] = "" maxsize = 5 minsize = 1 else: if race is None: sumw = 0.0 for ra in races: if ra["maxsettlement"] >= 0: sumw += float(ra['weight']) rand = random.random() * sumw dum = 0 for ra in races: if ra["maxsettlement"] >= 0: dum += float(ra['weight']) if rand < dum: output["race"] = ra['racename'] maxsize = max(1, min(5, int(ra['maxsettlement']))) minsize = max(1, int(ra['maxsettlement']) - 4) break else: output["race"] = race ra = rm.exracebyn(races, race) ra = np.random.choice(ra) maxsize = max(1, min(5, int(ra['maxsettlement']))) minsize = max(1, int(ra['maxsettlement']) - 4) if size == 0: setsizeweight = np.array([2.0, 3.0, 3.0, 2.0, 1.0]) setsizeweight = setsizeweight[minsize - 1:maxsize - 1] setsizeweight = setsizeweight / sum(setsizeweight) if minsize == maxsize: size = minsize else: size = np.random.choice(range(minsize, maxsize), p=setsizeweight) dummy = ["Outpost", "Hamlet", "Village", "Town", "City"] output["size"] = dummy[size - 1] rnd = random.random() if rnd < 0.55: output["name"] = random.choice(namelist) elif rnd < 0.70: output["name"] = random.choice(namelist1) + "-" + random.choice( namelist2) elif rnd < 0.90: output["name"] = random.choice(namelist1) + random.choice( namelist2).lower() else: output["name"] = randomnamegenerator.main() if random.random() < 0.85: tempraces = [] if random.random() < 0.96: if races == []: output["ethnicity"] = ethnicity else: tempraces = rm.exracebyn(races, output["race"]) else: if races == []: output["ethnicity"] = np.random.choice(names.humanethnicities) else: tempraces = rm.exracebys(races, size) output["ruler"] = fantasyNPCgenerator.main(tempraces, output["ethnicity"]) output["ruler"]["individual"] = True if output["ruler"]["gender"] == "female": output["ruler"]["occupation"] = random.choice(rulerlist)[1] else: output["ruler"]["occupation"] = random.choice(rulerlist)[0] ruler = output["ruler"]["occupation"] if output["ruler"]["occupation"] == "Elder": output["ruler"]["age"] = "" else: output["ruler"] = {} output["ruler"]["individual"] = False if random.random() < 0.85: output["ruler"]["number"] = random.randint(2, 14) else: output["ruler"]["number"] = random.randint(15, 30) output["ruler"]["title"] = str(random.choice(councillist)) ruler = output["ruler"]["title"] output["ruler"]["adjective"] = str(random.choice(counciladjectivelist)) institutionnum = random.randint(round(size / 2.1) + 1, size) if institutionnum > 3: institutionnum = 4 output["institutions"] = [] for i in range(institutionnum): output["institutions"].append(fantasyinstitutiongenerator.main()) output["institutions"][i]["name"] = output["institutions"][i][ "name"].replace("@here", output["name"]) for institutcheck in output["institutions"]: for i in range(institutionnum): if output["institutions"][i]["name"] == institutcheck["name"]: if output["institutions"][i] != institutcheck: output["institutions"].pop(i) break output["problem"] = str(random.choice(problemlist)) output["asset"] = str(random.choice(assetlist)) output["oddity"] = str(random.choice(odditylist)) output["sizenum"] = size output["problem"] = output["problem"].replace("@settlement@", str(output["size"]), 4) output["asset"] = output["asset"].replace("@settlement@", str(output["size"]), 4) output["oddity"] = output["oddity"].replace("@settlement@", str(output["size"]), 4) output["problem"] = output["problem"].replace("@ruler@", str(ruler), 4) output["asset"] = output["asset"].replace("@ruler@", str(ruler), 4) output["oddity"] = output["oddity"].replace("@ruler@", str(ruler), 4) output["asset"] = output["asset"].lower() output["oddity"] = output["oddity"].lower() output["asset"] = output["asset"].capitalize() output["oddity"] = output["oddity"].capitalize() return (output)
def main(size=0): # Generates a random settlement from tables and RNGs, the output is an object #The input selects the size 0: Random, 1:Outpost, 2:Village, 3:Town, 4:City output = {} if size == 0: rand = random.random() size = 1 if rand < 0.87: size = 2 if rand < 0.65: size = 3 if rand < 0.30: size = 4 if rand < 0.30: size = 5 if size == 1: output["population"] = random.randint(6, 20) elif size == 2: output["population"] = random.randint(21, 100) elif size == 3: output["population"] = random.randint(101, 400) elif size == 4: output["population"] = random.randint(401, 2500) elif size == 5: output["population"] = random.randint(2501, 30000) dummy = ["Outpost", "Hamlet", "Village", "Town", "City"] output["size"] = dummy[size - 1] if random.random() < 0.65: output["name"] = random.choice(namelist) else: output["name"] = randomnamegenerator.main() if random.random() < 0.97: output["age"] = random.randint( 0, 300) + (size - 1) * random.randint(20, 250) else: output["age"] = "Unknown" if random.random() < 0.85: output["ruler"] = fantasyNPCgenerator.main(random.choice(rulerlist)) output["ruler"]["individual"] = True if output["ruler"]["occupation"] == "Elder": output["ruler"]["age"] = round(output["ruler"]["age"] / 2) + 60 else: output["ruler"] = {} output["ruler"]["individual"] = False if random.random() < 0.85: output["ruler"]["number"] = random.randint(2, 14) else: output["ruler"]["number"] = random.randint(15, 30) if output["ruler"]["number"] > output["population"] / 2: output["ruler"]["number"] = round(output["population"] / 2) output["ruler"]["title"] = str(random.choice(councillist)) output["ruler"]["adjective"] = str(random.choice(counciladjectivelist)) institutionnum = random.randint(1, size) output["institutions"] = [] for i in range(institutionnum): output["institutions"].append(fantasyinstitutiongenerator.main()) output["institutions"][i]["name"] = output["institutions"][i][ "name"].replace("@here", output["name"]) output["problem"] = str(random.choice(problemlist)) output["asset"] = str(random.choice(assetlist)) output["oddity"] = str(random.choice(odditylist)) return (output)
def fantasysettlementformat(races, settlement): # general settlement stuff output = "__**" + settlement["name"] + "**__: " output += settlement["race"].capitalize() + " " + settlement["size"] + "\n" # output += "Population: " + str(settlement["population"]) + "\n" Current philosophy goes against giving an accurate population, plus settlement have sufficient content openoutput = output # output += "Age: " + str(settlement["age"]) + "\n" Current philosophy goes against giving an accurate age secretoutput = output output = "Asset: " + settlement["asset"] + "\n" output += "Oddity: " + settlement["oddity"] + "\n" openoutput += output + "\n" output += "Problem: " + settlement["problem"] + "\n" secretoutput += output + "\n" # Ruler stuff output = "__Ruler__: " if settlement["ruler"]["individual"]: output += settlement["ruler"]["name"] + "\nA" output += str(settlement["ruler"]["age"]) + " " + str(settlement["ruler"]["gender"]) + " " + str(settlement["ruler"]["race"]) + " " + str(settlement["ruler"]["occupation"]) + "\n" openoutput += output + "\n" output += "Characteristic: " + settlement["ruler"]["characteristic"] + "\n" output += "Trait: " + settlement["ruler"]["trait"] + "\n" if str(settlement["ruler"]["secret"]) != str("Has no secret"): output += "Secret: " + settlement["ruler"]["secret"] + "\n" secretoutput += output + "\n" else: output += settlement["ruler"]["adjective"] + " " + settlement["ruler"]["title"] output += "\nNumber of membres: " + str(settlement["ruler"]["number"]) openoutput += output + "\n\n" secretoutput += output + "\n\n" # Institutions output = "__Institutions__" for institution in settlement["institutions"]: output += "\n**" + institution["name"] + "**\n" output += institution["discriptor"] openoutput += output + "\n" secretoutput += output output = "" if np.random.random()<0.85: ethnicity = settlement["ethnicity"] tempraces = rm.exracebyn(races, settlement["race"]) else: ethnicity = np.random.choice(names.humanethnicities) tempraces = rm.exracebys(races, settlement["sizenum"]) if institution["identifier"] == 1 or institution["identifier"] == 2: #inn/tavern output += "\nOddity: " + institution["oddity"] \ + "\nSpeciality: " + institution["specialty"] output += "\nSecret: " + institution["secret"] secretoutput += output output = "" owner = fantasyNPCgenerator.main(tempraces, ethnicity, "owner") secretoutput += "\n" + secretcharaformat(owner) + "\n" # Removed Waiter from settlement inns, too much info already # secretoutput += "\n__Waiter__\n" + secretcharaformat(waiter) + "\n" elif institution["identifier"] == 3: #trading post secretoutput += "\nFood vendors:\n" for vendor in institution["food"]: secretoutput += " - " + vendor + "\n" secretoutput += "Smell: " + institution["smell"] + "\n" elif institution["identifier"] == 4: #Temple secretoutput += "\nPrincipal succour: " + institution["succour"] + "\n" highpriest = fantasyNPCgenerator.main(tempraces, ethnicity, "High priest") secretoutput += "\n" + secretcharaformat(highpriest) + "\n" elif institution["identifier"] == 5: #Library secretoutput += "\nAreas of focus:\n" for discipline in institution["disciplines"]: secretoutput += " - " + discipline + "\n" librarian = fantasyNPCgenerator.main(tempraces, ethnicity, "Librarian") secretoutput += "\n" + secretcharaformat(librarian) + "\n" elif institution["identifier"] == 6: #University secretoutput += "\nClasses taught:\n" for discipline in institution["disciplines"]: secretoutput += " - " + discipline + "\n" dean = fantasyNPCgenerator.main(tempraces, ethnicity, "Dean") secretoutput += "\n" + secretcharaformat(dean) + "\n" elif institution["identifier"] == 7: #Park secretoutput += "\nCentre piece: " + institution["centrepiece"] + "\n" return(openoutput, secretoutput)
def main(ctx, races, item, *args): arg = [] for input in args: arg.append(input) # /|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|/ # Genre prep # /|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|/ dum = [] if item in ["fantasynpc", "fnpc", "fantasyinn", "finn", "fantasysettlement", "fsettlement", "fset", "fantasybookcase", "fbookcase", "fbc", "fantasybook", "fbook"]: for race in races: if race["genre"] == 'fantasy': dum.append(race) races = dum # /|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|/ # Names # /|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|/ if item == "name" or item =="n": numloop = 1 types = [] openoutput = "" typelist = [] typelist.extend(names.ethnicities) typelist.extend(["random", "r", "settlement", "set", "inn", "ship", "book"]) full = False gender = None gen = False lenght = [4,10] for input in arg: try: int(input) integer = True except ValueError: integer = False if integer: numloop = int(input) else: if input == 'full' or input == 'fullname': full = True elif input == 'female' or input == 'f': gender = 'female' elif input == 'male' or input =='m': gender = 'male' elif input == 'surname' or input == 'sur' or input == 's': full = True gender = 'surname' elif input == 'short': lenght = [2,6] elif input == 'long': lenght = [9,15] elif input == 'endless': lenght = [12,22] elif input in typelist: types.append(input) else: openoutput += "Unknown name type: " + input + " so ignored\n" for i in range(numloop): if len(types) == 0: type = "eng" else: type = np.random.choice(types) if type == "random" or type == "r" : openoutput += names.randname(lenght) if full: openoutput += " " + names.randname(lenght) + "\n" else: openoutput += "\n" elif type in names.ethnicities: if type in names.humangentypelist: gen = True #easter egg for a friend if ctx.message.author.id == int(132528782794817536) and "japan" in args: openoutput +="Rice" #end easter egg if gender == None: gender = np.random.choice(["male", "female"]) if gender == "male": string = type + "m" openoutput += names.name(gen, string, lenght) + ' ' elif gender == "female": string = type + "f" openoutput += names.name(gen, string, lenght) + ' ' if full: if type in names.nosurnamelist: string = type + "m" openoutput += names.name(True, string, lenght) + "\n" else: string = type + "sur" openoutput += names.name(gen, string, lenght) + "\n" else: openoutput += "\n" elif type == "settlement" or type == "set": dum = fantasysettlementgenerator.main(races) openoutput += dum["name"] + "\n" elif type == "inn": dum = fantasyinngenerator.main() openoutput += titlecase(dum["name"]) + "\n" elif type == "ship": openoutput += medievalshipnamegenerator.main() + "\n" elif type == "book" or type == "b": dum = fantasybookgenerator.main() openoutput += titlecase(dum["title"]) + "\n" else: openoutput += "Errorname: mybad\n" # /|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|/ # Titles # /|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|/ elif item == "booktitle" or item == "btitle": openoutput = "" if len(arg) == 0: arg.append(1) loop = 0 while loop < int(arg[0]): loop += 1 dum = fantasybookgenerator.main() openoutput += titlecase(dum["title"]) + "\n" # /|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|/ # NPCS # /|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|/ elif item == "fantasynpc" or item == "fnpc": #Generates a fantasy NPC. numloop = 1 race = None job = None ethnicity = 'eng' for input in arg: try: int(input) integer = True except ValueError: integer = False if integer: numloop = int(input) else: if any(input == ra['racename'] for ra in races): race = input elif input in names.ethnicities: ethnicity = input else: job = input openoutput = "" secretoutput = "" if race == None: tempraces = races else: tempraces = [] for ra in races: if race == ra['racename']: tempraces.append(ra) for i in range(numloop): NPC = fantasyNPCgenerator.main(tempraces, ethnicity, job) openoutput += str(charaformat(NPC)) + "\n\n" secretoutput += str(secretcharaformat(NPC)) + "\n\n" # /|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|/ # Inns # /|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|/ elif item == "fantasyinn" or item == "finn": tempraces = rm.exracebys(races, 2) numloop = 1 ethnicity = "eng" for input in arg: try: int(input) integer = True except ValueError: integer = False if integer: numloop = int(input) else: if input in names.ethnicities: ethnicity = input openoutput = "" secretoutput = "" for i in range(numloop): inn = fantasyinngenerator.main() output = "\n**" + inn["name"] + "**\nOddity: " + inn["oddity"] \ + "\nSpeciality: " + inn["specialty"] openoutput += output output += "\nSecret: " + inn["secret"] secretoutput += output owner = fantasyNPCgenerator.main(tempraces, ethnicity, "Innkeeper") waiter = fantasyNPCgenerator.main(tempraces, ethnicity, "Waiter") openoutput += "\n\n" + owner["name"] +":"+ " A" + owner["age"] + " "+ str(owner["gender"]) +\ " "+ str(owner["race"]) + " owner\nCharacteristic: " + owner["characteristic"] if waiter["gender"] == "female": openoutput += "\n\n" + waiter["name"] +":"+ " A" + waiter["age"] + " "+ str(waiter["gender"]) +\ " "+ str(waiter["race"]) + " waitress\nCharacteristic: " + waiter["characteristic"] else: openoutput += "\n\n" + waiter["name"] +":"+ " A" + waiter["age"] + " "+ str(waiter["gender"]) +\ " "+ str(waiter["race"]) + " waiter\nCharacteristic: " + waiter["characteristic"] openoutput += "\n" secretoutput += "\n\n" + owner["name"] +":"+ " A" + owner["age"] + " "+ str(owner["gender"]) +\ " "+ str(owner["race"]) + " owner\nCharacteristic: " + owner["characteristic"] + "\nTrait: " + owner["trait"] if owner["secret"] != "Has no secret": secretoutput += "\nSecret: " + owner["secret"] if waiter["gender"] == "female": secretoutput += "\n\n" + waiter["name"] +":"+ " A" + waiter["age"] + " "+ str(waiter["gender"]) +\ " "+ str(waiter["race"]) + " waitress\nCharacteristic: " + waiter["characteristic"] + "\nTrait: " + waiter["trait"] else: secretoutput += "\n\n" + waiter["name"] +":"+ " A" + waiter["age"] + " "+ str(waiter["gender"]) +\ " "+ str(waiter["race"]) + " waiter\nCharacteristic: " + waiter["characteristic"] + "\nTrait: " + waiter["trait"] if waiter["secret"] != "Has no secret": secretoutput += "\nSecret: " + waiter["secret"] + "\n" secretoutput += "\n" # /|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|/ # Missions # /|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|/ elif item == "mission" or item == "mis" or item == "m": #Generates a mission. if len(arg) == 0: mission = missiongenerator.main() else: mission = missiongenerator.main(int(arg[0])) output = "Difficulty: " + str(mission["difficulty"]) + "\nObjective: \n" i = 0 while i < len(mission["objectives"]): output += " * " + mission["objectives"][i-1] + "\n" i += 1 output += "Reward: " + str(mission["reward"]) + "\n" if len(mission["opencomplications"]) > 0: output += "Complications: \n" i = 0 while i < len(mission["opencomplications"]): output += " * " + mission["opencomplications"][i] + "\n" i += 1 openoutput = output if len(mission["secretcomplications"]) > 0: output += "Secret complications: \n" i = 0 while i < len(mission["secretcomplications"]): output += " * " + mission["secretcomplications"][i-1] + "\n" i += 1 secretoutput = output elif item == "jobboard" or item == "jb": if len(arg) == 0: arg.append(5) openoutput = "**Job Board**\n" secretoutput = "**Job Board**\n" loop = 0 while loop < int(arg[0]): loop += 1 mission = missiongenerator.main() output = "\n__Job: " + str(loop) + "/" + str(arg[0]) + "__\nDifficulty: " + str(mission["difficulty"]) + "\nObjective: \n" i = 0 while i < len(mission["objectives"]): output += " * " + mission["objectives"][i] + "\n" i += 1 output += "Reward: " + str(mission["reward"]) if len(mission["opencomplications"]) > 0: output += "\nComplications:" i = 0 while i < len(mission["opencomplications"]): output += "\n * " + mission["opencomplications"][i] i += 1 openoutput += output + "\n" if len(mission["secretcomplications"]) > 0: output += "\nSecret complications: " i = 0 while i < len(mission["secretcomplications"]): output += "\n * " + mission["secretcomplications"][i] i += 1 secretoutput += output + "\n" output = "" # /|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|/ # Settlements # /|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|/ elif item == "fantasysettlement" or item == "fsettlement" or item == "fset": #fantasy settlement size = 0 race = None ethnicity = 'eng' for input in arg: try: int(input) integer = True except ValueError: integer = False if integer: size = int(input) else: if any(input == ra['racename'] for ra in races): race = input elif input in names.ethnicities: ethnicity = input if size > 5 or size < 0: openoutput = "The input must be a number between 1 and 5, see itemlist for more info" else: set = fantasysettlementgenerator.main(races, race, ethnicity, size) openoutput, secretoutput = fantasysettlementformat(races, set) # /|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|/ # Books # /|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|/ elif item == "fantasybook" or item == "fbook": #fantasy book book = fantasybookgenerator.main() if len(arg) == 0: arg.append(1) openoutput = "" secretoutput = "" loop = 0 while loop < int(arg[0]): loop += 1 book = fantasybookgenerator.main() openoutput += "\nTitle: " + titlecase(book["title"]) + \ "\nAuthor: " + book["author"].title() #+ "\nState: " + book["state"].capitalize() doesn't fell needed, hard to fit in some contexts secretoutput += "\nTitle: " + titlecase(book["title"]) + \ "\nAuthor: " + book["author"].title() + " a " +book["authorjob"].lower() #+ "\nState: " + book["state"].capitalize() doesn't fell needed, hard to fit in some contexts secretoutput += "\nSubject: " + book["subject"].capitalize() secretoutput += "\nBranch: " + book["branch"].capitalize() secretoutput += "\nFocus: " + book["focus"].capitalize() if book["secret"] != "no secret": secretoutput += "\nSecret: " + book["secret"].capitalize() secretoutput += "\n" openoutput += "\n" # /|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|/ # Planets # /|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|/ elif item == "syfanplanet": #Syfan planet if len(arg) > 1: planet = syfanplanetgenerator.main(arg[0], arg[1]) if len(arg) == 1: planet = syfanplanetgenerator.main(arg[0]) if len(arg) == 0: planet = syfanplanetgenerator.main() if planet["error"] != None: openoutput = planet["error"] else: openoutput = "__**" + planet["name"] + "**__\n" openoutput += "*" + planet["descriptor"].capitalize() + "*\n" if planet["government"] != None: openoutput += "\nGovernment: " + planet["government"].capitalize() openoutput += "\nGravity: " + planet["gravity"] openoutput += "\nSol: " + planet["sol"] + "\n" openoutput += "Environments: \n" i = 0 while i < len(planet["environment"]): openoutput += " * " + planet["environment"][i] + "\n" i += 1 openoutput += "\nAsset: " + planet["asset"] openoutput += "\nOddity: " + planet["oddity"] openoutput += "\nProblem: " + planet["problem"] openoutput += "\n\n" # end of generator # /|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|/ # Misc # /|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|/ elif item == "riddle": if len(arg) == 0: arg.append("0") if arg[0] in ["0", "1", "2", "3", "4", "5"]: riddle = riddlegenerator.main(arg[0]) openoutput = " " + riddle["riddle"] secretoutput = " " + riddle["riddle"] + "\n" + "__Answer: __" + riddle["answer"] openoutput = openoutput.replace("\\n", "\n") secretoutput = secretoutput.replace("\\n", "\n") else: openoutput = "The difficulty rating of the riddles are between 1 and 5." elif item == "riddles": openoutput = "" secretoutput = "" if len(arg) == 0: arg.append(1) loop = 0 while loop < int(arg[0]): loop += 1 riddle = riddlegenerator.main(0) openoutput += " " + riddle["riddle"] + "\n\n" secretoutput += " " + riddle["riddle"] + "\n" + "__Answer: __" + riddle["answer"] + "\n\n" openoutput = openoutput.replace("\\n", "\n") secretoutput = secretoutput.replace("\\n", "\n") elif item == "insult" or item == "insults": valid = True argslist = ["default", "empty", "empty"] test = 0 numloop = 1 if len(arg) > 0: track = 0 for input in arg: try: int(input) integer = True except ValueError: integer = False if integer: numloop = int(input) elif isinstance(input, str): if input in "intelligence": dum = "intelligence" test += 1 if input in "character": dum = "character" test += 1 if input == "looks": dum = "appearance" test += 1 if input in "appearance": dum = "appearance" test += 1 if input in "miscellaneous": dum = "misc" test += 1 if input in "comeback": dum = "comeback" test += 1 argslist[track] = dum track += 1 if test > 1: openoutput = "Could not recognize this type of insult" valid = False else: openoutput = "Insult items need either strings or integer" valid = False if valid: openoutput = "" args = (argslist[0], argslist[1], argslist[2]) loop = 0 while loop < numloop: loop += 1 openoutput += insultgenerator.main(*args) + "\n" elif item == "weather" or item == "w": if len(arg) == 0: arg.append(0) openoutput = weathergenerator.main(arg[0]) # /|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|/ # Book keeping # /|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|//|\\|/ elif item == "nothing was entered0": openoutput = "There must be an argument after gen, use !itemlist to get a list" else: openoutput = item + " is not a valid generator argument, use !itemlist to get a list" try: secretoutput except NameError: secretoutput = openoutput if "#" in secretoutput: for tag in taglist: rand = np.random.randint(1,len(tag)) openoutput = openoutput.replace(tag[0], tag[rand], 5) secretoutput = secretoutput.replace(tag[0], tag[rand], 5) if "[[" in secretoutput: memory = [[""]] split1 = secretoutput.split("[[") secretoutput = split1[0] i = len(split1) for j in range(1,i): split2 = split1[j].split("]]") list = split2[0].split("/") if list in memory: secretoutput += memory[0][memory.index(list)] + split2[1] else: memory.append(list) memory[0].append(np.random.choice(list)) secretoutput += memory[0][-1] + split2[1] if "[[" in openoutput: split1 = openoutput.split("[[") openoutput = split1[0] i = len(split1) for j in range(1,i): split2 = split1[j].split("]]") list = split2[0].split("/") openoutput += memory[0][memory.index(list)] + split2[1] secretoutput = secretoutput.replace(" ", " ", 10) secretoutput = secretoutput.replace(" ", " ", 100) secretoutput = secretoutput.replace(" .", ".", 10) secretoutput = secretoutput.replace(" ,", ",", 10) secretoutput = secretoutput.replace(" :", ":", 10) openoutput = openoutput.replace(" ", " ", 10) openoutput = openoutput.replace(" ", " ", 100) openoutput = openoutput.replace(" .", ".", 10) openoutput = openoutput.replace(" ,", ",", 10) openoutput = openoutput.replace(" :", ":", 10) return(openoutput, secretoutput)