repl.it
@will_johnson/

CopyOfRPGWithoutAName

Python

No description

fork
loading
Files
  • main.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
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
from random import randint
import time
"""
FIX:
  potion turns
  exp2+ not giving correct xp, giving exp1's xp

ADD:
  loot
  biome effects on player (possibly different for each character type and sub area if i can be arsed)
  more dev commands

OPTIMISATIONS:
  change import time to from time
  like everything
"""
"""
PCs
"""

class pc(object):
  def __init__(self, Health = 100, Speed = 3, Strength = 1, Attack = 25, Defence = 25, XP = 0, Inventory = []):
    self.hlth = Health
    self.spe = Speed
    self.Str = Strength
    self.att = Attack
    self.Def = Defence
    self.xp = XP
    self.spec = []
    self.inv = Inventory
  
  def add_special(self, special):
    self.spec.append(special)
  
  def add_inventory(self, item):
    self.inv.append(item)
  
  def all_stats(self):
    print('Here are your basic stats:')
    print('Health:', self.hlth)
    print('Speed:', self.spe)
    print('Strength:', self.Str)
    print('Attack:', self.att)
    print('Defence:', self.Def)
    print('Special:', self.spec)
    print('Inventory:', self.inv)
    print('XP:', self.xp)

  
class tank(pc):
  def __init__(self):
    pc.__init__(self, 250, 2, 5, 30, 15)

class athlete(pc):
  def __init__(self):
    pc.__init__(self, 100, 5, 3, 30, 10)

class brute(pc):
  def __init__(self):
    pc.__init__(self, 300, 1, 5, 30, 30) 

class warlock(pc):
  def __init__(self):
    pc.__init__(self, 150, 3, 3, 40, 20)

"""
NPCs
"""

class npc(object):
  def __init__(self, Description = "", Health = 100, Speed = 10, Strength = 1, Attack = 10, Defence = 10):
    self.desc = Description
    self.hlth = Health
    self.spe = Speed
    self.Str = Strength
    self.att = Attack
    self.Def = Defence
    self.spec = []

  def add_special(self, special):
    self.spec.append(special)

class goblin(npc):
  def __init__(self):
    npc.__init__(self, "goblin", 100, 4, 1, 10, 10) 

class orc(npc):
  def __init__(self):
    npc.__init__(self, "orc", 200, 2, 2, 20, 20)

class warrior(npc):
  def __init__(self):
    npc.__init__(self, "warrior", 300, 2, 3, 30, 30)

class destroyer(npc):
  def __init__(self):
    npc.__init__(self, "destroyer", 400, 1, 4, 40, 40)

"""
POTIONS
"""

class potions(object):
  def __init__(self, Description = "", Health = 0, Turns = 0, Speed = 0, Strength = 0, Attack = 0, Defence = 0, XP = 10):
    self.desc = Description
    self.hlth = Health
    self.trns = Turns
    self.spe = Speed
    self.Str = Strength
    self.att = Attack
    self.Def = Defence
    self.xp = XP
  
  def get_desc(self):
    print(self.desc)

"""
Health
"""
class health1(potions):
  def __init__(self):
    potions.__init__(self, "HEA 1: Regenerates 20 health.", 20)

class health2(potions):
  def __init__(self):
    potions.__init__(self, "HEA 2: Regenerates 30 health.", 30)

class health3(potions):
  def __init__(self):
    potions.__init__(self, "HEA 3: Regenerates 50 health.", 50)

class health4(potions):
  def __init__(self):
    potions.__init__(self, "HEA 4: Regenerates 100 health.", 100)
"""
Speed
"""
class speed1(potions):
  def __init__(self):
    potions.__init__(self, "SPE 1: Adds 1 speed for 1 turn.", 0, 1, 1)

class speed2(potions):
  def __init__(self):
    potions.__init__(self, "SPE 2: Adds 1 speed for 2 turns.", 0, 2, 1)

class speed3(potions):
  def __init__(self):
    potions.__init__(self, "SPE 3: Adds 2 speed for 2 turns.", 0, 2, 2)

class speed4(potions):
  def __init__(self):
    potions.__init__(self, "SPE 4: Adds 3 speed for 3 turns.", 0, 3, 3)
"""
Strength
"""
class strength1(potions):
  def __init__(self):
    potions.__init__(self, "STR 1: Adds 1 strength for 1 turn.", 0, 1, 0, 1)

