repl.it
@Seazyns/

Hero Legends - Optimized Work Version

Python

Work Version

fork
loading
Files
  • main.py
  • Text Documents
  • attack.py
  • enemy.py
  • hero.py
main.py
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
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
### IMPORTS ###
import pickle, random, os, sys, threading
from attack import *
from enemy import *
from hero import *
from replit import clear
from time import sleep

# Color
cursorUp = '\x1b[1A'
eraseLine = '\x1b[2K'
reset = '\033[0m'
red = '\033[31m'
orange = '\033[33m'
blue = '\033[36m'
green = '\033[32m'
purple = '\033[35m'

### Functions ###
def tprint(s):
    for c in s:
        sys.stdout.write(c)
        sys.stdout.flush()
        sleep(0.05)

### MODE SELECTION ###
def selectMode():
	while True:
		clear()
		print("Hero Legends - Mode Selection\n")
		print("[Modes]")
		print("(1) Classic Mode")
		print("(2) Story Mode [WIP]")
		selectedMode = input("\n> ")
		if selectedMode == "1":
			classicMenu()
		if selectedMode == "2":
			storyMenu()

### CLASSIC - VARIABLES ###
# Player Attacks
melee = ClassicAttack("Melee",20,0)
snowball = ClassicAttack("Snowball",30,10)
fireball = ClassicAttack("Fireball",40,15)
spear = ClassicAttack("Spear",30,10)
sword = ClassicAttack("Sword",40,15)
bowArrow = ClassicAttack("Bow & Arrow",30,10)
crossbow = ClassicAttack("Cross Bow",40,15)
# Monster / Boss Attacks
meleeEnemy = ClassicAttack("Melee",8,0)
meleeBoss = ClassicAttack("Melee",16,0)

# Players
wizard = ClassicHero("Wizard",125,125,125,125,melee,snowball,fireball)
knight = ClassicHero("Knight",175,175,75,75,melee,spear,sword)
archer = ClassicHero("Archer",150,150,100,100,melee,bowArrow,crossbow)

# Monsters & Bosses
monsterOne = ClassicEnemy("Monster",50,50,meleeEnemy)
monsterTwo = ClassicEnemy("Monster",75,75,meleeEnemy)
bossOne = ClassicEnemy("Boss",125,125,meleeBoss)
bossTwo = ClassicEnemy("Boss",150,150,meleeBoss)

# Monster / Boss Lists
monsterList = [monsterOne,monsterTwo]
bossList = [bossOne,bossTwo]

# Extra
guestAccess = 0

### CLASSIC - GET VALUES ###
def classicCharacterStats():
	print("[{}]".format(player.getName()))
	print("HP: ({}/{})".format(player.getHealth(),player.getMaxHealth()))
	print("Mana: ({}/{})\n".format(player.getMana(),player.getMaxMana()))

def classicDisplayAttack(x,y,z):
	print("\n({}) {} Attack [{}]".format(z,y,x.getName()))
	print("Damage: {}".format(x.getDamage()))
	if x.manaCost > 0:
		print("Mana Cost: {}".format(x.getManaCost()))

### CLASSIC - Bank Interest: Threading ###
def bankInterest():
	sleep(600)
	player.bankCoins = player.bankCoins * player.bankInterestRate
	threading.Timer(1, bankInterest).start()

### CLASSIC - MAIN MENU ###
def classicMenu():
	global guestAccess
	while True:
		clear()
		print("Hero Legends - Classic Mode")
		print("Important: Fork Game (Unless Playing as Guest!) to Save / Load Progress!")
		print("\n[Options]")
		print("(a) Mode Selection")
		print("\n[Main Menu]")
		print("(1) Tutorial")
		print("(2) Signup")
		print("(3) Login")
		print("(4) Guest")
		print("(5) Credits")
		menuInput = input("\n> ")
		if menuInput.lower() == "a":
			selectMode()
		elif menuInput == "1":
			classicTutorial()
		elif menuInput == "2":
			classicSignup()
		elif menuInput == "3":
			classicLogin()
		elif menuInput == "4":
			guest()
			guestAccess = 1
			classicPregame()
		elif menuInput == "5":
			credits()

