-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpythonGame.py
More file actions
2054 lines (1919 loc) · 90.6 KB
/
pythonGame.py
File metadata and controls
2054 lines (1919 loc) · 90.6 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
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
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import random
import math
import sys
import os
escape = False
choices = ["1", "2", "3", "4"]
yes_no = ["y", "n", "Y", "N"]
directions = ["1", "2", "3"]
class Item:
def __init__ (self, name, item_type, coins=0):
self.name = name
self.type = item_type
self.cost = coins
class Spell(Item):
def __init__ (self, name, description, mana, power):
super().__init__(name, "spell")
self.desc = description
self.mana = mana
self.power = power
def print_spell(self):
print("********************************")
print("| Spell stats : |")
print("| Name : " + stringBuilder(self.name, 15) + "|")
print("| Mana : " + stringBuilder(self.mana, 15) + "|")
print("| Power : " + stringBuilder(self.power, 15) + "|")
print("********************************")
class Weapon(Item):
def __init__ (self, name, coins, damage, speed):
super().__init__(name, "weapon", coins)
self.damage = damage
self.speed = speed
def print_weapon(self):
print("********************************")
print("| Weapon stats: |")
print("| Name : " + stringBuilder(self.name, 15) + "|")
print("| Damage : " + stringBuilder(self.damage, 15) + "|")
print("| Speed : " + stringBuilder(self.speed, 15) + "|")
print("********************************")
class Armor(Item):
def __init__ (self, name, coins, resistance):
super().__init__(name, "armor", coins)
self.resistance = resistance
def print_armor(self):
print("**************************************")
print("| Armour stats : |")
print("| Name : " + stringBuilder(self.name, 20) + "|")
print("| Resistance : " + stringBuilder(self.resistance, 20) + "|")
print("**************************************")
class Food(Item):
def __init__ (self, name, coins, rations):
super().__init__(name, "food", coins)
self.rations = rations
class Potion(Item):
def __init__ (self, name, coins, health):
super().__init__(name, "potion", coins)
self.health = health
class Player:
def __init__(self, name, stats):
self.name = name
self.stats = stats
self.weapon = fist
self.coins = 4
self.armor = cloth
self.spell = spells[0]
self.escape = False
self.bossesDefeated = 0
def print_coins(self):
print("You currently have " + str(p.coins) + " coins!\n")
def print_stats(self):
print("***********************************")
print("| Player stats : |")
print("| Name : " + stringBuilder(self.name, 15) + "|")
print("| Coins : " + stringBuilder(self.coins, 15) + "|")
print("| Bosses Killed : " + stringBuilder(self.bossesDefeated, 15) + "|")
print("***********************************")
pause()
self.weapon.print_weapon()
pause()
self.armor.print_armor()
pause()
self.spell.print_spell()
pause()
self.stats.print_all_stats()
pause()
def addItem(self, item):
item_type = item.type
if(item_type == "weapon"):
currentWeapon = self.weapon
self.weapon = item
print("You upgraded your weapon from " + currentWeapon.name + " to " + self.weapon.name + "!\n")
elif(item_type == "armor"):
currentArmor = self.armor
self.armor = item
self.stats.totalHP += item.resistance
print("You upgraded your armor from " + currentArmor.name + " to " + self.armor.name + "!\n")
elif(item_type == "food"):
print("YUM! Eating the " + item.name + " added " + str(item.rations) + " to your mana and saturation!\n")
self.stats.addHunger(item.rations)
self.stats.addMana(item.rations)
elif(item_type == "potion"):
print("Drinking the " + item.name + " added " + str(item.health) + " to your mana and saturation!\n")
self.stats.addHealth(item.health)
self.stats.addMana(item.health)
elif(item_type == "spell"):
self.spell = item
def armorCheck(self):
num = random_num(3)
if(num == 1):
return True
else:
return False
def dexCheck(self):
if(random_num(100) < math.floor((self.stats.dex + self.weapon.speed) * .1)):
print("Congrats! Your incredible speed allows you to strike AGAIN \n")
return True
else:
return False
def attack(self, enemy):
print("You chose to attack the enemy with your " + self.weapon.name + "!\n")
hit = randomish_num(self.stats.str)
if(hit == random.randint(math.floor(self.stats.str/2),self.stats.str)):
print("You missed the " + enemy.name + " on your attack!\n")
else:
hit += self.weapon.damage
hit = math.ceil(hit)
critical = random_num(100)
if(self.stats.meleeCrit > critical):
print("CRITICAL STRIKE!\n")
hit *=1.5
print("You dealt " + str(hit) + " damage to the " + enemy.name + "\n")
enemy.stats.hp -= hit
if(self.dexCheck()):
self.attack(enemy)
def castSpell(self, enemy):
print("You chose to attack the enemy with your " + self.spell.name + "!\n")
hit = math.ceil(self.spell.power * self.stats.int)
self.stats.mana -= self.spell.mana
critical = random_num(100)
if(self.stats.magCrit > critical):
print("CRITICAL STRIKE!\n")
hit *=1.5
print("You dealt " + str(hit) + " damage to the " + enemy.name + "\n")
enemy.stats.hp -= hit
if(self.dexCheck()):
self.attack(enemy)
def rest(self):
print("You chose to rest give your body a rest!\n")
healthGain = math.floor(random_numLow(self.stats.totalHP)*.33)
manaGain = math.floor(random_numLow(self.stats.int)*.33)
self.stats.addHealth(healthGain)
self.stats.addMana(manaGain)
print("You gained " + str(healthGain) + " hp and " + str(manaGain) + " mana from your short rest!\n")
def retreat(self):
run = random_num(100)
if(run < self.stats.dex):
print("You have successfully escaped!\n")
return True
else:
print("You failed to escape\n")
return False
def addXP(self, xp):
self.stats.xp += xp
print("You have " + str(self.stats.xp) + " / " + str(self.stats.xpToLevelUp) + " experience points!\n")
while(self.stats.xp >= self.stats.xpToLevelUp):
self.stats.xp -= self.stats.xpToLevelUp
self.levelUp()
pause()
def levelUp(self):
print("Well done " + self.name + " you leveled up!\n")
self.stats.level += 1
self.stats.xpToLevelUp = math.ceil(self.stats.xpToLevelUp * 1.1)
if(self.stats.level % 5 == 0 and not spells == []):
self.gainSpell()
else:
skillPoints = math.ceil(self.stats.level / 2)
skillBonus = random_numLow(skillPoints)
print("You gained " + str(skillBonus) + " skill points for leveling up!\n")
self.stats.sp += skillBonus
pause()
self.skillRaise()
print("You have " + str(self.stats.xp) + " / " + str(self.stats.xpToLevelUp) + " experience points!\n")
def gainSpell(self):
spells.remove(spells[0])
self.addItem(spells[0])
print("You have found time to practice your wizardry and learned the " + self.spell.name + " spell!\n")
def skillRaise(self):
response = ""
while response not in choices:
print_skills()
print("You have " + str(self.stats.sp) + " skill points to use to level up your stats!")
response = input("What stats would you like to increase? (Type <1, 2, 3, 4> based on the corresponding items)\n")
clear()
if response in choices:
response = self.skillup(response)
else:
print("Please respond with 1, 2, 3, or 4!\n")
pause()
def skillup(self, response):
if(response == "1"):
num = random_num(2)
self.stats.sp -= 1
self.stats.str += num
print("You went to a weight room and leveled up your strength by " + str(num) + ", you now have " + str(self.stats.str) + " strength! \n")
elif(response == "2"):
num = random_num(5)
self.stats.sp -= 1
self.stats.dex += num
print("You leveled up your dexterity by " + str(num) + ", you now have " + str(self.stats.dex) + " dexterity \n")
elif(response == "3"):
num = random_num(2)
self.stats.sp -= 1
self.stats.int += num
print("You studied in your spare time and gained " + str(num) + " intelligence! You now have " + str(self.stats.int) + " intelligence \n")
elif(response == "4"):
num = random_num(4)
self.stats.sp -= 1
self.stats.totalHP += num
self.stats.hp += num
print("You leveled up your health and gained " + str(num) + " permanent health! You now have " + str(self.stats.totalHP) + " health \n")
if(self.stats.sp == 0):
return response
else:
response = ""
return response
pause()
class Enemy:
def __init__(self, name, stats, coins, experience):
self.name = name
self.stats = stats
self.anger = 0
self.coins = coins
self.xp = experience
def dexCheck(self):
if(random_num(100) < math.floor(self.stats.dex * .1)):
print("The enemies incredible speed allows it to strike AGAIN\n")
return True
else:
return False
def attack(self, player):
hit = randomish_num(self.stats.str)
if(hit == random.randint(math.floor(self.stats.str/2),self.stats.str)):
print("Luckily, the " + self.name + " missed you!\n")
elif(hit <= player.armor.resistance and player.armorCheck()):
print("Your " + player.armor.name + " prevented you from taking damage from the enemy's attack\n")
else:
num = random_num(4)
if(num == range(1,4)):
hit -= player.armor.resistance
if(hit < 1):
hit = random_num(2)
reflect = random_num(100)
if(player.stats.reflect > reflect):
hit = math.ceil(hit*.75)
print("You REFLECTED " + str(hit) + " damage back to the " + self.name + "!\n")
else:
print("The " + self.name + " dealt " + str(hit) + " damage to the " + player.name + "\n")
player.stats.hp -= hit
if(self.dexCheck()):
self.attack(player)
if(player.stats.hp <= 0):
restore = random_num(100)
if(player.stats.restore > restore):
player.stats.addHealth(math.ceil(player.stats.totalHP * .25))
class Stats:
def __init__(self, strength, dexterity, intelligence, health):
self.str = strength
self.dex = dexterity
self.int = intelligence
self.totalHP = health
self.hp = health
self.mana = intelligence
self.food = 30
self.foodCap = 50
self.xp = 0
self.xpToLevelUp = 20
self.level = 1
self.sp = 0
self.magCrit = 0
self.meleeCrit = 0
self.reflect = 0
self.restore = 0
def print_all_stats(self):
print("***********************************")
print("| Stats |")
print("| Strength : " + stringBuilder(self.str, 12) + "|")
print("| Dexterity : " + stringBuilder(self.dex, 12) + "|")
print("| Intelligence : " + stringBuilder(self.int, 12) + "|")
print("| Total Health : " + stringBuilder(self.totalHP, 12) + "|")
print("| Hit Points : " + stringBuilder(self.hp, 12) + "|")
print("| Mana : " + stringBuilder(self.mana, 12) + "|")
print("| Food : " + stringBuilder(self.food, 12) + "|")
print("| Experience : " + stringBuilder(self.xp, 12) + "|")
print("| Experience needed : " + stringBuilder(self.xpToLevelUp, 12) + "|")
print("| Level : " + stringBuilder(self.level, 12) + "|")
print("***********************************")
def addHealth(self, amount):
self.hp += amount
if(self.hp > self.totalHP):
self.hp = self.totalHP
def addMana(self, amount):
self.mana += amount
if(self.mana > self.int):
self.mana = self.int
def toFullHealth(self):
self.hp = self.totalHP
def toFullMana(self):
self.mana = self.int
def toFullHunger(self):
self.food = self.foodCap
def toFullSaturation(self):
self.toFullHealth()
self.toFullHunger()
self.toFullMana()
def addHunger(self, amount):
self.food += amount
if(self.food > self.foodCap):
self.food = self.foodCap
def buffStats(self, percent, add=0):
self.str = math.floor((self.str * percent) + add)
self.dex = math.floor((self.dex * percent) + add)
self.int = math.floor((self.int * percent) + add)
self.totalHP = math.floor((self.totalHP * percent) + add)
self.toFullSaturation()
# Spells
lightning = Spell("Lightning bolt", "lightning strikes upon enemy", 3, .75)
firebolt = Spell("Firebolt", "Throws flames at enemy", 3, .78)
iceshard = Spell("Ice shard", "Powerful ice strike", 3, .82)
earthquake = Spell("Earth shatter", "Earthquake rumbles enemy", 4, .87)
tornado = Spell("Tornado", "Tornado hits enemy", 4, .93)
plasma = Spell("Plasma ray", "Pelts enemy with pure plasma", 4, 1)
sunstrike = Spell("Sun strike", "Sunrays beam down the enemy", 5, 1.1)
meteor = Spell("Meteor shower", "Crushes enemy from above", 5, 1.25)
snap = Spell("Thanos snap", "I am inevitable", 5, 2)
spells = [lightning, firebolt, iceshard, earthquake, tornado, plasma, sunstrike, meteor, snap]
# Potions:
small_hp = Potion("Small HP potion", 15, 30)
medium_hp = Potion("Medium HP potion", 35, 50)
large_hp = Potion("Large HP potion", 75, 80)
full_hp = Potion("Full HP potion", 100, 10000)
out_of_pots = Potion("Out of potions", 99999, 9999)
potions = [small_hp, small_hp, medium_hp, medium_hp, small_hp, large_hp, full_hp, medium_hp, small_hp, large_hp, full_hp, out_of_pots]
# Food:
banana = Food("banana", 15, 15)
muffin = Food("muffin", 15, 15)
pancake = Food("pancake", 15, 15)
soup = Food("soup", 15, 15)
lasagne = Food("lasagne", 15, 15)
wontons = Food("wontons", 15, 15)
icecream = Food("icecream", 15, 15)
pizza = Food("pizza", 15, 15)
hamburger = Food("hamburger", 15, 15)
cereal = Food("cereal", 15, 15)
outoffood = Food("out of food", 99999, 9999)
food = [banana, muffin, pancake, soup, lasagne, wontons, icecream, pizza, hamburger, outoffood]
# Weapons:
fist = Weapon("fist", 0, 0, 0)
stick = Weapon("stick", 5, 1, 1)
butter_knife = Weapon("butter knife", 35, 2, 2)
shortsword = Weapon("shortsword", 95, 4, 2)
katana = Weapon("katana", 135, 6, 4)
axe = Weapon("axe", 170, 8, 5)
butcher_knife = Weapon("butcher's knife", 215, 13, 3)
spear = Weapon("spear", 270, 14, 5)
sword = Weapon("sword", 335, 21, 10)
machete = Weapon("machete", 420, 28, 18)
war_scythe = Weapon("war scythe", 525, 36, 20)
battle_axe = Weapon("battle axe", 670, 48, 3)
war_hammer = Weapon("war hammer", 1025, 72, 10)
lightsaber = Weapon("Lightsaber", 1650, 100, 75)
zeus = Weapon("Zeus's Bolt",2500 ,185, 100)
alloutofstock = Weapon("Out of stock", 99999, 9999, 999)
weapons = [stick, butter_knife, shortsword, katana, axe, butcher_knife, spear, sword, machete, war_scythe, battle_axe, war_hammer, lightsaber, zeus, alloutofstock]
# Armor:
cloth = Armor("cloth armor", 0, 1)
silk = Armor("silk armor", 25, 2)
leather = Armor("leather armor", 80, 4)
chainmail = Armor("chainmail armor", 190, 9)
copper = Armor("copper armor", 280, 16)
iron = Armor("iron armor", 365, 25)
steele = Armor("steele armor", 460, 36)
chromium = Armor("chromium armor", 570, 49)
celestial = Armor("celestial armor", 715, 64)
dimensional = Armor("dimensional armor", 1120, 100)
vibranium = Armor("vibranium armor", 2000, 150)
alloutofstockarmor = Armor("out of stock", 99999, 9999)
armor = [silk, leather, chainmail, copper, iron, steele, chromium, celestial, dimensional, vibranium, alloutofstockarmor]
# Simple way to implement stats in an enemy or player
def getStats(strength, dexterity, intelligence, health):
return Stats(randomish_num(math.ceil(strength)), randomish_num(math.ceil(dexterity)), randomish_num(math.ceil(intelligence)), randomish_num(math.ceil(health)))
# Generates Random Numbers
def randomish_num(integer):
return random.randint(math.floor(integer/2),integer)
def random_num(integer):
return random.randint(1, integer)
def random_numLow(integer):
if(math.floor(integer/2) < 1):
return 1
return random.randint(1, math.floor(integer/2))
# Prints out the skills of a player
def print_skills():
print("***********************************************************************")
print("1.) Strength = " + stringBuilder(p.stats.str, 5) + "Affects how much damage you inflict on an enemy")
print("2.) Dexterity = " + stringBuilder(p.stats.dex, 5) + "Affects your speed and chance to combo")
print("3.) Intelligence = " + stringBuilder(p.stats.int, 5) + "Affects your mana and spell strength")
print("4.) Health = " + stringBuilder(p.stats.totalHP, 5) + "Affects your total amount of hp")
print("***********************************************************************\n")
# Function to determine the spacing added to a string
def stringBuilder(string, totalLength):
if(type(string) != str):
string = str(string)
strLength = len(string)
blankSpaces = ""
for i in range(totalLength - strLength):
blankSpaces += " "
string += blankSpaces
return string
# Prints out the store
def print_store():
print("********************************")
print(" item | Cost ")
print("1. " + stringBuilder(potions[0].name, 17) + "| " + stringBuilder(potions[0].cost, 4) + " coins")
print("2. " + stringBuilder(weapons[0].name, 17) + "| " + stringBuilder(weapons[0].cost, 4) + " coins")
print("3. " + stringBuilder(food[0].name, 17) + "| " + stringBuilder(food[0].cost, 4) + " coins")
print("4. " + stringBuilder(armor[0].name, 17) + "| " + stringBuilder(armor[0].cost, 4) + " coins")
print("5. Press 5 to view your stats!")
print("L. Press L to leave this store!")
print("********************************\n")
# Allows user to buy an item
def store_buy(item, itemArray):
if(p.coins >= item.cost):
response = ""
while response not in yes_no:
response = input("Are you sure you want to purchase the " + item.name + " that costs " + str(item.cost) + " coins? (Y/N) \n")
if(response.lower() == "y"):
p.coins -= item.cost
p.addItem(item)
itemArray.remove(item)
print("Thanks for purchasing the " + item.name + "! You have " + str(p.coins) + " coins remaining! \n")
elif(response.lower() == "n"):
print("We will put this item back on the shelf!\n")
else:
yesnoInputFail()
pause()
else:
print("Sorry you don't have enough coins to buy this item!\n")
# Store Module
def store(enemy, coinMin):
response = ""
while response not in yes_no:
response = input("Would you like to buy something before going on the journey? " + "You have " + str(p.coins) + " coins to spend (Y/N)\n")
clear()
if (response.lower() == "y"):
response = ""
if(p.coins <= coinMin and p.coins < min(potions[0].cost ,weapons[0].cost, food[0].cost, armor[0].cost)):
response = earnShopMoney(enemy, coinMin)
elif(p.coins < min(potions[0].cost ,weapons[0].cost, food[0].cost, armor[0].cost)):
print("Sorry you don't have enough coins to shop here!\n")
else:
while response != "l":
p.print_coins()
print_store()
response = input("What would you like to purchase? (Type <1, 2, 3, 4, or 5> based on the corresponding items) Type L to leave!\n").lower()
clear()
if(response == "1"):
store_buy(potions[0], potions)
elif(response == "2"):
store_buy(weapons[0], weapons)
elif(response == "3"):
store_buy(food[0], food)
elif(response == "4"):
store_buy(armor[0], armor)
elif(response == "5"):
p.print_stats()
elif("l"):
print("Thanks for stopping by the shop!\n")
else:
print("Please respond with 1, 2, 3, or 4 to purchase something, or L to leave, you're wasting electricty!\n")
response = "n"
elif(response.lower() == "n"):
response = ""
if(p.coins <= coinMin):
response = earnShopMoney(enemy, coinMin)
else:
response = "n"
print("You decide to leave the shop to continue your quest!\n")
else:
yesnoInputFail()
def earnShopMoney(enemy, coinMin):
response = ""
while response not in yes_no:
response = input("Shopkeeper: You are dirt poor! Do you want to earn some money? (Y/N)\n")
clear()
if(response.lower() == "y"):
response = ""
storeBattle(enemy)
return response
elif(response.lower() == "n"):
print("That's fine! Come again soon!\n")
return response
else:
yesnoInputFail()
def yesnoInputFail():
print("Sorry I couldn't understand, (type: Y/N)\n")
def choiceInputFail():
print("Please respond with 1, 2, 3, or 4!\n")
# Store Battle for coins
def storeBattle(enemy):
print("Alright you are going to have to battle the " + enemy.name + " on my brother's farm\n")
print("You travel a bit to the farm and see in the distance a menacing " + enemy.name + "!\n")
pause()
battle(p, enemy)
# Battle Module
def battle(player, enemy):
enemy_coins = enemy.coins
enemy_xp = enemy.xp
turn = ""
if(player.stats.dex > enemy.stats.dex):
print("Since your dexterity is higher than the enemy, you get to go first!\n")
turn = player.name
else:
print("Since your dexterity is lower than the enemy, you get to go second.\n")
turn = enemy.name
pause()
while(player.stats.hp > 0 and enemy.stats.hp > 0 and not player.escape):
turn = fight(player, enemy, turn)
printHealth(player, enemy)
pause()
if(player.stats.hp <= 0):
print("You lose! Should've trained harder! THE END! \n")
gameoverOption(player)
elif(player.escape):
print("You left quickly to saftey! Phew that was a close one!\n")
enemy.stats.toFullHealth()
enemy.coins = math.ceil(enemy_coins * .75)
enemy.xp = math.ceil(enemy_xp * .75)
player.escape = False
pause()
else:
coinReward = randomish_num(enemy.coins)
xpReward = randomish_num(enemy.xp)
enemy.stats.buffStats(1.25)
print("Congrats, you defeated the " + enemy.name)
print("You earned " + str(coinReward) + " coins and " + str(xpReward) + " experience from the fight!\n")
player.addXP(xpReward)
player.coins += coinReward
player.stats.food -= random_num(3)
if(player.stats.food > 5):
player.stats.addHealth(random_numLow(player.stats.totalHP))
player.stats.addMana(random_numLow(player.stats.int))
# Prints fight menu during a player's turn
def fightMenu():
print("******************************************************")
print(" options | Description ")
print("1. Melee Attack | Strike with " + p.weapon.name + "!")
print("2. Cast " + stringBuilder(p.spell.name, 15) + "| " + stringBuilder(p.spell.desc, 29))
print("3. Rest | Gain back health and mana ")
print("4. Run | Evade fight ")
print("5. Print your statistics ")
print("******************************************************\n")
# Runs the battle
def fight(player, enemy, turn):
response = ""
if(turn == player.name):
while response not in choices:
response = ""
printHealth(player, enemy)
fightMenu()
response = input("It is your turn! (Type <1, 2, 3, 4, or 5> based on the corresponding options to fight!)\n")
clear()
if(response == "1"):
player.attack(enemy)
elif(response == "2" and player.stats.mana >= player.spell.mana):
player.castSpell(enemy)
elif(response == "2" and player.stats.mana < player.spell.mana):
print("You don't have enough mana to cast the spell!\n")
response = ""
elif(response == "3"):
player.rest()
elif(response == "4" and enemy not in bosses):
if(player.retreat()):
player.escape = True
elif(response == "4" and enemy in bosses):
print("You cannot escape the wrath of the " + enemy.name + "!!!!\n")
elif(response == "5"):
player.print_stats()
else:
print("You need to respond with 1, 2, 3, or 4!\n")
return enemy.name
elif(turn == enemy.name):
enemy.attack(player)
return player.name
def printHealth(player, enemy):
print("********************************************")
print(" " + stringBuilder(player.name, 12) + " hp: " + stringBuilder((str(player.stats.hp) + " / " + str(player.stats.totalHP)), 12) + "Mana: " + stringBuilder((str(player.stats.mana) + " / " + str(player.stats.int)), 12))
print(" " + stringBuilder(enemy.name, 12) + " hp: " + stringBuilder((str(enemy.stats.hp) + " / " + str(enemy.stats.totalHP)), 12) + "Mana: " + stringBuilder((str(enemy.stats.mana) + " / " + str(enemy.stats.int)), 12))
print("********************************************\n")
def clear():
os.system('cls||clear')
def forest(p):
continueQuest = False
response = ""
print("You come across a dense forest with towering trees, you have a bad feeling about this.")
print("Despite your concerns, you are a warrior and continue and enter the forest")
print("Cutting through vines with your " + p.weapon.name + " you see a path in the distance")
while response not in yes_no:
response = input("Do you want to investigate the path? (Y/N)\n").lower()
clear()
if(response == 'y'):
investFpath(p)
elif(response == 'n'):
navigateF(p)
else:
yesnoInputFail()
if(p.bossesDefeated >= 2):
response = ""
while response not in yes_no:
response = input("would you like to continue your quest (Y) or go back to the forest (N) (Y/N) \n warning you must complete another boss to come back to this message \n").lower()
clear()
if(response == 'y'):
continueQuest = True
elif(response == 'n'):
continueQuest = False
else:
yesnoInputFail()
if(not continueQuest):
response = ""
print("You got so confused navigating the land that you came back to the same first path!")
print("Defeat two bosses to find the next piece of the map!\n")
def labyrinth(p):
bossesBeat = p.bossesDefeated + 1
print("You come out of the forest more confident than ever knowing that you defeated very powerful bosses\n")
print("However, you know that there will be tougher challenges in the future!\n")
pause()
print("You find yourself in the village of siawathi where there are no enemies and you can finally take a break\n")
print("You meet some folks, grab a few drinks and feast. The people display excellent hospitality.\n")
pause()
print("After a couple of nights in the village, healing wounds and scars from monsters, you feel well rested to continue!\n")
print("You regain all your hunger, health, and mana throughout these nights.\n")
p.print_stats()
print("You go to the local shopping district and see that there are a few shops that interest you\n")
shoppingDistrict(p)
response = ""
while (response != "l") or (bossesBeat > p.bossesDefeated):
labyrinthPaths()
response = input("Where would you like to go? (1, 2, 3, or 4)\n").lower()
clear()
if(response == "1"):
shoppingDistrict(p)
elif(response == "2"):
getZone(p, "abandoned cave", zoneText, caveMonsters, queenSpider, 1.2)
print("You find your way back out of the cave and return to Siawathi!\n")
elif(response == "3"):
getZone(p, "atlantis", zoneText, oceanMonsters, poseidon, 1.3)
print("You find your way back out of the water and return to Siawathi!")
print("The person who lended you the aquatic equipment allows you to return it for free for rescuing Poseidon\n")
elif(response == "4"):
getZone(p, "xeon8", zoneText, alienMonsters, alienWarlord, 1.2)
print("After defeating the alien warlord, you take one of their space pods and return to Siawathi")
print("After being ubducted by aliens, you decide not to frolic the fields any more\n")
elif(response == "l" and bossesBeat <= p.bossesDefeated):
print("You decide to leave the area after all that action!\n")
elif(response == "l" and bossesBeat > p.bossesDefeated):
print("You still need to defeat a boss!\n")
else:
choiceInputFail()
pause()
def labyrinthPaths():
print("********************************************************")
print(" Location: ")
print(" 1.) Return to the Shopping District ")
print(" 2.) Explore the abandoned miner's cave ")
print(" 3.) Loot a shipwreck ")
print(" 4.) Frolic in the dandelion fields ")
print(" L.) Type L to leave if you defeated at least one boss ")
print("********************************************************n")
def shoppingDistrict(p):
response = ""
secret = True
while response not in choices:
shops()
response = input("Where would you like to go? (1, 2, 3, or 4)\n").lower()
clear()
if(response == "1"):
store(werewolf, 5)
response = ""
elif(response == "2"):
blacksmith(p)
response = ""
elif(response == "3"):
bar(p)
response = ""
elif(response == "4"):
print("Thanks for shopping at the siawathi shopping district! Come again soon!\n")
elif(response == "yeet" and secret == True):
print("You see a shady man with a cloak over his head tap a stone brick of one of the buildings\n")
print("You don't see the man anymore\n")
pause()
print("You go over to where the stone was and tap the same stone and a purple portal sucks you into a new dimension\n")
pause()
print(p.name + " it's about time you showed up. We are the miquiderans, the secret underground organization that defends villages from evil presences\n")
print("After viewing your progress throughout the first few dungeons, we see that you have a lot of potential to be great\n")
pause()
print("We are granting you one of these items that will help you on your quest\n")
pause()
resistanceSociety(p)
print("You leave the area and are super excited about your new item!\n")
secret = False
elif(response == "yeet" and secret == False):
print("You return to the stone building and attempt to tap the stone which lead you to the portal, but the portal does not seem to generate anymore!\n")
else:
choiceInputFail()
pause()
def resistanceSociety(p):
response = ""
while response not in choices:
printResistance()
response = input("Which item would you like to have? (1, 2, 3, or 4) \n").lower()
clear()
if(response == "1"):
print("You equipped the Winged Sceptor and now have its power")
p.stats.magCrit += 15
elif(response == "2"):
print("You equipped the Elemental Shield and now have its power")
p.stats.reflect += 5
elif(response == "3"):
print("You equipped the Ring of Restoration and now have its power")
p.stats.restore += 25
elif(response == "4"):
print("You equipped the Amulet of Ares and now have its power")
p.stats.meleeCrit += 20
else:
choiceInputFail()
def printResistance():
print("****************************************************************************")
print(" Item: Description: ")
print(" 1.) Winged Sceptor A powerful magical item that grants a 15 percent ")
print(" critcal chance to enemies on magic attacks ")
print(" 2.) Elemental Shield A shield that has a 5 percent chance of reflecting")
print(" a portion of the enemies damage ")
print(" 3.) Ring of Restoration A ring that provides a 25 percent chance that on ")
print(" death in battle you will resurrect ")
print(" 4.) Amulet of Ares A war amulet that has a 20 percent chance that to ")
print(" critical on melee strikes ")
print("****************************************************************************\n")
def bar(p):
response = ""
drinks = 0
while response != "l":
printBar()
response = input("What can I do for you?\n").lower()
clear()
if(response == "1"):
if(canBuy(p, 12)):
print("You ate some crappy bar food +5 hunger!\n")
p.stats.addHunger(5)
pause()
elif(response == "2"):
if(canBuy(p, 4)):
if(drinks < 2):
print("You take a drink and feel fine")
elif(drinks < 5):
print("You start to feel a little dizzy\n")
elif(drinks < 15):
print("You see the room spinning and grab a table, you probably shouldn't drink anymore")
else:
print("You lose! Should've known when to stop drinking! THE END! \n")
gameoverOption(p)
drinks += 1
elif(response == "3"):
print("A man with an eyepatch spits on you, and says: you came to the wrong bar\n")
print("You and the man go into battle!\n")
battle(p, mediumMonsters("normal", "angry man", 40, 40))
print("The man skimps away from you and sits back at his table\n")
elif(response == "l"):
print("Thanks for stopping at my blacksmith! Come again soon!\n")
pause()
else:
print("Please select 1, 2, 3, 4, or L to leave!\n")
def gameoverOption(p):
print("GAME OVER!\n")
response = ""
while response not in yes_no:
response = input("Would you like to continue? (Y/N)\n").lower()
if(response == "y"):
p.stats.toFullSaturation()
game()
elif(response == "n"):
sys.exit()
else:
yesnoInputFail()
def printBar():
print("********************************************")
print(" Item: Coins: ")
print(" 1.) Bar Food 12 ")
print(" 2.) Alcohol 4 ")
print(" 3.) Bar Fight - ")
print(" L.) Type: L to leave ")
print("********************************************\n")
def blacksmith(p):
response = ""
while response != "l":
printBlacksmith()
response = input("What can I do for you?\n").lower()
clear()
if(response == "1"):
if(canBuy(p, 40)):
print("Your " + p.armor.name + "'s resistance increased by 2!\n")
pause()
p.armor.resistance += 2
elif(response == "2"):
if(canBuy(p, 35)):
print("Your " + p.weapon.name + "'s speed increased by 5!\n")
pause()
p.weapon.speed += 5
pause()
elif(response == "3"):
if(canBuy(p, 45)):
print("Your " + p.weapon.name + "'s damage increased by 3!\n")
pause()
p.weapon.damage += 3
elif(response == "4"):
p.weapon.print_weapon()
p.armor.print_armor()
elif(response == "l"):
print("Thanks for stopping at my blacksmith! Come again soon!\n")
pause()
else:
print("Please select 1, 2, 3, 4, or L to leave!\n")
def printBlacksmith():
print("**************************************************")
print(" Service: Coins: ")
print(" 1.) Improve Armor Resistance 40 ")
print(" 2.) Enhance Weapon Speed 35 ")
print(" 3.) Upgrade Weapon Damage 45 ")
print(" 4.) To see item statistics ")
print(" Type: L to leave ")
print("**************************************************\n")
def canBuy(p, cost):
if(p.coins >= cost):
p.coins -= cost
return True
print("You can't afford to buy this!\n")
return False
def shops():
print("***************************************************************")
print(" 1.) General Store : Purchase new gear for upcoming battles! ")
print(" 2.) Blacksmith : Upgrade weapons and armor here! ")
print(" 3.) Bar : Drink away your problems here! ")
print(" 4.) Leave District : Return to your journey! ")
print("***************************************************************\n")
def dragonsden(p):
bossesBeat = p.bossesDefeated + 2
print("The road is tough, you somehow came out of those dungeons alive. You look forward and see a giant mountainous region... the dragon den is towering above you\n")
pause()
print("Deep within this mountain lives the legendary fire dragon\n")
print("You turn back and can no longer see the Siawathi village. The journey lies ahead as you trek towards the mountain\n")
pause()
print("Hidden in a valley, you see faded lanterns and dark rotting buildings\n")
print("You decide to stay the night in an abandoned building and sleep until morning\n")
pause()
print("The town open and it is not the same as Siawathi, but nonetheless contains similar shops...\n")
print("You reach the shopping district, and a man with three eyes taps you on your shoulder and tells you to come with him\n")
pause()
print("You hesistate and the man whispers look if you want to kill the dragon you have to capture at least two of the three elemental stones\n")
pause()
print("Who... who are you?\n")
pause()
print("I'm orken the messenger, I traveled long and far to meet you at this very location, they are hidden in three places near the dragon's den\n")
print("You must quickly gear up, and search for the stones!\n")
print("He hands you a map with all three of the locations on them\n")
pause()
shoppingDistrict(p)
print("You exit the shopping district and continue on your adventure and continue on your way\n")
response = ""
while (response != "l") or (bossesBeat > p.bossesDefeated):
dragonsdenPaths()
response = input("Where would you like to go? (1, 2, 3, or 4)\n").lower()
clear()
if(response == "1"):
shoppingDistrict(p)
elif(response == "2"):
getZone(p, "dark volcano", zoneText, lavamonsters, demonlord, 1.4)
print("After taking the volcanic elemental stone, the volcano rumbles loudly, the earth shakes as you quickly sprint down the side of it.")
print("Lava shoots out from the top of the volcano, and you sprint for your life, with your adrenaline pumping you take summon spell that shields you from the falling lava\n")
pause()
print("Luckily, you made it out alive...\n")
elif(response == "3"):
getZone(p, "ice cavern", zoneText, icemonsters, icetitan, 1.4)
print("You take the ice stone from the titan and you see ice shards fall from the ceiling, you immediately run back to safety.")
pause()
print("You duck and weave through the ice to find your way outside of the ice cavern alive!\n")
elif(response == "4"):
getZone(p, "earth shrine", zoneText, earthmonsters, tarturus, 1.4)
print("You take the earth stone, and sprint back to the surface. The earth rumbles as the floor diverges beneath you...")
pause()
print("You begin to fall to your impending doom when you take your " + p.weapon.name + " and shove it into the soft earth\n")
print("Hanging on for dear life by your " + p.weapon.name + " you cast a spell that creates ladders from your weapon to the surface")
pause()
print("You climb all the way back up and have secured the earth stone\n")
elif(response == "l" and bossesBeat <= p.bossesDefeated):
print("You decide to leave the area after all that action!\n")
elif(response == "l" and bossesBeat > p.bossesDefeated):
print("You still need to get two elemental stones!\n")
else:
choiceInputFail()
pause()
def dragonsdenPaths():
print("**********************************************************")
print(" Location: ")
print(" 1.) Return back to the store ")
print(" 2.) Dark Volcano ")
print(" 3.) Ice Cavern ")
print(" 4.) Earth Shrine ")
print(" Type L to leave if you have at least two elemental stones")
print("**********************************************************\n")
def easyMonsters(version, name, coins = 25, xp = 25):
stats = ""
if(version == "fast"):
stats = getStats(3, 200, 20, 20)
elif(version == "normal"):