class strength2(potions):
  def __init__(self):
    potions.__init__(self, "STR 2: Adds 1 strength for 2 turns.", 0, 2, 0, 1)

class strength3(potions):
  def __init__(self):
    potions.__init__(self, "STR 3: Adds 2 strength for 2 turns.", 0, 2, 0, 2)

class strength4(potions):
  def __init__(self):
    potions.__init__(self, "STR 4: Adds 3 strength for 3 turns.", 0, 3, 0, 3)
"""
Attack
"""
class attack1(potions):
  def __init__(self):
    potions.__init__(self, "ATT 1: Adds 5 attack for 1 turn.", 0, 1, 0, 5)

class attack2(potions):
  def __init__(self):
    potions.__init__(self, "ATT 2: Adds 5 attack for 2 turns", 0, 2, 0, 5)

class attack3(potions):
  def __init__(self):
    potions.__init__(self, "ATT 3: Adds 10 attack for 2 turns.", 0, 2, 0, 10)

class attack4(potions):
  def __init__(self):
    potions.__init__(self, "ATT 4: Adds 20 attack for 1 turn.", 0, 1, 0, 20)
"""
Defence
"""
class defence1(potions):
  def __init__(self):
    potions.__init__(self, "DEF 1: Adds 5 defence for 1 turn.", 0, 1, 0, 0, 5)

class defence2(potions):
  def __init__(self):
    potions.__init__(self, "DEF 2: Adds 5 defence for 2 turns.", 0, 2, 0, 0, 5)

class defence3(potions):
  def __init__(self):
    potions.__init__(self, "DEF 3: Adds 10 defence for 2 turns.", 0, 2, 0, 0, 10)

class defence4(potions):
  def __init__(self):
    potions.__init__(self, "DEF 4: Adds 20 defence for 1 turn.", 0, 1, 0, 0, 20)
"""
XP
"""
class exp1(potions):
  def __init__(self):
    potions.__init__(self, "EXP 1: Adds 20 XP.", 0, 0, 0, 0, 0, 20)

class exp2(potions):
  def __init__(self):
    potions.__init__(self, "EXP 2: Adds 50 XP.", 0, 0, 0, 0, 0, 50)

class exp3(potions):
  def __init__(self):
    potions.__init__(self, "EXP 3: Adds 100 XP.", 0, 0, 0, 0, 0, 100)

class exp4(potions):
  def __init__(self):
    potions.__init__(self, "EXP 4: Adds 200 XP.", 0, 0, 0, 0, 0, 200)

"""
Main Program
"""

def main():
  global player
  global enemystate
  global flee
  global block_chance
  global dodge
  global end
  global original_speed
  global original_strength
  global original_attack
  global original_defence
  end = False
  class_assignment()
  player = pc()
  player.add_special('Block')
  player.all_stats()
  print("")
  #player = brute()
  #player.all_stats()
  class_select()
  original_speed = player.spe
  original_strength = player.Str
  original_attack = player.att
  original_defence = player.Def
  print("")
  player.all_stats()
  print("")
  time.sleep(1)
  print("")
  time.sleep(1)
  inventory_select()
  print("")
  player.all_stats()
  time.sleep(1)
  print("")
  global no_of_turns
  no_of_turns = 0
  dodge = 1
  block_chance = 1
  flee = False
  while player.hlth > 0 and end == False:
    generate_next_area()
    for i in range(area_length + 1):
      if i == 0:
        set_next_tile(tile_type, "start")
        spawn_enemies("start")
        time.sleep(1)
        while enemystate != "dead":
          if player.spe > enemy.spe:
            pcturn()
            if enemystate == "dead" or flee == True:
              break
            time.sleep(1)
            npcturn()
            if enemystate == "dead" or flee == True:
              break
          else:
            npcturn()
            time.sleep(1)
            pcturn()
            if enemystate == "dead" or flee == True:
              break
          print("")
      elif i == area_length:
        set_next_tile(tile_type, "end")
        spawn_enemies("end")
        time.sleep(1)
        while enemystate != "dead":
          if player.spe > enemy.spe:
            pcturn()
            if enemystate == "dead" or flee == True:
              break
            time.sleep(1)
            npcturn()
            if enemystate == "dead" or flee == True:
              break
          else:
            npcturn()
            time.sleep(1)
            pcturn()
            if enemystate == "dead" or flee == True:
              break
          print("")
      else:
        set_next_tile(tile_type, i)
        spawn_enemies(i)
        time.sleep(1)
        while enemystate != "dead":
          if player.spe > enemy.spe:
            pcturn()
            if enemystate == "dead" or flee == True:
              break
            time.sleep(1)
            npcturn()
            if enemystate == "dead" or flee == True:
              break
          else:
            npcturn()
            time.sleep(1)
            pcturn()
            if enemystate == "dead" or flee == True:
              break
          print("")
        print("")