### CLASSIC - TUTORIAL ###
def classicTutorial():
	while True:
		clear()
		print("Hero Legends - Tutorial\n")
		print("[Tutorial]")
		print("In Hero Legends, heroes fight monsters and bosses to level up and prestige.")
		print("Once they hit level 100, they prestige and gain stat boosts.")
		print("Every 5 levels, you will receive an upgrade token to use at the upgrade table.")
		print("You can boost your attack, defense and also the coins and gems you get from chests.")
		print("\n[Options]")
		print("(1) Main Menu")
		tutorialInput = input("\n> ")
		if tutorialInput == "1":
			classicMenu()

### CLASSIC - SIGNUP ###
def classicSignup():
	global username, password, filename
	clear()
	print("Hero Legends - Signup\n")
	print("[Signup]")
	username = input("Username: ")
	password = input("Password: ")
	filename = ("{}_{}Classic.pickle".format(username,password))
	if os.path.exists(filename):
		print("\nAccount Already Exists!")
		sleep(0.75)
		classicMenu()
	guestAccess = 0
	classicPregame()

### CLASSIC - LOGIN ###
def classicLogin():
	global username, password, filename
	clear()
	print("Hero Legends - Login\n")
	print("[Login]")
	username = input("Username: ")
	password = input("Password: ")
	filename = ("{}_{}Classic.pickle".format(username,password))
	if os.path.exists(filename):
		guestAccess = 0
		load()
		threading.Thread(target=bankInterest).start()
		classicGameMenu()
	else:
		print("\nAccount Does Not Exist!")
		sleep(0.75)
		classicMenu()

### CLASSIC - SAVE ###
def classicSave():
	if player.autoSave == 1:
		if os.path.exists(filename):
			os.remove(filename)
		with open(filename,'wb+') as f:
			pickle.dump(player,f)

### CLASSIC - LOAD ###
def classicLoad():
	global player
	with open(filename,'rb') as f:
		player = pickle.load(f)

### CLASSIC - PRE GAME ###
def classicPregame():
	global player
	while True:
		clear()
		print("Hero Legends - Select Character\n")
		print("(1) Wizard \nStats: HP:{}, Mana:{}".format(wizard.getHealth(),wizard.getMana()))
		print("(2) Knight \nStats: HP:{}, Mana:{}".format(knight.getHealth(),knight.getMana()))
		print("(3) Archer \nStats: HP:{}, Mana:{}\n".format(archer.getHealth(),archer.getMana()))
		characterInput = input("> ")
		if characterInput == "1":
			player = wizard
			break
		elif characterInput == "2":
			player = knight
			break
		elif characterInput == "3":
			player = archer
			break
	if guestAccess == 1:
		threading.Thread(target=bankInterest).start()
		classicGameMenu()
	# Settings
	while True:
		clear()
		player.calcAutoSave()
		print("Toggle AutoSave: (On/Off)")
		autoDetect = input("> ")
		if autoDetect.lower() == "on":
			player.autoSave = 1
			break
		elif autoDetect.lower() == "off":
			player.autoSave = 0
			break
	classicSave()
	threading.Thread(target=bankInterest).start()
	classicGameMenu()

