-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame.py
1158 lines (1070 loc) · 45.4 KB
/
game.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
logo = """ ` ``
./:------...` `-/ ..........` ....... `..... `-:::-.` `.----.` ....... ......`....... .----.` ..
`+yNNNdyssyhddy/. `/hNN- /yNNNdyydmdo. :yNNNy- `ommhs/` .ymmyssdmy` `/sdho++oydy+. :smmmo: :smmo-`/ymmmo/ `/hds+oymh-
.MMM: `:hMMms` `hMMMd` .NMMo``.yMMm. :MMM- .yNd/. `hMM+` .sy` /dMm/` `/mMmo` .NMM. `dh` /MMd` +MMo`` `/d:
`MMN. `yMMMs :NhNMMs` `NMMo +MMM- :MMM.`+mm+` ``` `dMMd/` `` :NMM/ -dMMy``NMM. `hy :MMd` +MMm/. `
`````````.MMM. ``.```:NMMN-.-dh:sMMN/```.-NMMy//omMms.`` :MMMhdMd:``` ``` ` -dNMMmy+-.`yMMN-````````.oMMM:-NMM-```.```.dy.```/MMd.```` ```.smMMmho:...``````
````````.NMM- ```` `.mMMN..hMhyyNMMm-``..NMMdsmMMm:``` :MMMsdMNy:``. ` `:ohNMMNo.sMMN-`````````+MMM/.NMM-`````` .my` `/MMd`` ` ````.+ymMMNy.````
`mMM. -NMN+`sN+:::/NMMy` `NMMs`-hMMh- :MMM-`+mMNs.. ./ `-sMMN--mMMo` `hMMh``mMM: .No /MMd` ` :` `/mMM/
`mMM: `./mMd/`+Ms /MMM+ .NMMs `sNMm/` :MMM- .sNMmo. `yNo. `mMN- :mMMo. .sMNy. oNMd- .ym- /MMm` -h:+Ns. +MM+
`+sNMMmsooshdds/./sNN/` -mNNmo/sNNNd: :ymmy:` -sNNNo` `oNNNdo-` `/mNms//smy- .+dmho++oshds:` /hNmhoooyhs- ./hNNNs+//+odN/-yNds//odmo`
`:::::::::--.` `--:--` .------------ `.--` .-----` .------. .:////:. `.-:///:.` .:///:-` .-------------` -:///:-`
\n""" + ' '* 80 + 'T E X T R P G \n\n'
bonfire = """ O
'
[
}
|
========= (
|#| (
|#| ((/
|#|((((((
|((/((//(((
,(((((((*((((
((((/((((**(((
. ((((((/(****((((((
(( (((((*******((((((( /
(((((((*****.*****((((((((/
/(((*((*****....****(((((((
(((**/*****......*****((( """
you_died = """ .'......................................................................................................................................................................'.
..'......................................................................................................................................................................'.
... ... ... ... .... .. ........ .... ........... .......
... .. .. .. .... .. ... .... ... ... .. ... .....
... .. .. .. .. .. .. ... .. .. .. ...
... .. ... ... .. .. .. ... .. .. ... ..
.... .. .. .. .. .. .. .. ......... ... ...
.. ... .. .. .. .. .. .. ... .. .. ...
.. ... ... .. .. .. ... .. .. .. ..
.. .. .. ... .. .. ... .. .. .. .. ...
.... ... ... ... .. .......... .... ............ .........
.... ..... .... ...... .... ........... .......
... ..
.'......................................................................................................................................................................''. """
victory = """ ,,,, ,,, ,,, ,;;;,, ,,,,,,,,,, ,;;;, ,,,,, ,, ,, ,;;;, ,,, ,,, ,,, ,,,,,,,,,,, ,,,,,,,,,,,,,,,,,,
,cxl, ,lo;,ld: ,:lc::codlllclxoclo: :lcccccc; cxo:ldc,,cxo, :dc, ,l: ,clc::cod::dl, ,od; cdc ;dxccl:,cxl, ,lo;,lxl:lc,cxo:cloo:,
,xx; ;oc ok: ld: ,cc,, :ko ,,lxc, ,ld: :ko ,dO: ,lkl ;ol, :kd, ,oo; ;l;:kl dk;.ckl ,dx; ,, ,xx; ;oc lkc.,, ckl ;lkd,
:ko cl, ok::xc :ko :ko ,ox;;kd, lk: lxc;oc ;lldl lx; , :ko,,,,;dk;.ckl ,dk; ,, :ko cl, lOc ,, ckl cOo
,dk: :l; ok:lk: :ko cOl ckc;kx:coc lkxc, co:ox;,dx, :Oxccccckk;.cOl ,dOlco: ,dk: :l; lOdcoc ckl ;kx,
;kd;lc ok:lOc :ko cOo ckc;kklxkc ,xk; .;oo:lko,dO: :kl dk;.cOl ,dk; ;, :kd;lc lOc ,; ckl ;xd,
lOxl, ok:;kk: ,, :ko ,ok: ,dd,;ko ,lkc ,dx; ,lo, lkc:Ox; ;,:kl dk;.cOl ,dk; lOxl, lOc ckl , ,lx:
,dk;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'''.';.:l;'';:cdOo. .. .,,. .,'.cc.....,',xNMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNOc;...'' ... ...,c,'..cc,coo:. .... ..'..:; .,:lodKWMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMKk0x' .. .. ....,,....,',lc. . .. . .'. ..'ldx0NWWMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNOdc. . .. ..... . ... ,:. .,lkKXWMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWd. . .. ...... .lc .lXMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMO. .. ...'''.. .:dd,.. .. cXMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMN: .';'. .''...... .:x00x; .;. ':::c' ..dWMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMk. . .... ...'... .;:oxo,.,,',lKWNNk.,Oc;0MMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMWO;.';'. ......... .. ':cc:;,..;KMMWddNO:kMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMWk;....,. .';;'. ..,;,.. .',;c:..cXMMNNMNOKMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMWo....'. 'c. ... .. .,,..... .. ...,;''kMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMXko,. 'c;. ;0Xc ....;cclc;....... .,:c,. ..:XMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMXkkd,..'l:;ll:' ....,'.',;:cc::;'. .clcldllKMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMWKkxl',dc. .;l:.:kxololcoo;;;. . .lo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,'',,'::.'l,..;dKWMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMWWWNNNNKKK00Oxool; . .. .. . .. .. ....''..,l0WMMMMMMMMMMMMMMMMM"""
from os import system, name
from random import randint
global_loot = {
#all possible inventory objects dict
'fist' : {
'name': 'fist',
'class': 'weapon',
'power': 24,
'prot': 17,
'distance': 0.5,
'info': 'convenient to use when you have no weapons',
},
'prison key' : {
'name': 'prison room key',
'class': 'key',
'info': 'key that opens your prison room you have been locked in',
},
'asylum arena key': {
'name': 'asylum arena key',
'class': 'key',
'info': 'key which can be taken from asylum demon',
},
'balders knight sword' : {
'class': 'weapon',
'name': 'balders knight weapon',
'power': 75,
'prot': 23,
'distance': 0.8,
'info': 'sword taken from balder undead knight'
},
'balders knight armor' : {
'class': 'armor',
'name': 'balders knight armor',
'prot': 45,
'info': 'armor taken from balder undead knight',
},
'wooden magic stick' : {
'class': 'weapon',
'name': 'wooden magic stick',
'power': 30,
'prot': 13,
'distance': 2,
'info': 'wooden stick which mostly use roving magicians'
},
"poor magician's dress" : {
'class': 'armor',
'name': "poor magician's dress",
'prot': 21,
'info': 'dress with sewn holes'
},
'underpants' : {
'class': 'armor',
'name': "underpants",
'prot': 12,
'info': "doesn't protect anything but the most important"
},
'broken sword':{
'class' : 'weapon',
'name' : 'broken rusty sword',
'prot' : 9,
'power' : 45,
'distance' : 0.65,
'info' : 'broken undeads sword rusted by time'
},
'tower shield':{
'class' : 'weapon',
'name' : 'tower shield',
'prot' : 43,
'power' : 23,
'distance' : 0.5,
'info' : 'black tower shield mostly used by undead soldiers'
},
'undead soldiers armor':{
'class' : 'armor',
'name' : 'undead soldier`s armor',
'prot' : 40,
'info' : 'armor set taken from neutralized undead'
},
'astorian knights shield': {
'class' : 'weapon',
'name' : 'tower shield',
'prot' : 43,
'power' : 23,
'distance' : 0.5,
'info' : 'black tower shield mostly used by undead soldiers'
}
}
classes = [
# used to create a hero in newgame start
{
'name' : '',
'class' : 'knight',
'info' : 'very powerfull',
'start-inv' : 'knight sword and armor',
'health' : 100,
'power' : 100,
'luck' : 0.8,
'sword' : global_loot['balders knight sword'],
'armor' : global_loot['balders knight armor'],
'shield' : global_loot['fist'],
'inventory' : [
global_loot['underpants'],
global_loot['balders knight sword'],
global_loot['balders knight armor'],
],
}, {
'name' : '',
'class' : 'magician',
'info' : 'long distance fight',
'start-inv' : 'magic stick and dress',
'health' : 50,
'power' : 100,
'luck' : 1,
'sword' : global_loot['wooden magic stick'],
'armor' : global_loot["poor magician's dress"],
'shield' : global_loot['fist'],
'inventory' : [
global_loot['underpants'],
global_loot['wooden magic stick'],
global_loot["poor magician's dress"],
],
}, {
'name' : '',
'class' : 'poor',
'info' : 'ultra lucky',
'start-inv' : 'nothing',
'health' : 120,
'power' : 100,
'luck' : 1.6,
'sword' : global_loot['fist'],
'armor' : global_loot['underpants'],
'shield' : global_loot['fist'],
'inventory' : [
global_loot['underpants'],
],
}
]
hero = {
'name' : 'Jordan',
'class' : 'knight',
'info' : 'very powerfull',
'start-inv' : 'knight sword and armor',
'health' : 100,
'init_heal' : 100,
'estus' : None,
'power' : 100,
'luck' : 0.8,
'sword' : global_loot['balders knight sword'],
'armor' : global_loot['balders knight armor'],
'shield' : global_loot['fist'],
'inventory' : [
global_loot['underpants'],
global_loot['balders knight sword'],
global_loot['balders knight armor'],
],
}
enemies = {
'room corridor': {},
'asylum demon': {
'name': 'asylum demon',
'health': 425,
'init_heal' : 425,
},
'corridor archer': {
'name': 'corridor archer',
'health': 30,
'init_heal' : 30,
},
'steel ball undead': {
'name': 'corridor archer',
'health': 50,
'init_heal' : 50,
},
'third floor undeads': {
'name': 'third floor undeads',
'health': 80,
'init_heal' : 80,
}
}
opened_doors = []
alive_enemies = [el for el in enemies.keys()]
current_map = 'prison'
curr_location = None
prev_location = None
last_fire = 'prison room'
def enemy_rebirth():
global hero, alive_enemies, enemies, last_fire
clear()
last_fire = curr_location
if hero['estus']:
hero['estus'] = 1
hero['health'] = hero['init_heal']
alive_enemies = [el for el in enemies.keys()]
line = "Y O U H A V E T A K E N A R E S T"
print('\n' * 10)
print('__' * 87 + '\n')
print(' ' * (87 - len(line) // 2) + line + '\n')
line = 'ENEMIES RESURRECT AFTER TAKING REST'
print(' ' * (87 - len(line) // 2) + line )
print('__' * 87 + '\n')
enter_to_continue()
def enemy_stat(enemy):
name_low = enemy['name']
name = ''
for char in name_low:
name += char + ' '
print('\n' + " " * 68 + " " * (19 - len(name)//2) + name.upper())
health_bar = '■' * int(42 * enemy['health'] / enemy['init_heal']) + ' ' * int(42 - 42 * enemy['health'] / enemy['init_heal'])
print('\n' + " "*58 + "-------|" + health_bar.upper() + "|------- \n")
def boss_defeat():
clear()
print('\n' * 7)
print(victory)
enter_to_continue()
def drop(*items):
"""random drop after killing an enemy
hero dict and items dicts which can be dropped
{'name': 'broken sword', 'poss': 25}
the less possibility the more chance to get the object
"""
global hero
for item in items:
name = item['name']
obj = global_loot[name]
if obj in hero['inventory']: # in case if the drop object is already in inventory
continue
possibility = item['poss']
luck = hero['luck']
if randint(0,100) * luck >= possibility:
hero['inventory'].append(obj)
message('you`ve got ' + name + '!')
return hero
def move(enemy, poss, type):
"""enemy_obj, possibility, type(attack or dodge).
possibility is here for poss. of taking damage.
the less possib. the more chance to succeed."""
global hero
sword = hero['sword']
num = randint(1,100) * hero['luck']
if type == 'attack' or type == 'Attack':
num = num * sword['distance']
if num >= poss:
num = int(num)
enemy['health'] -= num
return f"This attack was successfull, you have taken {num} from enemy's health"
else:
armor = hero['armor']
damage = (100 - armor['prot']) / 100
num = int(damage * num)
hero['health'] -= num
return f"That wasn't a successfull move, you are taking {num} amounts of dammage"
else:
shield = hero['shield']
if shield == global_loot['fist']:
# hero can protect itself with weapon instad of fist
shield = sword
num = num * shield['prot'] / 50
if num >= poss:
num = num * sword['distance']
num = int(num)
enemy['health'] -= num
return f"your dodge was successfull, you have taken {num} from enemy's health"
else:
num = num * (100 - shield['prot']) / 100
num = int(num)
hero['health'] -= num
return f"You couldn't successfully dodge, you are taking {num} amounts of dammage"
def hero_creator():
global hero
clear()
hero_obj = {}
location_print('select your class')
params = ['class', 'health', 'luck', 'info']
length = [15, 10, 10, 35]
table(params, length, classes)
user_choice = input("\n" + " " * 83 + ">| ")
if user_choice == '0':
return main_menu()
elif user_choice not in [str(index + 1) for index in range(len(classes))]:
alert('wrong input')
return hero_creator()
hero_obj = classes[int(user_choice) - 1]
hero_obj['init_heal'] = hero_obj['health']
hero_obj['estus'] = None
location_print('enter your name')
hero_name = input("\n" + " " * 67 + ">| ")
if len(hero_name) > 15:
new_name = ''
for i in range(13):
new_name += hero_name[i]
hero_name = new_name + '...'
hero_obj['name'] = hero_name
hero = hero_obj
def clear():
# for windows
if name == 'nt':
system('cls')
# for mac and linux(here, os.name is 'posix')
else:
system('clear')
def enter_to_continue():
print(' ' * 66 + '-' * 42 + '\n' + " " * 76 + "press Enter to continue")
input()
clear() # clearing the console
def show_status():
global hero
# one line display of hero status
health_bar = '■ ' * int(hero['health'] // 10) + '□ ' * int((hero['init_heal'] - hero['health']) // 10)
if hero['health'] % 10 >= 5:
health_bar = '■ ' + health_bar
elif hero['health'] % 10 >=1:
health_bar = health_bar + '□ '
health_bar = '+ ' + health_bar
#sword and armor
shield = hero['shield']
if hero['shield'] == global_loot['fist']:
shield = hero['sword']
tools = ' X ' + str(hero['sword']['power']) + ' # ' + str(hero['armor']['prot']) + ' [] ' + str(shield['prot'])
if hero['estus'] != None:
tools += ' * ' + str(hero['estus'])
print(' ' * 47 + '~ ' + hero['name'] + ' ' + health_bar + ' ' * (76 - len(hero['name'] + health_bar + tools)) + tools)
def situation(text):
print(' ' * 47 + '-' * 80 + '\n') # newline
arr = text.split()
line = ''
for word in arr:
if len(line + word) <= 76:
line += word + " "
else:
print(" " * 45 + '| ' + line + ' ' * (77 - len(line)) +' |')
line = word + " "
print(" "*45 + '| ' + line + ' ' * (77 - len(line)) +' |')
print('\n' + ' ' * 47 + '-' * 80)
def message(msg):
clear()
text = ''
for char in msg:
text += char + ' '
print('\n' * 10)
print(' ' * 47 + '-' * 80 + '\n')
line = " "*(38 - len(text) // 2) + text.upper() + " "*(38 - len(text) // 2 + len(text) % 2)
print(" "*45 + '| ' + line + ' ' * (77 - len(line)) +' |')
print('\n' + ' ' * 47 + '-' * 80)
enter_to_continue()
def location_print(name):
long_name = ''
for char in name:
long_name += char + ' '
print('\n' + " "*58 + "-------| " + " "*(19 - len(long_name)//2) + long_name.upper() + " "*(19 - len(long_name)//2) + " |------- \n")
def alert(message):
clear()
text = ''
for char in message: #making spaces between characters in sentence
text += char + ' '
print('\n' * 10)
print(" "*58 + ">> !! >> " + "█" + " "*(19 - len(text)//2) + text.upper() + " "*(19 - len(text)//2) + "█" + " << !! << ")
print(" "*68 + "_"*39)
enter_to_continue()
def table(params, percentage, arr):
""" params = ['name', 'info'],
params length percentage = [25, 40],
actual array = [{'name': 'prison room key', 'info': 'opens your prison room'}] """
line = ''
left_space_amount = 62
underline = "_"
for i in range(len(percentage)): # printing header line
space = round(75 * percentage[i]/100)
left_space_amount -= (space - len(params[i]))//2
line += params[i].upper() + " " * (space - len(params[i])) + " | "
underline += '_' * (space + 3)
line = ' ' * (left_space_amount + 8) + "| " + line
underline = ' ' * (left_space_amount + 8) + underline
print(line + "\n" + underline + "\n")
for index in range(len(arr)): #printing body
obj = arr[index]
line = ' ' * left_space_amount + f"<| {index + 1} |> " + '| '
for i in range(len(percentage)):
param = params[i]
space = round(75 * percentage[i]/100)
line += str(obj[param]) + " " * (space - len(str(obj[param]))) + " | "
print(line + f"<| { index + 1 } |>" +"\n" + underline + "\n")
print("\n" + " "*58 + "<| 0 |> " + "-" + " "*(20 - len('EXIT')//2) + 'EXIT' + " "*(20 - len('exit')//2) + "-" + " <| 0 |> ")
print(" "*67 + "_"*40 + '\n')
#locations functions
def tool_change(tool):
global hero
new_arr = []
params = []
length = []
clear()
show_status()
situation(f"Chose the {tool} you want to change to")
for el in hero['inventory']:
if (tool == 'shield' or tool == 'sword') and el['class'] == 'weapon':
new_arr.append(el)
elif tool == 'armor' and el['class'] == 'armor':
new_arr.append(el)
if tool == 'shield' or tool == 'sword':
params = ['i', 'name', 'prot', 'power', 'info']
length = [5, 30, 10, 10, 70]
for el in new_arr:
if el['power'] >= el['prot']:
# if its a sword
el['i'] = ' X '
else:
# if its a shield
el['i'] = ' [] '
else:
params = ['i', 'name', 'prot', 'info']
length = [5, 30, 10, 70]
for el in new_arr:
el['i'] = ' # '
table(params, length, new_arr)
chs = input("\n" + " " * 67 + ">| ")
if chs in [str(el + 1) for el in range(len(new_arr))]:
chs = int(chs)
hero[tool] = new_arr[chs - 1]
elif chs == '0':
pass
else:
alert('wrong input')
return tool_change(tool)
def inventory():
global hero
while True:
clear()
show_status()
situation("Chose parameter you want to change")
params = ['i', 'parameter', 'current status']
length = [5, 30, 20]
options = [
{'i': ' X ', 'parameter': 'sword', 'current status': hero['sword']['power']},
{'i': ' # ', 'parameter': 'armor', 'current status': hero['armor']['prot']}
]
if hero['shield'] == global_loot['fist']:
options.append({'i': ' [] ', 'parameter': 'shield', 'current status': hero['sword']['prot']})
else:
options.append({'i': ' [] ', 'parameter': 'shield', 'current status': hero['shield']['prot']})
table(params, length, options)
chs = input("\n" + " " * 67 + ">| ")
if chs == '1':
tool_change('sword')
elif chs == '2':
tool_change('armor')
elif chs == '3':
tool_change('shield')
elif chs == '0':
break
else:
alert('wrong input')
continue
def death():
global curr_location, hero, last_fire
clear()
print('\n' * 7)
print(you_died)
enter_to_continue()
for enemy in enemies:
enemy['health'] = enemy['init_heal']
alive_enemies = [el for el in enemies.keys()]
curr_location = last_fire
hero['health'] = hero['init_heal']
return load_location()
def set_location(loc):
global curr_location, prev_location
if loc != curr_location:
prev_location = curr_location
curr_location = loc
location_print(loc)
def load_location():
clear()
if curr_location == 'prison room':
return prison_room()
elif curr_location == 'room corridor':
return room_corridor()
elif curr_location == 'central fire':
return central_fire()
elif curr_location == 'central arena':
return central_arena()
elif curr_location == 'side corridor':
return side_corridor()
elif curr_location == 'second floor':
return second_floor()
elif curr_location == 'third floor':
return third_floor()
elif curr_location == 'platform':
return platform()
else:
alert("no games found")
def take_rest():
global alive_enemies, enemies, curr_location, last_fire
alive_enemies = [el for el in enemies.keys()]
for enemy in enemies:
enemy['health'] = enemy['init_heal']
last_fire = curr_location
enemy_rebirth()
def drink_estus():
global hero
if not hero['estus']:
message('You have no estus left')
return 0
init = hero['init_heal']
if hero['health'] + 40 < init:
hero['health'] += 40
else:
hero['health'] = init
hero['estus'] -= 1
def undead_archer_fight(location, next_location):
global enemies, hero, curr_location
archer = enemies[location]
text = ''
while archer['health'] > 0:
if hero['health'] <= 0:
return death()
clear()
show_status()
enemy_stat(archer)
if text:
situation(text)
options = [
'Rush the enemy',
'Try to dodge',
'Get back',
'Escape',
'Open inventory'
]
if global_loot['astorian knights shield'] not in hero['inventory'] and curr_location == 'side corridor':
# if hero haven't taken shield
options.append('Look to side prison-room')
if hero['estus']:
#if hero returned after taking estus
options.append('Drink estus')
chs = output(options)
if chs == 1:
text = move(archer, 15, 'attack')
elif chs == 2:
text = move(archer, 20, 'dodge')
elif chs == 3:
return load_location()
elif chs == 4:
curr_location = next_location
return load_location()
elif chs == 5:
inventory()
return undead_archer_fight(location, next_location)
elif chs == 6 and global_loot['astorian knights shield'] not in hero['inventory']:
hero = drop({'name': 'astorian knights shield', 'poss': 0})
elif (chs == 6 and hero['estus']) or (chs == 7 and hero['estus']):
drink_estus()
alive_enemies.remove(location)
hero = drop(
{'name': 'broken sword', 'poss': 15},
{'name': 'undead soldiers armor', 'poss': 20},
#{'name': 'tower shield', 'poss': 12}
)
archer['health'] = archer['init_heal']
message('You have eliminated enemy')
def undead_swordsman_fight(location, next_location):
global enemies, hero, curr_location
swordsman = enemies[location]
text = ''
while swordsman['health'] > 0:
if hero['health'] <= 0:
return death()
clear()
show_status()
enemy_stat(swordsman)
if text:
situation(text)
options = [
'Rush the enemy',
'Try to dodge',
'Get back',
'Escape',
'Open inventory'
]
if hero['estus']:
#if hero returned after taking estus
options.append('Drink estus')
chs = output(options)
if chs == 1:
text = move(swordsman, 15, 'attack')
elif chs == 2:
text = move(swordsman, 20, 'dodge')
elif chs == 3:
return load_location()
elif chs == 4:
curr_location = next_location
return load_location()
elif chs == 5:
inventory()
return undead_swordsman_fight(location, next_location)
elif chs == 6 and hero['estus']:
drink_estus()
else:
alert('wrong input')
return undead_swordsman_fight()
alive_enemies.remove(location)
hero = drop(
{'name': 'broken sword', 'poss': 15},
{'name': 'undead soldiers armor', 'poss': 20},
{'name': 'tower shield', 'poss': 12}
)
swordsman['health'] = swordsman['init_heal']
message('You have eliminated enemy')
def asydemon_fight():
global enemies
boss = enemies['asylum demon']
text = ''
while boss['health'] > 0:
if hero['health'] <= 0:
return death()
clear()
show_status()
enemy_stat(boss) #show status
if text:
situation(text)
options = [
'Attack the demon',
'Try to dodge',
'Escape to side door',
'Open backside of central doors'
]
if hero['estus']:
options.append('Drink estus')
chs = output(options)
if chs == 1:
text = move(boss, 40, 'attack')
elif chs == 2:
text = move(boss, 25, 'dodge')
elif chs == 3:
return side_corridor()
elif chs == 4:
message('door is closed')
elif hero['estus'] and chs == 5:
drink_estus()
boss_defeat()
key = global_loot['asylum arena key']
hero['inventory'].append(key)
message('you`ve got ' + key['name'] + '!')
enemies['asylum demon'] = None
alive_enemies.remove('asylum demon')
return central_arena()
def platform():
global enemies, hero
clear()
show_status()
set_location('platform')
if enemies['asylum demon']:
situation("You see the asylum demon down there")
options = [
'Jump on demon',
'Wait',
'Get back'
]
chs = output(options)
if chs == 1:
boss = enemies['asylum demon']
boss['health'] -= 100
return asydemon_fight()
elif chs == 2:
message("That wasn't a smart move")
message("The demon takes you and throw to floor")
hero['health'] -= 60
return asydemon_fight()
else:
if 'third floor undeads' not in alive_enemies:
undead_swordsman_fight('third floor undeads', 'second floor')
return second_floor()
else:
situation("You see empty arena")
output(['Get back'])
if chs == 1:
if 'third floor undeads' not in alive_enemies:
undead_swordsman_fight('third floor undeads', 'second floor')
if 'steel ball undead' in alive_enemies:
undead_swordsman_fight('steel ball undead', 'third floor')
return second_floor()
def third_floor():
if 'third floor undeads' not in alive_enemies:
undead_swordsman_fight('third floor undeads', 'platform')
return platform()
def second_floor():
global curr_location, hero
text = ''
while True:
clear()
show_status()
set_location('second floor')
if text:
situation(text)
options = [
'Go upper',
'Go down by stairs',
'Back to side fire',
]
if curr_location in opened_doors:
options.append('Look through giant hole')
if hero['estus']:
options.append('Drink estus')
chs = output(options)
if chs == 1:
if curr_location not in opened_doors:
clear()
show_status()
situation('You hear strange voices coming upper')
options = [
'Rush',
'Get back',
'Jump to side',
]
chs = output(options)
if chs == 1 or chs == 2:
text = "That was a giant steel ball, You couldn't dodge it but it has left a big hole on wall"
hero['health'] -= 50
else:
text = "That was a giant steel ball, You could dodge it and it has left a big hole on wall"
opened_doors.append(curr_location)
else:
if 'steel ball undead' in alive_enemies:
undead_swordsman_fight('steel ball undead', 'third floor')
return third_floor()
else:
return third_floor()
elif chs == 2:
if 'central fire' not in opened_doors:
message('You have opened door to central fire')
opened_doors.append('central fire')
return central_fire()
elif chs == 3:
if 'corridor archer' in alive_enemies:
undead_archer_fight('corridor archer', 'second floor')
return side_corridor()
else:
return side_corridor()
elif curr_location in opened_doors and chs == 4 and not hero['estus']:
clear()
show_status()
situation("You see a wounded knight")
options = [
"Attack him",
'Talk to knight',
'Leave',
]
chs = output(options)
if chs == 1:
hero['estus'] = 2
text = 'You have killed the knight and got estus, estus restores your health'
elif chs == 2:
hero['estus'] = 2
text = ' - I am an astorian knight im damaged so I cant move, take this estus, estus restores your health'
elif chs == 3:
continue
elif curr_location in opened_doors and chs == 4:
text = 'The knight lies wounding on ground'
elif chs == 5:
drink_estus()
else:
alert('wrong input')
return load_location()
def side_corridor():
clear()
show_status()
set_location('side corridor')
print(bonfire)
options = [
'Take a rest',
'Go further by corridor',
'Return to central arena',
'Open inventory',
]
chs = output(options)
if chs == 1:
take_rest()
return side_corridor()
elif chs == 2:
if 'corridor archer' in alive_enemies:
undead_archer_fight('corridor archer', 'second floor')
return second_floor()
else:
return second_floor()
elif chs == 3:
return central_arena()
elif chs == 4:
inventory()
return side_corridor()
def central_arena():
clear()
set_location('central arena')
if enemies['asylum demon']:
message("here it come flying from the sky")
print(asylum_demon)
enter_to_continue()
return asydemon_fight()
else:
clear()
show_status()
situation('Empty arena')
options = [
'Go to side door',
'Open backside of central doors',
"Back to central fire"
]
chs = output(options)
if chs == 1:
return side_corridor()
elif chs == 2:
message("You see a giant crow which takes you away")
message("Thank you for playing")
return main_menu()
else:
return central_fire()
def central_fire():
clear()
show_status()
set_location('central fire')
print(bonfire)
options = [
'take a rest',
'go to side door',
'go through central gates',
'go to prison corridor',
'open inventory'
]
user_chose = output(options)
if user_chose == 1:
take_rest()
return central_fire()
elif user_chose == 2:
if curr_location in opened_doors:
return second_floor()
else:
message('door cant be opened from this side')
return central_fire()
elif user_chose == 3:
central_arena()
elif user_chose == 4:
return room_corridor()
elif user_chose == 5:
inventory()
return central_fire()