"""
Selection Functions
"""

def class_select(): # allows the player to select a class, changes appropriate values and adds specials
  global player
  global classselection
  print('Please select a class from the following: ' '\n'
        'Tank, Athlete, Brute, Warlock or Default')
  inputcorrect = False
  while inputcorrect == False:
    classselection = input("Selection: ").lower()
    if classselection == "tank":
      player = tank()
      player.add_special("Double Punch")
      break
    elif classselection == "athlete":
      player = athlete()
      player.add_special("Dodge")
      break
    elif classselection == "brute":
      player = brute()
      player.add_special("Uppercut")
      break
    elif classselection == "warlock":
      player = warlock()
      player.add_special("Lightning Strike")
      break
    elif classselection == "default":
      break
    elif classselection == "ULDRULDRULDRRLStSe":
      dev()
    else:
      print("Incorrect class, please select again.")


def inventory_select(): # allows player to select inventory based on class & play style
  global player
  inventory1 = ["ATT 1", "ATT 2", "HEA 1", "HEA 2"]
  inventory2 = ["DEF 1", "DEF 2", "HEA 1", "HEA 2"]
  inventory3 = ["SPE 1", "SPE 2", "HEA 1", "HEA 2"]
  inventory4 = ["STR 1", "STR 2", "HEA 1", "HEA 2"]
  inventory5 = ["EXP 1", "EXP 2", "HEA 1", "HEA 2"]
  print("Please select from one of the following inventories:" "\n",
        "1:", inventory1, "\n",
        "2:", inventory2, "\n",
        "3:", inventory3, "\n",
        "4:", inventory4, "\n",
        "5:", inventory5, "\n"
        " 6: Random inventory")
  inputcorrect = False
  while inputcorrect == False:
    invselect = input("Selection: ")
    if invselect == "1":
      player.inv = inventory1
      break
    elif invselect == "2":
      player.inv = inventory2
      break
    elif invselect == "3":
      player.inv = inventory3
      break
    elif invselect == "4":
      player.inv = inventory4
      break
    elif invselect == "5":
      player.inv = inventory5
      break
    elif invselect == "6":
      inventory6 = []
      for i in range (0,4):
        inventory6.append(RandomPotion())
      player.inv = inventory6
      break
    else:
      print("Incorrect inventory number, please select again.")

"""
Generation Based Functions
"""

def generate_next_area():
  """
  Random number generator to choose what type of tile, then another random number for how long in area
  """
  global tile_type
  tile_type = randint(1,5) #5 biomes
  global area_length
  area_length = randint(3,7) #3-7 tile long areas

