-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
1657 lines (1518 loc) · 59.5 KB
/
main.py
File metadata and controls
1657 lines (1518 loc) · 59.5 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
from time import sleep
import random
from sys import stdout
from pathlib import Path
room_1_right_wall_broken = False
room_2_right_wall_broken = False
room_2_left_enemy_killed = False
npc_house_npc_killed = False
room_2_right_wall_hp = 3
player_hp = 5
room_2_left_enemy_hp = 2
boss_hp = 12
player_dmg = 1
player_move = ""
player_reaction_move = ""
dodged = None
word_delay = 0.05
current_room = ""
save_folder = Path("saves/")
save_file = save_folder / "save_1.txt"
def create_save():
global room_1_right_wall_broken
global room_2_right_wall_broken
global npc_house_npc_killed
global player_hp
global player_dmg
global current_room
global save_file
global save_folder
current_room = "start_game"
save_1 = open(save_file, "w")
save_1.write("""room_1_right_wall_broken:\
""" + str(room_1_right_wall_broken) + " \n")
save_1.write("""room_2_right_wall_broken:\
""" + str(room_2_right_wall_broken) + " \n")
save_1.write("""npc_house_npc_killed:\
""" + str(npc_house_npc_killed) + " \n")
save_1.write("player_hp:" + str(player_hp) + " \n")
save_1.write("player_dmg:" + str(player_dmg) + " \n")
save_1.write("current_room:" + str(current_room) + " \n")
save_1.close()
start_game()
def save_game():
global room_1_right_wall_broken
global room_2_right_wall_broken
global npc_house_npc_killed
global player_hp
global player_dmg
global current_room
global save_file
global save_folder
save_1 = open(save_file, "w")
save_1.write("""room_1_right_wall_broken:\
""" + str(room_1_right_wall_broken) + " \n")
save_1.write("""room_2_right_wall_broken:\
""" + str(room_2_right_wall_broken) + " \n")
save_1.write("""npc_house_npc_killed:\
""" + str(npc_house_npc_killed) + " \n")
save_1.write("player_hp:" + str(player_hp) + " \n")
save_1.write("player_dmg:" + str(player_dmg) + " \n")
save_1.write("current_room:" + str(current_room) + " \n")
save_1.close()
def load_game():
global room_1_right_wall_broken
global room_2_right_wall_broken
global npc_house_npc_killed
global player_hp
global player_dmg
global current_room
global save_file
global save_folder
try:
save_1 = open(save_file, "r")
except FileNotFoundError:
delayed_print_words("You don't have a save file.")
play_game()
has_a_save = True
if has_a_save:
save_1 = open(save_file, "r")
saved_variables = save_1.readlines()
for i in saved_variables:
if "room_1_right_wall_broken:" in i:
room_1_right_wall_broken = eval(i[25:])
elif "room_2_right_wall_broken:" in i:
room_2_right_wall_broken = eval(i[25:])
elif "npc_house_npc_killed:" in i:
npc_house_npc_killed = eval(i[21:])
elif "player_hp:" in i:
player_hp = int(i[10:])
elif "player_dmg:" in i:
player_dmg = float(i[11:])
elif "current_room:" in i:
current_room = i[13:]
save_1.close()
eval(current_room)()
def play_game():
choice = valid_input("""What would you like to do?\n Start New Sav\
e\n Load your Save""", ["new", "load", "start"]).lower()
if "new" in choice or "start" in choice:
create_save()
else:
load_game()
def available_commands():
global current_room
global npc_house_npc_killed
if current_room == "npc_house" and npc_house_npc_killed is False:
delayed_print_words("""Available Commands:\n Jump to the Left\
\n Jump to the Right\n Move Left\n Move Right\n Jump Up\n Attack\n T\
alk\n Exit to Title\n Help""")
eval(current_room)()
elif current_room == "room_3_town":
delayed_print_words("""Available Commands:\n Jump to the Left\
\n Jump to the Right\n Move Left\n Move Right\n Jump Up\n Attack\n E\
nter House\n Exit to Title\n Help""")
eval(current_room)()
else:
delayed_print_words("""Available Commands:\n Jump to the Left\
\n Jump to the Right\n Move Left\n Move Right\n Jump Up\n Attack\n E\
xit to Title\n Help""")
eval(current_room)()
def exit_to_title():
global current_room
answer = valid_input("""Are you sure you want to exit the game?\n \
Yes\n No""", ["yes", "no"])
if "yes" in answer:
save_game()
title_screen()
else:
eval(current_room)()
def delayed_print_words(text):
global word_delay
for char in text:
print(char, end="")
sleep(word_delay)
stdout.flush()
sleep(0.5)
print("")
return ""
def valid_input(input_text, options=[]):
global word_delay
while True:
sleep(word_delay)
response = input(delayed_print_words(input_text)).lower()
for option in options:
if option in response:
return response
delayed_print_words("""That isn't a response I know what to do\
with. \nPlease check your spelling and try again.""")
delayed_print_words("For a list of Commands enter Help")
def title_screen():
delayed_print_words("Title Screen:")
choice = valid_input("""What would you like to do?\n Play Game\n S\
ettings\n Close Game""", ["play", "play game", "settings", "close", """c\
lose game"""]).lower()
if "play" in choice:
play_game()
elif "settings" in choice:
settings()
else:
exit()
def is_float(user_input):
try:
float(user_input)
except ValueError:
return False
return True
def settings():
delayed_print_words("Settings:")
choice = valid_input("""What would you like to do?\n Change The Te\
xt Speed\n Exit to the Title Screen""", ["text", "speed", "exit"]).lower()
if "text" in choice or "speed" in choice:
set_text_speed()
else:
title_screen()
def set_text_speed():
global word_delay
delayed_print_words("Please input the text speed you want:")
text_speed = input()
if float(text_speed) > 2:
delayed_print_words("That number is to High")
set_text_speed()
elif is_float(text_speed):
word_delay = float(text_speed)
settings()
else:
delayed_print_words("""That isn't a number.\nPlease enter a nu\
mber.""")
set_text_speed()
def room_1():
global current_room
current_room = "room_1"
delayed_print_words("""You find yourself in the middle of a dece\
ntly sized, but dimly-lit cavern.\nOn each side of this cavern a wal\
l seems to extend upwards forever.""")
action = valid_input("What would you like to do?", ["jump"and"""le\
ft""", "jump"and"right", "help", "left", "right", "jump", "attack", """e\
xit"""])
if "left" in action and "jump" in action:
delayed_print_words("""You leap towards the left side of the\
cavern.""")
room_1_left()
elif "right" in action and "jump" in action:
delayed_print_words("""You leap towards the right of the cav\
ern.""")
room_1_right()
elif "help" in action:
available_commands()
elif "left" in action:
delayed_print_words("""You walk to the left side of the cave\
rn.""")
room_1_left()
elif "right" in action:
delayed_print_words("""You walk to the right side of the cav\
ern.""")
room_1_right()
elif "jump" in action:
delayed_print_words("""You leap high into the air and land r\
ight where you jumped from.""")
room_1()
elif "exit" in action:
exit_to_title()
else:
delayed_print_words("""You swing your sword out in front of yo\
u.""")
room_1()
def room_1_left():
global current_room
current_room = "room_1_left"
delayed_print_words("""You look at the wall.\nIt seems to be of \
sturdy construction.""")
action = valid_input("What would you like to do?", ["jump"and"""le\
ft""", "jump"and"right", "help", "left", "right", "jump", "attack", """e\
xit"""])
if "left" in action and "jump" in action:
delayed_print_words("""You leap to the left as your face sma\
shes against the wall.""")
room_1_left()
elif "right" in action and "jump" in action:
delayed_print_words("""You leap towards the middle of the ca\
vern.""")
room_1()
elif "help" in action:
available_commands()
elif "left" in action:
delayed_print_words("""You walk into the wall.""")
room_1_left()
elif "right" in action:
delayed_print_words("""You walk to the middle of the cavern.\
""")
room_1()
elif "jump" in action:
delayed_print_words("""You leap high into the air and land r\
ight where you jumped from.""")
room_1_left()
elif "exit" in action:
exit_to_title()
else:
delayed_print_words("""You swing your sword at the wall.\nA \
piece of the stone chips off.""")
room_1_left()
def room_1_right():
global room_1_right_wall_broken
global current_room
current_room = "room_1_right"
if not room_1_right_wall_broken:
delayed_print_words("""You look at the wall.\nPart of the wa\
ll has large cracks down it.\nPeering through the largest crack, you\
notice on the other side there is something moving.""")
action = valid_input("What would you like to do?", ["""jump\
"""and"left", "jump"and"right", "help", "right", "left", "jump", """atta\
ck""", "exit"])
if "left" in action and "jump" in action:
delayed_print_words("""You leap towards the middle of th\
e cavern.""")
room_1()
elif "right" in action and "jump" in action:
delayed_print_words("""You leap to the right as your fac\
e smashes against the wall.""")
room_1_right()
elif "help" in action:
available_commands()
elif "right" in action:
delayed_print_words("""You walk into the wall.""")
room_1_right()
elif "left" in action:
delayed_print_words("""You walk to the middle of the cav\
ern.""")
room_1()
elif "jump" in action:
delayed_print_words("""You leap high into the air and la\
nd right where you jumped from.""")
room_1_right()
elif "exit" in action:
exit_to_title()
else:
delayed_print_words("""You swing your sword at the wall.\
\nWhen your sword makes contact with the wall, the cracks begin to w\
iden!\nAs the cracks in the wall rapidly get bigger a portion of the\
wall crumbles to the ground.\nWith the wall broken you can probably\
squeeze through.""")
room_1_right_wall_broken = True
room_1_right()
if room_1_right_wall_broken:
delayed_print_words("""You are standing on the right side of\
a dimly lit cavern.\nThe wall to your right seems to have been brok\
en.\nThe hole looks large enough to squeeze through.""")
action = valid_input("What would you like to do?", ["""jump\
"""and"left", "jump"and"right", "help", "left", "right", "jump", """atta\
ck""", "exit"])
if "left" in action and "jump" in action:
delayed_print_words("""You leap towards the middle of th\
e cavern.""")
room_1()
elif "right" in action and "jump" in action:
delayed_print_words("""You leap to the right as your fac\
e smashes against the wall.""")
room_1_right()
elif "help" in action:
available_commands()
elif "left" in action:
delayed_print_words("""You walk to the middle of the cav\
ern.""")
room_1()
elif "jump" in action:
delayed_print_words("""You leap high into the air and la\
nd right where you jumped from.""")
room_1_right()
elif "attack" in action:
delayed_print_words("""You swing your sword at the wall\
.\nA bit of the stone around the hole chips off.""")
room_1_right()
elif "exit" in action:
exit_to_title()
else:
delayed_print_words("""You squeeze your way through the \
hole in the wall.""")
room_2_far_left()
def room_2_far_left():
global current_room
current_room = "room_2_far_left"
if not room_2_left_enemy_killed:
delayed_print_words("""You look around and see a long cavern\
ahead.\nYou notice the ceiling in here is a little way above your h\
ead.\nYou see something moving farther along the cavern.""")
action = valid_input("What would you like to do?", ["""jump\
"""and"left", "jump"and"right", "help", "left", "right", "jump", """\
attack""", "exit"])
if "left" in action and "jump" in action:
delayed_print_words("""You leap to the left as your head\
smashes into the ceiling.""")
room_2_far_left()
elif "right" in action and "jump" in action:
delayed_print_words("""You leap to the right as your hea\
d smashes into the ceiling.""")
room_2_far_left()
elif "help" in action:
available_commands()
elif "right" in action:
delayed_print_words("""You walk to the right of the long\
cavern.""")
room_2_left()
elif "left" in action:
delayed_print_words("""You squeeze your way through the \
hole in the wall.""")
room_1_right()
elif "jump" in action:
delayed_print_words("""You leap into the air as your hea\
d smashes into the ceiling.""")
room_2_far_left()
elif "exit" in action:
exit_to_title()
else:
delayed_print_words("""You swing your sword out in front\
of you.""")
room_2_far_left()
else:
delayed_print_words("""You look around and see a long cavern\
ahead.\nYou notice the ceiling in here is a little way above your h\
ead.""")
action = valid_input("What would you like to do?", ["""jump\
"""and"left", "jump"and"right", "help", "left", "right", "jump", """atta\
ck""", "exit"])
if "left" in action and "jump" in action:
delayed_print_words("""You leap to the left as your head\
smashes into the ceiling.""")
room_2_far_left()
elif "right" in action and "jump" in action:
delayed_print_words("""You leap to the right as your hea\
d smashes into the ceiling.""")
room_2_far_left()
elif "help" in action:
available_commands()
elif "left" in action:
delayed_print_words("""You squeeze your way through the \
hole in the wall.""")
room_1_right()
elif "right" in action:
delayed_print_words("""You walk to the right of the long\
cavern.""")
room_2_left()
elif "jump" in action:
delayed_print_words("""You leap into the air as your hea\
d smashes into the ceiling.""")
room_2_far_left()
elif "exit" in action:
exit_to_title()
else:
delayed_print_words("""You swing your sword out in front\
of you.""")
room_2_far_left()
def room_2_left():
global current_room
current_room = "room_2_left"
delayed_print_words("""You look around and see a long cavern ahead\
.\nYou notice the ceiling in here is a little way above your head.""")
if not room_2_left_enemy_killed:
first_combat_players_turn()
else:
action = valid_input("What would you like to do?", ["""jump\
"""and"left", "jump"and"right", "help", "left", "right", "jump", """atta\
ck""", "exit"])
if "left" in action and "jump" in action:
delayed_print_words("""You leap to the left as your head\
smashes into the ceiling.""")
room_2_left()
elif "right" in action and "jump" in action:
delayed_print_words("""You leap to the right as your hea\
d smashes into the ceiling.""")
room_2_left()
elif "help" in action:
available_commands()
elif "left" in action:
delayed_print_words("""You walk to the left of the long \
cavern.""")
room_2_far_left()
elif "right" in action:
delayed_print_words("""You walk to the right of the long\
cavern.""")
room_2_right()
elif "jump" in action:
delayed_print_words("""You leap into the air as your hea\
d smashes into the ceiling.""")
room_2_left()
elif "exit" in action:
exit_to_title()
else:
delayed_print_words("""You swing your sword out in front\
of you.""")
room_2_left()
def first_combat_players_turn():
global player_dmg
global player_hp
global room_2_left_enemy_hp
global room_2_left_enemy_killed
global player_move
global current_room
global save_file
global save_folder
current_room = "first_combat_players_turn"
if player_hp <= 0:
delayed_print_words("""As you take that last hit you know th\
is is the end of you.\nYour limbs begin to feel weak as the last bit\
of your lifeforce fades away.\n\nYou have lost.""")
save_1 = open(save_file, "w")
save_1.write("Dead")
save_1.close()
title_screen()
elif room_2_left_enemy_hp <= 0:
delayed_print_words("""As your sword connects with the beast\
, its thick carapace splits.\nBlack foul-smelling blood pours out of\
the gaping wound and the giant bug’s lifeless corpse falls to the g\
round.""")
room_2_left_enemy_killed = True
room_2_left()
delayed_print_words("""In front of you, you see a large bug-like c\
reature come barreling towards you.""")
delayed_print_words(f"Your HP:{player_hp}")
action = valid_input("What would you like to do?", ["jump"and"""le\
ft""", "jump"and"right", "help", "left", "right", "jump", "attack", """e\
xit"""])
if "left" in action and "jump" in action:
delayed_print_words("""You leap out of the way of the beasts a\
ttack.""")
player_move = "jump"
first_combat_enemies_turn()
elif "right" in action and "jump" in action:
delayed_print_words("""You leap over the beast.\nAs you get \
to the other side of the beast you see the ground isnt at the same l\
evel you jumped from, and you fall into a hole in the ground.""")
in_pit()
elif "help" in action:
available_commands()
elif "left" in action:
delayed_print_words("""You run to the left of the long cavern \
away from the beast.""")
room_2_far_left()
elif "right" in action:
delayed_print_words("""You walk to the right going headfirst\
into the beasts attack.\nYou feel a sharp pain run through your bod\
y""")
player_hp -= 1
player_move = "right"
first_combat_enemies_turn()
elif "jump" in action:
delayed_print_words("""You leap out of the way of the beasts\
attack.""")
player_move = "jump"
first_combat_enemies_turn()
elif "attack" in action:
delayed_print_words("""You swing your sword at the beast.""")
room_2_left_enemy_hp -= player_dmg
player_move = "attack"
first_combat_enemies_turn()
else:
exit_to_title()
def first_combat_enemies_turn():
global player_hp
global room_2_left_enemy_hp
global room_2_left_enemy_killed
global player_move
global save_file
global save_folder
if player_hp <= 0:
delayed_print_words("""As you take that last hit you know th\
is is the end of you.\nYour limbs begin to feel weak as the last bit\
of your lifeforce fades away.\n\nYou have lost.""")
save_1 = open(save_file, "w")
save_1.write("Dead")
save_1.close()
title_screen()
elif room_2_left_enemy_hp <= 0:
delayed_print_words("""As your sword connects with the beast\
, its thick carapace splits.\nBlack foul-smelling blood pours out of\
the gaping wound and the giant bug’s lifeless corpse falls to the g\
round.""")
room_2_left_enemy_killed = True
room_2_left()
if player_move == "attack":
delayed_print_words("""As your sword connects the beast screec\
hes out in pain.""")
first_combat_players_turn()
elif player_move == "jump":
delayed_print_words("""The beast charges right past you.""")
first_combat_players_turn()
else:
delayed_print_words("""The bug-like creature’s hulking body \
slams into you.\nYou feel a sharp pain run through your body.""")
player_hp -= 1
first_combat_players_turn()
def room_2_right():
global current_room
current_room = "room_2_right"
delayed_print_words("""You look around and see a long cavern ahe\
ad.\nYou notice the ceiling in this part of the cavern is a good way\
s above your head.\nA few steps away from you, you see a deep pit.\
""")
action = valid_input("What would you like to do?", ["jump"and"""le\
ft""", "jump"and"right", "help", "left", "right", "jump", "attack", """e\
xit"""])
if "left" in action and "jump" in action:
delayed_print_words("""You leap towards the left of the long\
cavern.""")
room_2_left()
elif "right" in action and "jump" in action:
delayed_print_words("""You leap over the pit.""")
room_2_far_right()
elif "help" in action:
available_commands()
elif "left" in action:
delayed_print_words("""You walk to the left of the long cave\
rn.""")
room_2_left()
elif "right" in action:
delayed_print_words("""You walk forward and fall into the pi\
t.""")
in_pit()
elif "jump" in action:
delayed_print_words("""You leap high into the air and land r\
ight where you jumped from.""")
room_2_right()
elif "attack" in action:
delayed_print_words("""You swing your sword out in front of \
you.""")
room_2_right()
else:
exit_to_title()
def in_pit():
global current_room
current_room = "in_pit"
delayed_print_words("""You are in a deep pit.""")
action = valid_input("What would you like to do?", ["""jump\
"""and"left", "jump"and"right", "help", "left", "right", "jump", """atta\
ck""", "exit"])
if "left" in action and "jump" in action:
delayed_print_words("""You leap out of the pit.""")
room_2_right()
elif "right" in action and "jump" in action:
delayed_print_words("""You leap out of the pit.""")
room_2_far_right()
if "left" in action:
delayed_print_words("""You walk to the left side of the \
pit.""")
in_pit()
elif "right" in action:
delayed_print_words("""You walk to the right side of the\
pit.""")
in_pit()
elif "help" in action:
available_commands()
elif "jump" in action:
delayed_print_words("""You leap high into the air, as yo\
u get to the apex of your jump you see out of the pit.""")
in_pit()
elif "attack" in action:
delayed_print_words("""You swing your sword out in front\
of you.""")
in_pit()
else:
exit_to_title()
def room_2_far_right():
global room_2_right_wall_hp
global room_2_right_wall_broken
global current_room
current_room = "room_2_far_right"
if not room_2_right_wall_broken:
if room_2_right_wall_hp == 0:
delayed_print_words("""The cracks in the wall widen fast\
er and faster!\nSuddenly pieces of the wall start falling down.\nYou\
jump out of the way narrowly dodging the falling debris.\nLight sta\
rts pouring in!\nAs the dust settles you see the source of the light\
, the moon shining beautifully.""")
room_2_right_wall_broken = True
room_2_far_right()
delayed_print_words("""You are in a large cavern.\nUnlike th\
e other caverns you’ve been in this one very well lit.\nLight in thi\
s cavern is coming from a large wall on the right.\nThe wall has lar\
ge cracks running down it.""")
action = valid_input("What would you like to do?", ["""jump\
"""and"left", "jump"and"right", "help", "left", "right", "jump", """atta\
ck""", "exit"])
if "jump" in action and "left" in action:
delayed_print_words("""You leap over the pit to the left\
.""")
room_2_right()
elif "right" in action and "jump" in action:
delayed_print_words("""You leap to the right as you smas\
h into the wall.\nAs you impact the wall the cracks widen.""")
room_2_right_wall_hp -= 1
room_2_far_right()
elif "help" in action:
available_commands()
elif "left" in action:
delayed_print_words("""You walk to the left and fall int\
o the pit.""")
in_pit()
elif "right" in action:
delayed_print_words("""You walk into the wall.""")
room_2_far_right()
elif "jump" in action:
delayed_print_words("""You leap high into the air and la\
nd back where you leaped from.""")
room_2_far_right()
elif "attack" in action:
delayed_print_words("""You swing your sword at the large\
wall\nAs you do the cracks in the wall widen.""")
room_2_right_wall_hp -= 1
room_2_far_right()
else:
exit_to_title()
else:
delayed_print_words("""You are in a large cavern\nUnlike the\
other caverns you’ve been in this one extremely well lit.\nMoon lig\
ht is pouring in from a ginormous hole on the right side of the cave\
rn.""")
action = valid_input("What would you like to do?", ["""jump\
"""and"left", "jump"and"right", "help", "right", "left", "jump", """atta\
ck""", "exit"])
if "jump" in action and "left" in action:
delayed_print_words("""You leap over the pit to the left\
.""")
room_2_right()
elif "right" in action and "jump" in action:
delayed_print_words("""You leap to the right out of the \
large hole in the wall.""")
room_3_cliff()
elif "help" in action:
available_commands()
elif "left" in action:
delayed_print_words("""You walk to the left and fall int\
o the pit.""")
in_pit()
elif "right" in action:
delayed_print_words("""You walk to the right out the hol\
e in the wall.""")
room_3_cliff()
elif "jump" in action:
delayed_print_words("""You leap high into the air and la\
nd back where you leaped from.""")
room_2_far_right()
elif "attack" in action:
delayed_print_words("You swing your sword out in front o\
f you.")
room_2_far_right()
else:
exit_to_title()
def room_3_cliff():
global current_room
current_room = "room_3_cliff"
delayed_print_words("""You stand at the edge of a cliffside.\nTo\
the right the earth has been broken away.\nLooking over the edge of\
the cliff you see a long way down the ground can be seen.\nOff in t\
he distance a small town can be seen.""")
action = valid_input("What would you like to do?", ["jump"and"le\
ft", "jump"and"right", "help", "left", "right", "jump", "attack", "ex\
it"])
if "left" in action and "jump" in action:
delayed_print_words("""You leap into the cavern.""")
room_2_far_right()
elif "right" in action and "jump" in action:
delayed_print_words("""You leap off the cliff.\nYou fall for\
a few seconds and land on the ground below.\nWeirdly you felt no pa\
in when you impacted the ground.""")
room_3_left()
elif "help" in action:
available_commands()
elif "left" in action:
delayed_print_words("""You walk into the cavern.""")
room_2_far_right()
elif "right" in action:
delayed_print_words("""You walk off the cliff.\nYou fall for\
a few seconds and land on the ground below.\nWeirdly you felt no pa\
in when you impacted the ground.""")
room_3_left()
elif "jump" in action:
delayed_print_words("""You leap high into the air and land b\
ack where you leaped from.""")
room_3_cliff()
elif "attack" in action:
delayed_print_words("""You swing your sword out in front of \
you.""")
room_3_cliff()
else:
exit_to_title()
def room_3_left():
global current_room
current_room = "room_3_left"
delayed_print_words("""You are in a large barren flat piece of l\
and, large chunks of the broken wall are scattered along the ground\
.\nThe moon shining down upon you.\nOff in the distance a small town\
can be seen.""")
action = valid_input("What would you like to do?", ["jump"and"le\
ft", "jump"and"right", "help", "left", "right", "jump", "attack", "e\
xit"])
if "left" in action and "jump" in action:
delayed_print_words("""You leap to the left as your face sma\
shes against the wall.""")
room_3_left()
elif "right" in action and "jump" in action:
delayed_print_words("""You leap to the right.""")
room_3_left()
elif "help" in action:
available_commands()
elif "left" in action:
delayed_print_words("""You walk into the wall.""")
room_3_left()
elif "right" in action:
delayed_print_words("""You walk off in the direction of the \
town.\nAfter a long walk you finally enter the town.""")
room_3_town()
elif "jump" in action:
delayed_print_words("""You leap high into the air and land b\
ack where you leaped from.""")
room_3_left()
elif "attack" in action:
delayed_print_words("""You swing your sword out in front of \
you.""")
room_3_left()
else:
exit_to_title()
def room_3_town():
global current_room
current_room = "room_3_town"
delayed_print_words("""You are in a small town with unlit street\
lamps scattered about.\nLooking at all the houses you notice only o\
ne has light shining from within.""")
action = valid_input("What would you like to do?", ["jump"and"le\
ft", "jump"and"right", "help", "left", "right", "jump", "attack", "ex\
it", "go into", "enter", "house"])
if "left" in action and "jump" in action:
delayed_print_words("""You leap to the left.""")
room_3_left()
elif "right" in action and "jump" in action:
delayed_print_words("""You leap to the right.""")
room_3_left()
elif "help" in action:
available_commands()
elif "left" in action:
delayed_print_words("""You walk off in the direction of the \
cliff.\nAfter a long walk you finally reach the cliffside.""")
room_3_left()
elif "right" in action:
delayed_print_words("""You walk off to the right.\nAfter a l\
ong walk you see a large opened iron gateway.""")
room_3_right()
elif "jump" in action:
delayed_print_words("""You leap high into the air and land b\
ack where you leaped from.""")
room_3_town()
elif "attack" in action:
delayed_print_words("""You swing your sword out in front of \
you.""")
room_3_town()
elif "enter" in action or "go into" in action or "house" in action:
delayed_print_words("""You go up to the one house with its l\
ights on.\nYou go to check the door and notice it is unlocked.\nYou \
open the door and go into the house.""")
npc_house()
else:
exit_to_title()
def npc_house():
global npc_house_npc_killed
global player_dmg
global current_room
current_room = "npc_house"
if not npc_house_npc_killed:
delayed_print_words("""You are standing inside a small house\
with swords and armor hanging on the walls.\nTo the right you see a\
n old man sitting in a chair.""")
action = valid_input("What would you like to do?", ["jump\
"and"left", "jump"and"right", "help", "left", "right", "jump", "attac\
k", "exit", "talk", "speak"])
if "left" in action and "jump" in action:
delayed_print_words("""You leap to the left hitting your\
head on the ceiling of the house.""")
npc_house()
elif "right" in action and "jump" in action:
delayed_print_words("""You leap to the right hitting you\
r head on the ceiling of the house.""")
npc_house()
elif "help" in action:
available_commands()
elif "left" in action:
delayed_print_words("""You walk out the door of the hous\
e.""")
room_3_town()
elif "right" in action:
delayed_print_words("""You walk to the right of the hous\
e.""")
npc_house()
elif "jump" in action:
delayed_print_words("""You leap into the air hitting you\
r head on the ceiling of the house.""")
room_3_town()
elif "attack" in action:
delayed_print_words("""You swing your sword out at the o\
ld man, decapitating him.\nHis lifeless body falls to the ground.""")
npc_house_npc_killed = True
npc_house()
elif "talk" in action and player_dmg == 1 or "speak\
" in action and player_dmg == 1:
delayed_print_words("""You go up to the old man, as he s\
ees you, he says\n\"Why hello there fella, haven’t seen many people \
around here in a while.\nThat monster has come by and killed all but\
me.\nI see you’ve got yourself a sword there\nYou wouldn’t happen t\
o be going to slay that terrible beast, would ya?\nHmm the silent ty\
pe ay.\nWell if you are, he stays at the edge of town, his lair lies\
behind a large iron gateway...\nOr so i have been told, i haven’t l\
eft my house in years.\nBack when i was younger i was a quite the fi\
erce warrior, but now im just an old man.\nHere take this sword with\
ya, its much sharper than your own.\nShould help you make short wor\
k of the beast!\"""")
player_dmg = 1.5
npc_house()
elif "talk" in action or "speak" in action:
delayed_print_words("""You go up to the old man, he look\
s up and says to you\n\"I’m afraid i have nothing left to give ya.\n\
Once that beast has been slain you are welcome to live here in the t\
own.\nPlenty of places for you to choose from since he’s killed ever\
yone other than me.\"""")
npc_house()
else:
exit_to_title()
else:
delayed_print_words("""You are standing inside a small house\
with swords and armor hanging on the walls.\nTo the right you see t\
he decapitated corpse of an old man laying on the floor.""")
action = valid_input("What would you like to do?", ["jump\
"and"left", "jump"and"right", "help", "left", "right", "jump", "attac\
k", "exit"])
if "left" in action and "jump" in action:
delayed_print_words("""You leap to the left hitting your\
head on the ceiling of the house.""")
npc_house()
elif "right" in action and "jump" in action:
delayed_print_words("""You leap to the right hitting you\
r head on the ceiling of the house.""")
npc_house()
elif "help" in action:
available_commands()
elif "left" in action:
delayed_print_words("""You walk out the door of the hous\
e.""")
room_3_town()
elif "right" in action:
delayed_print_words("""You walk to the right of the hous\
e.""")
npc_house()
elif "jump" in action:
delayed_print_words("""You leap into the air hitting you\
r head on the ceiling of the house.""")
room_3_town()