### CLASSIC - GAME MENU ###
def classicGameMenu():
	while True:
		player.calcMaxXp()
		clear()
		print("Hero Legends - Game Menu\n")
		print("[{}]".format(username))
		print("Coins: {}".format(player.getCoins()))
		print("Gems: {}\n".format(player.getGems()))
		classicCharacterStats()
		print("Level: {}".format(player.getLevel()))
		print("XP: ({}/{})".format(player.getXp(), player.getMaxXp()))
		print("\n[Game Menu]")
		print("(a) Play Level")
		print("(b) Upgrade Table")
		print("(c) Shop")
		print("(d) Casino")
		print("(e) Bank")
		print("\n[Options]")
		print("(1) Save")
		print("(2) Settings")
		print("(3) Exit")
		gameInput = input("\n> ")
		if gameInput.lower() == "a":
			classicChooseLevel()
		elif gameInput.lower() == "b":
			classicUpgradeTable()
		elif gameInput.lower() == "c":
			classicShop()
		elif gameInput.lower() == "d":
			classicCasino()
		elif gameInput.lower() == "e":
			classicBank()
		elif gameInput == "1":
			classicSave()
		elif gameInput == "2":
			classicSettings()
		elif gameInput == "3":
			if player.autoSave == 1:
				classicSave()
			sys.exit(0)

### CLASSIC - LEVEL ###
def classicChooseLevel():
	global monsterCount, bossCount, chestMonsterCount,chestBossCount
	clear()
	# Choose Number of Monsters and Bosses
	monsterCount = random.randrange(2,6)
	bossCount = random.randrange(1,3)
	chestMonsterCount = monsterCount
	chestBossCount = bossCount
	# Play Level
	while True:
		if monsterCount > 0 or bossCount > 0:
			classicPlayLevel()
		elif monsterCount == 0 and bossCount == 0:
			player.healAll()
			classicChest()
			break

# Play Level
def classicPlayLevel():
	global chosenAttackWeapon, pickedMonster, currentEnemy, monsterCount, bossCount
	# Pick Monster
	if monsterCount > 0:
		pickedMonster = random.choice(monsterList)
		currentEnemy = "monster"
	# Pick Boss
	elif monsterCount == 0 and bossCount > 0:
		pickedMonster = random.choice(bossList)
		currentEnemy = "boss"
	# Loop Attacking
	while True:
		clear()
		classicLevelCheck()
		# Monster Dead
		if pickedMonster.health <= 0:
			print("Hero Legends\n")
			print("You defeated a {}".format(pickedMonster.getName()))
			# Player Xp
			if pickedMonster.name == "Monster":
				xpCount = (player.lvl * 5)
			elif pickedMonster.name == "Boss":
				xpCount = (player.lvl * 10)
			player.gainXp(xpCount)
			print("You got {} Xp!".format(xpCount))
			input("\nPress 'Enter' to Continue!")
			clear()
			pickedMonster.healAll()
			if currentEnemy == "monster":
				monsterCount -= 1
				break
			if currentEnemy == "boss":
				bossCount -= 1
				break
		# Fighting Monsters / Bosses
		print("Hero Legends - Level\n")
		print("[Enemies]")
		if monsterCount > 0:
			print("Monsters: {}".format(monsterCount))
		print("Bosses: {}\n".format(bossCount))
		classicCharacterStats()
		print("[Enemy]")
		print("{}".format(pickedMonster.getName()))
		print("HP: ({}/{})\n".format(pickedMonster.health,pickedMonster.maxHealth))
		print("[Attack]")
		classicDisplayAttack(player.defaultAttack,"Default","a")
		classicDisplayAttack(player.attackOne,"Primary","b")
		classicDisplayAttack(player.attackTwo,"Secondary","c")
		print("\n[Options]")
		print("(1) Run Away")
		attackInput = input("\n> ")
		if attackInput.lower() == "a":
			chosenAttackWeapon = player.defaultAttack
			classicAttackDamage()
		elif attackInput.lower() == "b":
			chosenAttackWeapon = player.attackOne
			classicAttackDamage()
		elif attackInput.lower() == "c":
			chosenAttackWeapon = player.attackTwo
			classicAttackDamage()
		elif attackInput.lower() == "1":
			runawayChance = random.randint(0,101)
			if runawayChance < 25:
				player.healAll()
				pickedMonster.healAll()
				print("\nYou Successfully Ranaway!")
				sleep(1.5)
				classicGameMenu()
			else:
				print("\nYou Were Unsuccessful in Running Away!")
				sleep(1)
				classicEnemyAttackDamage()

