-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
1666 lines (1566 loc) · 61.9 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
'''
Copyright (c) 2023 speedydelete
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
'''
# Imports
from browser import document, alert
from browser.timer import set_timeout
from browser.local_storage import storage
from browser import ajax
from hashlib import sha256 as _sha
from collections import OrderedDict
import base64
from time import time
from browser import html
# Redirect stderr
import sys
class stderr_writer:
def write(self, x):
document.write(x.replace('\n', '<br>'))
sys.stderr = stderr_writer()
# Who uses bytes
def sha(x): return int(_sha(str(x).encode('utf-8')).hexdigest(), 16)
# Because apparently js random on chrome pulls from the computers rng chip,
# and if it dosen't exist, it returns constant values
def randint(x, y=None):
global time, sha
if y == None:
x, y = 0, x
y += 1
return (sha(time()) % (y - x)) + x
def choice(x):
return x[randint(0, len(x) - 1)]
def shuffle(x):
old_type = type(x)
y = []
while len(x) > 0:
z = choice(x)
del x[x.index(z)]
y.append(z)
x = eval(f'{old_type}(y)')
# Constants
storage_key = 'skyblock'
items = [
[1, 'Air', 0, None, ['unbreakable'], None],
[2, 'Grass Block', 20, [[3], 1, [1], [2], [1], [1], [1], 0], ['m_shovel'], None],
[3, 'Dirt', 5, True, ['m_shovel'], None],
[4, 'Sapling', 10, [[4], 2, [1], [4], [1], [1], [1], 0], [], None],
[5, 'Sideways Log Y', 10, True, ['m_axe'], None],
[6, 'Upright Log', 10, True, ['m_axe'], None],
[7, 'Log1', 10, [[6], 2, [1], [6], [1], [1], [1], 0], ['m_axe'], None],
[8, 'Log2', 10, [[6], 7, [1], [6], [1], [1], [1], 0], ['m_axe'], None],
[9, 'Log3', 10, [[6], 8, [1], [6], [1], [1], [1], 0], ['m_axe'], None],
[10, 'Leaves', 15, [[4, 13, 13], 1, [0, 0, 1, 2], [10], [0, 1, 1, 2], [1, 1, 1, 2], [1, 1, 2, 2], 0], ['m_hoe'], None],
[11, 'Leaves1', 15, [[4, 13, 13], 2, [0, 0, 1, 2], [10], [0, 1, 1, 2], [1, 1, 1, 2], [1, 1, 2, 2], 0], ['m_hoe'], None],
[12, 'Leaves2', 15, [[4, 13, 13], 9, [0, 0, 1, 2], [10], [0, 1, 1, 2], [1, 1, 1, 2], [1, 1, 2, 2], 0], ['m_hoe'], None],
[13, 'Stick', 1.25, True, ['m_axe'], None],
[14, 'Sideways Log X', 10, True, ['m_axe'], None],
[15, 'Wooden Pickaxe', 10, None, ['can_break_pick_1', 'picks', 'noplace', 'wooden_tools', 'tools'], None],
[16, 'Wooden Sword', 7.5, None, ['swords', 'noplace', 'wooden_tools', 'tools'], None],
[17, 'Wooden Axe', 10, None, ['axes', 'noplace', 'wooden_tools', 'tools'], None],
[18, 'Wooden Shovel', 5, None, ['shovels', 'noplace', 'wooden_tools', 'tools'], None],
[19, 'Wooden Hoe', 7.5, None, ['hoes', 'wooden_tools', 'noplace', 'tools'], None],
[20, 'Wooden Planks', 2.5, True, ['m_axe'], None],
[21, 'Generator1', 0, None, ['unbreakable'], None],
[22, 'Generator2', 0, None, ['unbreakable'], None],
[23, 'Generator3', 0, None, ['unbreakable'], None],
[24, 'Generator4', 0, None, ['unbreakable'], None],
[25, 'Stone', 10, True, ['requires_pick_1', 'm_pick'], None],
[26, 'Coal Ore', 20, [[30], 1, [1, 2, 3], [26], [1, 2, 3, 3], [1, 2, 3, 3, 4], [2, 3, 4, 4, 5], 2], ['requires_pick_1', 'm_pick'], None],
[27, 'Iron Ore', 40, [[31], 1, [1], [27], [1, 1, 2], [1, 2, 2], [2, 3, 3], 0], ['requires_pick_2', 'm_pick'], None],
[28, 'Gold Ore', 60, [[32], 1, [1], [28], [1, 1, 2], [1, 2, 2], [2, 3, 3], 0], ['requires_pick_3', 'm_pick'], None],
[29, 'Diamond Ore', 140, [[35], 1, [1], [29], [1, 1, 2], [1, 2, 2], [2, 3, 3], 10], ['requires_pick_3', 'm_pick'], None],
[30, 'Coal', 10, None, ['noplace'], None],
[31, 'Raw Iron', 40, None, ['noplace'], None],
[32, 'Raw Gold', 60, None, ['noplace'], None],
[33, 'Iron Ingot', 45, None, ['noplace'], None],
[34, 'Gold Ingot', 67.5, None, ['noplace'], None],
[35, 'Diamond', 140, None, ['noplace'], None],
[36, 'Copper Ore', 30, [[37], 1, [1, 2, 3], [36], [1, 2, 3, 3], [1, 2, 3, 3, 4], [2, 3, 4, 4, 5], 0], ['requires_pick_1', 'm_pick'], None],
[37, 'Raw Copper', 15, None, ['noplace'], None],
[38, 'Copper Ingot', 17.5, None, ['noplace'], None],
[39, 'Block of Coal', 90, True, ['requires_pick_1', 'm_pick'], None],
[40, 'Block of Iron', 405, True, ['requires_pick_2', 'm_pick'], None],
[41, 'Block of Gold', 607.5, True, ['requires_pick_3', 'm_pick'], None],
[42, 'Block of Diamond', 1260, True, ['requires_pick_3', 'm_pick'], None],
[43, 'Block of Copper', 157.5, True, ['requires_pick_1', 'm_pick'], None],
[44, 'Fuel', 1, None, ['noplace'], None],
[45, 'Copper Pickaxe', 55, None, ['noplace', 'copper_tools', 'picks', 'tools', 'can_break_pick_1', 'can_break_pick_2'], None],
[46, 'Copper Sword', 53.75, None, ['noplace', 'copper_tools', 'swords', 'tools'], None],
[47, 'Copper Axe', 55, None, ['noplace', 'copper_tools', 'axes', 'tools'], None],
[48, 'Copper Shovel', 20, None, ['noplace', 'copper_tools', 'shovels', 'tools'], None],
[49, 'Copper Hoe', 37.5, None, ['noplace', 'copper_tools', 'hoes', 'tools'], None],
[50, 'Iron Pickaxe', 137.5, None, ['noplace', 'iron_tools', 'picks', 'tools', 'can_break_pick_1', 'can_break_pick_2', 'can_break_pick_3'], None],
[51, 'Iron Sword', 91.25, None, ['noplace', 'iron_tools', 'swords', 'tools'], None],
[52, 'Iron Axe', 137.5, None, ['noplace', 'iron_tools', 'axes', 'tools'], None],
[53, 'Iron Shovel', 47.5, None, ['noplace', 'iron_tools', 'shovels', 'tools'], None],
[54, 'Iron Hoe', 92.5, None, ['noplace', 'iron_tools', 'hoes', 'tools'], None],
[55, 'Diamond Pickaxe', 302.5, None, ['noplace', 'diamond_tools', 'picks', 'tools', 'can_break_pick_1', 'can_break_pick_2', 'can_break_pick_3', 'can_break_pick_4'], None],
[56, 'Diamond Sword', 201.5, None, ['noplace', 'diamond_tools', 'swords', 'tools'], None],
[57, 'Diamond Axe', 302.5, None, ['noplace', 'diamond_tools', 'axes', 'tools'], None],
[58, 'Diamond Shovel', 102.75, None, ['noplace', 'diamond_tools', 'shovels', 'tools'], None],
[59, 'Diamond Hoe', 202.75, None, ['noplace', 'diamond_tools', 'hoes', 'tools'], None],
[60, 'Lapis Lazuli Ore', 50, [[61], 1, [1, 2, 2, 3, 3], [60], [2, 2, 3, 3], [2, 3, 3], [3], 3], ['requires_pick_2', 'm_pick'], None],
[61, 'Lapis Lazuli', 20, None, ['noplace'], None],
[62, 'Block of Lapis Lazuli', 180, True, ['requires_pick_2', 'm_pick'], None],
[63, 'Water', 0, None, [], None],
[64, 'Bucket', 135, None, [], None],
[65, 'Bucket of Water', 150, None, [], None],
[66, 'Farmland', 0, [[3], 1, [1], [3], [1], [1], [1], 0], ['m_hoe'], None],
[67, 'Wet Farmland', 0, [[3], 1, [1], [3], [1], [1], [1], 0], ['m_hoe'], None],
[68, 'Wheat', 10, None, ['noplace'], None],
[69, 'Seeds', 2, [[69], 67, [1], [69], [1], [1], [1], 0], ['m_hoe'], None],
[70, 'Wheat1', 0, [[69], 67, [1], [69], [1], [1], [1], 0], ['m_hoe'], None],
[71, 'Wheat2', 0, [[69], 67, [1], [69], [1], [1], [1], 0], ['m_hoe'], None],
[72, 'Wheat3', 0, [[69], 67, [1], [69], [1], [1], [1], 0], ['m_hoe'], None],
[73, 'Wheat4', 0, [[69], 67, [1], [69], [1], [1], [1], 0], ['m_hoe'], None],
[74, 'Wheats', 0, [[69, 69, 68], 67, [2, 3], [69, 68], [2, 3, 3], [2, 3, 3, 4], [3, 4, 4, 5], 1], ['m_hoe'], None],
[75, 'Potato', 10, [[75], 67, [1], [75], [1], [1], [1], 0], ['m_hoe'], None],
[76, 'Potato1', 0, [[75], 67, [1], [75], [1], [1], [1], 0], ['m_hoe'], None],
[77, 'Potatoes', 0, [[75], 67, [2, 3], [75], [2, 3, 4], [3, 4, 5], [4, 5, 6], 1], ['m_hoe'], None],
[78, 'Carrot', 10, [[78], 67, [1], [78], [1], [1], [1], 0], ['m_hoe'], None],
[79, 'Carrot1', 0, [[78], 67, [1], [78], [1], [1], [1], 0], ['m_hoe'], None],
[80, 'Carrot2', 0, [[78], 67, [1], [78], [1], [1], [1], 0], ['m_hoe'], None],
[81, 'Carrots', 0, [[78], 67, [2, 3], [78], [2, 3, 4], [3, 4, 5], [4, 5, 6], 1], ['m_hoe'], None],
[82, 'Bread', 30, None, ['noplace'], None],
[83, 'Emerald Ore', 120, [[84], 1, [1], [83], [1, 1, 2], [1, 2, 2], [2, 3, 3], 10], ['requires_pick_3', 'm_pick'], None],
[84, 'Emerald', 120, None, ['noplace'], None],
[85, 'Redstone Ore', 100, [[86], 1, [1, 2, 2, 3, 3], [85], [2, 2, 3, 3], [2, 3, 3], [3], 3], ['requires_pick_3', 'm_pick'], None],
[86, 'Redstone Dust', 40, None, ['noplace'], None],
[87, 'Deepslate', 20, True, ['requires_pick_1', 'm_pick'], None],
[88, 'Deepslate Coal Ore', 40, [[30], 1, [1, 2, 3], [88], [1, 2, 3, 3], [1, 2, 3, 3, 4], [2, 3, 4, 4, 5], 2], ['requires_pick_1', 'm_pick'], None],
[89, 'Deepslate Iron Ore', 80, [[31], 1, [1], [89], [1, 1, 2], [1, 2, 2], [2, 3, 3], 0], ['requires_pick_2', 'm_pick'], None],
[90, 'Deepslate Copper Ore', 60, [[37], 1, [1, 2, 3], [90], [1, 2, 3, 3], [1, 2, 3, 3, 4], [2, 3, 4, 4, 5], 0], ['requires_pick_1', 'm_pick'], None],
[91, 'Deepslate Gold Ore', 120, [[32], 1, [1], [91], [1, 1, 2], [1, 2, 2], [2, 3, 3], 0], ['requires_pick_3', 'm_pick'], None],
[92, 'Deepslate Emerald Ore', 240, [[84], 1, [1], [92], [1, 1, 2], [1, 2, 2], [2, 3, 3], 10], ['requires_pick_3', 'm_pick'], None],
[93, 'Deepslate Redstone Ore', 200, [[86], 1, [1, 2, 2, 3, 3], [93], [2, 2, 3, 3], [2, 3, 3], [3], 3], ['requires_pick_3', 'm_pick'], None],
[94, 'Deepslate Diamond Ore', 280, [[35], 1, [1], [94], [1, 1, 2], [1, 2, 2], [2, 3, 3], 10], ['requires_pick_3', 'm_pick'], None],
[95, 'Deepslate Lapis Lazuli Ore', 100, [[61], 1, [1, 2, 2, 3, 3], [95], [2, 2, 3, 3], [2, 3, 3], [3], 3], ['requires_pick_2', 'm_pick'], None],
[96, 'Block of Redstone', 360, True, ['requires_pick_3', 'm_pick'], None],
[97, 'Block of Emerald', 1080, True, ['requires_pick_3', 'm_pick'], None],
[98, 'Mycelium', 5, True, ['m_shovel'], None],
[99, 'Mushroom Stem', 5, True, ['m_shovel'], None],
[100, 'Red Mushroom Block', 5, True, ['m_shovel'], None],
[101, 'Brown Mushroom Block', 5, True, ['m_shovel'], None],
[102, 'Red Mushroom', 5, [[102], 98, [1], [102], [1], [1], [1], 0], [], None],
[103, 'Brown Mushroom', 5, [[103], 99, [1], [102], [1], [1], [1], 0], [], None],
[104, 'Netherrack', 5, True, ['m_pick', 'requires_pick_1'], None],
[105, 'Glowstone', 5, [[106], 1, [1, 2, 3, 3, 4, 4], [105], [1], [1], [1], 0], ['m_pick', 'requires_pick_1'], None],
[106, 'Glowstone Dust', 2.8, None, ['noplace'], None],
[107, 'Soul Sand', 5, True, ['m_pick', 'requires_pick_1'], None],
[108, 'Soul Soil', 5, True, ['m_pick', 'requires_pick_1'], None],
[109, 'Gravel', 5, [[109] * 15 + [110], 1, [1], [109], [1], [1], [1]], [], None],
[110, 'Flint', 45, True, ['noplace'], None],
[111, 'Flint and Steel', 90, True, ['tools'], None],
[112, 'Clay', 5, True, ['m_shovel'], None],
[113, 'Sand', 5, True, ['m_shovel'], None],
[114, 'Mud', 5, True, ['m_shovel'], None],
[115, 'Snow Block', 5, True, ['m_shovel'], None],
[116, 'Snowball', 1.25, None, ['noplace'], None],
[117, 'Ice', 1, True, ['m_pick', 'requires_pick_1'], None],
[118, 'Packed Ice', 9, True, ['m_pick', 'requires_pick_1'], None],
[119, 'Blue Ice', 81, True, ['m_pick', 'requires_pick_1'], None],
[120, 'Smooth Stone', 10, True, ['m_pick', 'requires_pick_1'], None],
[121, 'Stone Bricks', 10, True, ['m_pick', 'requires_pick_1'], None],
[122, 'Cracked Stone Bricks', 10, True, ['m_pick', 'requires_pick_1'], None],
[123, 'Mossy Stone Bricks', 10, True, ['m_pick', 'requires_pick_1'], None],
[124, 'Chiseled Stone Bricks', 10, True, ['m_pick', 'requires_pick_1'], None],
[125, 'Granite', 10, True, ['m_pick', 'requires_pick_1'], None],
[126, 'Polished Granite', 10, True, ['m_pick', 'requires_pick_1'], None],
[127, 'Diorite', 10, True, ['m_pick', 'requires_pick_1'], None],
[128, 'Polished Diorite', 10, True, ['m_pick', 'requires_pick_1'], None],
[129, 'Andesite', 10, True, ['m_pick', 'requires_pick_1'], None],
[130, 'Polished Andesite', 10, True, ['m_pick', 'requires_pick_1'], None],
[131, 'Basalt', 10, True, ['m_pick', 'requires_pick_1'], None],
[132, 'Polished Basalt', 10, True, ['m_pick', 'requires_pick_1'], None],
[133, 'Smooth Basalt', 10, True, ['m_pick', 'requires_pick_1'], None],
[134, 'Blackstone', 10, True, ['m_pick', 'requires_pick_1'], None],
[135, 'Polished Blackstone', 10, True, ['m_pick', 'requires_pick_1'], None],
[136, 'Chiseled Polished Blackstone', 10, True, ['m_pick', 'requires_pick_1'], None],
[137, 'Polished Blackstone Bricks', 10, True, ['m_pick', 'requires_pick_1'], None],
[138, 'Cracked Polished Blackstone Bricks', 10, True, ['m_pick', 'requires_pick_1'], None],
[139, 'Gilded Blackstone', 10, True, ['m_pick', 'requires_pick_1'], None],
[140, 'Red Sand', 10, True, ['m_pick', 'requires_pick_1'], None],
[141, 'Nether Quartz Ore', 10, [[142], 1, [1], [141], [2], [3], [4]], ['m_pick', 'requires_pick_1'], None],
[142, 'Nether Quartz', 10, None, ['noplace'], None],
[143, 'Nether Gold Ore', 10, [[144], 1, [2, 3, 4, 5], [144], [3, 4, 5], [4, 5, 6], [5, 6, 7]], ['m_pick', 'requires_pick_1'], None],
[144, 'Gold Nugget', 10, None, ['noplace'], None],
[145, 'Iron Nugget', 10, None, ['noplace'], None],
[146, 'Deepslate Bricks', 10, True, ['m_pick', 'requires_pick_1'], None],
[147, 'Cracked Deepslate Bricks', 10, True, ['m_pick', 'requires_pick_1'], None],
[148, 'Deepslate Tiles', 10, True, ['m_pick', 'requires_pick_1'], None],
[149, 'Cracked Deepslate Tiles', 10, True, ['m_pick', 'requires_pick_1'], None],
[150, 'Polished Deepslate', 10, True, ['m_pick', 'requires_pick_1'], None],
[151, 'Chiseled Deepslate', 10, True, ['m_pick', 'requires_pick_1'], None],
[152, 'Calcite', 10, True, ['m_pick', 'requires_pick_1'], None],
[153, 'Tuff', 10, True, ['m_pick', 'requires_pick_1'], None],
[154, 'Obsidian', 10, True, ['m_pick', 'requires_pick_4'], None],
[155, 'Crying Obsidian', 10, True, ['m_pick', 'requires_pick_4'], None],
[156, 'Ancient Debris', 500, True, ['m_pick', 'requires_pick_4'], None],
[157, 'Netherite Scrap', 600, None, ['noplace'], None],
[158, 'Netherite Ingot', 2500, None, ['noplace'], None],
[159, 'Block of Netherite', 22500, True, ['m_pick', 'requires_pick_4'], None],
[160, 'Netherite Pickaxe', 7500, None, ['noplace', 'tools', 'netherite_tools', 'picks', 'can_break_pick_1', 'can_break_pick_2', 'can_break_pick_3', 'can_break_pick_4'], None],
[161, 'Netherite Sword', 5000, None, ['noplace', 'tools', 'netherite_tools', 'swords'], None],
[162, 'Netherite Axe', 7500, None, ['noplace', 'tools', 'netherite_tools', 'axes'], None],
[163, 'Netherite Shovel', 2500, None, ['noplace', 'tools', 'netherite_tools', 'shovels'], None],
[164, 'Netherite Hoe', 5000, None, ['noplace', 'tools', 'netherite_tools', 'hoes'], None],
[165, 'Block of Amethyst', 10, True, ['m_pick', 'requires_pick_1'], None],
[166, 'Block of Quartz', 10, True, ['m_pick', 'requires_pick_1'], None],
[167, 'Smooth Quartz', 10, True, ['m_pick', 'requires_pick_1'], None],
[168, 'Quartz Pillar', 10, True, ['m_pick', 'requires_pick_1'], None],
[169, 'Chiseled Quartz', 10, True, ['m_pick', 'requires_pick_1'], None],
[170, 'Quartz Bricks', 10, True, ['m_pick', 'requires_pick_1'], None],
[171, 'Sandstone', 10, True, ['m_pick', 'requires_pick_1'], None],
[172, 'Cut Sandstone', 10, True, ['m_pick', 'requires_pick_1'], None],
[173, 'Chiseled Sandstone', 10, True, ['m_pick', 'requires_pick_1'], None],
[174, 'Red Sandstone', 10, True, ['m_pick', 'requires_pick_1'], None],
[175, 'Cut Red Sandstone', 10, True, ['m_pick', 'requires_pick_1'], None],
[176, 'Chiseled Red Sandstone', 10, True, ['m_pick', 'requires_pick_1'], None],
[177, 'Herobrine', 1000000, None, ['noplace', 'can_break_pick_1', 'can_break_pick_2', 'can_break_pick_3'], None],
]
generator = [
[0, [2], 'gb-plains', 'Plains'],
[1, [25] * 50 + [125, 127, 129] * 4 + [36] * 5 + [26] * 4 + [27] * 3 + [28] * 2 + [85, 85, 83, 29], 'gb-caves1', 'Upper Caves'],
[2, [87] * 50 + [89, 90] * 5 + [91, 93, 95, 153] * 3 + [94, 94, 88, 92], 'gb-caves2', 'Lower Caves'],
[5, [98, 98, 98, 99, 100, 101, 102, 103], 'gb-mfields', 'Mushroom Fields'],
[3, [104, 104, 104, 104, 104, 104, 105, 107, 107, 108, 109, 109] * 200 + [156], 'gb-netherw', 'Nether Wastes'],
[2, [115] * 20 + [117] * 5 + [118] * 3 + [119], 'gb-snowb', 'Snowy Beach'],
[1, [109, 112, 113, 114] * 10 + [139], 'gb-oceanf', 'Ocean Floor'],
[3, [132, 133, 133] * 400 + [156], 'gb-bdelta', 'Basalt Deltas'],
[2, [152, 133, 165] * 1000 + [177], 'gb-geode', 'Amethyst Geode'],
[3, [107, 108, 156] * 400 + [156], 'gb-ssvall', 'Soul Sand Valley'],
[6, [134, 135, 136, 137, 138] * 9 + [139] * 3 + [41], 'gb-bastion', 'Bastion'],
]
nature_recipes = [
[[[1, 5]], [4, 20]],
[[[1, 6]], [4, 20]],
[[[1, 14]], [4, 20]],
[[[1, 5]], [1, 6]],
[[[1, 5]], [1, 14]],
[[[1, 6]], [1, 5]],
[[[1, 6]], [1, 14]],
[[[1, 14]], [1, 5]],
[[[1, 14]], [1, 6]],
[[[2, 20]], [4, 13]],
[[[4, 106]], [1, 105]],
[[[9, 117]], [1, 118]],
[[[9, 118]], [1, 119]],
]
stone_recipes = [
[[[1, 25]], [1, 120]],
[[[1, 25]], [1, 121]],
[[[1, 25]], [1, 122]],
[[[1, 25]], [1, 123]],
[[[1, 25]], [1, 124]],
[[[1, 120]], [1, 25]],
[[[1, 121]], [1, 25]],
[[[1, 122]], [1, 25]],
[[[1, 123]], [1, 25]],
[[[1, 124]], [1, 25]],
[[[1, 125]], [1, 126]],
[[[1, 127]], [1, 128]],
[[[1, 129]], [1, 130]],
[[[1, 126]], [1, 125]],
[[[1, 128]], [1, 127]],
[[[1, 130]], [1, 129]],
[[[1, 131]], [1, 132]],
[[[1, 131]], [1, 133]],
[[[1, 132]], [1, 131]],
[[[1, 133]], [1, 131]],
[[[4, 142]], [1, 166]],
[[[1, 166]], [1, 167]],
[[[1, 166]], [1, 168]],
[[[1, 166]], [1, 169]],
[[[1, 169]], [1, 170]],
[[[1, 167]], [1, 166]],
[[[1, 168]], [1, 166]],
[[[1, 169]], [1, 166]],
[[[1, 170]], [1, 166]],
[[[1, 113]], [1, 171]],
[[[1, 171]], [1, 172]],
[[[1, 171]], [1, 173]],
[[[1, 172]], [1, 171]],
[[[1, 173]], [1, 171]],
[[[1, 140]], [1, 174]],
[[[1, 174]], [1, 175]],
[[[1, 174]], [1, 176]],
[[[1, 175]], [1, 174]],
[[[1, 176]], [1, 174]],
[[[9, 30]], [1, 39]],
[[[9, 33]], [1, 40]],
[[[9, 34]], [1, 41]],
[[[9, 35]], [1, 42]],
[[[9, 38]], [1, 43]],
[[[9, 86]], [1, 96]],
[[[9, 84]], [1, 95]],
[[[1, 39]], [9, 30]],
[[[1, 40]], [9, 33]],
[[[1, 41]], [9, 34]],
[[[1, 42]], [9, 35]],
[[[1, 43]], [9, 38]],
[[[1, 96]], [9, 86]],
[[[1, 95]], [9, 84]],
[[[9, 158]], [1, 159]],
[[[1, 159]], [9, 158]],
[[[1, 33]], [9, 145]],
[[[1, 34]], [9, 144]],
[[[4, 157], [4, 34]], [1, 158]],
[[[9, 145]], [1, 33]],
[[[9, 144]], [1, 34]],
[[[1, 134]], [1, 135]],
[[[1, 135]], [1, 134]],
[[[1, 135]], [1, 136]],
[[[1, 136]], [1, 135]],
[[[1, 135]], [1, 137]],
[[[1, 137]], [1, 135]],
[[[1, 137]], [1, 138]],
[[[1, 138]], [1, 137]],
[[[1, 87]], [1, 146]],
[[[1, 146]], [1, 87]],
[[[1, 146]], [1, 147]],
[[[1, 147]], [1, 146]],
[[[1, 87]], [1, 148]],
[[[1, 148]], [1, 87]],
[[[1, 148]], [1, 149]],
[[[1, 149]], [1, 148]],
[[[1, 87]], [1, 150]],
[[[1, 150]], [1, 87]],
[[[1, 87]], [1, 151]],
[[[1, 151]], [1, 87]],
]
tools_recipes = [
[[[2, 13], [3, 20]], [1, 15]],
[[[1, 13], [2, 20]], [1, 16]],
[[[2, 13], [3, 20]], [1, 17]],
[[[2, 13], [1, 20]], [1, 18]],
[[[2, 13], [2, 20]], [1, 19]],
[[[2, 13], [3, 38]], [1, 45]],
[[[2, 13], [3, 33]], [1, 50]],
[[[2, 13], [3, 35]], [1, 55]],
[[[1, 13], [2, 38]], [1, 46]],
[[[1, 13], [2, 38]], [1, 51]],
[[[1, 13], [2, 38]], [1, 56]],
[[[2, 13], [3, 38]], [1, 47]],
[[[2, 13], [3, 33]], [1, 52]],
[[[2, 13], [3, 35]], [1, 57]],
[[[2, 13], [1, 38]], [1, 48]],
[[[2, 13], [1, 33]], [1, 53]],
[[[2, 13], [1, 35]], [1, 58]],
[[[2, 13], [2, 38]], [1, 49]],
[[[2, 13], [2, 33]], [1, 54]],
[[[2, 13], [2, 35]], [1, 59]],
[[[3, 33]], [1, 64]],
[[[2, 13], [3, 158]], [1, 160]],
[[[1, 13], [2, 158]], [1, 161]],
[[[2, 13], [3, 158]], [1, 162]],
[[[2, 13], [1, 158]], [1, 163]],
[[[2, 13], [2, 158]], [1, 164]],
]
other_recipes = []
food_recipes = [
[[[3, 68]], [1, 82]],
]
fuel_recipes = [
[[[1, 30]], [8, 44]],
]
smelt_recipes = [
[[1, 37], [1, 38], 5],
[[1, 31], [1, 33], 5],
[[1, 32], [1, 34], 5],
[[1, 156], [1, 157], 100],
]
recipe_data_vars = [[nature_recipes, '-nature'], [stone_recipes, '-stone'], [tools_recipes, '-tools'], \
[other_recipes, '-other'], [food_recipes, '-food'], [fuel_recipes, '-fuel']]
base_tiles = [[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,4,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2]]
moons = ['New Moon', 'Waxing Crescent', 'Waxing Half', 'Waxing Gibbous', \
'Full Moon', 'Waning Gibbous', 'Waning Half', 'Waning Crescent']
rare_moons = ['Harvest Moon', 'Blue Moon', 'Supermoon', 'Super Blood Moon', 'Pork Moon', 'Dire Moon', \
'Bloodstained Moon', 'Lunar Eclipse', 'Minmus Mun']
very_rare_moons = ['Total Solar Eclipse', 'Nightmare Moon']
shop = [
['Layer above', '<span id="lprice-1"></span>', 'buy_layer_above'],
['Layer below', '<span id="lprice-2"></span>', 'buy_layer_below'],
['Bucket -> Water Bucket', '$45', 'buy_wb'],
['Seeds', '$100', 'buy_seeds'],
['Potato', '$100', 'buy_potato'],
['Carrot', '$100', 'buy_carrot'],
['Grass Block', '100', 'buy_grass_block'],
['<span id="rtsinfo"></span>', '<span id="rtsprice"></span>', 'buy_rts'],
['Unlock avatar', '$25,000', 'buy_servant'],
['1ǥ', '$1,000', 'buy_gen_money']
]
# Makes item properties more accessible to the code
names = {x[0]: x[1] for x in items}
rnames = {v: k for k, v in names.items()}
prices = {x[0]: x[2] for x in items}
loot_table = {x[0]: x[3] for x in items if x[3] != None}
for x in dict(loot_table):
if loot_table[x] == True:
loot_table[x] = [[int(x)], 1, [1], [int(x)], [1], [1], [1], 0]
tags = {}
for k, v in {x[0]: x[4] for x in items}.items():
for x in v:
tags.setdefault(x,[]).append(k)
# Utility functions
# Checks if something is breakable and reduces durability
def break_block(c, inventory, d=False):
global randint
try:
item = tuple(inventory)[0]
count = inventory[item][0]
meta = inventory[item][1]
except IndexError:
item = 0
count = 0
meta = 0
if c in tags['unbreakable']:
return False
elif c in tags['requires_pick_1'] and \
item not in tags['can_break_pick_1']:
return None
elif c in tags['requires_pick_2'] and \
item not in tags['can_break_pick_2']:
return None
elif c in tags['requires_pick_3'] and \
item not in tags['can_break_pick_3']:
return None
elif c in tags['requires_pick_4'] and \
item not in tags['can_break_pick_4']:
return None
elif c == 63 and item != 64:
return False
else:
try:
meta = inventory[item][1]
except KeyError:
return True
m = 1
if type(meta) == complex:
meta = meta.imag()
meta = int(meta)
meta %= 8
if meta == 0:
m = 1
elif meta == 1:
m = 2
elif meta == 2:
m = 3
elif meta == 3:
m = 4
if randint(1, m) == 1 and d == False:
d = 0
if item in tags['wooden_tools']:
d += 1/64
elif item in tags['copper_tools']:
d += 1/128
elif item in tags['iron_tools']:
d += 1/384
elif item in tags['diamond_tools']:
d += 1/1024
elif item in tags['netherite_tools']:
d += 1/2048
elif item == 111:
d += 1/64
if (item in tags['picks'] and c not in tags['m_pick']) or \
(item in tags['axes'] and c not in tags['m_axe']) or \
(item in tags['shovels'] and c not in tags['m_shovel']) or \
(item in tags['swords'] and c not in tags['m_sword']) or \
(item in tags['hoes'] and c not in tags['m_hoe']):
d *= 2
inventory[item][1] -= d
if item in tags['tools']:
if inventory[item][1] <= 0:
del inventory[item]
return None
return True
# Checks if you can place a block
def can_place(x, y):
global tags
if x == 4:
return y == 2
elif x in [102, 103]:
return y == 98
elif x in tags['noplace']:
return False
elif x in [69, 75, 78]:
return y == 67
elif y == 63:
return can_place(x, 1)
else:
return y == 1
# Saving/loading "encryption" functions
def encode(x):
x = repr(x).encode('utf-8').decode('latin-1')
y = 'x'
for i, b in enumerate(x):
y += chr((sha('techno never dies' + y[-1] + str(i)) % 256) ^ ord(b))
return base64.b64encode(y[1:].encode('latin-1')).decode('latin-1')
def decode(x):
try:
x = base64.b64decode(x.encode('latin-1')).decode('latin-1')
y = ''
x = 'x' + x
for i, b in enumerate(x[1:]):
y += chr((sha('techno never dies' + x[i] + str(i)) % 256) ^ ord(b))
return eval(y.encode('latin-1').decode('utf-8'))
except Exception as e:
alert(f'Invalid save! ({str(e)})')
# Format an item for display
def format_item(i):
global tags
item = i[0]
durability = i[1][1]
if item in tags['tools']:
a = ' (' + str(round(durability*100, 1)) + '%)'
else:
a = ''
return f'{i[1][0]}x {names[i[0]]}' + a
# Display an image
def set_img(x, y, new):
if items[new][5] != None:
path = items[new][5]
else:
path = f'https://2dskyblock.github.io/assets/{new}.png'
document[str(y) + '-' + str(x)].attrs['src'] = path
# Copied from Lib/tkinter/__init__.py
def flatten(x):
res = []
for item in x:
if isinstance(item, [tuple, list]):
res += flatten(item)
else:
res.append(item)
return res
# Display statistics
def display_stats():
global stats, alert, flatten, prices, all_tiles
at2 = flatten(all_tiles)
isv = '{:,.2f}'.format(float(str(sum([prices.get(x, 0) for x in at2]))))
alert(f'''Island value: ${isv}
Blocks broken: {stats[0]}
Blocks placed: {stats[1]}
Times generator used: {stats[2]}
Trees grown: {stats[3]}
Layers: {len(all_tiles)}
Times switched between layers: {stats[5]}
Shop items bought: {stats[6]}
Times dirt converted to grass: {stats[7]}
Money earned: {stats[8]}
Money spent: {stats[9]}
Items crafted: {stats[10]}
Items smelted: {stats[11]}
Times crafted: {stats[12]}
Times smelted: {stats[13]}''')
# Load a save
def load_save(save):
global all_tiles, inventory, sel, money, layer_price, z, l_offset, \
gen_level, stats, xp, levels, rts, servant_inv, servant_break, \
servant_place, servant_sell, has_servant, servant_layers, \
game_time, gen_money, gen_mode, has_gens, game_seed
try:
load = decode(save)
if load == None:
return
ver = load[0]
if ver > 5:
alert('Downgrading a world is not supported. Close the game.')
raise SystemExit(0)
else:
all_tiles = load[1]
inventory = load[2]
sel = load[3]
money = load[4]
layer_price = load[5]
z = load[6]
l_offset = load[7]
gen_level = load[8]
stats = load[9]
xp = load[10]
levels = load[11]
rts = load[12]
servant_inv = load[13]
servant_break = load[14]
servant_place = load[15]
servant_sell = load[16]
has_servant = load[17]
servant_layers = load[18]
game_time = load[19]
has_gens = load[20]
gen_mode = load[21]
gen_money = load[22]
game_seed = load[23]
# Post-load
tiles = all_tiles[z]
if has_servant:
del document['servant-upgrade']
for x in has_gens:
document[generator[x][2]].unbind('click')
document[generator[x][2]].bind('click', get_gen_shop_sel(x))
document[generator[x][2]].innerHTML = 'Select'
except KeyError:
pass
# Get a save
def _save():
return encode({0:5,1:all_tiles,2:inventory,3:sel,4:money,5:layer_price,\
6:z,7:l_offset,8:gen_level,9:stats,10:xp,11:levels,12:rts,\
13:servant_inv,14:servant_break,15:servant_place,\
16:servant_sell,17:has_servant,18:servant_layers,\
19:game_time,20:has_gens,21:gen_mode,22:gen_money,23:game_seed})
# Add a layer
def add_layer(down=False):
global all_tiles, base_tiles, z, l_offset
if down:
all_tiles = [[[int(a) for a in b] for b in base_tiles],] + all_tiles
z += 1
l_offset += 1
else:
all_tiles.append([[int(a) for a in b] for b in base_tiles])
# Hide all the sub-screens
def hide_all():
document['crafting'].style.display = 'none'
document['upgrades'].style.display = 'none'
document['gen'].style.display = 'none'
document['slscreen'].style.display = 'none'
document['servantm'].style.display = 'none'
document['game'].style.display = 'none'
# Button functions
# Get click handlers for images
def get_handle_click(x, y):
def handle_click(_event):
global inventory
click_bind(x, y, inventory)
return handle_click
# Generator selection button
def get_gen_shop_sel(n):
def gen_shop_sel(_ev):
global gen_mode
gen_mode = int(n)
return gen_shop_sel
# Generator buying button
def get_gen_shop_buy(n, gb):
def gen_shop_buy(_ev):
global has_gens, gen_mode, generator, gen_money
if generator[n][0] > gen_money:
alert('You don\'t have enough ǥ!')
else:
gen_money -= generator[n][0]
has_gens.append(n)
document[gb].unbind('click')
document[gb].bind('click', get_gen_shop_sel(n))
document[gb].innerHTML = 'Select'
return gen_shop_buy
# Shop buy buttons
def buy_layer_above(_ev):
global money, layer_price, stats
if money >= layer_price:
stats[6] += 1
stats[4] += 1
stats[9] += layer_price
money -= layer_price
add_layer()
layer_price *= 3
else:
alert('Not enough money!')
def buy_layer_below(_ev):
global money, layer_price, stats
if money >= layer_price:
stats[6] += 1
stats[4] += 1
stats[9] += layer_price
money -= layer_price
add_layer(True)
layer_price *= 3
else:
alert('Not enough money!')
def buy_wb(_ev):
global inventory, money, stats
if 64 in inventory and inventory[64][0] > 0:
if money >= 45:
stats[6] += 1
money -= 45
inventory[64][0] -= 1
if 65 not in inventory:
inventory[65] = [1, 0]
else:
inventory[65][0] += 1
else:
alert('Not enough money!')
else:
alert('You need an empty bucket!')
def buy_seeds(_ev):
global money, stats, inventory
if money >= 100:
stats[6] += 1
money -= 100
if 69 not in inventory:
inventory[69] = [1, 0]
else:
inventory[69][0] += 1
else:
alert('Not enough money!')
def buy_potato(_ev):
global money, stats, inventory
if money >= 100:
stats[6] += 1
money -= 100
if 75 not in inventory:
inventory[75] = [1, 0]
else:
inventory[75][0] += 1
else:
alert('Not enough money!')
def buy_carrot(_ev):
global money, stats, inventory
if money >= 100:
stats[6] += 1
money -= 100
if 78 not in inventory:
inventory[78] = [1, 0]
else:
inventory[78][0] += 1
else:
alert('Not enough money!')
def buy_grass_block(_ev):
global money, stats, inventory
if money >= 100:
stats[6] += 1
money -= 100
if 2 not in inventory:
inventory[2] = [1, 0]
else:
inventory[2][0] += 1
else:
alert('Not enough money!')
def buy_rts(_ev):
global rts, money, stats
rtp = int(1.005**((4*rts-3)*(100**(((4*rts-3)%10)/10+1))))
if money >= rtp:
money -= rtp
stats[6] += 1
rts += 0.25
else:
alert('Not enough money!')
def buy_servant(_ev):
global has_servant, stats, money
if money >= 25000:
money -= 25000
has_servant = True
del document['servant-upgrade']
stats[6] += 1
else:
alert('Not enough money!')
def buy_gen_money(_ev):
global money, stats, gen_money
if money >= 1000:
money -= 1000
stats[6] += 1
gen_money += 1
else:
alert('Not enough money!')
# Avatar add layer button
def servant_add_layer(_ev):
global servant_layers, l_offset, all_tiles
x = input('Enter new layer:')
try:
x = int(x)
except ValueError:
alert('Invalid layer!')
return
if x - l_offset + 1 not in list(range(len(all_tiles))) or x == 1:
alert('Invalid layer!')
else:
servant_layers.append(x)
# Avatar remove layer button
def servant_remove_layer(_ev):
global servant_layers
x = input('Enter layer:')
if x not in [str(y) for y in servant_layers]:
alert('Invalid layer!')
else:
del servant_layers[servant_layers.index(int(x))]
# Avatar add break button
def servant_add_break(_ev):
global servant_break, rnames, tags
it = input('Enter block:')
if it not in rnames:
alert('Invalid block!')
elif rnames[it] in tags['noplace']:
alert('Invalid block!')
else:
servant_break.append(rnames[it])
# Avatar remove break button
def servant_remove_break(_ev):
global servant_break, rnames
it = input('Enter block:')
if it not in rnames:
alert('Invalid block!')
elif rnames[it] not in servant_break:
alert('Invalid block!')
else:
del servant_break[rnames[it]]
# Avatar add place button
def servant_add_place(_ev):
global servant_place, rnames
it = input('Enter block:')
if it not in rnames:
alert('Invalid block!')
elif rnames[it] in tags['noplace']:
alert('Invalid block!')
else:
servant_place.append(rnames[it])
# Avatar remove place button
def servant_remove_place(_ev):
global servant_place, rnames
it = input('Enter block:')
if it not in rnames:
alert('Invalid block!')
elif rnames[it] not in servant_place:
alert('Invalid block!')
else:
del servant_place[rnames[it]]
# Avatar add sell button
def servant_add_sell(_ev):
global servant_sell, rnames
it = input('Enter item:')
if it not in rnames:
alert('Invalid item!')
else:
servant_sell.append(rnames[it])
# Avatar remove sell button
def servant_remove_sell(_ev):
global servant_sell
it = input('Enter item:')
if it not in rnames:
alert('Invalid item')
elif rnames[it] not in servant_sell:
alert('Invalid item!')
else:
del servant_sell[it]
# Crafting button bind
def get_craft_bind(inp, out):
def craft_bind(_ev):
global inventory, tags, stats
for e in inp:
x = e[0]
y = e[1]
if y in inventory and inventory[y][0] >= x:
inventory[y][0] -= x
else:
alert('Not enough materials!')
return
if out[1] not in inventory:
stats[10] += out[0]
stats[12] += 1
inventory[out[1]] = [out[0], 0]
if out[1] in tags['tools']:
inventory[out[1]][1] = 1
else:
inventory[out[1]][1] += out[0]
inventory[out[1]][0] += out[0]
return craft_bind
# Crafting tab bind
def get_craft_switch(to, nto):
def craft_switch(_ev):
global document
document[to].style.display = 'inline'
for x in nto:
document[x].style.display = 'none'
return craft_switch
# Smelting button bind
def get_smelt_bind(inp, out, xp_gain):
def smelt_bind(_ev):
global inventory, xp
x = inp[0]
y = inp[1]
if y in inventory and inventory[y][0] >= x:
inventory[y][0] -= x
else:
alert('No materials!')
return
if 44 not in inventory:
alert('No fuel!')
return
elif inventory[44][0] == 0:
alert('No fuel!')
return
inventory[44][0] -= 1
if out[1] not in inventory:
inventory[out[1]] = [out[0], 0]
else:
inventory[out[1]][1] += (out[0]/inventory[out[1]][0])
inventory[out[1]][0] += out[0]
stats[11] += out[0]
stats[13] += 1
xp += xp_gain
return smelt_bind
# Back button
def back_btn(_ev):
hide_all()
document['game'].style.display = 'inline'
b_show = False
c_show = False
servant_shop = False
gen_shop = False
show_upgrade = False
# Up button
def button_up_layer(_ev):
global z, all_tiles
if z != len(all_tiles) - 1:
z += 1
# Down button
def button_down_layer(_ev):
global z
if z != 0:
z -= 1
# Inventory scroll buttons
def button_up_inv(_ev):
global inventory, sel
inventory.move_to_end(tuple(inventory)[0])
sel = tuple(inventory)[0]
def button_down_inv(_ev):