def set_next_tile(area_type, Tile_Type): #generates messages (*biome adding after outer ifs*)
  """
  Jungle, Cave, Desert, Arctic, Grasslands
  Start, 1, 2, 3, 4, 5, End
  """
  if area_type == 1: #Jungle
    if Tile_Type == "start":
      print("You are entering the jungle!")
    elif Tile_Type == 1:
      print("You begin to delve into the branches!")
    elif Tile_Type == 2:
      print("You are much thicker in the branches now!")
    elif Tile_Type == 3:
      print("You can barely see a thing in the misty jungle!")
    elif Tile_Type == 4:
      print("You begin to see some light through the treetops!")
    elif Tile_Type == 5:
      print("You see the branches parting and move towards the light!")
    elif Tile_Type == "end":
      print("You find an exit to the jungle, or so you think...")
  elif area_type == 2: #cave
    if Tile_Type == "start":
      print("You are entering the caves!")
    elif Tile_Type == 1:
      print("You begin to smell the mould and murk around you!")
    elif Tile_Type == 2:
      print("You can barely see, it is so dark!")
    elif Tile_Type == 3:
      print("It's pitch black, you can only smell the mould and dirty water dripping from the ceiling!")
    elif Tile_Type == 4:
      print("It begins to get lighter!")
    elif Tile_Type == 5:
      print("You can see the sunlight at the end of the caves!")
    elif Tile_Type == "end":
      print("You find an exit to the caves, or so you think...")
  elif area_type == 3: #desert
    if Tile_Type == "start":
      print("You are entering the desert!")
    elif Tile_Type == 1:
      print("You begin to feel the heat of the sun on your back!")
    elif Tile_Type == 2:
      print("You can only see sand in every direction!")
    elif Tile_Type == 3:
      print("You almost collapse because of the heat!")
    elif Tile_Type == 4:
      print("You can see mountains in the distance!")
    elif Tile_Type == 5:
      print("You can see an exit to the desert!")
    elif Tile_Type == "end":
      print("You find an exit to the desert, or so you think...!")
  elif area_type == 4: #arctic
    if Tile_Type == "start":
      print("You are entering the arctic!")
    elif Tile_Type == 1:
      print("You feel the cold biting at your toes!")
    elif Tile_Type == 2:
      print("You trip over some snowballs!")
    elif Tile_Type == 3:
      print("You're caught in a blizzard!")
    elif Tile_Type == 4:
      print("You begin to see shadows from a new place far away!")
    elif Tile_Type == 5:
      print("You begin to see grass poking through the snow!")
    elif Tile_Type == "end":
      print("You find an exit to the arctic, or so you think...")
  elif area_type == 5: #grasslands
    if Tile_Type == "start":
      print("You are entering the grasslands!")
    elif Tile_Type == 1:
      print("You wade through the long grass!")
    elif Tile_Type == 2:
      print("The grass is so high it's brushing against your face!")
    elif Tile_Type == 3:
      print("You are submerged in the long grass!")
    elif Tile_Type == 4:
      print("You begin to see over the top of the grass!")
    elif Tile_Type == 5:
      print("The grass is short enough to run through now!")
    elif Tile_Type == "end":
      print("You find an exit to the grasslands, or so you think...")
  