# Level Check
def classicLevelCheck():
	# Player Dead
	if player.health <= 0:
		player.healAll()
		print("Hero Legends\n")
		print("[Stats]")
		print("You Died!")
		randomCoins = random.randint(5,11)
		if player.coins >= randomCoins:
			player.coins -= randomCoins
		else:
			randomCoins = player.coins
			player.coins -= randomCoins
		if randomCoins > 0:
			print("You Lost {} Coins!".format(randomCoins))
		input("\nPress 'Enter' to Return to Hub!")
		classicGameMenu()

# Enemy Attack
def classicEnemyAttackDamage():
	if pickedMonster.health > 0:
		enemyHitChance = random.randint(0,101)
		if enemyHitChance < 75:
			doDamage = random.randint(4,pickedMonster.attackOne.damage)
			player.health -= doDamage
			print("{} did {} Damage to your {}".format(pickedMonster.getName(),doDamage,player.getName()))
		else:
			print("\n{} Missed Attack".format(pickedMonster.getName()))
		sleep(1)
		clear()

# Player vs. Enemy
def classicAttackDamage():
	# Player Attacks Enemy
	if player.mana >= chosenAttackWeapon.manaCost:
		pickedMonster.health -= chosenAttackWeapon.damage
		player.mana -= chosenAttackWeapon.manaCost
		print("\n{} used {} and did {} Damage to the {}".format(player.getName(),chosenAttackWeapon.getName(),chosenAttackWeapon.getDamage(),pickedMonster.getName()))
		sleep(1)
		if chosenAttackWeapon.manaCost > 0:
			print("Mana Lost: {}".format(chosenAttackWeapon.getManaCost()))
			sleep(1.5)
		# Enemy Hits Player
		classicEnemyAttackDamage()
	else:
		print("\nNot Enough Mana!")
		sleep(1)
		clear()

# Chest
def classicChest():
	chestGems = 0
	# Randomize
	chestMonsterCoins = random.randint(chestMonsterCount, (5*chestMonsterCount))
	chestBossCoins = random.randint(chestBossCount, (10*chestBossCount))
	chestGemsChance = random.randint(0,101)
	# Amounts
	totalChestCoins = chestMonsterCoins + chestBossCoins + player.coinBoost
	player.coins += totalChestCoins
	if chestGemsChance < 10 + player.gemBoost:
		chestGems = 1
		player.gems += chestGems
	clear()
	print("Hero Legends\n")
	print("[Items]")
	print("Coins Earned: {}".format(totalChestCoins))
	if chestGems > 0:
		print("Gems Earned: {}".format(chestGems))
	input("\nPress 'Enter' to Close Chest!")
	if player.autoSave == 1:
		classicSave()

### CLASSIC - UPGRADE TABLE ###
def classicUpgradeTable():
	while True:
		clear()
		print("Hero Legends- Upgrade Table")
		print("Upgrade Tokens: {}".format(player.getUpgradeTokens()))
		print("\n[Upgrade Table]")
		print("(a) Health Cap [+20]")
		print("(b) Mana Cap [+20]")
		print("(c) Chest Coin Boost [+2]")
		print("(d) Chest Gem Boost [+1%]\n")
		print("[Options]")
		print("(1) Game Menu")
		upgradeTableInput = input("\n> ")
		if upgradeTableInput == "1":
			classicGameMenu()
		if player.upgradeTokens > 0:
			player.upgradeTokens -= 1
			if upgradeTableInput == "a":
				player.maxHealth += 20
				player.healAll()
				print("\nSuccessfully Upgraded Health Cap by 20")
			elif upgradeTableInput == "b":
				player.maxMana += 20
				player.healAll()
				print("\nSuccessfully Upgraded Mana Cap by 20")
			elif upgradeTableInput == "c":
				player.coinBoost += 2
				print("\nSuccessfully Upgraded Coin Boost by 2")
			elif upgradeTableInput == "d":
				player.gemBoost += 1
				print("\nSuccessfully Upgraded Gem Boost by 1%")
			if player.autoSave == 1:
				classicSave()
		else:
			print("\nNot Enough Upgrade Tokens!")
		input("Press 'Enter' to Continue!")

