-
Notifications
You must be signed in to change notification settings - Fork 1
/
main_1.3.19.py
1921 lines (1786 loc) · 129 KB
/
main_1.3.19.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
#! python3
# text_games
# version 1.3.19
# description: improved command prompts, power up
# imports
import random
# functions
def locale(current_room):
print('You are ' + world[current_room]['prefix'] + ' ' + world[current_room]['name'] + world[current_room]['name2'] + '.')
print(world[current_room]['desc'])
if room in special_rooms:
do_special(room)
show_things(current_room)
show_creatures(current_room)
def look_around(current_room):
print('You are ' + world[current_room]['prefix'] + ' ' + world[current_room]['name'] + world[current_room]['name2'] + '.')
print(world[current_room]['desc'])
show_exits(current_room)
show_things(current_room)
show_creatures(current_room)
def examine_item(current_room):
global inventory_quantity
global room_has_items
global room_has_mobs
global target
update_things_in_room(current_room)
if target in available_targets(current_room):
for thing in things:
if thing['name'].lower() == target.lower():
print(thing['description'])
return
if room_has_mobs:
for mob in creatures:
if mob['room'] == current_room and mob['name'].lower() == target:
if mob['is_dead'] == True:
print(mob['dead_description'])
else:
print(
mob['description'] + '\n' + mob['name'] + ' ' + creature_wellness(mob['current_hp'], mob['max_hp']),
end='')
if mob['is_hostile'] == False:
print(' ' + mob['status_neutral'])
else:
print(' ' + mob['status_hostile'])
return
if room_has_items or inventory_quantity > 0 or room_has_mobs:
available_choices = []
print('Things you can examine:')
if room_has_mobs:
for mob in creatures:
if mob['room'] == current_room:
print(mob['name'].capitalize())
available_choices.append(mob['name'].lower())
if room_has_items:
for thing in things:
if (thing['location'] == current_room and thing['on_person'] == False):
print(thing['name'].capitalize())
available_choices.append(thing['name'].lower())
if inventory_quantity > 0:
for thing in things:
if (thing['on_person'] == True):
print(thing['name'].capitalize())
available_choices.append(thing['name'].lower())
print('What do you want to examine? (type the name or press ENTER for none)')
choice = input('Examine: ').lower()
if choice == '':
return
while choice not in available_choices:
print('That\'s not a valid choice. Try again.')
print('What do you want to examine? (type the name or press ENTER for none)')
choice = input('Examine: ').lower()
if choice == '':
return
for thing in things:
if thing['name'].lower() == choice:
print(thing['description'])
for mob in creatures:
if mob['name'].lower() == choice:
if mob['is_dead'] == True:
print(mob['dead_description'])
else:
print(
mob['description'] + '\n' + mob['name'] + ' ' + creature_wellness(mob['current_hp'], mob['max_hp']),
end='')
if mob['is_hostile'] == False:
print(' ' + mob['status_neutral'])
else:
print(' ' + mob['status_hostile'])
# old code below
# print(
# mob['description'] + '\n' + mob['name'] + ' ' + creature_wellness(mob['current_hp'], mob['max_hp']),
# end='')
# if mob['is_dead'] == True:
# print()
# elif mob['is_hostile'] == False:
# print(' ' + mob['status_neutral'])
# else:
# print(' ' + mob['status_hostile'])
else:
print('There isn\'t anything to examine here. Go find something!')
def creature_wellness(current, max):
percentage = current / max * 100
if percentage > 75:
return "is in good shape." + " (" + str(current) + "\\" + str(max) + ")"
elif percentage > 50:
return "appears to be in some pain." + " (" + str(current) + "\\" + str(max) + ")"
elif percentage > 25:
return "is hurting but still dangerous." + " (" + str(current) + "\\" + str(max) + ")"
elif percentage > 0:
return "is seriously wounded." + " (" + str(current) + "\\" + str(max) + ")"
else:
return "is dead."
def show_creatures(current_room):
global room_has_mobs
room_has_mobs = False
for mob in creatures:
if mob['room'] == current_room:
if mob['is_dead'] == False:
if mob['is_hostile'] == False:
print(mob['name'] + ' is here. ' + mob['status_neutral'])
else:
print(mob['name'] + ' is here. ' + mob['status_hostile'])
# current HP print for debug
#print('DEBUG - Mob Current HP: ' + str(mob['current_hp']))
if mob['was_seen'] == False:
print( mob['description'] + '\n' )
mob['was_seen'] = True
else:
print(mob['name'] + ' is here, but it\'s dead.')
room_has_mobs = True
def show_things(current_room):
global room_has_items
visible_items = 0
for thing in things:
if (thing['location'] == current_room and thing['on_person'] == False):
visible_items = visible_items + 1
room_has_items = True
if visible_items == 0:
print('You don\'t see anything special.')
room_has_items = False
else:
print('Visible items:')
for thing in things:
if (thing['location'] == current_room and thing['on_person'] == False):
print(thing['prefix'].capitalize() + ' ' + thing['name'])
def update_things_in_room(current_room):
global room_has_items
global room_has_mobs
visible_items = 0
for thing in things:
if (thing['location'] == current_room and thing['on_person'] == False):
visible_items = visible_items + 1
room_has_items = True
if room_has_mobs:
for mob in creatures:
if (mob['room'] == current_room and mob['name'].lower() == target):
visible_items = visible_items + 1
room_has_items = True
if visible_items == 0:
room_has_items = False
def show_inventory(quantity):
if quantity > 0:
print('You are carrying:')
for thing in things:
if thing['on_person'] == True:
print(thing['prefix'].capitalize() + ' ' + thing['name'])
else:
print('You aren\'t carrying anything.')
def take_item(current_room):
global inventory_quantity
global room_has_items
global target
update_things_in_room(current_room)
if room_has_items:
available_choices = []
for thing in things:
if (thing['location'] == current_room and thing['on_person'] == False):
available_choices.append(thing['name'].lower())
for thing in things:
if thing['name'].lower() == target.lower():
if thing['moveable'] == True:
thing['on_person'] = True
inventory_quantity = inventory_quantity + 1
# old print('You pick up ' + thing['prefix'] + ' ' + thing['name'] + '.')
print('You pick up the ' + thing['name'] + '.')
return
else:
# old print('You can\'t take ' + thing['prefix'] + ' ' + thing['name'] + '.')
print('You can\'t take the ' + thing['name'] + '.')
return
print('Items you see:')
for thing in range(len(available_choices)):
print(available_choices[thing].capitalize())
print('What item do you want to take? (type the item name or press ENTER for none)')
choice = input('Take: ').lower()
if choice == '':
return
while choice not in available_choices:
print('That\'s not a valid choice. Try again.')
print('What item do you want to take? (type the item name or press ENTER for none)')
choice = input('Take: ').lower()
if choice == '':
return
for thing in things:
if thing['name'].lower() == choice:
if thing['moveable'] == True:
thing['on_person'] = True
inventory_quantity = inventory_quantity + 1
print('You pick up the ' + thing['name'] + '.')
# old print('You pick up ' + thing['prefix'] + ' ' + thing['name'] + '.')
else:
print('You can\'t take the ' + thing['name'] + '.')
# old print('You can\'t take ' + thing['prefix'] + ' ' + thing['name'] + '.')
else:
print('There aren\'t any items worth taking.')
def drop_item(current_room):
global inventory_quantity
global target
if inventory_quantity == 0:
print('You aren\'t carrying anything.')
return
update_things_in_room(current_room)
if target != '':
if target in available_targets(current_room):
for thing in things:
if thing['name'].lower() == target.lower():
thing['on_person'] = False
thing['location'] = current_room
user_has_items = True
print('You drop the ' + thing['name'] + '.')
# old print('You drop ' + thing['prefix'] + ' ' + thing['name'] + '.')
inventory_quantity = inventory_quantity - 1
return
else:
print('\"' + target + '\" is not in your inventory.')
if inventory_quantity > 0:
available_choices = []
print('Items you are carrying:')
for thing in things:
if (thing['on_person'] == True):
print(thing['name'].capitalize())
available_choices.append(thing['name'].lower())
print('What item do you want to drop? (type the item name or press ENTER for none)')
choice = input('Drop: ').lower()
if choice == '':
return
while choice not in available_choices:
print('That\'s not a valid choice. Try again.')
print('What item do you want to drop? (type the item name or press ENTER for none)')
choice = input('Drop: ').lower()
if choice == '':
return
for thing in things:
if thing['name'].lower() == choice:
thing['on_person'] = False
thing['location'] = current_room
user_has_items = True
print('You drop the ' + thing['name'] + '.')
# old print('You drop ' + thing['prefix'] + ' ' + thing['name'] + '.')
inventory_quantity = inventory_quantity - 1
else:
print('You aren\'t carrying anything.')
def use_item(current_room):
global inventory_quantity
global room_has_items
global target
update_things_in_room(current_room)
if target != '':
if target in available_targets(current_room):
if weapon_checker(target) == True:
pick_up_if_weapon(target)
if attack_checker(current_room):
check_event(current_room, target)
player_attack(current_room, target)
else:
check_event(current_room, target)
else:
check_event(current_room, target)
creature_attack(current_room)
return
else:
print('\"' + target + '\" is not available to use.')
if room_has_items or inventory_quantity > 0:
available_choices = []
print('Items you can use:')
if room_has_items:
for thing in things:
if (thing['location'] == current_room and thing['on_person'] == False):
print(thing['name'].capitalize())
available_choices.append(thing['name'].lower())
if inventory_quantity > 0:
for thing in things:
if (thing['on_person'] == True):
print(thing['name'].capitalize())
available_choices.append(thing['name'].lower())
print('What item do you want to use? (type the item name or press ENTER for none)')
choice = input('Use: ').lower()
if choice == '':
return
while choice not in available_choices:
print('That\'s not a valid choice. Try again.')
print('What item do you want to use? (type the item name or press ENTER for none)')
choice = input('Use: ').lower()
if choice == '':
return
if weapon_checker(choice) == True:
pick_up_if_weapon(choice)
if attack_checker(current_room):
check_event(current_room, choice)
player_attack(current_room, choice)
else:
check_event(current_room, choice)
else:
check_event(current_room, choice)
creature_attack(current_room)
else:
print('There isn\'t anything you can use here.')
def attack_checker(current_room):
global room_has_mobs
if room_has_mobs:
for mob in creatures:
if mob['room'] == current_room and mob['is_dead'] == False:
if mob['is_hostile'] == False:
print('Do you want to attack ' + mob['name'] + '? This will make it hostile towards you.')
fight = input('Enter \'Y\' or \'Yes\': ')
if fight.lower() == 'y' or fight.lower() == 'yes':
return True
else:
return False
else:
return True ## assumes once mob is hostile that player wants to fight it
def player_attack(current_room, weapon):
global room_has_mobs
if room_has_mobs:
for mob in creatures:
if mob['room'] == current_room and mob['is_dead'] == False:
for thing in things:
if thing['name'].lower() == weapon and thing['is_weapon'] == False:
return
mob['is_hostile'] = True
if current_room in special_rooms:
do_special(current_room)
if (random.randrange(1, 100) + thing['hit_bonus']) > 50:
damage = thing['base_damage'] + random.randrange(1, thing['damage'])
print('It hits ' + mob['name'] + ' for ' + str(damage) + ' damage.')
mob['current_hp'] = mob['current_hp'] - damage
if mob['current_hp'] <= 0:
print('That was a fatal blow.')
mob['is_dead'] = True
else:
miss = random.randrange(1, 10)
if miss < 6:
print('It misses ' + mob['name'] + '.')
elif miss < 9:
print(mob['name'] + ' dodges the attack.')
else:
print('The attack glances off ' + mob['name'] + '.')
print(mob['name'] + ' ' + creature_wellness(mob['current_hp'], mob['max_hp']) )
if mob['is_dead'] == True:
if mob['death_event'] != 0:
do_event(mob['death_event'], current_room)
return
else:
print('')
return
def creature_attack(current_room):
global room_has_mobs
global player_hp
if room_has_mobs:
for mob in creatures:
if mob['room'] == current_room and mob['is_dead'] == False and mob['is_hostile'] == True:
if (mob['is_fatigued'] == False and mob['attack_chance'] >= random.randrange(1, 100)):
print(mob['name'] + ' attacks!')
mob['is_fatigued'] = True
if (random.randrange(1, 100) + mob['hit_bonus']) > 50:
damage = 10 + random.randrange(1, mob['damage'])
print('It hits you for ' + str(damage) + ' damage.')
player_hp = player_hp - damage
if player_hp <= 0:
print('That was a fatal blow.')
else:
miss = random.randrange(1, 10)
if miss < 6:
print('It misses you.')
elif miss < 9:
print('You dodge the attack.')
else:
print('The attack glances off you.')
else:
hostile_posture = random.randrange(1, 3)
if hostile_posture == 1:
print(mob['name'] + ' gives you a hateful stare.')
elif hostile_posture == 2:
print(mob['name'] + ' catches its breath.')
else:
print(mob['name'] + ' readies for combat.')
player_wellness(player_hp, 100)
def creature_follow(current_room, new_room):
global room_has_mobs
global player_hp
global exit_room
if new_room == exit_room:
return
if room_has_mobs:
for mob in creatures:
if mob['room'] == current_room and mob['is_dead'] == False and mob['is_hostile'] == True:
mob['room'] = new_room
print(mob['name'] + ' follows you.')
def remove_creature_fatigue(current_room):
global room_has_mobs
if room_has_mobs:
for mob in creatures:
if mob['room'] == current_room and mob['is_dead'] == False and mob['is_hostile'] == True:
mob['is_fatigued'] = False
def player_wellness(current, max):
percentage = current / max * 100
if percentage > 75:
print("You are in good shape. (" + str(current) + "\\" + str(max) + ')')
elif percentage > 50:
print("You are in some pain. (" + str(current) + "\\" + str(max) + ')')
elif percentage > 25:
print("You are hurting but still able to fight. (" + str(current) + "\\" + str(max) + ')')
elif percentage > 0:
print("You are seriously wounded. (" + str(current) + "\\" + str(max) + ')')
else:
print("You are dead.")
def weapon_checker(item):
global inventory_quantity
for thing in things:
if thing['name'].lower() == item:
if thing['is_weapon'] == True:
return True
else:
return False
def pick_up_if_weapon(item):
global inventory_quantity
for thing in things:
if thing['name'].lower() == item and thing['is_weapon'] == True:
if thing['on_person'] == True:
return
thing['on_person'] = True
inventory_quantity = inventory_quantity + 1
print('You pick up the ' + thing['name'] + '.')
def available_targets(current_room):
global inventory_quantity
global room_has_items
global target
update_things_in_room(current_room)
if room_has_items or inventory_quantity > 0:
available_choices = []
if room_has_items:
for thing in things:
if (thing['location'] == current_room and thing['on_person'] == False):
available_choices.append(thing['name'].lower())
if inventory_quantity > 0:
for thing in things:
if (thing['on_person'] == True):
available_choices.append(thing['name'].lower())
return available_choices
def check_event(current_room, used_item):
# print('DEBUG: checking what happens when using ' + used_item + ' in room # ' + str(current_room))
# print(events)
for event in events:
if (event['room'] == current_room and event['item_name'].lower() == used_item):
if event['done'] == False:
do_event(event['id'], current_room)
return
else:
print(event['already_done_text'])
return
# problem if item can be used in 999 and in specific room - solution? make event index of specific room event lower than event index of any room 999? or have specific room inserted before 999?
if (event['room'] == 999 and event['item_name'].lower() == used_item):
if event['done'] == False:
do_event(event['id'], current_room)
return
else:
print(event['already_done_text'])
return
print('Nothing happened. Maybe try somewhere else? Or try when another item is near?')
def do_event(event_id, current_room):
global inventory_quantity
global game_choice
global player_hp
if game_choice == '1':
# simple event: print text only
# mona lisa wink, ball in house x 3, ride trike, ball everywhere besides house, post, machine, broken well
if event_id in [0, 1, 4, 8, 9, 10, 12, 13, 14, 15, 16]:
print(events[event_id]['first_time_text'])
events[event_id]['done'] = True
# create room event template
# plant tree
if event_id in [2]:
print(events[event_id]['first_time_text'])
events[event_id]['done'] = True
# new room
world[7]['visible'] = True
# updated connecting room description - BE CAREFUL TO BUILD ON PREVIOUS DESCRIPTION
world[4][
'desc'] = 'The grassy clearing at the end of the road is accented by a few tall trees. A new tree in the center has low, inviting branches. Part of the grass is bare along the southern edge, and it contains a strange etching of a house and a winged creature. The street is at the north end of the park, a trail leads through the trees to the west, and a meadow is to the east.'
# updated connecting room exits - BE CAREFUL TO INCLUDE PREVIOUS EXITS
world[4]['exits'] = {'n': 3, 'u': 7, 'e': 10, 'w': 11}
# find item and modify description
item_index = ['tree kit' in i['name'] for i in things].index(True)
things[item_index][
'description'] = 'The empty tree kit box claims: \'Makes a real life tree in seconds! No digging required. For best results, use in an open area.\''
# create portal
if event_id in [7]:
# birdhouse is prerequisite - if 'birdhouse' required because using robin in yard only has effect if birdhouse has been created
if 'birdhouse' in str(things):
print(events[event_id]['first_time_text'])
events[event_id]['done'] = True
# new room
world[5]['visible'] = True
# updated connecting room description - BE CAREFUL TO BUILD ON PREVIOUS DESCRIPTION
world[4][
'desc'] = 'The grassy clearing at the end of the road is dappled with light shining through the tall trees. A new tree in the center has low, inviting branches. Where the grass was worn to the south, you now see a brightly glowing portal! The street is at the north end of the park, a trail leads through the trees to the west, and a meadow is to the east.'
# updated connecting room exits - BE CAREFUL TO INCLUDE PREVIOUS EXITS
world[4]['exits'] = {'n': 3, 'u': 7, 's': 5}
delete_thing('robin')
# removing this since delete_thing adjusts inventory inventory_quantity = inventory_quantity - 1
else:
print('Nothing happened.')
# unlock gate
if event_id in [20]:
print(events[event_id]['first_time_text'])
events[event_id]['done'] = True
# new room
world[13]['visible'] = True
# updated connecting room description - BE CAREFUL TO BUILD ON PREVIOUS DESCRIPTION
world[12][
'desc'] = 'This gentle valley is surrounded by leafy trees and bushes. A path is visible to the west. To the north you see an open iron gate, beyond which lies the mouth of a cave.'
# updated connecting room exits - BE CAREFUL TO INCLUDE PREVIOUS EXITS
world[12]['exits'] = {'e': 11, 'n': 13}
# create thing event template
# remove bird from egg
if event_id in [3]:
print(events[event_id]['first_time_text'])
events[event_id]['done'] = True
# create new object - LOCATION CAN BE ANY IF ON_PERSON IS TRUE OTHERWISE MATCH LOCATION TO EVENT ROOM
things.append({'name': 'robin', 'prefix': 'a',
'description': 'Its feathers are matted down by egg goo, and the baby bird is struggling to open its tiny eyes. It would be gross if it weren\'t so darn cute.',
'location': 7, 'on_person': True, 'moveable': True, 'is_weapon': False})
inventory_quantity = inventory_quantity + 1 ## add to inventory if appending thing on_person == True
things.append({'name': 'egg shell', 'prefix': 'an',
'description': 'There\'s little to do with the broken egg shell shards.', 'location': 7,
'on_person': False, 'moveable': True, 'is_weapon': False})
delete_thing('egg')
# reveal basement
if event_id in [5]:
print(events[event_id]['first_time_text'])
events[event_id]['done'] = True
# create new object - LOCATION CAN BE ANY IF ON_PERSON IS TRUE OTHERWISE MATCH LOCATION TO EVENT ROOM
things.append({'name': 'toy house', 'prefix': 'a',
'description': 'This miniature colonial appears to be worn from play. You can imagine dolls going in and out of the doors and windows.',
'location': 6, 'on_person': False, 'moveable': True, 'is_weapon': False})
# make birdhouse
if event_id in [6]:
print(events[event_id]['first_time_text'])
events[event_id]['done'] = True
# create new object - LOCATION CAN BE ANY IF ON_PERSON IS TRUE OTHERWISE MATCH LOCATION TO EVENT ROOM
things.append({'name': 'birdhouse', 'prefix': 'a',
'description': 'The toy house resting atop the post will surely attract small, avian creatures.',
'location': 1, 'on_person': False, 'moveable': False, 'is_weapon': False})
delete_thing('toy house')
# make flashlight
if event_id in [11]:
print(events[event_id]['first_time_text'])
events[event_id]['done'] = True
# create new object - LOCATION CAN BE ANY IF ON_PERSON IS TRUE OTHERWISE MATCH LOCATION TO EVENT ROOM
things.append({'name': 'flashlight', 'prefix': 'a',
'description': 'It\'s your standard issue flashlight. Looks like it could help you see in dark places, but it wouldn\'t do much elsewhere.',
'location': 9, 'on_person': False, 'moveable': True, 'is_weapon': False})
delete_thing('coin')
# make functional well
if event_id in [17]:
print(events[event_id]['first_time_text'])
events[event_id]['done'] = True
# create new object - LOCATION CAN BE ANY IF ON_PERSON IS TRUE OTHERWISE MATCH LOCATION TO EVENT ROOM
things.append({'name': 'well', 'prefix': 'the',
'description': 'The well is still old, but now you can raise and lower the bucket.',
'location': 10, 'on_person': False, 'moveable': False, 'is_weapon': False})
delete_thing('broken well')
delete_thing('bucket')
# make key
if event_id in [18]:
print(events[event_id]['first_time_text'])
events[event_id]['done'] = True
# create new object - LOCATION CAN BE ANY IF ON_PERSON IS TRUE OTHERWISE MATCH LOCATION TO EVENT ROOM
things.append({'name': 'key', 'prefix': 'a',
'description': 'The brass key is partially covered in moss. It feels heavy.', 'location': 10,
'on_person': False, 'moveable': True, 'is_weapon': False})
# drop pebble
if event_id in [19]:
print(events[event_id]['first_time_text'])
events[event_id]['done'] = True
delete_thing('pebble')
elif game_choice == '2':
if event_id in [0]:
print(events[event_id]['first_time_text'])
events[event_id]['done'] = True
if event_id in [1]:
print(events[event_id]['first_time_text'])
events[event_id]['done'] = True
player_hp = player_hp + 50
if player_hp > 100:
player_hp = 100
### player_wellness(player_hp, 100) removing this because it can be redundant
# create new object - LOCATION CAN BE ANY IF ON_PERSON IS TRUE OTHERWISE MATCH LOCATION TO EVENT ROOM
things.append({'name': 'empty bottle', 'prefix': 'an',
'description': 'Staring at the empty elixir bottle fills you with longing.', 'location': 1,
'on_person': True, 'moveable': True, 'is_weapon': False})
inventory_quantity = inventory_quantity + 1 ## add to inventory if appending thing on_person == True
delete_thing('elixir')
elif game_choice == '3':
global launch_code
# simple event: print text only, put weapons in here
if event_id in [0, 5, 6, 7, 10, 14, 16, 18, 19, 22, 27, 36, 37, 38]:
print(events[event_id]['first_time_text'])
events[event_id]['done'] = True
# use stimpack
if event_id in [1]:
print(events[event_id]['first_time_text'])
events[event_id]['done'] = True
player_hp = player_hp + 30
if player_hp > 100:
player_hp = 100
things.append({'name': 'empty stimpack', 'prefix': 'an',
'description': 'The hollow tube of the used stimpack is of little use now.', 'location': current_room,
'on_person': True, 'moveable': True, 'is_weapon': False})
inventory_quantity = inventory_quantity + 1 ## add to inventory if appending thing on_person == True
delete_thing('stimpack')
# unlock detention elevator
if event_id in [2]:
print(events[event_id]['first_time_text'])
events[event_id]['done'] = True
# new room
world[5]['visible'] = True
# updated connecting room description - BE CAREFUL TO BUILD ON PREVIOUS DESCRIPTION
world[4][
'desc'] = 'The elevator goes up to the Main Deck. The detention hallway is to the east.'
# updated connecting room exits - BE CAREFUL TO INCLUDE PREVIOUS EXITS
world[4]['exits'] = {'e': 1, 'u': 5}
delete_thing('keycard')
# detention key card drops from guard upon death
if event_id in [3]:
print(events[event_id]['first_time_text'])
events[event_id]['done'] = True
# create new object - LOCATION CAN BE ANY IF ON_PERSON IS TRUE OTHERWISE MATCH LOCATION TO EVENT ROOM OR USE current_room VARIABLE
things.append({'name': 'keycard', 'prefix': 'a',
'description': 'This sleek card reads, "Detention Elevator." Emblazoned under the text is an image of a box with an arrow inside it.',
'location': current_room, 'on_person': False, 'moveable': True, 'is_weapon': False})
# using breathing mask
if event_id in [4]:
print(events[event_id]['first_time_text'])
#events[event_id]['done'] = True always do the first time text then add to inventory if not already there
for thing in things:
if thing['name'].lower() == 'breathing mask':
if thing['on_person'] == True:
return
thing['on_person'] = True
inventory_quantity = inventory_quantity + 1
#print('You pick up the ' + thing['name'] + '.') first_time_text implies item is picked up
# create empty fuel cell and quarters keycard
if event_id in [8]:
print(events[event_id]['first_time_text'])
events[event_id]['done'] = True
delete_thing('fuel cell')
delete_thing('corpse')
things.append({'name': 'empty fuel cell', 'prefix': 'an',
'description': 'The spent fuel cell has nothing inside it.', 'location': 10,
'on_person': True, 'moveable': True, 'is_weapon': False})
inventory_quantity = inventory_quantity + 1 ## add to inventory if appending thing on_person == True
# create new object - LOCATION CAN BE ANY IF ON_PERSON IS TRUE OTHERWISE MATCH LOCATION TO EVENT ROOM
things.append({'name': 'quarters keycard', 'prefix': 'a',
'description': 'After wiping it clean, you see this keycard has the words \'Crew Quarters\' printed on it.',
'location': 10, 'on_person': False, 'moveable': True, 'is_weapon': False})
# unlock quarters elevator
if event_id in [9]:
print(events[event_id]['first_time_text'])
events[event_id]['done'] = True
# new room
world[28]['visible'] = True
# updated connecting room description - BE CAREFUL TO BUILD ON PREVIOUS DESCRIPTION
world[13][
'desc'] = 'The elevator goes down to Crew Quarters. To the east is a widening hallway.'
# updated connecting room exits - BE CAREFUL TO INCLUDE PREVIOUS EXITS
world[13]['exits'] = {'e': 12, 'd': 28}
delete_thing('quarters keycard')
# unlock mess elevator
if event_id in [11]:
print(events[event_id]['first_time_text'])
events[event_id]['done'] = True
# new room
world[35]['visible'] = True
# updated connecting room description - BE CAREFUL TO BUILD ON PREVIOUS DESCRIPTION
world[34][
'desc'] = 'This elevator goes down to the Mess Hall and Medical Services Deck. The observation deck is to the north.'
# updated connecting room exits - BE CAREFUL TO INCLUDE PREVIOUS EXITS
world[34]['exits'] = {'d': 35, 'n': 32}
delete_thing('mess keycard')
# detention key card drops from guard upon death
if event_id in [12]:
print(events[event_id]['first_time_text'])
events[event_id]['done'] = True
# create new object - LOCATION CAN BE ANY IF ON_PERSON IS TRUE OTHERWISE MATCH LOCATION TO EVENT ROOM OR USE current_room VARIABLE
things.append({'name': 'mess keycard', 'prefix': 'a',
'description': 'This worn card reads, "Mess & Medical Elevator." Emblazoned under the text is an image of a box with an arrow inside it.',
'location': current_room, 'on_person': False, 'moveable': True, 'is_weapon': False})
if event_id in [13]:
print(events[event_id]['first_time_text'])
events[event_id]['done'] = True
# create new object - LOCATION CAN BE ANY IF ON_PERSON IS TRUE OTHERWISE MATCH LOCATION TO EVENT ROOM
things.append({'name': 'soldier eye', 'prefix': 'a',
'description': 'You don\'t feel great about how you got it, but the eyeball is pretty cool.',
'location': 39, 'on_person': True, 'moveable': True, 'is_weapon': False})
inventory_quantity = inventory_quantity + 1 ## add to inventory if appending thing on_person == True
# replace existing soldier with a modified version
delete_thing('fallen soldier')
things.append({'name': 'fallen soldier', 'prefix': 'a',
'description': 'This dead crewmate is bent backwards, leaning on the countertop. They have the insignia and fatigues of a tactical combat specialist. '
'Unlike the other bodies you encountered, this one seems frozen in shock, face up with one eye and mouth wide open.',
'location': 39, 'on_person': False, 'moveable': False, 'is_weapon': False, 'damage': 0, 'hit_bonus': 0})
# use large stimpack
if event_id in [15]:
print(events[event_id]['first_time_text'])
events[event_id]['done'] = True
player_hp = player_hp + 90
if player_hp > 100:
player_hp = 100
things.append({'name': 'empty large stimpack', 'prefix': 'an',
'description': 'There\'s not much to do with the large stimpack now that it is drained.', 'location': current_room,
'on_person': True, 'moveable': True, 'is_weapon': False})
inventory_quantity = inventory_quantity + 1 ## add to inventory if appending thing on_person == True
delete_thing('large stimpack')
# unlock armory elevator
if event_id in [17]:
print(events[event_id]['first_time_text'])
events[event_id]['done'] = True
# new room
world[23]['visible'] = True
# updated connecting room description - BE CAREFUL TO BUILD ON PREVIOUS DESCRIPTION
world[11][
'desc'] = 'The elevator goes down to the Armory. The wide hallway is to the north.'
# updated connecting room exits - BE CAREFUL TO INCLUDE PREVIOUS EXITS
world[11]['exits'] = {'n': 10, 'd': 23}
events[38]['done'] = False
# unlock bridge elevator
if event_id in [20]:
print(events[event_id]['first_time_text'])
events[event_id]['done'] = True
# new room
world[42]['visible'] = True
# updated connecting room description - BE CAREFUL TO BUILD ON PREVIOUS DESCRIPTION
world[33][
'desc'] = 'The elevator goes up to the Bridge. To the south is the observation deck.'
# updated connecting room exits - BE CAREFUL TO INCLUDE PREVIOUS EXITS
world[33]['exits'] = {'s': 32, 'u': 42}
delete_thing('bridge keycard')
# detention key card drops from guard upon death
if event_id in [21]:
print(events[event_id]['first_time_text'])
events[event_id]['done'] = True
# create new object - LOCATION CAN BE ANY IF ON_PERSON IS TRUE OTHERWISE MATCH LOCATION TO EVENT ROOM OR USE current_room VARIABLE
things.append({'name': 'bridge keycard', 'prefix': 'a',
'description': 'This dark gray card has no words on it, but when held at a certain angle, a stylized bridge materialzes. Below the bridge image you can see a box with an arrow inside it.',
'location': current_room, 'on_person': False, 'moveable': True, 'is_weapon': False})
# use wound salve
if event_id in [23]:
print(events[event_id]['first_time_text'])
events[event_id]['done'] = True
player_hp = player_hp + 35
if player_hp > 100:
player_hp = 100
things.append({'name': 'used wound salve', 'prefix': 'a',
'description': 'The wound salve jar is empty. What a shame.', 'location': current_room,
'on_person': True, 'moveable': True, 'is_weapon': False})
inventory_quantity = inventory_quantity + 1 ## add to inventory if appending thing on_person == True
delete_thing('wound salve')
# use hot sauce on hulking guard
if event_id in [24]:
if creature_in_same_room(current_room, 2):
print(events[event_id]['first_time_text'])
events[event_id]['done'] = True
creatures[2]['current_hp'] = int(creatures[2]['current_hp'] * 0.75)
delete_thing('hot sauce')
else:
print('Nothing happened. Maybe try somewhere else? Or try when another item is near?')
# use mayonnaise on hulking guard
if event_id in [25]:
if creature_in_same_room(current_room, 2):
print(events[event_id]['first_time_text'])
events[event_id]['done'] = True
creatures[2]['current_hp'] = int(creatures[2]['current_hp'] * 0.75)
delete_thing('mayonnaise')
else:
print('Nothing happened. Maybe try somewhere else? Or try when another item is near?')
# use pear powder on hulking guard
if event_id in [26]:
if creature_in_same_room(current_room, 2):
print(events[event_id]['first_time_text'])
events[event_id]['done'] = True
creatures[2]['current_hp'] = int(creatures[2]['current_hp'] * 0.75)
delete_thing('pear powder')
else:
print('Nothing happened. Maybe try somewhere else? Or try when another item is near?')
# assemble override lever from 3 parts
if event_id in [28, 29, 30]:
necessary_parts = 0
for thing in things:
if thing['name'] == 'allen claw' and ( thing['location'] == current_room or thing['on_person'] == True ):
necessary_parts += 1
if thing['name'] == 'smooth bar' and ( thing['location'] == current_room or thing['on_person'] == True ):
necessary_parts += 1
if thing['name'] == 'gummy grip' and ( thing['location'] == current_room or thing['on_person'] == True ):
necessary_parts += 1
if necessary_parts == 3:
things.append({'name': 'override lever', 'prefix': 'the',
'description': 'This majestic implement is full of potential. A genuine lever of power.',
'location': current_room, 'on_person': True, 'moveable': True, 'is_weapon': False})
inventory_quantity = inventory_quantity + 1 ## add to inventory if appending thing on_person == True
delete_thing('allen claw')
delete_thing('smooth bar')
delete_thing('gummy grip')
print(events[event_id]['first_time_text'])
else:
print('Nothing happened. Maybe try somewhere else? Or try when another item is near?')
# open bridge door
if event_id in [31]:
print(events[event_id]['first_time_text'])
events[event_id]['done'] = True
# new room
world[44]['visible'] = True
# updated connecting room description - BE CAREFUL TO BUILD ON PREVIOUS DESCRIPTION
world[43][
'desc'] = 'This is the bridge-level security desk. An open door to the bridge is to the west. To the east is the Systems Control room. South is an elevator bay.'
# updated connecting room exits - BE CAREFUL TO INCLUDE PREVIOUS EXITS
world[43]['exits'] = {'w': 44, 'e': 45, 's': 42}
# use escape pod launch code generator
if event_id in [32]:
print(events[event_id]['first_time_text'])
events[event_id]['done'] = True
launch_code = str(random.randrange(0, 9)) + str(random.randrange(0, 9)) + 'L07A' + str(random.randrange(0, 9)) + str(random.randrange(0, 9))
print('It reads: ' + launch_code)
# activate hangar elevator
if event_id in [33]:
print(events[event_id]['first_time_text'])
events[event_id]['done'] = True
# new room
world[19]['visible'] = True
# updated connecting room description - BE CAREFUL TO BUILD ON PREVIOUS DESCRIPTION
world[9][
'desc'] = 'The elevator goes down to the Hangar. To the south is the walkway.'
# updated connecting room exits - BE CAREFUL TO INCLUDE PREVIOUS EXITS
world[9]['exits'] = {'s': 8, 'd': 19}
# remove old console create new one
delete_thing('lockdown console')
things.append({'name': 'lockdown console', 'prefix': 'the',
'description': 'The lockdown console has a small screen that reads: \n\t"NO LOCKDOWN - Offline systems: none"'
'\nThere is an empty lever socket just below the screen.',
'location': 45, 'on_person': False, 'moveable': False, 'is_weapon': False, 'damage': 0, 'hit_bonus': 0})
# use escape pod launch controls
if event_id in [34]:
print(events[event_id]['first_time_text'])
code_checker()
# use escape pod launch console
if event_id in [35]:
print(events[event_id]['first_time_text'])
code_checker()
# apply phaser booster
if event_id in[39]:
print(events[event_id]['first_time_text'])
delete_thing('phaser')
delete_thing('phaser booster')
things.append({'name': 'phaser', 'prefix': 'a',
'description': 'The V-8 phaser pistol is a reliable mid- to close-range weapon, especially now that it is BOOSTED.',
'location': 999, 'on_person': True, 'moveable': True, 'is_weapon': True, 'base_damage': 25, 'damage': 30, 'hit_bonus': 45})
inventory_quantity = inventory_quantity + 1 ## add to inventory if appending thing on_person == True
# use stimpack
if event_id in [40]:
print(events[event_id]['first_time_text'])
events[event_id]['done'] = True
player_hp = player_hp + 60
if player_hp > 100:
player_hp = 100
things.append({'name': 'empty medium stimpack', 'prefix': 'an',
'description': 'The medium stimpack served its purpose.', 'location': current_room,
'on_person': True, 'moveable': True, 'is_weapon': False})
inventory_quantity = inventory_quantity + 1 ## add to inventory if appending thing on_person == True
delete_thing('medium stimpack')
# checks if correct launch code is entered
def code_checker( ):
global launch_code
global room
entered_code = input('Enter launch code: ')
if room == 22 and entered_code.lower() == launch_code.lower():
print('The console beeps happily. The screen reads: "LAUNCH SEQUENCE INITIATED"')
room = 99
else:
print('The screen replies: INVALID LAUNCH CODE')
# function to check if certain creature is in same room as player
def creature_in_same_room( current_room, id):
if creatures[id]['is_dead'] == False and creatures[id]['room'] == current_room:
return True
else:
return False
def do_special(current_room):
global player_hp
global special_done
# print('game_choice: ', game_choice)
if game_choice == '3':
# bad air damage in any room outside of detention level if breathing mask not in inventory
if current_room >= 5:
for thing in things:
# print('thing name: ', thing['name'].lower())
if thing['name'].lower() == 'breathing mask':