-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGenerate-Title.ps1
464 lines (440 loc) · 14.3 KB
/
Generate-Title.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
<#
*****************************************************
* Generate-Title *
*****************************************************
Created By: Gunslap
Date Created: March 3rd, 2019
Purpose:
The main function in this script (Generate-Title) will create and return a randomized Video Game title
Requirements:
The associated word list files
#>
#region Helper Functions
#Helper function to load up the word files
function Populate-WordLists()
{
#Try loading the word lists in from the same relative path as the script:
if(!$GLOBAL:nouns){$GLOBAL:nouns = Get-Content -Path "$PSScriptRoot\nouns.txt" -ErrorAction SilentlyContinue}
if(!$GLOBAL:adjectives){$GLOBAL:adjectives= Get-Content -Path "$PSScriptRoot\adjectives.txt" -ErrorAction SilentlyContinue}
if(!$GLOBAL:verbs){$GLOBAL:verbs = Get-Content -Path "$PSScriptRoot\verbs.txt" -ErrorAction SilentlyContinue}
#If they still don't exist, read them in from host:
if(!$GLOBAL:nouns){
$wordPath = Read-Host -Prompt "Path to word lists?"
$GLOBAL:nouns = Get-Content -Path "$wordPath\nouns.txt" -ErrorAction SilentlyContinue
if(!$GLOBAL:adjectives){$GLOBAL:adjectives= Get-Content -Path "$wordPath\adjectives.txt" -ErrorAction SilentlyContinue}
if(!$GLOBAL:verbs){$GLOBAL:verbs = Get-Content -Path "$wordPath\verbs.txt" -ErrorAction SilentlyContinue}
}
#If they STILL don't exist, throw an error
if(!$GLOBAL:nouns){Throw "ERROR: Word lists were not found at: $wordPath"}
}
#This function will return a noun with 0, 1, or 2 adjectives in front of it
function Generate-Noun()
{
#Get a noun
$noun = Get-Noun
#decide if we're going to get 0,1, or 2 adjectives
$num_adjectives = $(Get-Random -Minimum 0 -Maximum 9)
#0-3 = one adjective - 40% chance
if($num_adjectives -le 3)
{
#get one adjective
$adjective_1 = Get-Adjective
#add it before the noun
$noun = $adjective_1 + " " + $noun
}
#3 = two adjectives - 10% chance
elseif($num_adjectives -eq 4)
{
#get two adjectives
$adjective_1 = Get-Adjective
$adjective_2 = Get-Adjective
#add them before the noun
$noun = $adjective_1 + " " + $adjective_2 + " " + $noun
}
# any other case (5 or above) is no adjectives - 50%
#so do nothing to the noun
#return the noun + adjectives string
return $noun
}
#This function will return a single random Noun from the Noun array
function Get-Noun()
{
return $GLOBAL:nouns[$(Get-Random -Minimum 0 -Maximum ($GLOBAL:nouns.Length -1))]
}
#This function will return a single random Verb from the Verb array
function Get-Verb()
{
return $GLOBAL:verbs[$(Get-Random -Minimum 0 -Maximum ($GLOBAL:verbs.Length -1))]
}
#This function will return a single random Adjective from the Verb array
function Get-Adjective()
{
return $GLOBAL:adjectives[$(Get-Random -Minimum 0 -Maximum ($GLOBAL:adjectives.Length -1))]
}
#endregion
# Main Title Generator Function
function Generate-Title()
{
<#
.SYNOPSIS
This function will generate a video game title
.DESCRIPTION
This function will read in some word lists and randomly generate and return a video game title
.EXAMPLE
"Generate-Title"
Super Cobra Vehicle Simulator 5
#>
#Populate word lists
Populate-WordLists
$title = ""
$title_style = $(Get-Random -Minimum 0 -Maximum 8)
switch ($title_style){
#Single Noun
0 {
$noun_1 = Generate-Noun
$title = $noun_1
break
}
#Noun preposition Noun
1 {
$noun_1 = Generate-Noun
$noun_2 = Generate-Noun
#if it's over 40 characters, it's pretty freaking long, find shorter nouns!
while($($noun_1 + " in" + $noun_2).length -ge 40)
{
$noun_1 = Generate-Noun
$noun_2 = Generate-Noun
}
$joiner = $(Get-Random -Minimum 0 -Maximum 6)
switch($joiner){
#Of
0 {
$title = $noun_1 + " of " + $noun_2
break
}
#"In"
1 {
$title = $noun_1 + " in " + $noun_2
break
}
#"After"
2 {
$title = $noun_1 + " After " + $noun_2
break
}
#"Before"
3 {
$title = $noun_1 + " Before " + $noun_2
break
}
#"With"
4 {
$title = $noun_1 + " with " + $noun_2
break
}
#"Vs."
5 {
$title = $noun_1 + " Vs. " + $noun_2
break
}
#"Featuring"
6 {
$title = $noun_1 + " Featuring " + $noun_2
break
}
}
break
}
#I'M NOT A FAN OF THIS ONE YET. IT NEEDS SOME WORK FOR SURE
#Noun Verb Noun
2 {
$noun_1 = Generate-Noun
$verb_1 = Get-Verb
$noun_2 = Generate-Noun
while($($noun_1 + $verb_1 + $noun_2).length -ge 40)
{
$noun_1 = Generate-Noun
$noun_2 = Generate-Noun
}
$title = $noun_1 + " " + $verb_1 + " " + $noun_2
break
}
#Verb Noun
3 {
$verb_1 = Get-Verb
$noun_1 = Generate-Noun
while($($noun_1 + $verb_1).length -ge 40)
{
$noun_1 = Generate-Noun
}
$title = $verb_1 + " " + $noun_1
break
}
#Noun Verb Adjective
4 {
$noun_1 = Generate-Noun
$verb_1 = Get-Verb
$adjective_1 = Get-Adjective
while($($noun_1 + $verb_1 + $adjective_1).length -ge 40)
{
$noun_1 = Generate-Noun
}
$title = $noun_1 + " " + $verb_1 + " " + $adjective_1
break
}
#Default will be "Noun Noun"
default {
$noun_1 = Generate-Noun
#We don't want the second noun to have any adjectives
#as those are weird looking on this type so we'll pull one directly from the array:
$noun_2 = Get-Noun
#noun_2 = Generate-Noun
#if it's over 40 characters, it's pretty freaking long, try some new nouns!
while($($noun_1 + " in" + $noun_2).length -ge 40)
{
$noun_1 = Generate-Noun
$noun_2 = Get-Noun
}
#Save the title to the global title variable
$title = $noun_1 + " " + $noun_2
}
}
#Now that we've got our general title structure
#we'll check it for lenth, if it's too long
#skip even thinking of adding either a prefix or a suffix
#(and if it's already SUPER long we'll skip both)
$skip_prefix = $false
$skip_suffix = $false
#if it's already over 30, skip both
if($title.length -ge 30)
{
$skip_prefix = $true
$skip_suffix = $true
}
#if it's over 20, skip 1 at random
elseif($title.length -ge 20)
{
$skipper = Get-Random -Minimum 0 -Maximum 1
switch ($skipper)
{
0 {
$skip_prefix = $true
break
}
1 {
$skip_suffix = $true
break
}
}
}
#Skip if too long
if($skip_prefix -eq $false)
{
$prefix_modify = Get-Random -Minimum 0 -Maximum 100
$prefix_addition = ""
#7 choices, even odds would be 14/100 each
#Some of these make sense with a "The" in front of them
#and others with a "The" after them. We will set a flag
#to determine which "The" is appropriate
$the_before = $true
#"Super" - 10%
if($prefix_modify -le 10)
{
$prefix_addition = "Super "
}
#"Ultimate" - 10%
elseif($prefix_modify -ge 10 -AND $prefix_modify -le 20)
{
$prefix_addition = "Ultimate "
}
#"Extreme" - 7%
elseif($prefix_modify -ge 21 -AND $prefix_modify -le 28)
{
$prefix_addition = "Extreme "
}
#"Legend of" - 8%
elseif($prefix_modify -ge 29 -AND $prefix_modify -le 37)
{
$prefix_addition = "Legend of "
}
#"Age of" - 6%
elseif($prefix_modify -ge 38 -AND $prefix_modify -le 44)
{
$prefix_addition = "Age of "
}
#"Imagine" - 5%
elseif($prefix_modify -ge 45 -AND $prefix_modify -le 50)
{
$prefix_addition = "Imagine "
$the_before = $false
}
#"Revenge of" - 4%
elseif($prefix_modify -ge 51 -AND $prefix_modify -le 55)
{
$prefix_addition = "Revenge of "
$the_before = $false
}
#44% chance - no prefix!
#if a prefix was selected, add it in!
if($prefix_addition -ne "")
{
#Determine if we want a "The" in here and add the prefix
if($(Get-Random -Minimum 0 -Maximum 5) -eq 0 -AND $title.length -le 35)
{
#Can the "The" go before the prefix?
if($the_before -eq $true)
{
$title = "The " + $prefix_addition + $title
}
else
{
$title = $prefix_addition + "The " + $title
}
}
#No "The", just add the prefix
else
{
$title = $prefix_addition + $title
}
}
#No prefix, maybe we still want a "The"?
elseif($(Get-Random -Minimum 0 -Maximum 5) -eq 0 -AND $title.Length -le 35)
{
$title = "The " + $title
}
}
#Ending Modifier
if($skip_suffix -eq $false)
{
$ending_modify = Get-Random -Minimum 0 -Maximum 50
$ending_addition = ""
switch ($ending_modify)
{
#sequels
0 {
$ending_addition = " " + $(Get-Random -Minimum 2 -Maximum 10)
break
}
#"The Game"
1 {
$ending_addition = ": The Game"
break
}
#"Simulator"
2 {
$ending_addition = " Simulator"
break
}
#"GOTY Edition"
3 {
$ending_addition = " GOTY Edition"
break
}
#"Remastered"
4 {
$ending_addition = " Remastered"
break
}
#"HD"
5 {
$ending_addition = " HD"
break
}
#Year
6 {
$ending_addition = " " + $(Get-Random -Minimum 1000 -Maximum 3000)
break
}
#"Cronicles"
7 {
$ending_addition = " Cronicles"
break
}
#"Zero"
8 {
$ending_addition = " Zero"
break
}
#"Unleashed"
9 {
$ending_addition = " Unleashed"
break
}
#"Origins"
10 {
$ending_addition = " Origins"
break
}
#"Mania!"
11 {
$ending_addition = " Mania!"
break
}
#"XD"
12 {
$ending_addition = " XD"
break
}
#"Online"
13 {
$ending_addition = " Online"
break
}
#"For Kids!"
15 {
$ending_addition = " for Kids!"
break
}
#"Vengeance"
16 {
$ending_addition = " Vengeance"
break
}
#"Deluxe"
17 {
$ending_addition = " Deluxe"
break
}
# otherwise, do nothing
}
if($ending_addition -ne "")
{
$title = $title + $ending_addition
}
}
#return the completed Title
return $title
}
# Generates a random title from the provided template
function Generate-FromTemplate([string] $template)
{
Populate-WordLists
#find and replace nouns
while ($template.Contains("Noun") -eq $true) {
$firstC = $template.IndexOf("Noun")
$lastC = $template.IndexOf("Noun") + $("Noun").Length
$endC = $template.Length - ($template.IndexOf("Noun") + $("Noun").Length)
$before = $template.Substring(0,$firstC)
$after = $template.Substring($lastC,$endC)
$template = $before + $(Get-Noun) + $after
}
#find and replace verbs
while ($template.Contains("Verb") -eq $true) {
$firstC = $template.IndexOf("Verb")
$lastC = $template.IndexOf("Verb") + $("Verb").Length
$endC = $template.Length - ($template.IndexOf("Verb") + $("Verb").Length)
$before = $template.Substring(0,$firstC)
$after = $template.Substring($lastC,$endC)
$template = $before + $(Get-Verb) + $after
}
#find and replace adjectives
while ($template.Contains("Adjective") -eq $true) {
$firstC = $template.IndexOf("Adjective")
$lastC = $template.IndexOf("Adjective") + $("Adjective").Length
$endC = $template.Length - ($template.IndexOf("Adjective") + $("Adjective").Length)
$before = $template.Substring(0,$firstC)
$after = $template.Substring($lastC,$endC)
$template = $before + $(Get-Adjective) + $after
}
return $template
}