### CLASSIC - SHOP ###
def classicShop():
	while True:
		clear()
		print("Hero Legends- Shop\n")
		print("[Shop]")
		print("\n[Menu]")
		print("(1) Game Menu")
		shopInput = input("\n> ")
		if shopInput == "1":
			classicGameMenu()

### CLASSIC - CASINO ###
def classicCasino():
	while True:
		clear()
		print("Hero Legends - Casino")
		print("Coins: {}".format(player.getCoins()))
		print("\n[Gamble]")
		print("(a) Slots")
		print("\n[Options]")
		print("(1) Game Menu")
		print("(2) Gamble Info")
		gambleInput = input("\n> ")
		# Slots
		if gambleInput.lower() == "a":
			classicSlots()
		if gambleInput == "1":
			classicGameMenu()
		if gambleInput == "2":
			classicSlotsInfo()

def classicSlots():
	try:
		slotsAmount = input("Gamble Amount: ")
		if int(slotsAmount) > 0 and player.coins >= int(slotsAmount):
			player.coins -= int(slotsAmount)
			numberOne = random.randint(0,5)
			numberTwo = random.randint(0,5)
			numberThree = random.randint(0,5)
			clear()
			print("| {} | {} | {} |".format(numberOne,numberTwo,numberThree))
			# 3x Money | 3 Numbers
			if numberOne == numberTwo and numberOne == numberThree:
				sleep(1)
				print("You matched 3 numbers!")
				print("You have won 3x your gambled money: ${}!".format(3*int(slotsAmount)))
				player.coins += (3*int(slotsAmount))
				sleep(2.5)
			# 2x Money | 2 Numbers
			elif numberOne == numberTwo or numberTwo == numberThree or numberOne == numberThree:
				sleep(1)
				print("You matched 2 numbers!")
				print("You have won 2x your gambled money: ${}!".format(2*int(slotsAmount)))
				player.coins += (2*int(slotsAmount))
				sleep(2.5)
			# 0x Money | 1 or 0 Numbers
			else:
				sleep(1)
				print("You matched 0 numbers!")
				print("You lost all your gambled money!")
				sleep(2.5)
	except:
		clear()

def classicSlotsInfo():
	clear()
	print("[Slots]")
	print("Three numbers are rolled from 1 to 5.")
	print("No numbers matched = lose gambled money")
	print("Two numbers matched = 2x gambled money")
	print("Three numbers matched = 3x gambled money")
	input("\nPress 'Enter' to continue!")

### CLASSIC - BANK ###
def classicBank():
	while True:
		if player.bankAccount == 0:
			classicCreateBankAccount()
		clear()
		print("Hero Legends - Bank\n")
		print("Coins: {}".format(player.getCoins()))
		print("Bank Balance: {}".format(int(player.getBankCoins())))
		print("\n[Bank]")
		print("(a) Deposit")
		print("(b) Withdraw")
		print("\n[Options]")
		print("(1) Game Hub")
		bankInput = input("\n> ")
		if bankInput.lower() == "a":
			try:
				depositAmount = input("Deposit Amount: ")
				if int(depositAmount) > 0 and player.coins >= int(depositAmount):
					player.bankCoins += int(depositAmount)
					player.coins -= int(depositAmount)
					print("\nSuccessfully Deposited!")
					sleep(0.75)
				else:
					print("\nError!")
					sleep(0.75)
			except:
				print("\nError!")
				sleep(0.75)
		elif bankInput.lower() == "b":
			try:
				withdrawAmount = input("Withdraw Amount: ")
				if int(withdrawAmount) > 0 and player.bankCoins >= int(withdrawAmount):
					player.coins += int(withdrawAmount)
					player.bankCoins -= int(withdrawAmount)
					print("Successfully Withdrawn!")
					sleep(0.75)
				else:
					print("\nError!")
					sleep(0.75)
			except:
				print("\nError!")
				sleep(0.75)
		elif bankInput == "1":
			classicGameMenu()