def spawn_enemies(current_depth):
  """
  Generate enemies based on depth into area (the random number from generate_next_area). Maximum at mid point.
  """
  max_diff = -(-area_length // 2) #ceiling division
  global enemy
  global enemystate
  if current_depth == "start" or current_depth == "end": #Easy - Med - Hard - Med - Easy (layout for areas)
    selection = randint(1,4)
    if 1 <= selection <= 3:
      enemy = goblin()
      print("A goblin appeared!")
    elif selection > 3:
      enemy = orc()
      print("An orc appeared!")
  elif current_depth == max_diff:
    selection = randint(1,3)
    if 1 <= selection <= 2:
      enemy = warrior()
      print("A warrior appeared!")
    elif selection > 2:
      enemy = destroyer()
      print("A destroyer appeared!")
  else:
    selection = randint(1,3)
    if 1 <= selection <= 2:
      enemy = orc()
      print("An orc appeared!")
    elif selection > 2:
      enemy = warrior()
      print("A warrior appeared!")
  enemystate = "alive"


"""
Turn based functions
"""

def pcturn():
  """
  Can choose:
  Fight
  Flight (-health)
  Look at Stats
  Use special
  Look at description for any item
  Look at inventory:
    Use potion
  """
  global no_of_turns
  global enemy
  global enemystate
  global player
  global flee
  global dodge
  global block_chance
  global speed_turns
  global strength_turns
  global attack_turns
  global defence_turns
  speed_turns = 0
  strength_turns = 0
  attack_turns = 0
  defence_turns = 0
  speed = player.spe
  repeat = False
  flee = False
  block_chance = 1
  double_punch = 1
  uppercut = 1
  dodge = 1
  lightning_strike = 1
  special_used = False
  while speed > 0:
    time.sleep(1)
    if player.hlth <= 0:
      endgame()
    print("")
    if repeat == False:
      print("It's your turn as your speed was greater than the enemies. Please select an option:" "\n"
            "1: Fight (Fight the monster that has just appeared)" "\n"
            "2: Flight (Move to the next tile without fighting. Lose health and gain 0 XP)" "\n"
            "3: Look at your player's stats" "\n"
            "4: Use your special" "\n"
            "5: Look at your inventory (Use a potion this way)")
    else:
      print("Please pick an option (main menu)")
    repeat = True
    inputcorrect = False
    while inputcorrect == False:
      option = input("Selection: ")
      try:
        int(option)
      except:
        print("Incorrect input, please try again")
      else:
        option = int(option)
        if option < 1 or option > 5:
          print("Incorrect input, please try again")
        else:
          inputcorrect = True
          break
    if option == 1:
      """
      Fight
      """
      print("")
      print("You have chosen to fight" "\n"
            "You are fighting the",enemy.desc)
      strength_mult = randint(1, player.Str) #Strength multiplier RNG based on player.str
      if strength_mult < player.Str:
        strength_mult = 1
      else:
        strength_mult = player.Str
      miss_chance = randint(0,((player.hlth // 10) + (player.xp // 100))) #higher health + more xp = less chance-
      if miss_chance > 0:
        miss_chance = 1
      crit_chance = randint(0,((player.hlth // 10) - (player.xp // 100))) #lower health + more xp = greater chance
      if crit_chance == 1: 
        crit_chance = randint(2,3)
        print("Critical hit!")
      else:
        crit_chance = 1
      dmg_dealt = (((((((player.att*strength_mult) - (enemy.Def // 2))*uppercut)*double_punch)*crit_chance) + lightning_strike)*miss_chance) # Bontiful formulae
      enemy.hlth -= dmg_dealt
      if miss_chance == 0:
        print("You missed")
      if enemy.hlth < 0: #checks if enemy is dead
        print("You dealt",dmg_dealt,"damage and the",enemy.desc,"is dead")
        speed = 0
        enemystate = "dead"
      else: 
        print("You dealt",dmg_dealt,"damage and the",enemy.desc,"health is now",enemy.hlth)
        speed = 0
      player.xp += dmg_dealt // 10 #adds xp
      print("Your XP is currently",player.xp)
      no_of_turns += 1
      if special_used == True: #Resets special after use
        block_chance = 1
        double_punch = 1
        uppercut = 1
        dodge = 1
        lightning_strike = 1
        special_used = False
      if speed_turns > 0:
        speed_turns -= 1
      elif speed_turns == 0:
        player.spe = original_speed
      if defence_turns > 0:
        defence_turns -= 1
      elif defence_turns == 0:
        player.Def = original_defence
      if attack_turns > 0:
        attack_turns -= 1
      elif attack_turns == 0:
        player.att = original_attack
      if strength_turns > 0:
        strength_turns -= 1
      elif strength_turns == 0:
        player.Str = original_strength

    elif option == 2:
      """
      Flight
      """
      strength_mult = randint(1, enemy.Str) #Adds in a free turn for the opponent before moving on
      if strength_mult < enemy.Str:
        strength_mult = 1
      else:
        strength_mult = enemy.Str
      miss_chance = randint(0,10)
      if miss_chance > 0:
        miss_chance = 1
      dmg_dealt = (((enemy.att*strength_mult) - (player.Def // 2))*miss_chance)
      player.hlth -= dmg_dealt
      print("The",enemy.desc,"dealt",dmg_dealt,"damage and your health is now",player.hlth)
      speed = 0
      flee = True
    elif option == 3:
      """
      Get Stats
      """
      print("")
      player.all_stats()
    elif option == 4:
      """
      Special
      """
      if player.spec[0] == "Block": #Divides opponents damage by 2
        block_chance = 2
        print("You have used block. This will be used on the next npc turn.")
      elif player.spec[0] == "Double Punch": #Doubles player damage
        double_punch = 2
        print("You have used double punch. Your next turns attack damage will be multiplied by 2.")
      elif player.spec[0] == "Uppercut": #RNG multiplication of damage
        uppercut = randint(2,6)
        print("You have used uppercut. Your next turns attack damage will be multiplied.")
      elif player.spec[0] == "Dodge": #Divides opponents damage by 1000
        dodge = 1000
        print("You have used dodge, the enemy's next attack will be extremely small")
      elif player.spec[0] == "Lightning Strike": #Adds damage
        lightning_strike = randint(50,200)
        print("You have used lightning strike, a large attack damage will be added to your next turn")
      special_used = True
    elif option == 5:
      """
      Inventory seeing & potion use
      """
      print("")
      print("This is your inventory:")
      print(player.inv)
      print("Please select an option:" "\n"
            "1: Use a potion" "\n"
            "2: Get description for a potion")
      inputcorrect2 = False
      while inputcorrect2 == False:
        option2 = input("Selection: ")
        try:
          int(option2)
        except:
          print("Incorrect input, please try again")
        else:
          option2 = int(option2)
          if option2 < 1 or option2 > 2:
            print("Incorrect input, please try again")
          else:
            inputcorrect2 = True
            break
      if option2 == 1:
        print("Currently not working")
        print("Please select the position of the potion you want to use in your inventory, 1 being the first, 2 the second and so on. Type exit if you do not want to apply a potion.")
        inputcorrect3 = False
        while inputcorrect3 == False:
          option3 = input("Selection: ")
          try:
            int(option3)
          except:
            print("Incorrect input, please try again")
          else:
            option3 = int(option3)
            if option3 < 1 or option3 > len(player.inv):
              print("Incorrect input, please try again")
            else:
              inputcorrect3 = True
              break
          if option3 == "exit":
            break
        potionToAdd = str(player.inv[option3 - 1])
        if potionToAdd == "HEA 1": #more lists D:
          player.hlth += health1.hlth
          print("Added",health1.hlth,"health, your health is now",player.hlth)
          del player.inv[option3 - 1]
        elif potionToAdd == "HEA 2":
          player.hlth += health2.hlth
          print("Added",health2.hlth,"health, your health is now",player.hlth)
          del player.inv[option3 - 1]
        elif potionToAdd == "HEA 3":
          player.hlth += health3.hlth
          print("Added",health3.hlth,"health, your health is now",player.hlth)
          del player.inv[option3 - 1]
        elif potionToAdd == "HEA 4":
          player.hlth += health4.hlth
          print("Added",health4.hlth,"health, your health is now",player.hlth)
          del player.inv[option3 - 1]
        elif potionToAdd == "SPE 1":
          player.spe += speed1.spe
          speed_turns = speed1.trns
          print("Added",speed1.spe,"speed for",speed1.trns,"turns, your speed is now",player.spe)
          del player.inv[option3 - 1]
        elif potionToAdd == "SPE 2":
          player.spe += speed2.spe
          speed_turns = speed2.trns
          print("Added",speed2.spe,"speed for",speed2.trns,"turns, your speed is now",player.spe)
          del player.inv[option3 - 1]
        elif potionToAdd == "SPE 3":
          player.spe += speed3.spe
          speed_turns = speed3.trns
          print("Added",speed3.spe,"speed for",speed3.trns,"turns, your speed is now",player.spe)
          del player.inv[option3 - 1]
        elif potionToAdd == "SPE 4":
          player.spe += speed4.spe
          speed_turns = speed4.trns
          print("Added",speed4.spe,"speed for",speed4.trns,"turns, your speed is now",player.spe)
          del player.inv[option3 - 1]
        elif potionToAdd == "ATT 1":
          player.att += attack1.att
          attack_turns = attack1.trns
          print("Added",attack1.att,"attack for",attack1.trns,"turns, your attack is now",player.att)
          del player.inv[option3 - 1]
        elif potionToAdd == "ATT 2":
          player.att += attack2.att
          attack_turns = attack2.trns
          print("Added",attack2.att,"attack for",attack2.trns,"turns, your attack is now",player.att)
          del player.inv[option3 - 1]
        elif potionToAdd == "ATT 3":
          player.att += attack3.att
          attack_turns = attack3.trns
          print("Added",attack3.att,"attack for",attack3.trns,"turns, your attack is now",player.att)
          del player.inv[option3 - 1]
        elif potionToAdd == "ATT 4":
          player.att += attack4.att
          attack_turns = attack4.trns
          print("Added",attack4.att,"attack for",attack4.trns,"turns, your attack is now",player.att)
          del player.inv[option3 - 1]
        elif potionToAdd == "DEF 1":
          player.Def += defence1.Def
          defence_turns = defence1.trns
          print("Added",defence1.Def,"defence for",defence1.trns,"turns, your defence is now",player.Def)
          del player.inv[option3 - 1]
        elif potionToAdd == "DEF 2":
          player.Def += defence2.Def
          defence_turns = defence2.trns
          print("Added",defence2.Def,"defence for",defence2.trns,"turns, your defence is now",player.Def)
          del player.inv[option3 - 1]
        elif potionToAdd == "DEF 3":
          player.Def += defence3.Def
          defence_turns = defence3.trns
          print("Added",defence3.Def,"defence for",defence3.trns,"turns, your defence is now",player.Def)
          del player.inv[option3 - 1]
        elif potionToAdd == "DEF 4":
          player.Def += defence4.Def
          defence_turns = defence4.trns
          print("Added",defence4.Def,"defence for",defence4.trns,"turns, your defence is now",player.Def)
          del player.inv[option3 - 1]
        elif potionToAdd == "STR 1":
          player.Str += strength1.Str
          strength_turns = strength1.trns
          print("Added",strength1.Str,"strength for",strength1.trns,"turns, your strength is now",player.Str)
          del player.inv[option3 - 1]
        elif potionToAdd == "STR 2":
          player.Str += strength2.Str
          strength_turns = strength2.trns
          print("Added",strength2.Str,"strength for",strength2.trns,"turns, your strength is now",player.Str)
          del player.inv[option3 - 1]
        elif potionToAdd == "STR 3":
          player.Str += strength3.Str
          strength_turns = strength3.trns
          print("Added",strength3.Str,"strength for",strength3.trns,"turns, your strength is now",player.Str)
          del player.inv[option3 - 1]
        elif potionToAdd == "STR 4":
          player.Str += strength4.Str
          strength_turns = strength4.trns
          print("Added",strength4.Str,"strength for",strength4.trns,"turns, your strength is now",player.Str)
          del player.inv[option3 - 1]
        elif potionToAdd == "EXP 1":
          player.xp += exp1.xp
          print("Added",exp1.xp,"experience, your experience is now",player.xp)
          del player.inv[option3 - 1]
        elif potionToAdd == "EXP 2":
          player.xp += exp2.xp
          print("Added",exp2.xp,"experience, your experience is now",player.xp)
          del player.inv[option3 - 1]
        elif potionToAdd == "EXP 3":
          player.xp += exp3.xp
          print("Added",exp3.xp,"experience, your experience is now",player.xp)
          del player.inv[option3 - 1]
        elif potionToAdd == "EXP 4":
          player.xp += exp4.xp
          print("Added",exp4.xp,"experience, your experience is now",player.xp)
          del player.inv[option3 - 1]
        else:
          print("Incorrect input, please try again")
        

      elif option2 == 2:
        print("")
        potionchoice = input("Type in a potion in the format shown in the inventory: ")
        PotionDescription(potionchoice)
    else:
      """
      Error catching for the error catcher
      """
      print("Incorrect input, please try again")

def npcturn():
  """
  Enemy attacks in turn based upon speed, same as player.
  """
  global enemy
  global dodge
  global block_chance
  speed = enemy.spe
  repeat = False
  while speed > 0: #From old code, when speed meant amount of turns, now used to determine 1 turn length
    if repeat == True:  #On repeat, player abilities from previous turns are returned to default state
      block_chance = 1
      dodge = 1
    if player.hlth <= 0:  #Check if player is dead
      endgame()
    print("It is the enemies turn as their speed is higher")
    print("")
    strength_mult = randint(1, enemy.Str) #Essentially a damage multiplier based on strength
    if strength_mult < enemy.Str: #RNG of strength mult, the higher the strength, less chance, but more damage
      strength_mult = 1
    else:
      strength_mult = enemy.Str
    miss_chance = randint(0,10)
    if miss_chance > 0:   # 1 in 10 chance of missing
      miss_chance = 1
    dmg_dealt = (((((enemy.att * strength_mult) - (player.Def // 2))//dodge)//block_chance)*miss_chance) # D:
    if dmg_dealt < 0:
      dmg_dealt = 0
    player.hlth -= dmg_dealt
    if player.hlth <= 0: #Check if player is dead
      print("The",enemy.desc,"dealt",dmg_dealt,"damage and you are dead")
      speed = 0
      endgame()
    else: #Output damage
      print("The",enemy.desc,"dealt",dmg_dealt,"damage and your health is now",player.hlth)
      print("")
      speed = 0
    repeat = True


def loot():
  """
  Generate Loot and xp based on number of enemies killed, health remaining etc.
  """

"""
Other Functions
"""
def dev():
  """
  dev commands n stuff
  """
  option = input("Enter command: ")
  if option == "Reset Scores":
    array = ['0','0','0','0','0','0','0','0','0','0']
    reset = open("highscore.text", "w")
    reset.write(str(array))
    reset.close()

def RandomPotion():
  """
  Generates a random potion (Health, speed, strength, attack, defence, xp)
  """
  potiontype = ""
  potionlevel = ""
  overallpotion = ""
  Randtype = randint(0,99)
  randlevel = randint(0,99)
  if 0 <= Randtype <= 17:
    potiontype = "HEA "
  elif 18 <= Randtype <= 35:
    potiontype = "SPE "
  elif 36 <= Randtype <= 53:
    potiontype = "STR "
  elif 54 <= Randtype <= 71:
    potiontype = "ATT "
  elif 72 <= Randtype <= 89:
    potiontype = "DEF "
  else:
    potiontype = "EXP "
  
  if 70 <= randlevel <= 89:
    potionlevel = "2"
  elif 90 <= randlevel <= 96:
    potionlevel = "3"
  elif 97 <= randlevel <= 99:
    potionlevel = "4"
  else:
    potionlevel = "1"
  
  overallpotion = potiontype + potionlevel
  return overallpotion

def class_assignment():
  """
  assigning variables to each class
  """
  global health1
  global health2
  global health3
  global health4
  global speed1
  global speed2
  global speed3
  global speed4
  global strength1
  global strength2
  global strength3
  global strength4
  global attack1
  global attack2
  global attack3
  global attack4
  global defence1
  global defence2
  global defence3
  global defence4
  global exp1
  global exp2
  global exp3
  global exp4
  health1 = health1()
  health2 = health2()
  health3 = health3()
  health4 = health4()
  speed1 = speed1()
  speed2 = speed2()
  speed3 = speed3()
  speed4 = speed4()
  strength1 = strength1()
  strength2 = strength2()
  strength3 = strength3()
  strength4 = strength4()
  attack1 = attack1()
  attack2 = attack2()
  attack3 = attack3()
  attack4 = attack4()
  defence1 = defence1()
  defence2 = defence2()
  defence3 = defence3()
  defence4 = defence4()
  exp1 = exp1()
  exp2 = exp2()
  exp3 = exp3()
  exp4 = exp4()

def PotionDescription(potion):
  """
  An extremely long list of all items and then getting their descriptions
  """
  global health1
  global health2
  global health3
  global health4
  global speed1
  global speed2
  global speed3
  global speed4
  global strength1
  global strength2
  global strength3
  global strength4
  global attack1
  global attack2
  global attack3
  global attack4
  global defence1
  global defence2
  global defence3
  global defence4
  global exp1
  global exp2
  global exp3
  global exp4
  if potion == "HEA 1":
    print(health1.desc)
  elif potion == "HEA 2":
    print(health2.desc)
  elif potion == "HEA 2":
    print(health3.desc)
  elif potion == "HEA 2":
    print(health4.desc)
  elif potion == "SPE 1":
    print(speed1.desc)
  elif potion == "SPE 2":
    print(speed2.desc)
  elif potion == "SPE 3":
    print(speed3.desc)
  elif potion == "SPE 4":
    print(speed4.desc)
  elif potion == "STR 1":
    print(strength1.desc)
  elif potion == "STR 2":
    print(strength2.desc)
  elif potion == "STR 3":
    print(strength1.desc)
  elif potion == "STR 4":
    print(strength4.desc)
  elif potion == "ATT 1":
    print(attack1.desc)
  elif potion == "ATT 2":
    print(attack2.desc) 
  elif potion == "ATT 3":
    print(attack3.desc) 
  elif potion == "ATT 4":
    print(attack4.desc)
  elif potion == "DEF 1":
    print(defence1.desc)
  elif potion == "DEF 2":
    print(defence2.desc)
  elif potion == "DEF 3":
    print(defence3.desc)
  elif potion == "DEF 4":
    print(defence4.desc)
  elif potion == "EXP 1":
    print(exp1.desc)
  elif potion == "EXP 2":
    print(exp2.desc)
  elif potion == "EXP 3":
    print(exp3.desc)
  elif potion == "EXP 4":
    print(exp4.desc)  
  else:
    print("Not a potion")         


def endgame():
  """
  When the player dies
  """
  global end
  end = True
  print("")
  print("You have died, your final score was", player.xp, "and you lasted",no_of_turns,"turns.")
  highscores = open("highscore.txt", "r")
  array = highscores.readline()
  highscores.close()
  print(array)
  translation_table = dict.fromkeys(map(ord, "[],'"), None)
  array = array.translate(translation_table) #removes unwanted symbols before converting to list
  array = array.split() # converts to list
  array.sort(reverse = True) #sorts in descending order
  print(array)
  if player.xp > int(array[9]): #checks if player xp is a highscore
    array[9] = str(player.xp)
  array.sort(reverse = True) # resorts array
  print(array)
  print("Highscores:" + "\n")
  for i in range(0, (len(array))):
    print(str(i + 1) + ": " + str(array[i]) + " EXP" + "\n") #prints highscores
  highscores = open("highscore.txt", "w") #rewrites array to text file
  highscores.write(str(array))
  highscores.close()
  print("Please stop program and rerun for another game.")
  quit()
main()
Fetching token
?