-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcraftext.py
More file actions
1089 lines (798 loc) · 39.6 KB
/
Copy pathcraftext.py
File metadata and controls
1089 lines (798 loc) · 39.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import time
from textwrap import wrap
from random import randint
# CrafText - Text based crafting simulator
# region # Variables -
qty_added = 0
type_added = 0
bag_empty = True
# Game States -
game_running = True
game_main_menu = True
game_win = False
game_chop = False
game_mine = False
game_craft = False
game_smelt = False
wood_pick_f_c = False
stone_pick_f_c = False
iron_pick_f_c = False
wood_axe_f_c = False
stone_axe_f_c = False
# Box Ascii -
top_bot = "═"
sides = "║"
top_left = "╔"
top_right = "╗"
bot_left = "╚"
bot_right = "╝"
# endregion # End Variables
# region # Items Dictionary / Control Lists -
# Player Items Dictionary -
plr_inv = {"Logs": 0,
"Planks": 0,
"Sticks": 0,
"Stone": 0,
"Coal": 0,
"Iron Ore": 0,
"Iron Ingot": 0,
"Gold": 0,
"Wooden Pickaxe": 0,
"Stone Pickaxe": 0,
"Iron Pickaxe": 0,
"Wooden Axe": 0,
"Stone Axe": 0,
"Gold Statue": 0}
# Control Lists -
ctrs_list = ["Controls / Player Choices",
" ",
"[Quit] - Closes the game",
"[Controls] - Open this menu (Controls / Player Choices)",
"[Chop] - Chop down a tree.",
"[Mine] - Mine rock with chance to find stone or minerals.",
"[Craft] - Open crafting menu.",
"[Smelt] - Open smelting menu.",
"[Bag] - See what items you have."
]
craft_ctrs_list = ["Craft/Smelt Options",
"",
"[Quit] - Closes the game",
"[None] - Closes crafting/smelt menu",
"[Item Name] - type the name of the item you wish to craft/smelt, eg. [Wooden Pickaxe]"
]
# endregion # End Dict/Lists
# region # Game Functions -
# Center text - with 100 padding
def print_c_str(text, padding=100, char_fill=" "):
text = text.center(padding, char_fill)
print(text)
# Center text - with 100 padding and new line
def print_c_str_nl(text, padding=100, char_fill=" "):
text = text.center(padding, char_fill)
print(text)
print()
# Print line of text in a dynamic box
def print_in_box(text: str):
str_len = (len(text))
print_c_str(f"{top_left}{top_bot*(str_len+2)}{top_right}")
print_c_str(f"║ {text:^{str_len}} ║")
print_c_str_nl(f"{bot_left}{top_bot*(str_len+2)}{bot_right}")
# Control Menu - with dynamic box around
def ctrs_menu(ctr_list, width):
print_c_str(f"{top_left}{top_bot*(width+2)}{top_right}")
for ctrs in ctr_list:
print_c_str(f"║ {ctrs:^{width}} ║")
print_c_str_nl(f"{bot_left}{top_bot*(width+2)}{bot_right}")
# Find longest str in list
def max_char_in_list(list):
max_str_len = 0
for itm in list:
if len(itm) > max_str_len:
max_str_len = len(itm)
return max_str_len
# Quit Game - Text w box around, 5 second sleep before window closes.
def quit_game():
print_in_box("Thank you for playing!")
time.sleep(5)
exit()
# endregion # End Functions
# region # Main Game Loop -
while game_running:
# Main Menu Loop -
if game_main_menu:
print_in_box("Welcome To CrafText")
ctrs_menu(ctrs_list, (max_char_in_list(ctrs_list)))
print()
while game_main_menu:
game_timer = time.time()
print_c_str_nl(
"Type [Start] to start a new game, [Quit] to exit: ")
player_input = input()
if player_input.lower() == "quit":
quit_game()
# Game Intro -
elif player_input.lower() == "start":
if game_win:
plr_inv = dict.fromkeys(plr_inv, 0)
game_win = False
print_c_str(f"{top_left}{top_bot*98}{top_right}")
for line in wrap("Ahead of you, a peaceful river meanders through the valley, its clear waters reflecting the soft glow of the sky. The banks are lined with tall, sturdy trees, creating a quiet rhythm with every whisper of wind. In the distance, mountains pierce the sky with snow-capped peaks, while their lower slopes are covered in a blanket of pine trees.", width=96):
print(f"║ {line.center(96)} ║")
print_c_str_nl(f"{bot_left}{top_bot*98}{bot_right}")
print_c_str_nl(
"Your pockets feel empty, and you only have the clothes on your back. What do you choose to do?")
player_input = input()
game_main_menu = False
else:
print_in_box("Answer Invalid, Try again!")
# Quit Game -
if player_input.lower() == "quit":
quit_game()
# Open Controls Menu -
elif player_input.lower() == "controls":
ctrs_menu(ctrs_list, max_char_in_list(ctrs_list))
# Open Bag -
elif player_input.lower() == "bag":
print_c_str(f"{top_left}{top_bot*22}{top_right}")
if any(plr_inv.values()):
for itm, qty in plr_inv.items():
if qty > 0:
print_c_str(f"║ {itm:15}: {qty:3} ║")
else:
print_c_str(f"║{'Your Bag is Empty.':^22}║")
print_c_str_nl(f"{bot_left}{top_bot*22}{bot_right}")
# Wood Chop -
elif player_input.lower() == "chop":
game_chop = True
# Chop w Stone Axe
if game_chop:
while plr_inv.get("Stone Axe") >= 1:
print_c_str_nl(
"Would you like to use your Stone Axe? (Yes/No): ")
player_input = input()
if player_input.lower() == "quit":
quit_game()
elif player_input.lower() == "yes":
if stone_axe_f_c:
print_in_box(
"This new Axe is sure to fell a tree in no time!")
stone_axe_f_c = False
game_chop = False
qty_added = randint(2, 3)
plr_inv["Logs"] += qty_added
print_in_box(
f"You used your Stone Axe to chop down a tree got {qty_added} Logs.")
print_in_box(f"You now have {plr_inv.get('Logs')} Logs.")
break
elif player_input.lower() == "no":
break
else:
print_in_box("Answer MUST be either Yes or No, Try Again!")
# Chop w Wooden Axe
if game_chop:
while plr_inv.get("Wooden Axe") >= 1:
print_c_str_nl(
"Would you like to use your Wooden Axe? (Yes/No): ")
player_input = input()
if player_input.lower() == "quit":
quit_game()
elif player_input.lower() == "yes":
if wood_axe_f_c:
print_in_box(
"It will chop down a tree, won't it? Save my hands from punching a tree at least...")
wood_axe_f_c = False
game_chop = False
qty_added = randint(1, 2)
plr_inv["Logs"] += qty_added
print_in_box(
f"You used your Wooden Axe to chop down a small tree and gained {qty_added} Logs.")
print_in_box(f"You now have {plr_inv.get('Logs')} Logs.")
break
elif player_input.lower() == "no":
game_chop = False
qty_added = randint(0, 1)
print_in_box(
"You chose to try to chop a tree without the Axe from your bag... ")
# Failed to get Log w Fist (Have Stone Axe)
if qty_added == 0:
print_in_box(
f"You punched a tree as hard as you could but nothing broke loose.")
print_in_box(
f"You still have {plr_inv.get('Logs')} Logs.")
# Gain Log w Fist (Have Stone Axe)
else:
plr_inv["Logs"] += qty_added
print_in_box(
f"You shook the tree as hard as you could and a branch fell off.")
print_in_box(
f"You now have {plr_inv.get('Logs')} Logs.")
break
else:
print_in_box("Answer MUST be either Yes or No, Try Again!")
# If player doesn't have an Axe
if game_chop:
game_chop = False
qty_added = randint(0, 1)
if qty_added == 0:
print_in_box(
f"You tried to karate chop the tree but, you didn't even make a dent.")
print_in_box(
f"You still have {plr_inv.get('Logs')} Logs and bruised your hand")
else:
plr_inv["Logs"] += qty_added
print_in_box(
f"You found a fallen tree and managed to break off a chunk.")
print_in_box(f"You now have {plr_inv.get('Logs')} Logs.")
# Mine -
elif player_input.lower() == "mine":
game_mine = True
# Mine w Iron Pickaxe -
if game_mine:
while plr_inv.get("Iron Pickaxe") >= 1:
print_c_str_nl(
"Would you like to use your Iron Pickaxe to mine? (Yes/No): ")
player_input = input()
if player_input.lower() == "quit":
quit_game()
elif player_input.lower() == "yes":
game_mine = False
type_added = randint(1, 10)
if iron_pick_f_c:
print_in_box(
"Your new pickaxe carves though rock like butter enabling you to dig deeper and deeper")
iron_pick_f_c = False
# Gain Stone w Iron Pickaxe
if type_added == 1:
qty_added = randint(3, 4)
plr_inv["Stone"] += qty_added
print_in_box(
f"You knocked a chunk of rock loose with your Iron Pickaxe. It was just {qty_added} Stone.")
print_in_box(
f"You now have {plr_inv.get('Stone')} Stone.")
# Gain Coal w Iron Pickaxe
elif 2 <= type_added <= 3:
qty_added = randint(2, 3)
plr_inv["Coal"] += qty_added
print_in_box(
f"You swung the Iron pickaxe against the rock, breaking it into chunks Coal. You found {qty_added} Coal.")
print_in_box(
f"You now have {plr_inv.get('Coal')} Coal.")
# Gain Iron Ore w Iron Pickaxe
elif 4 <= type_added <= 7:
qty_added = randint(1, 2)
plr_inv["Iron Ore"] += qty_added
print_in_box(
f"You hurled your pickaxe at the rock and split a large rock in half revealing {qty_added} Iron Ore.")
print_in_box(
f"You now have {plr_inv.get('Iron Ore')} Iron Ore.")
# Gain Gold w Iron Pickaxe
else:
qty_added = 1
plr_inv["Gold"] += qty_added
print_in_box(
f"After hours down in the mine, you see a sparkle of gold in the corner of your eye. You gained {qty_added} Gold")
print_in_box(
f"You now have {plr_inv.get('Gold')} Gold.")
break
elif player_input.lower() == "no":
break
else:
print_in_box("Answer MUST be either Yes or No, Try Again!")
# Mine w Stone Pickaxe
if game_mine:
while plr_inv.get("Stone Pickaxe") >= 1:
print_c_str_nl(
"Would you like to use your Stone Pickaxe to mine? (Yes/No): ")
player_input = input()
if player_input.lower() == "quit":
quit_game()
elif player_input.lower() == "yes":
if stone_pick_f_c:
print_in_box(
"Your new Stone Pickaxe cuts though the rock easier enabling you to dig deeper into the earth.")
print_in_box(
"You may potentially find better minerals.")
stone_pick_f_c = False
game_mine = False
type_added = randint(1, 10)
# Gain Stone w Stone Pickaxe
if 1 <= type_added <= 3:
qty_added = randint(1, 3)
plr_inv["Stone"] += qty_added
print_in_box(
f"You hit every rock in sight and found nothing but rock. You gained {qty_added} Stone.")
print_in_box(
f"You now have {plr_inv.get('Stone')} Stone.")
# Gain Coal w Stone Pickaxe
elif 4 <= type_added <= 7:
qty_added = randint(1, 2)
plr_inv["Coal"] += qty_added
print_in_box(
f"You found a black rock while mining, It seemed different to other rocks so held onto it for safe keeping.")
print_in_box(
f"You found {qty_added} Coal. You now have {plr_inv.get('Coal')} Coal.")
# Gain Iron Ore w Stone Pickaxe
else:
qty_added = 1
plr_inv["Iron Ore"] += qty_added
print_in_box(
f"After hours of no luck, a small redish silver rock broke off the wall. You gained {qty_added} Iron Ore.")
print_in_box(
f"You now have {plr_inv.get('Iron Ore')} Iron Ore.")
break
elif player_input.lower() == "no":
break
else:
print_in_box("Answer MUST be either Yes or No, Try Again!")
# Mine w Wooden Pickaxe
if game_mine:
while plr_inv.get("Wooden Pickaxe") >= 1:
print_c_str_nl(
"Would you like to use your Wooden Pickaxe to mine? (Yes/No): ")
player_input = input()
if player_input.lower() == "quit":
quit_game()
elif player_input.lower() == "yes":
if wood_pick_f_c:
print_in_box(
"You get your freshly made pickaxe from your bag and head to the mountains for the first time.")
wood_pick_f_c = False
game_mine = False
type_added = randint(1, 10)
# Gain Stone w Wooden Pickaxe
if 1 <= type_added <= 5:
qty_added = 1
plr_inv["Stone"] += qty_added
print_in_box(
f"You hit the same piece of rock over and over again, finally a chunk split off")
print_in_box(
f"You gained {qty_added} Stone, You now have {plr_inv.get('Stone')} Stone.")
# Gain Coal w Wooden Pickaxe
elif type_added == 6:
qty_added = 1
plr_inv["Coal"] += qty_added
print_in_box(
"You found a black rock while mining, It seemed different to other rocks so held onto it for safe keeping.")
print_in_box(
f"You found {qty_added} Coal. You now have {plr_inv.get('Coal')} Coal.")
# Fail w Wooden Pickaxe
else:
print_in_box(
"You swung your Wooden Pickaxe and it bounced back, the rock seemed unfazed.")
print_in_box(
"You found nothing. Better Luck next time.")
break
elif player_input.lower() == "no":
break
else:
print_in_box("Answer MUST be either Yes or No, Try Again!")
# If player does not have/select a Pickaxe
if game_mine:
print_in_box("You require a Pickaxe to mine rocks")
game_mine = False
# Craft -
elif player_input.lower() == "craft":
game_craft = True
if any(plr_inv.values()):
print_c_str(f"{top_left}{top_bot*56}{top_right}")
if plr_inv.get("Logs") >= 1:
print_c_str(f"║{' ':56}║")
print_c_str(f"║ {'1 Log':^25} -> {'2 Planks':^25} ║")
print_c_str(f"║ {'1 Log':^25} -> {'4 Sticks':^25} ║")
if plr_inv.get("Planks") >= 3 and plr_inv.get("Sticks") >= 2:
print_c_str(f"║{' ':56}║")
print_c_str(
f"║ {'2x Sticks, 3x Planks':^25} -> {'1 Wooden Pickaxe':^25} ║")
print_c_str(
f"║ {'2x Sticks, 3x Planks':^25} -> {'1 Wooden Axe':^25} ║")
if plr_inv.get("Stone") >= 3 and plr_inv.get("Sticks") >= 2:
print_c_str(f"║{' ':56}║")
print_c_str(
f"║ {'2x Sticks, 3x Stone':^25} -> {'1 Stone Pickaxe':^25} ║")
print_c_str(
f"║ {'2x Sticks, 3x Stone':^25} -> {'1 Stone Axe':^25} ║")
if plr_inv.get("Iron Ingot") >= 3 and plr_inv.get("Sticks") >= 2:
print_c_str(f"║{' ':56}║")
print_c_str(
f"║ {'2x Sticks, 3x Iron Ingots':^25} -> {'1 Iron Pickaxe':^25} ║")
if plr_inv.get("Gold") >= 5:
print_c_str(f"║{' ':56}║")
print_c_str(
f"║ {'5x Gold':^25} -> {'1 Gold Statue':^25} ║")
print_c_str(f"║{' ':56}║")
print_c_str_nl(f"{bot_left}{top_bot*56}{bot_right}")
else:
print_in_box("You cant craft anything!")
game_craft = False
while game_craft:
print_c_str_nl("What would you like to craft?: ")
player_input = input()
if player_input.lower() == "quit":
quit_game()
elif player_input.lower() == "none":
game_craft = False
break
elif player_input.lower() == "craft controls":
ctrs_menu(craft_ctrs_list, max_char_in_list(craft_ctrs_list))
elif player_input.lower() == "planks":
max_craft = plr_inv.get('Logs')
print_c_str(f"{top_left}{top_bot*40}{top_right}")
print_c_str(
f"║ {'Total Logs':^30} : {plr_inv.get('Logs'):^5} ║")
print_c_str(f"║{' ':^40}║")
print_c_str(f"║{'Planks Recipe:':^40}║")
print_c_str(f"║{' ':^40}║")
print_c_str(f"║{'1x Log -> 2x Planks':^40}║")
print_c_str_nl(f"{bot_left}{top_bot*40}{bot_right}")
while game_craft:
print_c_str_nl(
f"How many logs would you like to use (1 - {max_craft})?: ")
player_input = input()
if not player_input.isdigit():
print_in_box(
f"{player_input} is not a number, please enter a number between 1 and {max_craft}.")
elif 1 <= int(player_input) <= max_craft:
plr_inv["Logs"] -= int(player_input)
plr_inv["Planks"] += (int(player_input)*2)
print_in_box(
f"You crafted {int(player_input)*2} Planks.")
print_in_box(f"You have {plr_inv['Logs']} Logs left.")
game_craft = False
break
else:
print_in_box(
f"{player_input} is not an valid number between 1 and {max_craft}, Try again!")
elif player_input.lower() == "sticks":
max_craft = plr_inv.get('Logs')
print_c_str(f"{top_left}{top_bot*40}{top_right}")
print_c_str(
f"║ {'Total Logs':^30} : {plr_inv.get('Logs'):^5} ║")
print_c_str(f"║{' ':^40}║")
print_c_str(f"║{'Sticks Recipe:':^40}║")
print_c_str(f"║{' ':^40}║")
print_c_str(f"║{'1x Log -> 4x Sticks':^40}║")
print_c_str_nl(f"{bot_left}{top_bot*40}{bot_right}")
while game_craft:
print_c_str_nl(
f"How many logs would you like to use (1 - {max_craft}?): ")
player_input = input()
if not player_input.isdigit():
print_in_box(
f"{player_input} is not a number, please enter a number between 1 and {max_craft}.")
elif 1 <= int(player_input) <= max_craft:
plr_inv["Logs"] -= int(player_input)
plr_inv["Sticks"] += (int(player_input)*4)
print_in_box(
f"You crafted {int(player_input)*4} Sticks.")
print_in_box(f"You have {plr_inv['Logs']} Logs left.")
game_craft = False
break
else:
print_in_box(
f"{player_input} is not an valid number between 1 and {max_craft}, Try again!")
elif player_input.lower() == "wooden pickaxe":
max_craft = min((int(plr_inv.get('Planks')/3)),
(int(plr_inv.get('Sticks')/2)))
print_c_str(f"{top_left}{top_bot*40}{top_right}")
print_c_str(
f"║ {'Total Planks':^30} : {plr_inv.get('Planks'):^5} ║")
print_c_str(
f"║ {'Total Sticks':^30} : {plr_inv.get('Sticks'):^5} ║")
print_c_str(f"║{' ':^40}║")
print_c_str(f"║{'Wooden Pickaxe Recipe:':^40}║")
print_c_str(f"║{' ':^40}║")
print_c_str(
f"║{'2x Sticks, 3x Planks -> Wooden Pickaxe':^40}║")
print_c_str_nl(f"{bot_left}{top_bot*40}{bot_right}")
while game_craft:
print_c_str_nl(
f"How many Wooden Pickaxe would you like to craft (1 - {max_craft})?: ")
player_input = input()
if not player_input.isdigit():
print_in_box(
f"{player_input} is not a number, please enter a number between 1 and {max_craft}.")
elif 1 <= int(player_input) <= max_craft:
plr_inv["Planks"] -= (int(player_input)*3)
plr_inv["Sticks"] -= (int(player_input)*2)
plr_inv["Wooden Pickaxe"] += (int(player_input))
print_in_box(
f"You crafted {int(player_input)} Wooden Pickaxe.")
print_in_box(
f"You have {plr_inv['Planks']} Planks and {plr_inv['Sticks']} Sticks left.")
wood_pick_f_c = True
game_craft = False
break
else:
print_in_box(
f"{player_input} is not an valid number between 1 and {max_craft}, Try again!")
elif player_input.lower() == "wooden axe":
max_craft = min((int(plr_inv.get('Planks')/3)),
(int(plr_inv.get('Sticks')/2)))
print_c_str(f"{top_left}{top_bot*40}{top_right}")
print_c_str(
f"║ {'Total Planks':^30} : {plr_inv.get('Planks'):^5} ║")
print_c_str(
f"║ {'Total Sticks':^30} : {plr_inv.get('Sticks'):^5} ║")
print_c_str(f"║{' ':^40}║")
print_c_str(f"║{'Wooden Axe Recipe:':^40}║")
print_c_str(f"║{' ':^40}║")
print_c_str(
f"║{'2x Sticks, 3x Planks -> Wooden Axe':^40}║")
print_c_str_nl(f"{bot_left}{top_bot*40}{bot_right}")
while game_craft:
print_c_str_nl(
f"How many Wooden Axe would you like to craft (1 - {max_craft})?: ")
player_input = input()
if not player_input.isdigit():
print_in_box(
f"{player_input} is not a number, please enter a number between 1 and {max_craft}.")
elif 1 <= int(player_input) <= max_craft:
plr_inv["Planks"] -= (int(player_input)*3)
plr_inv["Sticks"] -= (int(player_input)*2)
plr_inv["Wooden Axe"] += (int(player_input))
print_in_box(
f"You crafted {int(player_input)} Wooden Axe.")
print_in_box(
f"You have {plr_inv['Planks']} Planks and {plr_inv['Sticks']} Sticks left.")
wood_axe_f_c = True
game_craft = False
break
else:
print_in_box(
f"{player_input} is not an valid number between 1 and {max_craft}, Try again!")
elif player_input.lower() == "stone pickaxe":
max_craft = min((int(plr_inv.get('Stone')/3)),
(int(plr_inv.get('Sticks')/2)))
print_c_str(f"{top_left}{top_bot*40}{top_right}")
print_c_str(
f"║ {'Total Stone':^30} : {plr_inv.get('Stone'):^5} ║")
print_c_str(
f"║ {'Total Sticks':^30} : {plr_inv.get('Sticks'):^5} ║")
print_c_str(f"║{' ':^40}║")
print_c_str(f"║{'Stone Pickaxe Recipe:':^40}║")
print_c_str(f"║{' ':^40}║")
print_c_str(
f"║{'2x Sticks, 3x Stone -> Stone Pickaxe':^40}║")
print_c_str_nl(f"{bot_left}{top_bot*40}{bot_right}")
while game_craft:
print_c_str_nl(
f"How many Stone Pickaxe would you like to craft (1 - {max_craft})?: ")
player_input = input()
if not player_input.isdigit():
print_in_box(
f"{player_input} is not a number, please enter a number between 1 and {max_craft}.")
elif 1 <= int(player_input) <= max_craft:
plr_inv["Stone"] -= (int(player_input)*3)
plr_inv["Sticks"] -= (int(player_input)*2)
plr_inv["Stone Pickaxe"] += (int(player_input))
print_in_box(
f"You crafted {int(player_input)} Stone Pickaxe.")
print_in_box(
f"You have {plr_inv['Stone']} Stone and {plr_inv['Sticks']} Sticks left.")
stone_pick_f_c = True
game_craft = False
break
else:
print_in_box(
f"{player_input} is not an valid number between 1 and {max_craft}, Try again!")
elif player_input.lower() == "stone axe":
max_craft = min((int(plr_inv.get('Stone')/3)),
(int(plr_inv.get('Sticks')/2)))
print_c_str(f"{top_left}{top_bot*40}{top_right}")
print_c_str(
f"║ {'Total Stone':^30} : {plr_inv.get('Stone'):^5} ║")
print_c_str(
f"║ {'Total Sticks':^30} : {plr_inv.get('Sticks'):^5} ║")
print_c_str(f"║{' ':^40}║")
print_c_str(f"║{'Stone Axe Recipe:':^40}║")
print_c_str(f"║{' ':^40}║")
print_c_str(
f"║{'2x Sticks, 3x Stone -> Stone Axe':^40}║")
print_c_str_nl(f"{bot_left}{top_bot*40}{bot_right}")
while game_craft:
print_c_str_nl(
f"How many Stone Axe would you like to craft (1 - {max_craft})?: ")
player_input = input()
if not player_input.isdigit():
print_in_box(
f"{player_input} is not a number, please enter a number between 1 and {max_craft}.")
elif 1 <= int(player_input) <= max_craft:
plr_inv["Stone"] -= (int(player_input)*3)
plr_inv["Sticks"] -= (int(player_input)*2)
plr_inv["Stone Axe"] += (int(player_input))
print_in_box(
f"You crafted {int(player_input)} Stone Axe.")
print_in_box(
f"You have {plr_inv['Stone']} Stone and {plr_inv['Sticks']} Sticks left.")
stone_axe_f_c = True
game_craft = False
break
else:
print_in_box(
f"{player_input} is not an valid number between 1 and {max_craft}, Try again!")
elif player_input.lower() == "iron pickaxe":
max_craft = min((int(plr_inv.get('Iron Ingot')/3)),
(int(plr_inv.get('Sticks')/2)))
print_c_str(f"{top_left}{top_bot*40}{top_right}")
print_c_str(
f"║ {'Total Iron Ingots':^30} : {plr_inv.get('Iron Ingot'):^5} ║")
print_c_str(
f"║ {'Total Sticks':^30} : {plr_inv.get('Sticks'):^5} ║")
print_c_str(f"║{' ':^40}║")
print_c_str(f"║{'Iron Pickaxe Recipe:':^40}║")
print_c_str(f"║{' ':^40}║")
print_c_str(
f"║{'2x Sticks, 3x Iron Ingot -> Iron Pickaxe':^40}║")
print_c_str_nl(f"{bot_left}{top_bot*40}{bot_right}")
while game_craft:
print_c_str_nl(
f"How many Pickaxe would you like to craft (1 - {max_craft})?: ")
player_input = input()
if not player_input.isdigit():
print_in_box(
f"{player_input} is not a number, please enter a number between 1 and {max_craft}.")
elif 1 <= int(player_input) <= max_craft:
plr_inv["Iron Ingot"] -= (int(player_input)*3)
plr_inv["Sticks"] -= (int(player_input)*2)
plr_inv["Iron Pickaxe"] += (int(player_input))
print_in_box(
f"You crafted {int(player_input)} Iron Pickaxe.")
print_in_box(
f"You have {plr_inv['Iron Ingot']} Iron Ingots and {plr_inv['Sticks']} Sticks left.")
iron_pick_f_c = True
game_craft = False
break
else:
print_in_box(
f"{player_input} is not an valid number between 1 and {max_craft}, Try again!")
elif player_input.lower() == "gold statue":
max_craft = (int(plr_inv.get('Gold')/5))
print_c_str(f"{top_left}{top_bot*40}{top_right}")
print_c_str(
f"║ {'Total Gold':^30} : {plr_inv.get('Gold'):^5} ║")
print_c_str(f"║{' ':^40}║")
print_c_str(f"║{'Gold Statue Recipe:':^40}║")
print_c_str(f"║{' ':^40}║")
print_c_str(f"║{'5x Gold -> 1x Gold Statue':^40}║")
print_c_str_nl(f"{bot_left}{top_bot*40}{bot_right}")
while game_craft:
print_c_str_nl(
f"How many Gold Statues would you like to craft (1 - {max_craft})?: ")
player_input = input()
if not player_input.isdigit():
print_in_box(
f"{player_input} is not a number, please enter a number between 1 and {max_craft}.")
elif 1 <= int(player_input) <= max_craft:
plr_inv["Gold"] -= (int(player_input)*5)
plr_inv["Gold Statue"] += int(player_input)
print_in_box(
f"You crafted {int(player_input)} Gold Statues.")
print_in_box(f"You have {plr_inv['Gold']} Gold left.")
game_craft = False
game_win = True
break
else:
print_in_box(
f"{player_input} is not an valid number between 1 and {max_craft}, Try again!")
# elif player_input.lower == "iron axe":
# pass
else:
print_in_box(
f"{player_input} is not a valid action, Try again!")
print_in_box(
"Type [Craft Controls] if you want to see actions you can perform.")
# Smelt -
elif player_input.lower() == "smelt":
game_smelt = True
if plr_inv.get("Logs") >= 4 or plr_inv.get("Coal") >= 3 and plr_inv.get("Iron Ore") >= 1:
print_c_str(f"{top_left}{top_bot*56}{top_right}")
if plr_inv.get("Logs") >= 4:
print_c_str(f"║{' ':56}║")
print_c_str(f"║ {'4 Log':^25} -> {'1 Coal':^25} ║")
if plr_inv.get("Coal") >= 3 and plr_inv.get("Iron Ore") >= 1:
print_c_str(f"║{' ':56}║")
print_c_str(
f"║ {'1x Iron Ore, 3x Coal':^25} -> {'1 Iron Ingot':^25} ║")
print_c_str(f"║{' ':56}║")
print_c_str_nl(f"{bot_left}{top_bot*56}{bot_right}")
else:
print_in_box("You cannot smelt anything!")
game_smelt = False
while game_smelt:
print_c_str_nl("What would you like to smelt?: ")
player_input = input()
if player_input.lower() == "quit":
quit_game()
elif player_input.lower() == "none":
game_smelt = False
break
elif player_input.lower() == "smelt controls":
ctrs_menu(craft_ctrs_list, max_char_in_list(craft_ctrs_list))
elif player_input.lower() == "iron ingot":
max_smelt = min((int(plr_inv.get('Iron Ore'))),
(int(plr_inv.get('Coal')/3)))
print_c_str(f"{top_left}{top_bot*40}{top_right}")
print_c_str(
f"║ {'Total Iron Ore':^30} : {plr_inv.get('Iron Ore'):^5} ║")
print_c_str(
f"║ {'Total Coal':^30} : {plr_inv.get('Coal'):^5} ║")
print_c_str(f"║{' ':^40}║")
print_c_str(f"║{'Iron Ingot Recipe:':^40}║")
print_c_str(
f"║{'1x Iron Ore, 3x Coal -> Iron Ingots':^40}║")
print_c_str_nl(f"{bot_left}{top_bot*40}{bot_right}")
while game_smelt:
print_c_str_nl(
f"How many Iron Ingots would you like to smelt (1 - {max_smelt})?: ")
player_input = input()
if not player_input.isdigit():
print_in_box(
f"{player_input} is not a number, please enter a number between 1 and {max_smelt}.")
elif 1 <= int(player_input) <= max_smelt:
plr_inv["Iron Ore"] -= (int(player_input))