def classicCreateBankAccount():
	while True:
		clear()
		print("Hero Legends - Bank\n")
		print("Coins: {}".format(player.getCoins()))
		print("Gems: {}\n".format(player.getGems()))
		print("[Bank Accounts]")
		print("(a) Basic Account [Interest: 2%] [Cost: 100 Coins & 5 Gems]")
		print("(b) Standard Account [Interest: 5%] [Cost: 250 Coins & 10 Gems]")
		print("(c) Premium Account [Interest: 10%] [Cost: 500 Coins & 20 Gems]")
		print("\n[Options]")
		print("(1) Game Menu")
		bankAccountChoice = input("\n> ")
		if bankAccountChoice.lower() == "a" and player.coins >= 100 and player.gems >= 5:
			print("\nSuccessful Purchase of Basic Account!")
			player.coins -= 100
			player.gems -= 5
			player.bankInterestRate += 0.02
			player.bankAccount += 1
			sleep(1.5)
			classicBank()
		elif bankAccountChoice.lower() == "b" and player.coins >= 250 and player.gems >= 10:
			print("\nSuccessful Purchase of Standard Account!")
			player.coins -= 250
			player.gems -= 10
			player.bankInterestRate += 0.05
			player.bankAccount += 1
			sleep(1.5)
			classicBank()
		elif bankAccountChoice.lower() == "c" and player.coins >= 500 and player.gems >= 20:
			print("\nSuccessful Purchase of Premium Account!")
			player.coins -= 500
			player.gems -= 20
			player.bankInterestRate += 0.1
			player.bankAccount += 1
			sleep(1.5)
			classicBank()
		elif bankAccountChoice == "1":
			classicGameMenu()
		else:
			print("\nError!")
			sleep(1.5)

### CLASSIC - SETTINGS ###
def classicSettings():
	while True:
		clear()
		print("Hero Legends - Settings\n")
		print("[Settings]")
		print("(a)", end = " ")
		player.calcAutoSave()
		print("\n[Settings Menu]")
		print("(1) Game Menu")
		settingsMenu = input("\n> ")
		if settingsMenu == "1":
			classicGameMenu()
		if settingsMenu.lower() == "a":
			classicToggleAutoSave()

# Toggle Auto Save
def classicToggleAutoSave():
	clear()
	player.calcAutoSave()
	print("Toggle Autosave: (On/Off)")
	changeAutoSave = input("> ")
	clear()
	if guestAccess == 1:
		print("Error!\nYou are using guest access!")
	elif changeAutoSave.lower() == "on" and player.autoSave == 0:
		player.autoSave += 1
		print("Turned on Auto Save!")
	elif changeAutoSave.lower() == "off" and player.autoSave == 1:
		player.autoSave -= 1
		print("Turned off Auto Save!")
	sleep(1)
	classicSave()

### STORY - VARIABLES ###
storyGuest = 0
storyPrologueAnimation = 1
# Player
storyPlayerTemplate = StoryHero("Name","Nationality","Gender")

### STORY - TEXT ###
prologue = "Year: 1200BCE\n Full of lush forests and beautiful gardens with a vibrant scenery, there was a village, Azmarin. On a beautiful evening, an army of orcs came to Azmarin with hopes of capturing it. Three brave heroes, stood up and casted extraordinary spells to seal off the horde of monsters inside a new dimension after breaching a portal in this reality. The villagers of Xernia were thankful for these heroes and without them, they would've lost their only home. They soon became part of the legend which was passed down for generations."

