def plotSelector(): motivePath = os.path.join(os.path.dirname(__file__), "plots", "motives.txt") actionPath = os.path.join(os.path.dirname(__file__), "plots", "actupon.txt") motive = lambda:util.selectFromFile(motivePath) action = lambda:util.selectFromFile(actionPath) charList = ["Alice","Bob","Casey"] mover = "Alice" # nameSelector(genderSelector()) # mover as in an Aristotle type way movee = "Bob" # nameSelector(genderSelector()) event = " ".join([mover,action(),movee]) #,"because",motive()]) reaction = " ".join(["and",movee,action(),mover]) eventList = [] for i in range(3): mover = random.choice(charList) listWithoutMover = charList[:] listWithoutMover.remove(mover) movee = random.choice(listWithoutMover) event = " ".join([mover,action(),movee]) if random.randint(0,1): l = event.split() l.insert(1,traitSelector().lower() + "ly") event = " ".join(l) eventList.append(event) if random.randint(0,1): l = event.split() l.insert(1,traitSelector().lower() + "ly") event = " ".join(l) if random.randint(0,1): l = reaction.split() l.insert(2,traitSelector().lower() + "ly") reaction = " ".join(l) moverTraits = " ".join(["Alice is",traitSelector().lower()]) moveeTraits = " ".join(["Bob is",traitSelector().lower()]) return "\n".join(eventList) + "\n"
def nameSelector(gender="male"): name = "" if gender == "male": maleNamesPath = os.path.join(os.path.dirname(__file__), "names", "maleFirst.txt") name += util.selectFromFile(maleNamesPath) else: femaleNamesPath = os.path.join(os.path.dirname(__file__), "names", "femaleFirst.txt") name += util.selectFromFile(femaleNamesPath) name += " " lastNamesPath = os.path.join(os.path.dirname(__file__), "names", "last.txt") name += util.selectFromFile(lastNamesPath) return name
def weatherSelector(season="winter", yesterday=UNDEFINED): if yesterday != UNDEFINED: #If a previous weather is provided there is a 50% chance it will be the same today if random.randint(0, 1): return yesterday seasonPathName = os.path.join(os.path.dirname(__file__), "weather", season + ".txt") return util.selectFromFile(seasonPathName)
def occupationTypeSelector(excluded=None,setting="urban"): settingFileName = "typesList" + setting.capitalize() + ".txt" occupationTypesPath = os.path.join(os.path.dirname(__file__), "occupations", settingFileName) retVal = util.selectFromFile(occupationTypesPath) if retVal == excluded: # if we get the excluded value, try again return occupationTypeSelector(excluded,setting) return retVal
def weatherSelector(season="winter",yesterday=UNDEFINED): if yesterday != UNDEFINED: #If a previous weather is provided there is a 50% chance it will be the same today if random.randint(0,1): return yesterday seasonPathName = os.path.join(os.path.dirname(__file__), "weather", season + ".txt") return util.selectFromFile(seasonPathName)
def eventSelector(): eventsPath = os.path.join(os.path.dirname(__file__), "events", "events.txt") return util.selectFromFile(eventsPath)
def nameSelector(): typeSeedInt = random.randint(1, 7) nounPath = os.path.join(os.path.dirname(__file__), "taverns", "tavernNouns.txt") descriptorPath = os.path.join(os.path.dirname(__file__), "taverns", "tavernDescriptors.txt") if typeSeedInt <= 1: #The NOUN and NOUN firstNounStr = util.selectFromFile(nounPath) secondNounStr = util.selectFromFile(nounPath) while firstNounStr == secondNounStr: secondNounStr = util.selectFromFile(nounPath) return "The " + firstNounStr + " and " + secondNounStr elif typeSeedInt <= 2: #The DESCRIPTOR NOUN and DESCRIPTOR NOUN firstNounStr = util.selectFromFile(nounPath) secondNounStr = util.selectFromFile(nounPath) firstDescriptorStr = util.selectFromFile(descriptorPath) secondDescriptorStr = util.selectFromFile(descriptorPath) while firstNounStr == secondNounStr: secondNounStr = util.selectFromFile(nounPath) while firstDescriptorStr == secondDescriptorStr: secondDescriptorStr = util.selectFromFile(descriptorPath) return "The " + firstDescriptorStr + " " + firstNounStr + " and " + secondDescriptorStr + " " + secondNounStr elif typeSeedInt <= 3: #The DESCRIPTOR NOUN and NOUN firstNounStr = util.selectFromFile(nounPath) secondNounStr = util.selectFromFile(nounPath) descriptorStr = util.selectFromFile(descriptorPath) while firstNounStr == secondNounStr: secondNounStr = util.selectFromFile(nounPath) return "The " + descriptorStr + " " + firstNounStr + " and " + secondNounStr elif typeSeedInt <= 4: #The NOUN and DESCRIPTOR NOUN firstNounStr = util.selectFromFile(nounPath) secondNounStr = util.selectFromFile(nounPath) descriptorStr = util.selectFromFile(descriptorPath) while firstNounStr == secondNounStr: secondNounStr = util.selectFromFile(nounPath) return "The " + firstNounStr + " and " + descriptorStr + " " + secondNounStr elif typeSeedInt <= 5: #The NOUN nounStr = util.selectFromFile(nounPath) return "The " + nounStr elif typeSeedInt <= 6: #The DESCRIPTOR Inn descriptorStr = util.selectFromFile(descriptorPath) return "The " + descriptorStr + " Inn " elif typeSeedInt <= 7: #The DESCRIPTOR NOUN nounStr = util.selectFromFile(nounPath) descriptorStr = util.selectFromFile(descriptorPath) return "The " + descriptorStr + " " + nounStr
def weaponSelector(): weaponsPath = os.path.join(os.path.dirname(__file__), "items", "weapons.txt") return util.selectFromFile(weaponsPath)
def traitSelector(): traitsPath = os.path.join(os.path.dirname(__file__), "traits", "traits.txt") return util.selectFromFile(traitsPath)
def hairLengthSelector(): hairLengthsPath = os.path.join(os.path.dirname(__file__), "hair", "hairLengths.txt") return util.selectFromFile(hairLengthsPath)
def hairTypeSelector(): hairTypePath = os.path.join(os.path.dirname(__file__), "hair", "hairTypes.txt") return util.selectFromFile(hairTypePath)
def hairColorSelector(eyecolor): hairColorPath = os.path.join(os.path.dirname(__file__), "hair", eyecolor + "EyesHair.txt") return util.selectFromFile(hairColorPath)
def eyeColorSelector(): eyeColorPath = os.path.join(os.path.dirname(__file__), "eyes", "eyeColor.txt") return util.selectFromFile(eyeColorPath)
def occupationSelector(occupationType=DEFAULT): if occupationType == DEFAULT: occupationType = occupationTypeSelector() occupationPath = os.path.join(os.path.dirname(__file__), "occupations", occupationType + ".txt") return util.selectFromFile(occupationPath)
def nameSelector(): typeSeedInt = random.randint(1,7) nounPath = os.path.join(os.path.dirname(__file__), "taverns", "tavernNouns.txt") descriptorPath = os.path.join(os.path.dirname(__file__), "taverns" , "tavernDescriptors.txt") if typeSeedInt <= 1: #The NOUN and NOUN firstNounStr = util.selectFromFile(nounPath) secondNounStr = util.selectFromFile(nounPath) while firstNounStr == secondNounStr: secondNounStr = util.selectFromFile(nounPath) return "The " + firstNounStr + " and " + secondNounStr elif typeSeedInt <= 2: #The DESCRIPTOR NOUN and DESCRIPTOR NOUN firstNounStr = util.selectFromFile(nounPath) secondNounStr = util.selectFromFile(nounPath) firstDescriptorStr = util.selectFromFile(descriptorPath) secondDescriptorStr = util.selectFromFile(descriptorPath) while firstNounStr == secondNounStr: secondNounStr = util.selectFromFile(nounPath) while firstDescriptorStr == secondDescriptorStr: secondDescriptorStr = util.selectFromFile(descriptorPath) return "The " + firstDescriptorStr + " " + firstNounStr + " and " + secondDescriptorStr + " " + secondNounStr elif typeSeedInt <= 3: #The DESCRIPTOR NOUN and NOUN firstNounStr = util.selectFromFile(nounPath) secondNounStr = util.selectFromFile(nounPath) descriptorStr = util.selectFromFile(descriptorPath) while firstNounStr == secondNounStr: secondNounStr = util.selectFromFile(nounPath) return "The " + descriptorStr + " " + firstNounStr + " and " + secondNounStr elif typeSeedInt <= 4: #The NOUN and DESCRIPTOR NOUN firstNounStr = util.selectFromFile(nounPath) secondNounStr = util.selectFromFile(nounPath) descriptorStr = util.selectFromFile(descriptorPath) while firstNounStr == secondNounStr: secondNounStr = util.selectFromFile(nounPath) return "The " + firstNounStr + " and " + descriptorStr + " " + secondNounStr elif typeSeedInt <= 5: #The NOUN nounStr = util.selectFromFile(nounPath) return "The " + nounStr elif typeSeedInt <= 6: #The DESCRIPTOR Inn descriptorStr = util.selectFromFile(descriptorPath) return "The " + descriptorStr + " Inn " elif typeSeedInt <= 7: #The DESCRIPTOR NOUN nounStr = util.selectFromFile(nounPath) descriptorStr = util.selectFromFile(descriptorPath) return "The " + descriptorStr + " " + nounStr
def nameSelector(): townNamesPath = os.path.join(os.path.dirname(__file__), "towns", "townNames.txt") return util.selectFromFile(townNamesPath)