SHOW:
|
|
- or go back to the newest paste.
1 | - | """ Settlement Generator """ |
1 | + | |
2 | - | #Imports the random module |
2 | + | |
3 | biome_type = random.choice(['Grassland','Mountain']) | |
4 | maxMinPop = {"Camp":[6,12], "Outpost":[15,25], "Village":[40,80], "Town":[80, 1000], "City":[1000, 2000], "Capital City":[2000, 5000]} | |
5 | - | #Creates a new class called Settlement |
5 | + | chosen_Settlement_Type = random.choice(list(maxMinPop.keys())) |
6 | - | class Settlement(): |
6 | + | population = random.choice (range(maxMinPop[chosen_Settlement_Type][0],maxMinPop[chosen_Settlement_Type] [1])) |
7 | - | #Sets the population size to a number from 0-20 |
7 | + | |
8 | - | populationSize = random.choice(range(20)) |
8 | + | def get_services(chosen_Settlement_Type): |
9 | - | #Makes a blank list that we can fill with people later |
9 | + | basic_services = ['Blacksmith','Tanner','Travelling Merchant','Cleric'] |
10 | - | denizenList = [] |
10 | + | advanced_services = ['Inn','Tavern','Farm','Stable', 'Shop','Church'] |
11 | - | |
11 | + | chosen_services = [] |
12 | - | #__init__ is called when an object of the class is created |
12 | + | #add in a premium services for town(maybe) city and capital |
13 | - | def __init__(self): |
13 | + | if chosen_Settlement_Type == 'Camp': |
14 | - | #runs the populateSettlement function |
14 | + | services = random.choice(range(0,3)) |
15 | - | self.populateSettlement() |
15 | + | for x in range(services): |
16 | - | |
16 | + | chosen_services.append(random.choice(basic_services)) |
17 | - | #This function generates people |
17 | + | |
18 | - | def generatePerson(self): |
18 | + | elif chosen_Settlement_Type == 'Outpost': |
19 | - | #This sub-function generated names for the people |
19 | + | services = random.choice(range(2,5)) |
20 | - | def generatePersonName(): |
20 | + | for x in range(services): |
21 | - | #List of syllables to pick from |
21 | + | chosen_services.append(random.choice(basic_services+basic_services+advanced_services)) |
22 | - | nameSyllables = [ |
22 | + | |
23 | - | "ka", "ke", "ki", "ko", "ku", |
23 | + | elif chosen_Settlement_Type == 'Village': |
24 | - | "ba", "be", "bi", "bo", "bu", |
24 | + | services = random.choice(range(4,10)) |
25 | - | "ta", "te", "ti", "to", "tu", |
25 | + | for x in range(services): |
26 | - | "ga", "ge", "gi", "go", "gu", |
26 | + | chosen_services.append(random.choice(basic_services+advanced_services)) |
27 | - | "ja", "je", "ji", "jo", "ju" |
27 | + | |
28 | - | "sa", "se", "si", "so", "su"] |
28 | + | elif chosen_Settlement_Type == 'Town': |
29 | services = random.choice(range(7,17)) | |
30 | - | #Choosing the number of syllables for each name |
30 | + | for x in range(services): |
31 | - | firstNameSyllables = random.choice(range(1,4)) |
31 | + | chosen_services.append(random.choice(basic_services+advanced_services)) |
32 | - | lastNameSyllables = random.choice(range(1,3)) |
32 | + | |
33 | elif chosen_Settlement_Type == 'City': | |
34 | - | #Creates the blank names, we will fill these later |
34 | + | services = random.choice(range(12,21)) |
35 | - | firstName = "" |
35 | + | for x in range(services): |
36 | - | lastName = "" |
36 | + | chosen_services.append(random.choice(basic_services+advanced_services)) |
37 | - | fullName = "" |
37 | + | |
38 | elif chosen_Settlement_Type == 'Capital City': | |
39 | - | #For each number in the sequence 1-whatever number was generated |
39 | + | services = random.choice(range(18,35)) |
40 | - | for x in range(firstNameSyllables): |
40 | + | for x in range(services): |
41 | - | #add a random syllable to our blank firstName variable |
41 | + | chosen_services.append(random.choice(basic_services+advanced_services)) |
42 | - | firstName += random.choice(nameSyllables) |
42 | + | |
43 | return chosen_services | |
44 | - | #See above, but this time for last name |
44 | + | |
45 | - | for x in range(lastNameSyllables): |
45 | + | |
46 | - | lastName += random.choice(nameSyllables) |
46 | + | |
47 | - | |
47 | + | if biome_type == 'Grassland': |
48 | - | #Concatanate first and last names to make a full name |
48 | + | race = random.choice (['Human','Human','Human','Dwarf']) |
49 | - | fullName = firstName.capitalize() + " " + lastName.capitalize() |
49 | + | |
50 | - | #Output that full name |
50 | + | elif biome_type == 'Mountain': |
51 | - | return fullName |
51 | + | race = random.choice (['Human','Dwarf','Dwarf','Dwarf']) |
52 | ||
53 | ||
54 | ||
55 | def human_name_gen(): | |
56 | syllables = ['mas', 'ran', 'lan', 'top', 'val', 'la', 'gar','cal','ron', | |
57 | 'lie','jera','mey','cop','per','dar', 'ren','ie','jes','har','ha','gre','hem','way','sam','mal','ik','war','hay'] | |
58 | ||
59 | laSyllables = ['smi','tay','low','lock','row','wood','ley','par','son','dal','house','river','field','hay'] | |
60 | ||
61 | first_s = random.choice(syllables) | |
62 | second_s = random.choice(syllables) | |
63 | ||
64 | for x in range(20): | |
65 | while True: | |
66 | first_s = random.choice(syllables).capitalize() | |
67 | second_s = random.choice(syllables) | |
68 | ||
69 | if first_s != second_s: | |
70 | first_name = first_s + second_s | |
71 | break | |
72 | ||
73 | surname = random.choice (laSyllables).capitalize() + random.choice(laSyllables) | |
74 | return (first_name + ' ' + surname) | |
75 | ||
76 | def dwarf_name_gen(): | |
77 | syllables = ['to', 'ro', 'for', 'lo', 'ran', 'ga', 'rag', 'var', 'lag', 'gar','rek','ron','vek','jera','ker','kot','dok','dar', 'ka'] | |
78 | ||
79 | body_names= ['hand', 'fist', 'leg', 'head', 'heart', 'eye', 'foot', 'arm', 'finger', 'toe', 'nose','hat'] | |
80 | rock_names= ['rock', 'stone','boulder', 'gold', 'lead', 'pebble','diamond','ruby','lapis','crag','cliff'] | |
81 | ||
82 | first_s = random.choice(syllables) | |
83 | second_s = random.choice(syllables) | |
84 | ||
85 | for x in range(20): | |
86 | - | name = generatePersonName() |
86 | + | while True: |
87 | first_s = random.choice(syllables).capitalize() | |
88 | second_s = random.choice(syllables) | |
89 | ||
90 | if first_s != second_s: | |
91 | first_name = first_s + second_s | |
92 | break | |
93 | ||
94 | surname = random.choice (rock_names).capitalize() + random.choice(body_names) | |
95 | return (first_name + ' ' + surname) | |
96 | ||
97 | - | def populateSettlement(self): |
97 | + | def get_leader_title(chosen_Settlement_Type): |
98 | - | #For every number 1-the size of the population |
98 | + | |
99 | - | for x in range(self.populationSize): |
99 | + | if chosen_Settlement_Type == 'Camp': |
100 | - | #create a new person and add them to the denizen list |
100 | + | leader_title = random.choice(['Captain ','','']) |
101 | - | self.denizenList.append(self.generatePerson()) |
101 | + | |
102 | - | |
102 | + | elif chosen_Settlement_Type == 'Outpost': |
103 | - | #Can be called from outwith the class to get the size |
103 | + | leader_title = random.choice(['Captain ','General ','Captain ','Lord ','Lady ','Captain ']) |
104 | - | def getSize(self): |
104 | + | |
105 | - | return self.populationSize |
105 | + | elif chosen_Settlement_Type == 'Village': |
106 | leader_title = random.choice (['Lord ','Lady ','Baron ','Baroness ','','','','','']) | |
107 | - | #Can be called from outwith the class to get the denizen list |
107 | + | |
108 | - | def getDenizens(self): |
108 | + | elif chosen_Settlement_Type == 'Town': |
109 | - | return self.denizenList |
109 | + | leader_title = random.choice (['Lord ','Lady ','Baron ','Baroness ','Mayor ','Mayor ','Mayor ','Mayor ']) |
110 | ||
111 | - | #Make a new settlement called ukuhara |
111 | + | elif chosen_Settlement_Type == 'City': |
112 | - | #Doing this runs the __init__() in the Settlement class |
112 | + | leader_title = random.choice (['King ','Queen ']) |
113 | - | ukuhara = Settlement() |
113 | + | |
114 | elif chosen_Settlement_Type == 'Capital City': | |
115 | - | print("Age" + " " + "Name") |
115 | + | leader_title = random.choice (['High King ','High Queen ','Queen ','King ']) |
116 | - | print("--------------------------------") |
116 | + | return (leader_title) |
117 | ||
118 | - | #For every item in the denizen list of Ukuhara |
118 | + | if race == 'Human': |
119 | - | for x in ukuhara.getDenizens(): |
119 | + | leader_name = get_leader_title(chosen_Settlement_Type) + human_name_gen() |
120 | - | #Print that persons age and name |
120 | + | |
121 | - | print(str(x["Age"])+ " " + x["Name"]+ " " + x["Job"]) |
121 | + | elif race == 'Dwarf': |
122 | leader_name = get_leader_title(chosen_Settlement_Type) + dwarf_name_gen() | |
123 | ||
124 | def generateDenizen(): | |
125 | #This sub-function generated names for the people | |
126 | def generatePersonJob(): | |
127 | jobList = [ | |
128 | "General Merchant", | |
129 | "Blacksmith", | |
130 | "Tailor", | |
131 | "Cobbler", | |
132 | "Tanner", | |
133 | "Doctor", | |
134 | "Wicken", | |
135 | "Wizard", | |
136 | "Healer", | |
137 | "Chef", | |
138 | "Baker", | |
139 | "Mercenary", | |
140 | "Arms Merchant", | |
141 | "Undertaker", | |
142 | "Executioner", | |
143 | "Carpenter", | |
144 | "Conjourer", | |
145 | "Stable Worker", | |
146 | "Falconer", | |
147 | "Hunter", | |
148 | "Farmer", | |
149 | "Banker", | |
150 | "Soldier", | |
151 | "Librarian" | |
152 | ] | |
153 | ||
154 | job = random.choice(jobList) | |
155 | return job | |
156 | ||
157 | ||
158 | #set name equal to the full name we just generated in the above function | |
159 | name = dwarf_name_gen() | |
160 | #Pick a random number for age | |
161 | age = random.choice(range(1,90)) | |
162 | #Pick a random job | |
163 | job = generatePersonJob() | |
164 | ||
165 | #Create a data dict that holds the name and age | |
166 | person = {"Name":name, "Age":age, "Job":job} | |
167 | #output the data dict we just made | |
168 | return person | |
169 | ||
170 | denizenList = [] | |
171 | for x in range(population): | |
172 | denizenList.append(generateDenizen()) | |
173 | ||
174 | services_list = get_services(chosen_Settlement_Type) | |
175 | ||
176 | print ("~ Settlement Generator ~") | |
177 | print ('Biome: '+ biome_type + "\n") | |
178 | print ("Type: "+ chosen_Settlement_Type + "\n") | |
179 | print ('Prominant race: ' + race + "\n") | |
180 | print ('Lead by: ' + leader_name + "\n") | |
181 | print ('Population: '+ str(population) + "\n") | |
182 | print ('Services: ') | |
183 | for x in set(services_list): | |
184 | print("> " + x + " - " + str(services_list.count(x))) | |
185 | print("\n") | |
186 | ||
187 | print ('Denizens: ') | |
188 | for x in denizenList: | |
189 | print(x["Name"]) | |
190 | print("\n") |