def get_goblin_names(count: int = 1): names_list = [] for i in range(0, count): pick_index = randint(0, len(type_options) - 1) pick = type_options[pick_index] if pick == 'short': parts = choose(goblin_names['parts'], 1) name = parts[0] elif pick == 'first_last': parts = choose(goblin_names['parts'], 3) joiners = choose(goblin_names['joiners'], 1) name = f'{parts[0]}{joiners[0]}{parts[1]}{parts[2].lower()}' elif pick == 'two_part': parts = choose(goblin_names['parts'], 2) joiners = choose(goblin_names['joiners'], 1) name = f'{parts[0]}{joiners[0]}{parts[1]}' elif pick == 'three_part': parts = choose(goblin_names['parts'], 3) joiners = choose(goblin_names['joiners'], 2) name = f'{parts[0]}{joiners[0]}{parts[1]}{joiners[1]}{parts[2]}' elif pick == 'long': parts = choose(goblin_names['parts'], 3) name = f'{parts[0]}{parts[1].lower()}{parts[2].lower()}' else: pick = 'normal' parts = choose(goblin_names['parts'], 2) name = f'{parts[0]}{parts[1].lower()}' end = choose(goblin_names['ends'], 1)[0] names_list.append(name + end) return names_list
def get_academic_titles(): titles = choose(names["gnome"]["titles"],round(gammavariate(0.75,2.5))) for i in range(0,len(titles)): if '{craft}' in titles[i]: titles[i] = titles[i].format(craft=choose(['Al','Br','Cl','Cp','Cg','Co','Co','Gb','J','L','M','P','S','T','We','Wo','M','Th','N'],1)[0],) titles = list(set(titles)) for i in range(0,len(titles)): if '{artifice}' in titles[i]: titles[i] = titles[i].format(artifice=choose(['Al','Ar','Bs'],1)[0]) return titles
def get_gnome_names(count:int=1,sex:str='both'): names_list = [] name_types = choose(type_options,count) for pick in name_types: if pick == 'first_last': name = f'{get_first("gnome", sex)} {choose(names["gnome"]["family"],1)[0]}' elif pick == 'two_first_last': name = f'{get_first("gnome", sex)} {get_first("gnome",choose([sex,"both"],1)[0])} {choose(names["gnome"]["family"],1)[0]}' elif pick == 'first_nick_last': first_name = get_first("gnome", sex) nickname = get_nick(first_name) name = f'{first_name} \'{nickname}\' {choose(names["gnome"]["family"],1)[0]}' elif pick == 'two_first_nick_last': firstnames = [get_first("gnome", sex),get_first("gnome",choose([sex,"both"],1)[0])] nickname = get_nick(choose(firstnames,1)[0]) name = f'{firstnames[0]} {firstnames[1]} \'{nickname}\' {choose(names["gnome"]["family"],1)[0]}' elif pick == 'first_two_last': name = f'{get_first("gnome", sex)} {choose(names["gnome"]["family"],1)[0]}-{choose(names["gnome"]["family"],1)[0]}' elif pick == 'first_nick_two_last': first_name = get_first("gnome", sex) nickname = get_nick(first_name) name = f'{first_name} \'{nickname}\' {choose(names["gnome"]["family"],1)[0]}-{choose(names["gnome"]["family"],1)[0]}' elif pick == 'two_first_nick_two_last': firstnames = [get_first("gnome", sex),get_first("gnome",choose([sex,"both"],1)[0])] nickname = get_nick(choose(firstnames,1)[0]) name = f'{firstnames[0]} {firstnames[1]} \'{nickname}\' {choose(names["gnome"]["family"],1)[0]}-{choose(names["gnome"]["family"],1)[0]}' elif pick == 'academic': titles = get_academic_titles() name = ", ".join([f'{get_first("gnome", sex)} ob {get_first("gnome","both")}'] + titles) else: pick = 'first_last' name = f'{get_first("gnome", sex)} {choose(names["gnome"]["family"],1)[0]}' if pick != 'academic': name = name.title() names_list.append(name) return names_list #def get_general_names(race:str="human",sex:str="both",count:int=1,names:dict=names): # # names_list=[] # # # surname_options = names[race]['family'] # givens = choose(given_name_options,count) # surnames = choose(surname_options,count) # # for i in range(0,count): # names_list.append(f'{givens[i]} {surnames[i]}'.strip()) # # return names_list
def get_shop_names(key_string: str, number: int = 10): shops_list = [] nouns, adjectives = populate_choices(key_string) for i in range(0, number): format = choose(choices)[0] shops_list.append(generate_shop(format, nouns, adjectives)) return shops_list
def get_general_names(race: str = "human", sex: str = "both", count: int = 1, names: dict = names): names_list = [] if sex == 'both' or sex == 'any': given_name_options = names[race]['male'] + names[race][ 'female'] + names[race]['both'] else: given_name_options = names[race][sex] + names[race]['both'] surname_options = names[race]['family'] givens = choose(given_name_options, count) surnames = choose(surname_options, count) for i in range(0, count): names_list.append(f'{givens[i]} {surnames[i]}'.strip()) return names_list
def get_nick(real_name: str=None, nick_format:str=None): if real_name is None: nick_format = 'separate' else: real_name = list(real_name) if nick_format is None: nick_format = choose(nick_options,1)[0] if nick_format == 'beginning': letters = randint(1,min(5,len(real_name)-1)) nickname = [] for i in range(0,letters): nickname = nickname + [real_name[i]] elif nick_format == 'ending': letters = randint(2,min(6,len(real_name)-1)) real_name.reverse() nickname = [] for i in range(0,letters): nickname = nickname + [real_name[i]] nickname.reverse() else: nickname=choose(names['gnome']['nicks'],1)[0] return "".join(nickname).title()
def get_hybrid_names(race_1: str, count: int = 1, race_2: str = 'human', sex: str = 'both', r1_given_rate: float = 0.50, r1_surname_rate: float = 0.50, names: dict = names): names_list = [] if r1_given_rate > 1: r1_given_rate = 1 if r1_surname_rate > 1: r1_surname_rate > 1 r2_given_rate = 1 - r1_given_rate r2_surname_rate = 1 - r1_surname_rate choices_r1g = round(count * r1_given_rate) choices_r1s = round(count * r1_surname_rate) choices_r2g = count - choices_r1g choices_r2s = count - choices_r1s if sex == 'both' or sex == 'any': givens_list_1 = choose(names[race_1]['male'] + names[race_1]['female'], choices_r1g) givens_list_2 = choose(names[race_2]['male'] + names[race_2]['female'], choices_r2g) else: givens_list_1 = choose(names[race_1][sex], choices_r1g) givens_list_2 = choose(names[race_2][sex], choices_r2g) surnames_list_1 = choose(names[race_1]['family'], choices_r1s) surnames_list_2 = choose(names[race_2]['family'], choices_r2s) givens_list = givens_list_1 + givens_list_2 surnames_list = surnames_list_1 + surnames_list_2 shuffle(givens_list) shuffle(surnames_list) for i in range(0, count): names_list.append(f'{givens_list[i]} {surnames_list[i]}'.strip()) return names_list
def get_first(race:str = 'gnome', sex:str = 'both',names:dict=names): if sex == 'both' or sex == 'any': given_name = choose((names[race]['male'] + names[race]['female'] + names[race]['both']),1)[0] else: given_name = choose((names[race][sex] + names[race]['both']),1)[0] return given_name.title()
def describe_random_dong(race:str=choose(list(database.keys()))[0]): min_height = database[race]['height_min'] avg_height = database[race]['height'] max_height = database[race]['height_max'] min_weight = database[race]['weight_min'] avg_weight = database[race]['weight'] max_weight = database[race]['weight_max'] n_steps = 50 add_count=max(int(n_steps/2.5),1) height_step_high = (max_height - avg_height)/n_steps height_step_low = (avg_height - min_height)/n_steps weight_step_high = (max_weight - avg_weight)/n_steps weight_step_low = (avg_weight - min_weight)/n_steps height_range = [] weight_range = [] for i in range(0,n_steps): height_range = height_range + [avg_height - height_step_low*i]*add_count + [avg_height + height_step_high*i]*add_count weight_range = weight_range + [avg_weight - weight_step_low*i]*add_count + [avg_weight + weight_step_high*i]*add_count add_count = max(1,add_count-1) if 'str' in database[race]: str_score = database[race]['str']-1 else: str_score = 10 if 'con' in database[race]: con_score = database[race]['con']-1 else: con_score = 10 if 'cha' in database[race]: cha_score = database[race]['cha']-1 else: cha_score = 10 str_range = [str_score-5]*4 + [str_score - 4]*28 + [str_score - 3]*36 + [str_score - 2]*48 + [str_score-1]*72 + [str_score]*96 + [str_score+1]*64 + [str_score+2]*32 + [str_score+3]*16 + [str_score+4]*12 + [str_score+5]*8 + [str_score+6]*6 + [str_score+7]*4 + [str_score+8]*3 + [str_score+8]*2 + [str_score+9] + [str_score+10] con_range = [con_score-5]*4 + [con_score - 4]*28 + [con_score - 3]*36 + [con_score - 2]*48 + [con_score-1]*72 + [con_score]*96 + [con_score+1]*64 + [con_score+2]*32 + [con_score+3]*16 + [con_score+4]*12 + [con_score+5]*8 + [con_score+6]*6 + [con_score+7]*4 + [con_score+8]*3 + [con_score+8]*2 + [con_score+9] + [con_score+10] cha_range = [con_score-5]*4 + [cha_score - 4]*28 + [cha_score - 3]*36 + [cha_score - 2]*48 + [cha_score-1]*72 + [cha_score]*96 + [cha_score+1]*64 + [cha_score+2]*32 + [cha_score+3]*16 + [cha_score+4]*12 + [cha_score+5]*8 + [cha_score+6]*6 + [cha_score+7]*4 + [cha_score+8]*3 + [cha_score+8]*2 + [cha_score+9] + [cha_score+10] dice_rolls = [i for i in range(1,21)] + [10] r_roll=choose(dice_rolls)[0] r_height=choose(height_range)[0] r_weight=choose(weight_range)[0] r_strength=choose(str_range)[0] r_constitution=choose(con_range)[0] r_charisma=choose(cha_range)[0] height_feet=floor(r_height/12) height_inches=int(round(r_height % 12,0)) height_text = f"{height_feet}'{height_inches}\"" if race.lower().startswith(tuple(['a','e','i','o','u'])): a_an = 'an' else: a_an = 'a' output_text = donger_text( race=race, roll=r_roll, height=r_height, weight=r_weight, strength=r_strength, constitution=r_constitution, charisma=r_charisma) return output_text
def generate_dickstribution(race:str='human'): length_dist = [] girth_dist = [] volume_dist = [] other_dists={ 'knot_width':[], 'knot_vol':[], 'knot_ratio':[], 'flare_width':[], 'flare_vol':[], 'flare_ratio':[] } build_mods = database[race]['build'] shape_mods = database[race]['shape'] print(shape_mods) min_height = database[race]['height_min'] avg_height = database[race]['height'] max_height = database[race]['height_max'] min_weight = database[race]['weight_min'] avg_weight = database[race]['weight'] max_weight = database[race]['weight_max'] n_steps = 50 add_count=max(int(n_steps/2.5),1) height_step_high = (max_height - avg_height)/n_steps height_step_low = (avg_height - min_height)/n_steps weight_step_high = (max_weight - avg_weight)/n_steps weight_step_low = (avg_weight - min_weight)/n_steps height_range = [] weight_range = [] for i in range(0,n_steps): height_range = height_range + [avg_height - height_step_low*i]*add_count + [avg_height + height_step_high*i]*add_count weight_range = weight_range + [avg_weight - weight_step_low*i]*add_count + [avg_weight + weight_step_high*i]*add_count add_count = max(1,add_count-1) if 'str' in database[race]: str_score = database[race]['str']-1 else: str_score = 10 if 'con' in database[race]: con_score = database[race]['con']-1 else: con_score = 10 if 'cha' in database[race]: cha_score = database[race]['cha']-1 else: cha_score = 10 str_range = [str_score-5]*4 + [str_score - 4]*28 + [str_score - 3]*36 + [str_score - 2]*48 + [str_score-1]*72 + [str_score]*96 + [str_score+1]*64 + [str_score+2]*32 + [str_score+3]*16 + [str_score+4]*12 + [str_score+5]*8 + [str_score+6]*6 + [str_score+7]*4 + [str_score+8]*3 + [str_score+8]*2 + [str_score+9] + [str_score+10] con_range = [con_score-5]*4 + [con_score - 4]*28 + [con_score - 3]*36 + [con_score - 2]*48 + [con_score-1]*72 + [con_score]*96 + [con_score+1]*64 + [con_score+2]*32 + [con_score+3]*16 + [con_score+4]*12 + [con_score+5]*8 + [con_score+6]*6 + [con_score+7]*4 + [con_score+8]*3 + [con_score+8]*2 + [con_score+9] + [con_score+10] cha_range = [con_score-5]*4 + [cha_score - 4]*28 + [cha_score - 3]*36 + [cha_score - 2]*48 + [cha_score-1]*72 + [cha_score]*96 + [cha_score+1]*64 + [cha_score+2]*32 + [cha_score+3]*16 + [cha_score+4]*12 + [cha_score+5]*8 + [cha_score+6]*6 + [cha_score+7]*4 + [cha_score+8]*3 + [cha_score+8]*2 + [cha_score+9] + [cha_score+10] dice_rolls = [i for i in range(1,21)] + [10] for i in range(0,5000): random_dong_draw = dong_calculator( roll=choose(dice_rolls)[0], height=choose(height_range)[0], weight=choose(weight_range)[0], strength=choose(str_range)[0], constitution=choose(con_range)[0], charisma=choose(cha_range)[0], build_mods=build_mods, shape_mods=shape_mods ) #print(random_dong_draw) length_dist.append(random_dong_draw['length']-0.06) girth_dist.append(random_dong_draw['girth']+0.015) volume_dist.append(random_dong_draw['volume']) for o in other_dists: if o in random_dong_draw: other_dists[o].append(random_dong_draw[o]) length_dist.sort() girth_dist.sort() volume_dist.sort() for o in other_dists: if len(other_dists[o]) > 1: other_dists[o].sort() return length_dist, girth_dist, volume_dist, other_dists
def get_tabaxi_names(count: int = 1): names_list = [] for i in range(0, count): pick_index = randint(0, len(type_options) - 1) pick = type_options[pick_index] if pick == 'adjective_noun': use_A = adjectives * 5 + colors * 3 + places + gerunds use_B = nouns * 3 + places part_1, part_2 = choose_separate(use_A, use_B) names_list.append(f'{part_1} {part_2}') elif pick == 'noun_adjective': use_A = nouns * 3 + places use_B = adjectives * 3 + colors * 3 + places + gerunds part_1, part_2 = choose_separate(use_A, use_B) names_list.append(f'{part_1}, {part_2}') elif pick == 'adjective_place': use_A = adjectives * 3 + colors * 3 + places + gerunds * 2 use_B = places part_1, part_2 = choose_separate(use_A, use_B) names_list.append(f'{part_1} {part_2}') elif pick == 'noun_place': use_A = nouns * 5 + numbers + places use_B = places part_1, part_2 = choose_separate(use_A, use_B) names_list.append(f'{part_1} {part_2}') elif pick == 'noun_of_place': use_A = nouns * 5 + colors + gerunds + places use_B = places part_1, part_2 = choose_separate(use_A, use_B) joiner = correct_article(choose(joiners['for_places'])[0], part_2) names_list.append(f'{part_1}{joiner}{part_2}') elif pick == 'noun_color': use_A = nouns * 5 + places + numbers use_B = colors parts = choose_separate(use_A, use_B) shuffle(parts) part_1, part_2 = parts names_list.append(f'{part_1} {part_2}') elif pick == 'number_noun': use_A = numbers use_B = nouns + places * 3 part_1 = choose(use_A)[0] part_2 = choose(use_B)[0] names_list.append(f'{part_1} {part_2}') elif pick == 'number_gerund': use_A = numbers use_B = gerunds part_1 = choose(use_A)[0] part_2 = choose(use_B)[0] names_list.append(f'{part_1} {part_2}') elif pick == 'noun_of_noun': use_A = nouns * 1 + colors * 1 + places * 1 + gerunds * 1 + numbers * 1 use_B = nouns * 3 + places part_1, part_2 = choose_separate(use_A, use_B) joiner = correct_possessive( correct_article(get_valid(joiners['for_nouns'], part_2), part_2), part_1) names_list.append(f'{part_1}{joiner}{part_2}') elif pick == 'verb_noun': use_A = gerunds use_B = nouns * 3 + places part_1, part_2 = choose_separate(use_A, use_B) joiner = correct_possessive( correct_article(choose(joiners['for_verbs'])[0], part_2), part_1) names_list.append(f'{part_1}{joiner}{part_2}') else: pick = 'noun_noun' use_A = nouns * 10 + colors * 3 + places * 5 + gerunds * 1 + numbers * 4 use_B = nouns * 5 + places * 1 + gerunds * 3 part_1, part_2 = choose_separate(use_A, use_B) names_list.append(f'{part_1} {part_2}') return names_list
def get_valid(list: list, match: str): correct_plural = False while correct_plural is False: pick = correct_article(choose(list)[0], match) correct_plural = is_correct_plural(pick, match) return pick
def dong_command_handler(text: str): error = False out_text = None split_text = text.lower().split(' ') try: if len(text) == 0: out_text = info_message elif len(split_text) == 1: if split_text[0].lower() in race_health_data: out_text = race_donger_text(split_text[0]) elif split_text[0].lower() == 'races': out_text = "The currently-supported races are as follows:\n\t" + "\n\t".join( list(race_health_data.keys())).title() elif split_text[0].lower() == 'random': race = choose(list(race_health_data.keys()))[0] out_text = describe_random_dong(race) elif split_text[0].lower().startswith('info'): out_text = info_message else: error = True elif len(split_text) == 2 and ( (split_text[0].lower() in race_health_data and split_text[1].lower() == 'random') or (split_text[0].lower() == 'random' and split_text[1].lower() in race_health_data)): if split_text[0].lower() in race_health_data: race = split_text[0] else: race = split_text[1] out_text = describe_random_dong(race) else: roll = None height = None weight = None strength = None constitution = None charisma = None for i in split_text: if i.lower().startswith('race:'): race = i.split(":").lower() elif ":" not in i and i in race_health_data: race = i.lower() elif i.lower().startswith('roll:'): roll = int(i.split(":")[1]) elif i.lower().startswith('height:'): height = i.split(":")[1] if "'" in height: feet = float(height.split("'")[0]) try: inches = float( height.split("'")[1].replace('"', '')) except: inches = 0.0 height = feet * 12 + inches else: height = int(height) elif i.lower().startswith('weight:'): weight = int(i.split(":")[1].split("l")[0]) elif i.lower().startswith('str:'): strength = int(i.split(":")[1]) elif i.lower().startswith('con'): constitution = int(i.split(":")[1]) elif i.lower().startswith('cha'): charisma = int(i.split(":")[1]) else: pass if race is None: race = 'human' if roll is None: roll = 10 if height is None: height = race_health_data[race]['height'] if weight is None: weight = race_health_data[race]['weight'] if strength is None: if 'str' in race_health_data[race]: strength = race_health_data[race]['str'] else: strength = 10 if constitution is None: if 'con' in race_health_data[race]: constitution = race_health_data[race]['con'] else: constitution = 10 if charisma is None: if 'cha' in race_health_data[race]: charisma = race_health_data[race]['cha'] else: charisma = 10 out_text = donger_text(race=race, roll=roll, height=height, weight=weight, strength=strength, constitution=constitution, charisma=charisma) except Exception as err: error = True err_txt = str(err) if error is True: out_text = '' return out_text
def generate_shop(choice: str, noun: list, adjective: list): if choice == 'noun': odds_the = 0.90 [choice] = choose(noun, 1) name = choice if randint(1, 100) / 100 <= odds_the: name = f'The {name}' elif choice == 'adjective': odds_the = 0.65 [choice] = choose(adjective, 1) name = choice if randint(1, 100) / 100 <= odds_the and ' the ' not in choice.lower(): name = f'The {name}' elif choice == 'adjective_noun': odds_the = 0.50 [choice_1, choice_2] = choose_separate(adjective, noun) name = f'{choice_1} {choice_2}' if randint(1, 100) / 100 <= odds_the: name = f'The {name}' elif choice == 'adjective_and_adjective': odds_the = 0.35 odds_or = 0.35 if randint(1, 100) / 100 <= odds_or: conjunction = 'or' else: conjunction = 'and' [choice_1, choice_2] = choose_separate(adjective, adjective) name = f'{choice_1} {conjunction} {choice_2}' if randint(1, 100) / 100 <= odds_the: name = f'The {name}' elif choice == 'noun_and_noun': odds_the = 0.50 odds_or = 0.20 if randint(1, 100) / 100 <= odds_or: conjunction = 'or' else: conjunction = 'and' [choice_1, choice_2] = choose_separate(noun, noun) name = f'{choice_1} {conjunction} {choice_2}' if randint(1, 100) / 100 <= odds_the: name = f'The {name}' elif choice == 'noun_noun_noun': odds_the = 0.20 odds_or = 0.10 if randint(1, 100) / 100 <= odds_or: conjunction = 'or' else: conjunction = 'and' [choice_1] = choose(noun, 1) [choice_2, choice_3] = choose_separate(noun, noun) name = f'{choice_1}, {choice_2}, {conjunction} {choice_3}' if randint(1, 100) / 100 <= odds_the: name = f'The {name}' elif choice == 'adjective_adjective_noun': odds_the = 0.20 odds_comma = 0.35 if randint(1, 100) / 100 <= odds_comma: conjunction = ', ' else: conjunction = ' ' [choice_1, choice_2, choice_3] = choose(adjective, 2) + choose(noun, 1) name = conjunction.join([choice_1, choice_2, choice_3]) if randint(1, 100) / 100 <= odds_the: name = f'The {name}' elif choice == 'adjective_adjective_adjective': odds_the = 0.10 odds_comma = 0.85 if randint(1, 100) / 100 <= odds_comma: conjunction = ', ' else: conjunction = ' ' [choice_1, choice_2, choice_3 ] = choose(adjective, 1) + choose_separate(adjective, adjective) name = conjunction.join([choice_1, choice_2, choice_3]) if randint(1, 100) / 100 <= odds_the: name = f'The {name}' else: choice = 'noun' name = generate_shop(choice, noun, adjective) return name.title()