chap1Part1 = 

### STORY - MAIN MENU ###
def storyMenu():
	global storyGuest
	while True:
		clear()
		print("Hero Legends - Story Mode\n")
		print("[Options]")
		print("(1) Mode Selection")
		print("\n[Main Menu]")
		print("(a) Signup")
		print("(b) Login")
		print("(c) Guest")
		print("(d) Credits")
		menuInput = input("\n> ")
		if menuInput == "1":
			selectMode()
		elif menuInput.lower() == "a":
			storySignup()
		elif menuInput.lower() == "b":
			storyLogin()
		elif menuInput.lower() == "c":
			storyGuest = 1
			guest()
			storyPregame()
		elif menuInput.lower() == "d":
			credits()

### STORY - SIGNUP ###
def storySignup():
	global username, password, filename
	clear()
	print("Hero Legends - Signup\n")
	print("[Signup]")
	username = input("Username: ")
	password = input("Password: ")
	filename = ("{}_{}Story.pickle".format(username,password))
	if os.path.exists(filename):
		print("\nAccount Already Exists!")
		sleep(0.75)
		storyMenu()
	guestAccess = 0
	storyPregame()

### STORY - LOGIN ###
def storyLogin():
	global username, password, filename
	clear()
	print("Hero Legends - Login\n")
	print("[Login]")
	username = input("Username: ")
	password = input("Password: ")
	filename = ("{}_{}Story.pickle".format(username,password))
	if os.path.exists(filename):
		guestAccess = 0
		storyLoad()
		storyGame()
	else:
		print("\nAccount Does Not Exist!")
		sleep(0.75)
		storyMenu()

### STORY - SAVE ###
def storySave():
	if storyGuest == 0:
		if os.path.exists(filename):
			os.remove(filename)
		with open(filename,'wb+') as f:
			pickle.dump(storyPlayer,f)

### STORY - LOAD ###
def storyLoad():
	global storyPlayer
	with open(filename,'rb') as f:
		storyPlayer = pickle.load(f)

### STORY - PREGAME ###
def storyPregame():
	global storyPlayer
	storyPlayer = storyPlayerTemplate
	storySave()
	storyGame()

### STORY - GAME ###
def storyGame():
	global storyInput, storyPrologueAnimation
	storyInfo()
	while True:
		# Prologue
		if storyPlayer.prologue == 1:
			# Animation
			if storyPrologueAnimation == 1:
				storySetAnimation(1,prologue,"Prologue")
				storyPrologueAnimation = 0
			elif storyPrologueAnimation == 0:
				storySetAnimation(0,prologue,"Prologue")
			# Options
			storyInput = input("> ")
			if storyInput.lower() == "continue":
				storyPlayer.prologue -= 1
				break
			else:
				storyOptions()
		# Story Complete
		else:
			storyComplete()

### STORY - OPTIONS ###
def storyOptions():
	if storyInput.lower() == "settings":
		storySettings()
	elif storyInput.lower() == "save":
		storySave()
	elif storyInput.lower() == "exit":
		sys.exit(0)
	elif storyInput.lower() == "help":
		storyInfo()

### STORY - INFORMATION ###
def storyInfo():
	while True:
		clear()
		print("{}Hero Legends - Infomation{}\n".format(storyPlayer.tColor,reset))
		print("{}Type the following in story mode when it asks for an input.\n".format(storyPlayer.tColor))
		print("{}'Help' - Open This Help Menu".format(storyPlayer.color))
		print("'Save' - Save Progress [Not on Guest Mode]")
		print("'Settings' - Open Settings Menu")
		print("'Continue' - To Move Along Storyline{}".format(reset))
		print("\nType 'okay' to continue!")
		infoInput = input("> ")
		if infoInput.lower() == "okay":
			break

