-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTDSRandomizer.py
More file actions
617 lines (560 loc) · 23.3 KB
/
TDSRandomizer.py
File metadata and controls
617 lines (560 loc) · 23.3 KB
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
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
from random import choice, randint
from time import sleep
import os
try:
print("Attempting to import termcolor.")
sleep(1)
from termcolor import cprint
except ModuleNotFoundError:
print("Unable to find the termcolor module.\n\nOn Linux, this can be provided by python3-termcolor, python-termcolor, dev-python/termcolor, etc. If your package manager does not provide it, install the module using pip.\n\nContrarily, if you are using macOS or Windows, you'll need to use pip.")
sleep(5)
print("I will now attempt to install it for you.")
sleep(1)
os.system("python -m pip install termcolor")
sleep(1)
from termcolor import cprint
print("We have termcolor, proceeding...")
sleep(1)
baseTowers = ["Farm","Commander","DJ Booth","Soldier","Freezer","Demoman","Paintballer","Pyromancer","Militant","Ace Pilot","Shotgunner","Rocketeer","Medic","Minigunner","Hunter","Military Base","Ranger","Electroshocker"
]
def TowerHandler(arr):
owned = []
cprint("I will now ask you about owning each tower in the specified list. Simply answer yes (or y) or no (or n).", "green", attrs=["bold"])
sleep(2)
if "Commander" in arr:
cprint("\nAutomatically adding the starter towers.", "magenta", attrs=["bold"])
sleep(1)
owned.append("Scout")
owned.append("Sniper")
for tower in arr:
cprint("\nDo you have", "green", attrs=["bold"], end=" ")
cprint(tower, "blue", attrs=["bold"], end="")
cprint("? [y/n]", "green", attrs=["bold"], end=" ")
promptif = input()
if promptif == "y" or promptif == "yes":
sleep(0.25)
owned.append(tower)
cprint("\n" + tower, "blue", attrs=["bold"], end=" ")
cprint("has been included in the local pool.", "green", attrs=["bold"])
elif promptif == "n" or promptif == "no":
sleep(0.25)
cprint("\nOK. I'll omit", "green", attrs=["bold"], end=" ")
cprint(tower, "blue", attrs=["bold"], end=" ")
cprint("from the pool.", "green", attrs=["bold"])
else:
raise ValueError("Invalid input given.")
cprint("\nWe're now done. Your custom pool with be used later on.", "green", attrs=["bold"])
sleep(0.5)
return owned
maps = [
"Portland",
"Grass Isle",
"Toyboard",
"Iceville",
"Necropolis",
"Meltdown",
"Marshlands",
"Harbor",
"Abandoned City",
"Autumn Falling",
"Cataclysm",
"Construction Crazy",
"Crossroads",
"Crystal Cave",
"Cyber City",
"Deserted Village",
"Forest Camp",
"Four Seasons",
"Fungi Island",
"Medieval Times",
"Moon Base",
"Nether",
"Retro Zone",
"Rocket Arena",
"Simplicity",
"Spring Fever",
"The Heights",
"Tropical Isles",
"Winter Bridges",
"Abyssal Trench",
"Candy Valley",
"Chess Board",
"Dusty Bridges",
"Farm Lands",
"Forgotten Docks",
"Night Station",
"Ruby Escort",
"Sky Islands",
"Winter Abyss",
"Wrecked Battlefield",
"Dead Ahead",
"Gilded Path",
"Infernal Abyss",
"Lay By",
"Mason Arch",
"Sacred Mountains",
"Space City",
"Winter Stronghold"
]
willUseFarm = False
hardcoreTowers = ["Accelerator", "Engineer"]
levelTowers = ["Crook Boss", "Turret", "Mortar", "Pursuit"]
mapTowers = ["Cowboy", "Warden"]
eventTowers = ["Gladiator", "Commando", "Slasher", "Archer", "Frost Blaster", "Swarmer", "Toxic Gunner", "Sledger", "Executioner", "Elf Camp"]
goldenTowers = ["Scout", "Soldier", "Pyromancer", "Cowboy", "Minigunner", "Crook Boss"]
loadout = []
cprint("\n\nTDS Randomizer v2.4 - Written by MagelessMayhem (Thymestl)\n\nPlease wait...\n\n", "cyan", attrs=["bold"])
sleep(2)
if os.path.isfile("customlist.txt"):
cprint("Welcome! What would you like to do?", "cyan", attrs=["bold"], end="\n\n")
cprint("1.", "green", attrs=["bold"], end=" ")
cprint("Randomize a loadout from scratch", "blue", attrs=["bold"], end="\n")
cprint("2.", "green", attrs=["bold"], end=" ")
cprint("Use an existing list for loadout randomization (customlist.txt)", "blue", attrs=["bold"], end="\n")
if os.path.isfile("golden.txt"):
cprint("3.", "green", attrs=["bold"], end=" ")
cprint("Randomize a loadout based on both the existing list and the separate golden list (golden.txt)", "blue", attrs=["bold"], end="\n\n")
cprint("If you want to randomize based on the existing list, select option 2 if you merged the golden perks with the main list, or option 3 if you left them separate. If you want to start over, select option 1.", "green", attrs=["bold"], end="\n\n")
cprint("Please select an option:", "cyan", attrs=["bold"], end=" ")
promptfile = int(input())
if promptfile == 1:
cprint("OK, proceeding normally.", "green", attrs=["bold"])
sleep(1)
elif promptfile >= 2:
cprint("OK, I'll use your list for customization.", "green", attrs=["bold"])
sleep(1)
list = open("customlist.txt", "r")
#Define variables early
customBase = []
for line in list.readlines():
customBase.append(line.strip("\n"))
if "Farm" in customBase:
cprint("\nYou had chosen Farm during the base tower phase of configuration. Should it be automatically included in the final loadout? This will help fund any offensive towers the randomizer generates. [y/n]", "cyan", attrs=["bold"], end=" ")
promptfarm = input()
if promptfarm == "y" or promptfarm == "yes":
willUseFarm = True
cprint("\nOK. Farm will be generated in slot 1.", "green", attrs=["bold"])
sleep(0.5)
loadout.append("Farm")
else:
cprint("\nOK. I'll proceed normally.", "green", attrs=["bold"])
sleep(0.5)
cprint("\nWould you also like the map to be randomized? It will be selected completely randomly with no difficulty bias. [y/n]", "cyan", attrs=["bold"], end=" ")
inputmap = input()
randommap = None
if inputmap == "y" or inputmap == "yes":
cprint("\nOK, the map will be randomly selected.", "green", attrs=["bold"], end=" ")
sleep(0.5)
randommap = choice(maps)
else:
cprint("\nOK, I'll let you pick your own map.", "green", attrs=["bold"])
cprint("\nNow randomizing, please wait...", "magenta", attrs=["bold"])
sleep(3)
fileData = customBase
if willUseFarm:
customBase.remove("Farm")
if len(loadout) < 1:
for i in range(0, 5):
# Generate normally
# Also ignore the last value; this is the player's level
selection = None
if len(customBase) > 0 and len(customBase) <= 2:
selection = customBase[0]
elif len(customBase) == 0:
continue
else:
selection = customBase[randint(0,len(customBase)-2)]
if selection.isdigit():
continue # Quit looping if we hit the player's level. This can only occur if the player has less than 5 towers.
loadout.append(selection)
customBase.remove(selection)
elif loadout[0] == "Farm" or len(loadout) == 0:
for i in range(0, 4):
selection = None
if len(customBase) <= 2:
selection = customBase[0]
elif len(customBase) == 0:
continue
else:
selection = customBase[randint(0,len(customBase)-2)]
if selection.isdigit():
continue
loadout.append(selection)
customBase.remove(selection)
if promptfile == 3:
goldfile = open("golden.txt", "r")
for gold in goldfile.readlines():
for tower in loadout:
if gold.split("\n")[0] == tower:
coinflip = randint(1,2)
if coinflip == 1:
newGolden = tower.replace(tower, "Golden " + tower)
loadout.append(newGolden)
loadout.remove(tower)
goldfile.close()
list.close()
cprint("\nThe loadout has successfully been generated:", "cyan", attrs=["bold"], end="\n\n")
if len(loadout) == 5: # Will go to this condition 99% of the time, since most players have at least 5 towers unlocked
cprint("1:", "green", attrs=["bold"], end=" ")
cprint(loadout[0], "blue", attrs=["bold"], end="\n")
cprint("2:", "green", attrs=["bold"], end=" ")
cprint(loadout[1], "blue", attrs=["bold"], end="\n")
cprint("3:", "green", attrs=["bold"], end=" ")
cprint(loadout[2], "blue", attrs=["bold"], end="\n")
cprint("4:", "green", attrs=["bold"], end=" ")
cprint(loadout[3], "blue", attrs=["bold"], end="\n")
cprint("5:", "green", attrs=["bold"], end=" ")
cprint(loadout[4], "blue", attrs=["bold"], end="\n\n")
# Otherwise it falls to one of these conditions.
elif len(loadout) == 4:
cprint("1:", "green", attrs=["bold"], end=" ")
cprint(loadout[0], "blue", attrs=["bold"], end="\n")
cprint("2:", "green", attrs=["bold"], end=" ")
cprint(loadout[1], "blue", attrs=["bold"], end="\n")
cprint("3:", "green", attrs=["bold"], end=" ")
cprint(loadout[2], "blue", attrs=["bold"], end="\n")
cprint("4:", "green", attrs=["bold"], end=" ")
cprint(loadout[3], "blue", attrs=["bold"], end="\n")
elif len(loadout) == 3:
cprint("1:", "green", attrs=["bold"], end=" ")
cprint(loadout[0], "blue", attrs=["bold"], end="\n")
cprint("2:", "green", attrs=["bold"], end=" ")
cprint(loadout[1], "blue", attrs=["bold"], end="\n")
cprint("3:", "green", attrs=["bold"], end=" ")
cprint(loadout[2], "blue", attrs=["bold"], end="\n")
else:
cprint("1:", "green", attrs=["bold"], end=" ")
cprint(loadout[0], "blue", attrs=["bold"], end="\n")
cprint("2:", "green", attrs=["bold"], end=" ")
cprint(loadout[1], "blue", attrs=["bold"], end="\n")
sleep(0.5)
if randommap != None:
cprint("Your map is:", "green", attrs=["bold"], end=" ")
cprint(randommap, "blue", attrs=["bold"])
sleep(0.5)
cprint("TDSRandomizer will now exit. Have fun!", "cyan", attrs=["bold"])
sleep(1)
os._exit(0)
cprint("First, I need to know what base towers you have.", "cyan", attrs=["bold"])
sleep(1)
customBase = TowerHandler(baseTowers)
cprint("\nNow, do you have either of the hardcore towers? [y/n]", "cyan", attrs=["bold"], end=" ")
prompthc = input()
if prompthc == "y" or prompthc == "yes":
cprint("\nDo you have", "green", attrs=["bold"], end=" ")
cprint("Accelerator", "blue", attrs=["bold"], end="")
cprint("? [y/n]", "green", attrs=["bold"], end=" ")
prompt1 = input()
if prompt1 == "y" or prompt1 == "yes":
sleep(0.25)
cprint("\nOK, I'll append it to your list.", "green", attrs=["bold"])
customBase.append("Accelerator")
elif prompt1 == "n" or prompt1 == "no":
sleep(0.25),
cprint("\nOK, I'll omit it from your list.", "green", attrs=["bold"])
else:
raise ValueError("Invalid input given.")
cprint("\nDo you have", "green", attrs=["bold"], end=" ")
cprint("Engineer", "blue", attrs=["bold"], end="")
cprint("? [y/n]", "green", attrs=["bold"], end=" ")
prompt1 = input()
if prompt1 == "y" or prompt1 == "yes":
sleep(0.25)
cprint("\nOK, I'll append it to your list.", "green", attrs=["bold"])
customBase.append("Engineer")
elif prompt1 == "n" or prompt1 == "no":
sleep(0.25),
cprint("\nOK, I'll omit it from your list.", "green", attrs=["bold"])
else:
raise ValueError("Invalid input given.")
else:
# Continue normally
sleep(0.5)
cprint("\nOK, you won't be asked about them.", "green", attrs=["bold"])
sleep(0.5)
cprint("\nDo you have either of the map towers? [y/n]", "cyan", attrs=["bold"], end=" ")
promptm = input()
if promptm == "y" or promptm == "yes":
cprint("\nDo you have", "green", attrs=["bold"], end=" ")
cprint("Cowboy", "blue", attrs=["bold"], end="")
cprint("? [y/n]", "green", attrs=["bold"], end=" ")
prompt1 = input()
if prompt1 == "y" or prompt1 == "yes":
sleep(0.25)
cprint("\nOK, I'll append it to your list.", "green", attrs=["bold"])
customBase.append("Cowboy")
elif prompt1 == "n" or prompt1 == "no":
sleep(0.25),
cprint("\nOK, I'll omit it from your list.", "green", attrs=["bold"])
else:
raise ValueError("Invalid input given.")
cprint("\nDo you have", "green", attrs=["bold"], end=" ")
cprint("Warden", "blue", attrs=["bold"], end="")
cprint("? [y/n]", "green", attrs=["bold"], end=" ")
prompt1 = input()
if prompt1 == "y" or prompt1 == "yes":
sleep(0.25)
cprint("\nOK, I'll append it to your list.", "green", attrs=["bold"])
customBase.append("Warden")
elif prompt1 == "n" or prompt1 == "no":
sleep(0.25),
cprint("\nOK, I'll omit it from your list.", "green", attrs=["bold"])
else:
raise ValueError("Invalid input given.")
else:
# Continue normally
sleep(0.5)
cprint("\nOK, you won't be asked about them.", "green", attrs=["bold"])
sleep(0.5)
cprint("\nWhat is your level in TDS?", "cyan", attrs=["bold"], end=" ")
intprompt = int(input())
if intprompt >= 30 and intprompt < 50:
cprint("\nOK, you should at least have", "green", attrs=["bold"], end=" ")
cprint("Crook Boss", "blue", attrs=["bold"], end="")
cprint(". I'll add it to your list.", "green", attrs=["bold"])
customBase.append("Crook Boss")
sleep(0.5)
elif intprompt >= 50 and intprompt < 75:
cprint("\nOK, you should at least have", "green", attrs=["bold"], end=" ")
cprint("Crook Boss", "blue", attrs=["bold"], end=" ")
cprint("and", "green", attrs=["bold"], end=" ")
cprint("Turret", "blue", attrs=["bold"], end="")
cprint(". I'll add them to your list.", "green", attrs=["bold"])
customBase.append("Crook Boss")
customBase.append("Turret")
sleep(0.5)
elif intprompt >= 75 and intprompt < 100:
cprint("\nOK, you should at least have", "green", attrs=["bold"], end=" ")
cprint("Crook Boss", "blue", attrs=["bold"], end="")
cprint(",", "green", attrs=["bold"], end=" ")
cprint("Turret", "blue", attrs=["bold"], end="")
cprint(", and", "green", attrs=["bold"], end=" ")
cprint("Mortar", "blue", attrs=["bold"], end="")
cprint(". I'll add them to your list.", "green", attrs=["bold"])
customBase.append("Crook Boss")
customBase.append("Turret")
customBase.append("Mortar")
sleep(0.5)
elif intprompt >= 100:
cprint("\nOK, you should have all of the level towers. I'll add them to your list.", "green", attrs=["bold"])
customBase.append("Crook Boss")
customBase.append("Turret")
customBase.append("Mortar")
customBase.append("Pursuit")
sleep(0.5)
else:
cprint("\nHmm, you don't seem to have any level towers. You might have bought them via gamepass; you may specify this next.", "green", attrs=["bold"])
if intprompt < 100:
cprint("\nDid you buy any of the level towers via gamepass (and are not currently the appropriate level to obtain them freely)? [y/n]", "green", attrs=["bold"], end=" ")
promptlv = input()
if promptlv == "y" or promptlv == "yes":
cprint("\nOK. You'll be redirected to the handler to enter the towers you have bought. If you already own the towers via level, you may simply answer no to the appropriate questions.", "green", attrs=["bold"])
sleep(1)
GPlist = TowerHandler(levelTowers)
customBase = customBase + GPlist
else:
cprint("\nOK, you won't be asked about them.", "green", attrs=["bold"])
sleep(0.5)
cprint("\nDo you have any event towers? [y/n]", "cyan", attrs=["bold"], end=" ")
promptev = input()
if promptev == "y" or promptev == "yes":
cprint("\nOK, you'll be redirected to the handler.", "green", attrs=["bold"])
sleep(1)
customEvent = TowerHandler(eventTowers)
customBase = customBase + customEvent
else:
cprint("\nOK, you won't be asked about them.", "green", attrs=["bold"])
sleep(0.5)
goldenIndependent = True
canUseGolden = False
cprint("\nDo you have any", "cyan", attrs=["bold"], end=" ")
cprint("golden perks", "yellow", attrs=["bold", "dark"], end="")
cprint("? [y/n]", "cyan", attrs=["bold"], end=" ")
promptg = input()
customGolden = None
if promptg == "y" or promptg == "yes":
canUseGolden = True
cprint("\nOK, you'll be redirected to the handler. You should answer each question based on whether you have the golden perk for that tower unlocked.", "green", attrs=["bold"])
sleep(1)
customGolden = TowerHandler(goldenTowers)
cprint("\nHow would you like to handle the randomization of golden perks?\n\n", "green", attrs=["bold"])
cprint("1.", "cyan", attrs=["bold"], end=" ")
cprint("Use them as a separate list and override corresponding towers based on a 50/50 chance", "blue", attrs=["bold"], end="\n")
cprint("2.", "cyan", attrs=["bold"], end=" ")
cprint("Replace corresponding towers in the list with their golden variants, and therefore only choose their golden variants if they are ever randomly chosen", "blue", attrs=["bold"], end="\n\n")
cprint("Please select an option:", "green", attrs=["bold"], end=" ")
promptgopt = int(input())
if promptgopt == 1:
cprint("\nOK, applying choice 1.", "green", attrs=["bold"])
sleep(1)
print(customGolden)
elif promptgopt == 2:
cprint("\nOK, applying choice 2. I am now merging the golden list into the custom one...", "green", attrs=["bold"])
goldenIndependent = False
sleep(1)
for tower in customGolden:
for target in customBase:
if tower == target:
cprint(tower + ":", "blue", attrs=["bold"], end=" ")
sleep(0.5)
newtower = target.replace(target, "Golden " + target)
customBase.append(newtower)
customBase.remove(target)
cprint("OK", "light_green", attrs=["bold"])
cprint("\nFinished.", "green", attrs=["bold"])
cprint("\nAnd finally, do you own any special towers, namely War Machine or Mecha Base? [y/n]", "cyan", attrs=["bold"], end=" ")
prompts = input()
if prompts == "y" or prompts == "yes":
sleep(0.5)
cprint("Do you have", "green", attrs=["bold"], end=" ")
cprint("War Machine", "blue", attrs=["bold"], end="")
cprint("? [y/n]", "green", attrs=["bold"], end=" ")
promptwm = input()
if promptwm == "y" or promptwm == "yes":
sleep(0.5)
cprint("OK, I'll add it to your pool.", "green", attrs=["bold"])
customBase.append("War Machine")
else:
sleep(0.5)
cprint("OK, I'll omit it from the pool.", "green", attrs=["bold"])
sleep(0.5)
cprint("Do you have", "green", attrs=["bold"], end=" ")
cprint("Mecha Base", "blue", attrs=["bold"], end="")
cprint("? [y/n]", "green", attrs=["bold"], end=" ")
promptmb = input()
if promptmb == "y" or promptmb == "yes":
sleep(0.5)
cprint("OK, I'll add it to your pool.", "green", attrs=["bold"])
customBase.append("Mecha Base")
else:
sleep(0.5)
cprint("OK, I'll omit it from the pool.", "green", attrs=["bold"])
else:
sleep(0.5)
cprint("OK, you won't be asked about them.", "green", attrs=["bold"])
sleep(0.5)
cprint("\nConfiguration has finally finished. Now proceeding to randomization.", "cyan", attrs=["bold"])
sleep(2)
willUseFarm = False
if "Farm" in customBase:
cprint("\nYou had chosen Farm during the base tower phase of configuration. Should it be automatically included in the final loadout? This will help fund any offensive towers the randomizer generates. [y/n]", "cyan", attrs=["bold"], end=" ")
promptfarm = input()
if promptfarm == "y" or promptfarm == "yes":
willUseFarm = True
cprint("\nOK. Farm will be generated in slot 1.", "green", attrs=["bold"])
sleep(0.5)
loadout.append("Farm")
else:
cprint("\nOK. I'll proceed normally.", "green", attrs=["bold"])
sleep(0.5)
cprint("\nWould you also like the map to be randomized? It will be selected completely randomly with no difficulty bias. [y/n]", "cyan", attrs=["bold"], end=" ")
inputmap = input()
randommap = None
if inputmap == "y" or inputmap == "yes":
cprint("\nOK, the map will be randomly selected.", "green", attrs=["bold"], end=" ")
sleep(0.5)
randommap = choice(maps)
else:
cprint("\nOK, I'll let you pick your own map.", "green", attrs=["bold"])
cprint("\nNow randomizing, please wait...", "magenta", attrs=["bold"])
sleep(3)
print(customBase)
fileData = []
for tower in customBase:
fileData.append(tower)
if willUseFarm:
customBase.remove("Farm")
if len(loadout) < 1:
for i in range(0, 5):
# Generate normally
# Also ignore the last value; this is the player's level
selection = None
if len(customBase) > 0 and len(customBase) <= 2:
selection = customBase[0]
elif len(customBase) == 0:
continue
else:
selection = choice(customBase)
if selection.isdigit():
continue # Quit looping if we hit the player's level. This can only occur if the player has less than 5 towers.
loadout.append(selection)
customBase.remove(selection)
elif loadout[0] == "Farm" or len(loadout) == 0:
for i in range(0, 4):
selection = None
if len(customBase) > 0 and len(customBase) <= 2:
selection = customBase[0]
elif len(customBase) == 0:
continue
else:
selection = choice(customBase)
if selection.isdigit():
continue
loadout.append(selection)
customBase.remove(selection)
if goldenIndependent and canUseGolden:
for tower in loadout:
for gold in customGolden:
if gold == tower:
coinflip = randint(1,2)
if coinflip == 1:
newGolden = tower.replace(tower, "Golden " + tower)
loadout.append(newGolden)
loadout.remove(tower)
fileData.append(str(intprompt))
print(fileData)
cprint("\nThe loadout has successfully been generated:", "cyan", attrs=["bold"], end="\n\n")
if len(loadout) == 5:
cprint("1:", "green", attrs=["bold"], end=" ")
cprint(loadout[0], "blue", attrs=["bold"], end="\n")
cprint("2:", "green", attrs=["bold"], end=" ")
cprint(loadout[1], "blue", attrs=["bold"], end="\n")
cprint("3:", "green", attrs=["bold"], end=" ")
cprint(loadout[2], "blue", attrs=["bold"], end="\n")
cprint("4:", "green", attrs=["bold"], end=" ")
cprint(loadout[3], "blue", attrs=["bold"], end="\n")
cprint("5:", "green", attrs=["bold"], end=" ")
cprint(loadout[4], "blue", attrs=["bold"], end="\n\n")
elif len(loadout) == 4:
cprint("1:", "green", attrs=["bold"], end=" ")
cprint(loadout[0], "blue", attrs=["bold"], end="\n")
cprint("2:", "green", attrs=["bold"], end=" ")
cprint(loadout[1], "blue", attrs=["bold"], end="\n")
cprint("3:", "green", attrs=["bold"], end=" ")
cprint(loadout[2], "blue", attrs=["bold"], end="\n")
cprint("4:", "green", attrs=["bold"], end=" ")
cprint(loadout[3], "blue", attrs=["bold"], end="\n")
elif len(loadout) == 3:
cprint("1:", "green", attrs=["bold"], end=" ")
cprint(loadout[0], "blue", attrs=["bold"], end="\n")
cprint("2:", "green", attrs=["bold"], end=" ")
cprint(loadout[1], "blue", attrs=["bold"], end="\n")
cprint("3:", "green", attrs=["bold"], end=" ")
cprint(loadout[2], "blue", attrs=["bold"], end="\n")
else:
cprint("1:", "green", attrs=["bold"], end=" ")
cprint(loadout[0], "blue", attrs=["bold"], end="\n")
cprint("2:", "green", attrs=["bold"], end=" ")
cprint(loadout[1], "blue", attrs=["bold"], end="\n")
if randommap != None:
cprint("Your map is:", "green", attrs=["bold"], end=" ")
cprint(randommap, "blue", attrs=["bold"])
sleep(0.5)
cprint("Would you like to save your custom tower list for future randomization? (Only recommended if golden perks were merged) [y/n]", "cyan", attrs=["bold"], end=" ")
promptsv = input()
if promptsv == "y" or promptsv == "yes":
fileData.append(str(intprompt))
sleep(0.5)
f = open("customlist.txt", "w")
f.write('\n'.join(fileData))
cprint("\nYour list has been saved to customlist.txt. You may modify it at any time.", "cyan", attrs=["bold"])
sleep(0.5)
f.close()
if goldenIndependent and canUseGolden:
goldfile = open("golden.txt", "w")
goldfile.write('\n'.join(customGolden))
cprint("\nYou had selected the 50/50 option during golden perk configuration; therefore, your golden perks list will be saved to golden.txt. You may modify it at any time.", "cyan", attrs=["bold"])
sleep(0.5)
goldfile.close()
cprint("TDSRandomizer will now exit. Have fun!", "cyan", attrs=["bold"])
sleep(1)