### STORY - SET ANIMATION ###
def storySetAnimation(x,y,z):
	while True:
		clear()
		print("{}Hero Legend - {}{}\n".format(storyPlayer.tColor,z,reset))
		sleep(0.5)
		if x == 1:
			tprint("{}{}{}".format(storyPlayer.color,y,reset))
			print("\n{}Type 'Help' to get help.{}".format(storyPlayer.color,reset))
			x = 0
		elif x == 0:
			print("{}{}{}".format(storyPlayer.color,y,reset))
			print("\n{}Type 'Help' to get help.{}".format(storyPlayer.color,reset))
			break	

### STORY - COMPLETE ###
def storyComplete():
	while True:
		clear()
		print("{}Hero Legends - Complete\n".format(storyPlayer.tColor))
		print("[Victory]{}".format(storyPlayer.color))
		print("You Beat Story Mode!")
		print("Many more chapters coming soon!{}".format(reset))
		print("Type 'Exit' to end game!")
		print("Type 'Save' to save game!")
		storyInput = input("\n> ")
		if storyInput.lower() == "exit":
			sys.exit(0)
		elif storyInput.lower() == "save":
			storySave()

### STORY - SETTINGS ###
def storySettings():
	while True:
		clear()
		print("{}Hero Legends - Settings\n".format(storyPlayer.tColor))
		print("[Settings]{}".format(storyPlayer.color))
		print("(a) Color")
		print("(b) Animation", end = " ")
		storyPlayer.getAnimation()
		print("\n{}[Options]{}".format(storyPlayer.tColor,storyPlayer.color))
		print("(1) Exit{}".format(reset))
		settingsMenu = input("\n> ")
		if settingsMenu == "1":
			break
		elif settingsMenu.lower() == "a":
			storyToggleColor()
		elif settingsMenu.lower() == "b":
			animationToggle()

# Toggle Color Change
def storyToggleColor():
	while True:
		clear()
		print("Title Color: ", end = '')
		storyPlayer.getTColor()
		print("Text Color: ", end = '')
		storyPlayer.getColor()
		print("\n{}[Color Options - Type]{}".format(storyPlayer.tColor,reset))
		print("White")
		print("{}Red".format(red))
		print("{}Orange".format(orange))
		print("{}Blue".format(blue))
		print("{}Green".format(green))
		print("{}Purple".format(purple))
		print("\n{}[Options]{}".format(storyPlayer.tColor,reset))
		print("(1) Exit")
		colorInput = input("\n> ")
		if colorInput == "1":
			break
		if colorInput.lower() in ("white", "red", "orange", "blue", "green", "purple", "yellow"):
			print("{}{}Choose [Title/Text]".format(cursorUp,eraseLine))
			colorPlaceInput = input("> ")
			if colorPlaceInput.lower() == "title":
				storyPlayer.changeTitleColor(colorInput)
			if colorPlaceInput.lower() == "text":
				storyPlayer.changeTextColor(colorInput)

# Toggle Animation
def animationToggle():
	print("{}{}Do you want the animation (On/Off)".format(cursorUp,eraseLine))
	animationInput = input("> ")
	if animationInput.lower() == "on":
		storyPlayer.animation = 1
	elif animationInput.lower() == "off":
		storyPlayer.animation = 0

### SIMILAR FUNCTIONS - GUEST ###
def guest():
	global username
	clear()
	print("Hero Legends - Guest\n")
	print("[Guest]")
	username = input("Username: ")

### SIMILAR FUNCTIONS - CREDITS ###
def credits():
	clear()
	print("Hero Legends - Credits\n")
	print("[Game Makers]")
	print("(Programmer) Seazyns")
	print("(Ideas) Ezolite")
	print("(Tester) Xobeen")
	print("\n[Socials]")
	print("Seazyns - Twitch: twitch.tv/seazyns")
	print("Xobeen - Mixer: mixer.com/xobeen")
	print("\n[Collabs]")
	print("Seazyns - Discord: Seazyns#8376")
	input("\nPress 'Enter' to continue!")

### RUN GAME ###
selectMode()