-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathlogic.js
1474 lines (1214 loc) · 66 KB
/
logic.js
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
logic = {
//these functions return true or false
darkWorldNW: function () { //check for access to this whole region
return items.pearl.val && //need this of course
(items.glove.val >= 2 || //kakariko portal
(items.glove.val >= 1 && items.hammer.val) || //kakariko portal
(items.boss11.val && items.hookshot.val && (items.hammer.val || items.glove.val || items.flippers.val)) //agahnim then river crossing
);
},
darkWorldEast: function () { //check for access to this whole region
return items.pearl.val && //need this of course
(items.boss11.val || //agahnim gives direct access
items.hammer.val && items.glove.val || //portal at flute 5
items.glove.val >= 2 && items.flippers.val //kakariko portal then river crossing
); //
},
darkWorldSouth: function () { //check for access to this whole region
return logic.darkWorldNW() || //can drop down from village -- includes hammer + glove option
(items.boss11.val && items.pearl.val && items.hammer.val); //agahnim + hammer also works
},
DMlight: function () { return (items.lamp.val || items.flute.val); }, //used to determine if DM chests require dark
climbDM: function () { return (items.glove.val || items.flute.val); }, //can get up Death Mountain
eastDM: function () { return logic.climbDM() && (items.hookshot.val || items.mirror.val && items.hammer.val); }, //can get to EDM
darkEastDM: function () { return logic.eastDM() && items.pearl.val && items.glove.val >= 2; }, //can get to dark EDM
cane: function () { return items.somaria.val || items.byrna.val; }, //the canes work against certain bosses
rod: function () { return items.firerod.val || items.icerod.val; }, //the rods work against certain bosses
fire: function () { return items.lamp.val || items.firerod.val; }, //can light torches
//Dungeon entry
entry0: function () { return true; },
entry1: function () { return items.book.val || items.glove.val >= 2 && items.flute.val && items.mirror.val },
entry2: function () { return logic.climbDM() && (items.mirror.val || items.hookshot.val && items.hammer.val) },
entry3: function () { return logic.darkWorldEast() },
entry4: function () { return logic.darkWorldSouth() && items.mirror.val && items.flippers.val },
entry5: function () { return logic.darkWorldNW() },
entry6: function () { return logic.darkWorldNW() },
entry7: function () { return items.pearl.val && items.glove.val >= 2 && items.flippers.val && (items.firerod.val || (items.bombos.val && items.sword.val >= 1)) },
entry8: function () { return items.pearl.val && items.glove.val >= 2 && items.flute.val && (items.boots.val || items.hookshot.val) },
entry9: function () { return logic.darkEastDM() && items.hammer.val && items.somaria.val },
entry10: function () { return items.crystal.val >= 7 && logic.darkEastDM() },
entry11: function () { return items.sword.val >= 2 || items.cape.val },
//this function returns 0, 1, or 3
// 0 = unavailable
// 1 = available
// 3 = possibly available
medallion: function (id) { //check for the correct MM/TR medallions; id is the dungeon id (8 = MM, 9 = TR)
medal = items["medal" + id].val; //identifies what medallion we want; 0 = unknown, 1 = bombos, 2 = ether, 3 = quake
return items.sword.val >= 1 ? //need a sword
medal == 0 ?
items.bombos.val && items.ether.val && items.quake.val ? //medallion is unknown
1 : //has all medallions so check is automatically passed
items.bombos.val || items.ether.val || items.quake.val ? 3 : 0 : //if at least one medallion, maybe ok; otherwise nope
medal == 1 && items.bombos.val || medal == 2 && items.ether.val || medal == 3 && items.quake.val ? //medallion is known and we need a specific one
1 : //has the specific matching medallion
0 : //does not have the matching medallion
0; //no sword, cannot use any medallions
},
//this sets the prizes in the item tracker based on completed dungeons
setPrizes: function () {
counts = { 0: 0, 1: 0, 2: 0, 3: 0, 4: 0, total: 0 }; //tally of each type of prize;
// 0 = unknown, 1 = red/blue pend, 2 = green pend, 3 = blue crystal, 4 = red crystal
for (i = 0; i <= 9; i++) { //checks each dungeon to see if it's completed and if so what its prize is
if (dungeons[i].completed) {
counts[dungeons[i].prize]++;
counts.total++;
}
}
//updates the item object with the counts that were found
items.pendant.val = Math.min(3, counts[1] + counts[2]); //total pendants of either colour
items.greenPendant.val = Math.min(1, counts[2]); //green pendant
items.crystal.val = Math.min(7, counts[3] + counts[4]); //total crystals of either colour
items.redCrystal.val = Math.min(2, counts[4]); //just red crystal
//a little extra logic that deduces pendants/crystals from the total count if not all prizes are known or marked correctly
//example: if there's more than 4 dungeons beaten, 1 of them must be a crystal, etc etc
if (counts.total >= 4) {
items.pendant.val = Math.max(counts.total - 7, items.pendant.val);
items.crystal.val = Math.max(counts.total - 3, items.crystal.val);
}
if (items.pendant.val >= 3) { //if you have three pendants, 1 must be green
items.greenPendant.val = 1;
}
if (items.crystal.val >= 7) { //if you have 7 crystals, 2 must be red
items.redCrystal.val = Math.max(2, items.redCrystal.val);
} else if (items.crystal.val >= 6) { //if you have 6 crystals, at least 1 is red
items.redCrystal.val = Math.max(1, items.redCrystal.val);
}
},
// Values that can be returned for any given chest:
// 0 = unavailable
// 1 = available
// 2 = available through dark room
// 3 = possibly available
// 4 = visible/checkable but unattainable
chests: {
0: function () { return 1; }, // Sahasrahla's Hut
1: function () { return items.greenPendant.val; }, // Sahasrahla
2: function () { // King Zora
return items.flippers.val || items.glove.val ? 1 : 0;
},
3: function () { return items.mushroom.val; }, // Potion Shop
4: function () { return items.flippers.val; }, // Zora's Ledge
5: function () { return items.flippers.val; }, // Waterfall Fairy
6: function () { // Master Sword Pedestal
return (items.pendant.val == 3) ?
1 :
items.book.val ? 4 : 0;
},
7: function () { // King's Tomb
return items.boots.val &&
(items.glove.val >= 2 ||
(logic.darkWorldNW() && items.mirror.val))
? 1 : 0;
},
8: function () { return 1; }, // Kakariko Tavern
9: function () { return 1; }, // Chicken House
10: function () { return 1; }, // Kakariko Well
11: function () { return 1; }, // Blind's Hideout
12: function () { return items.boots.val; }, // Pegasus Rocks
13: function () { return 1; }, // Bottle Merchant
14: function () { // Magic Bat
return items.powder.val &&
(items.hammer.val || logic.darkWorldNW() &&
items.mirror.val);
},
15: function () { return items.bottle.val >= 1 ? 1 : 0; }, // Sick Kid
16: function () { return 1; }, // Lost Woods Hideout
17: function () { return items.boss11.val && items.boots.val ? 1 : 4; }, // Lumberjack Tree
18: function () { return logic.darkWorldNW() && items.mirror.val ? 1 : 0; }, // Graveyard Ledge
19: function () { return 1; }, // Mushroom
20: function () { return 1; }, // Dam
21: function () { return 1; }, // Link's House
22: function () { return 1; }, // Aginah's Cave
23: function () { return 1; }, // Mini Moldorm Cave
24: function () { return 1; }, // Ice Rod Cave
25: function () { return items.flippers.val; }, // Hobo
26: function () { // Bombos Tablet
return items.book.val && items.mirror.val && logic.darkWorldSouth() ?
items.sword.val >= 2 ? 1 : 4 :
0;
},
27: function () { // Cave 45
return items.mirror.val &&
(logic.darkWorldNW() || items.boss11.val && items.pearl.val && items.hammer.val) ? 1 : 0;
},
28: function () { // Checkerboard Cave
return items.flute.val && items.glove.val >= 2 && items.mirror.val ? 1 : 0;
},
29: function () { return items.boots.val ? 1 : 4; }, // Library
30: function () { return 1; }, // Maze Race
31: function () { // Desert Ledge
return logic.entry1() ? 1 : 4;
},
32: function () { // Lake Hylia Island
return items.flippers.val ?
items.pearl.val && items.mirror.val && (items.boss11.val || items.glove.val >= 2 || items.glove.val && items.hammer.val) ?
1 : 4 :
4;
},
33: function () { return items.shovel.val; }, // Flute Spot
34: function () { return 1; }, // Sanctuary
35: function () { // Sewers - Secret Room
if (settings.keyMode == 2) {
maxKey = items.keyAny.val;
minKey = Math.max(0,
maxKey -
(logic.entry1() ? 1 : 0) -
(logic.entry2() ? 1 : 0) -
(logic.entry3() ? 6 : 0) -
(logic.entry4() ? 1 : 0) -
(logic.entry11() ? 2 : 0)
);
}
lampTest = items.lamp.val ? 1 : 2;
return settings.openMode == 0 || items.glove.val ?
1 :
settings.keyMode == 1 ?
items.key12.val ? lampTest : 0 :
settings.keyMode == 2 && items.keyShopFound.val == 0 ?
maxKey >= 1 ?
minKey >= 1 ? lampTest : 3 :
0 :
lampTest
;
},
36: function () { // Sewers - Dark Cross
return settings.openMode == 0 || items.lamp.val ? 1 : 2;
},
37: function () { return 1; }, // Hyrule Castle
38: function () { return 1; }, // Link's Uncle
39: function () { // Old Man
return logic.climbDM() ?
items.lamp.val ? 1 : 2 :
0;
},
40: function () { // Spectacle Rock Cave
return logic.climbDM() ?
logic.DMlight() ? 1 : 2 :
0;
},
41: function () { // Ether Tablet
return items.book.val && logic.climbDM() && (items.mirror.val || items.hookshot.val && items.hammer.val) ?
items.sword.val >= 2 ?
logic.DMlight() ? 1 : 2 :
4 :
0;
},
42: function () { // Spectacle Rock
return logic.climbDM() ?
items.mirror.val ?
logic.DMlight() ? 1 : 2 :
4 :
0;
},
43: function () { // Spiral Cave
return logic.eastDM() ?
logic.DMlight() ? 1 : 2 :
0;
},
44: function () { // Mimic Cave
return !(settings.keyMode == 1 && items.key9.val < 2) &&
items.pearl.val &&
items.hammer.val &&
items.glove.val >= 2 &&
items.somaria.val &&
items.mirror.val ?
logic.medallion(9) !== 1 ?
logic.medallion(9) :
items.firerod.val ?
logic.DMlight() ? 1 : 2 :
3 :
0;
},
45: function () { // Paradox Cave
return logic.eastDM() ?
logic.DMlight() ? 1 : 2 :
0;
},
46: function () { // Floating Island
return logic.eastDM() ?
items.mirror.val && items.pearl.val && items.glove.val >= 2 ?
logic.DMlight() ? 1 : 2 :
4 :
0;
},
47: function () { // Superbunny Cave
return items.pearl.val && items.glove.val >= 2 && logic.eastDM() ?
logic.DMlight() ? 1 : 2 :
0;
},
48: function () { // Hookshot Cave
return items.pearl.val && items.glove.val >= 2 && items.hookshot.val ?
logic.DMlight() ? 1 : 2 :
0;
},
49: function () { // Hookshot Cave - Bottom Chest
return items.pearl.val && items.glove.val >= 2 && (items.hookshot.val || (items.mirror.val && items.hammer.val && items.boots.val)) ?
logic.DMlight() ? 1 : 2 :
0;
},
50: function () { // Spike Cave
return items.pearl.val && items.glove.val && items.hammer.val && (items.byrna.val || items.cape.val) ?
logic.DMlight() ? 1 : 2 :
0;
},
51: function () { // Catfish"
return logic.darkWorldEast() && items.glove.val ? 1 : 0;
},
52: function () { // Pyramid
return items.boss11.val || logic.darkWorldEast() ? 1 : 0;
},
53: function () { // Pyramid Fairy
return items.redCrystal.val >= 2 && (items.boss11.val || logic.darkWorldEast()) ? 1 : 0;
},
54: function () { // Brewery
return logic.darkWorldNW() ? 1 : 0;
},
55: function () { // C-Shaped House
return logic.darkWorldNW() ? 1 : 0;
},
56: function () { // Chest Game
return logic.darkWorldNW() ? 1 : 0;
},
57: function () { // Hammer Pegs
return items.pearl.val && items.glove.val >= 2 && items.hammer.val ? 1 : 0;
},
58: function () { // Bumper Cave
return logic.darkWorldNW() ?
items.glove.val && items.cape.val ? 1 : 4 :
0;
},
59: function () { // BlackSmith
return items.pearl.val && items.glove.val >= 2 ? 1 : 0;
},
60: function () { // Purple Chest
return items.pearl.val && items.glove.val >= 2 ? 1 : 0;
},
61: function () { // Hype Cave
return logic.darkWorldSouth() ? 1 : 0;
},
62: function () { // Stumpy
return logic.darkWorldSouth() ? 1 : 0;
},
63: function () { // Digging Game
return logic.darkWorldSouth() ? 1 : 0;
},
64: function () { // Mire Shed
return items.pearl.val && items.flute.val && items.glove.val >= 2 ? 1 : 0;
}
},
//dungeon logic functions return an object containing the following
//boss =
// 0 = unavailable
// 1 = available
// 2 = available through dark room
// 3 = visible but not attainable
//max = the maximum items possibly available (including by certain sequence breaks)
//min = the minimum items possibly available (accounting for worst luck, bad key use if key-sanity, no dark rooms or sequence breaks)
dungeons: {
0: function () { // Eastern Palace
var bow = settings.keyMode == 2 ? (items.bow.val == 2 && items.keyShopFound.val || items.bow.val == 3) : items.bow.val >= 2,
lamp = items.lamp.val,
bigKey = items.bigKey0.val;
if (settings.keyMode == 1) { // KEY-SANITY LOGIC
boss = bow && bigKey ? // need these to reach
lamp ? 1 : 2 : // boss accessible; light determines status
0;
min = 3 + // base access
(lamp ? 1 : 0) + // BK chest
(bigKey ? 1 : 0) + // big chest
(lamp && bigKey && bow ? 1 : 0) // boss
;
max = 4 + // base access (includes BK chest regardless of lamp)
(bigKey ? 1 : 0) + // big chest
(bigKey && bow ? 1 : 0) // boss
;
} else { // REGULAR AND RETRO LOGIC
boss = bow ? // need this to reach
lamp ? 1 : 2 : // boss accessible; light determines status
0;
min = lamp ?
2 + // lamp guarantees two items
(bow ? 1 : 0) : // bow & lamp guarantees third item too
1; // if no lamp, it's possible only 1 chest before dark rooms has something
max = 3; // always possible for the first three chests to have items
}
return { boss: boss, max: max, min: min }
},
1: function () { //Desert Palace
var entry = logic.entry1(),
glove = items.glove.val,
reachLanmo = entry && logic.fire() && glove,
bow = settings.keyMode == 2 ? (items.bow.val == 2 && items.keyShopFound.val || items.bow.val == 3) : items.bow.val >= 2,
fightLanmo = reachLanmo && (items.hammer.val || items.sword.val >= 1 || bow || logic.cane() || logic.rod()),
boots = items.boots.val,
key = items.key1.val,
bigKey = items.bigKey1.val;
if (settings.keyMode == 1) { // KEY-SANITY LOGIC
boss = fightLanmo && bigKey ?
key ? 1 : 3 : // if no key, player might steal pot key for chests and lock themselves out of boss
0;
min = entry ?
1 + // base access
(boots ? 1 : 0) + // torch
(key ? 2 : 0) + // compass/BK chests
(bigKey ? 1 : 0) + // big chest
(fightLanmo && bigKey ? 1 : 0) : // boss
0;
max = entry ?
1 + // base access
(boots ? 1 : 0) + // torch
(bigKey ? 1 : 0) + // big chest
(glove ?
key && fightLanmo && bigKey ? 3 : 2 : // if fully equipped, can get 3; otherwise, stealing key gives 2
key ? 2 : 0) : // if no glove, need key to get 2 chests (no boss)
0;
} else if (settings.keyMode == 2) {
if (items.keyShopFound.val) { // RETRO LOGIC - INFINITE KEYS
boss = fightLanmo ? // have inventory to fight the boss
boots ? 1 : 3 : // big key might be on torch, so if missing boots, boss access unknown
0;
min = entry ?
boots ?
2 + // boots guarantee accessing everything but boss
(fightLanmo ? 1 : 0) : // if boss beatable too, can definitely get all
1 : // if BK on torch and map/compass in small chests, can only get 1 item
0;
max = entry ? 3 : 0; // map chest, compass chest, and BK chest might have items
} else { // RETRO LOGIC - LIMITED KEYS
maxKey = items.keyAny.val - (settings.openMode == 0 ? 1 : 0); // if standard, you must have used a key at Hyrule Castle
minKey = Math.max(0, // subtracts the other places you might have spent your keys, if they are accessible
items.keyAny.val -
1 - //Hyrule Castle
(logic.entry2() ? 1 : 0) - //Tower of Hera
(logic.entry3() ? 6 : 0) - //Palace of Darkness
(logic.entry4() ? 1 : 0) - //Swamp Palace
(logic.entry11() ? 2 : 0) //Agahnim
);
boss = fightLanmo ?
minKey >= 1 && boots ? 1 : 3 : // if missing boots or if key uncertain, boss state unknown
0;
min = entry && minKey >= 1 ?
boots ?
2 + // boots guarantee accessing everything but boss
(fightLanmo ? 1 : 0) : // if boss beatable too, can definitely get all
1 : // if BK on torch and map/compass in small chests, can only get 1 item
0;
max = entry ?
1 + //map chest
(maxKey >= 1 || glove ?
2 : // compass chest and BK chest accessible
boots ? 1 : 0) : // with no glove, best case is that torch has item
0;
}
} else { // REGULAR LOGIC
boss = fightLanmo ?
boots ? 1 : 3 : // if no boots, boss state unknown
0;
min = entry ?
fightLanmo && boots ?
2 : // can get everything
boots ? 1 : 0 : // if key or big key on torch, might not get any items
0;
max = entry ? 2 : 0; //2 of first three chests might have items
}
return { boss: boss, max: max, min: min }
},
2: function () { //Tower of Hera
var entry = logic.entry2(),
fightMold = entry && (items.sword.val >= 1 || items.hammer.val),
fire = logic.fire(),
light = logic.DMlight(),
key = items.key2.val,
bigKey = items.bigKey2.val
;
if (settings.keyMode == 1) { // KEY-SANITY LOGIC
boss = fightMold && bigKey ? // requirements for boss
light ? 1 : 2 : // checks if player had to use dark room to climb Death Mountain
0;
max = entry ?
2 + //base access
(key && fire ? 1 : 0) + //basement
(bigKey ? 2 : 0) + //upstairs
(bigKey && fightMold ? 1 : 0) : //Boss
0;
min = light ? max : 0; //sets min to 0 if had to go through dark
} else if (settings.keyMode == 2) {
if (items.keyShopFound.val) { // RETRO LOGIC - INFINITE KEYS
boss = fightMold ?
fire ?
light ? 1 : 2 : // checks if player had to use dark room to climb Death Mountain
3 : // big key might be in basement, locking out boss
0;
min = entry && light && fire ?
2 + // can open every chest and get at least 2 items
(fightMold ? 1 : 0) : // can also get 3rd item, if boss has it
0; // if basement required, might get no items
max = entry ? 3 : 0; // 3 items and big key could be in first 4 chests opened
} else { // RETRO LOGIC - LIMITED KEYS
maxKey = items.keyAny.val - (settings.openMode == 0 ? 1 : 0); // if standard, you must have used a key at Hyrule Castle
minKey = Math.max(0, // subtracts the other places you might have spent your keys, if they are accessible
items.keyAny.val -
1 - // Hyrule Castle
(logic.entry1() ? 1 : 0) - // Desert Palace
(logic.entry3() ? 6 : 0) - // Palace of Darkness
(logic.entry4() ? 1 : 0) - // Swamp Palace
(logic.entry11() ? 2 : 0) // Agahnim
);
boss = fightMold && maxKey >= 1 ?
fire && minKey >= 1 ?
light ? 1 : 2 : // checks if player had to use dark room to climb Death Mountain
3 : // big key might be in basement, locking out boss
0;
min = entry && light && fire && minKey >= 1 ?
2 + // can open every chest and get at least 2 items
(fightMold ? 1 : 0) : // can also get 3rd item, if boss has it
0; // if basement required, might get no items
max = entry ? 3 : 0; // 3 items and big key could be in first 4 chests opened
}
} else { // REGULAR LOGIC
boss = fightMold ?
fire ?
light ? 1 : 2 : // checks if player had to use dark room to climb Death Mountain
3 : // big key might be in basement, locking out boss
0;
min = entry && light && fire ?
1 + // can open every chest and get at least 1 item
(fightMold ? 1 : 0) : // can also get 2nd item, if boss has it
0; // if basement required, might get no items
max = entry ? 2 : 0; // 2 items and big key could be in first 3 chests opened
}
return { boss: boss, max: max, min: min }
},
3: function () { //Palace of Darkness
var entry = logic.entry3(),
lamp = items.lamp.val,
hammer = items.hammer.val,
bow = settings.keyMode == 2 ? (items.bow.val == 2 && items.keyShopFound.val || items.bow.val == 3) : items.bow.val >= 2,
hamBow = hammer && bow,
key = items.key3.val,
bigKey = items.bigKey3.val,
fightHelm = entry && hamBow
;
if (settings.keyMode == 1) { // KEY-SANITY LOGIC
boss = entry && hamBow && bigKey && key >= 1 ? // need all this for boss
key == 6 ?
lamp ? 1 : 2 : // checks if player has to go through dark
3 : // if less than 6 keys, might spend them all elsewhere
0;
min = entry ?
1 + // first chest
(key >= 1 || key == 0 && hamBow ? 2 : 0) + // next 2 chests (bridge and stalfos head room) -- can't waste a key on the front door if you don't have one ;)
(key >= 2 ? 1 : 0) + // next chest (BK chest)
(key >= 4 ? 1 : 0) + // next chest (turtle room -- dark basement not guaranteed)
(key >= 5 ? 1 : 0) + // next chest (harmless hellway)
(bow ? 2 : 0) + // mimic chests
((key == 2 || key == 4 || key == 5) && bow && hammer ? -1 : 0) + // if have hammer, might waste key going toward boss at these key counts. don't ask why 3 is left out, it just is
(key >= 3 && lamp && !hamBow ? 3 : 0) + // if you have light and no hammer+bow, you're forced to go toward the dark rooms, which have the most chests
(key >= 4 && hamBow && lamp ? 2 : 0) + // I dont know what these two mean
(key == 4 || key == 6 && hamBow && lamp ? 1 : 0) + // but they make the numbers right
(key >= 5 && lamp ? 1 : 0) + // now you can get 2 from the dark maze instead of 1 from somewhere else, I think is what this means
(key >= 5 && lamp && bigKey ? 1 : 0) + // big chest
(key >= 2 && hamBow && lamp && bigKey ? 1 : 0) : // now any door you open will get you at least one item
0;
max = entry ?
1 + // first chest
(bow ? 2 : 0) + // mimic chests
(key >= 1 || key == 0 && hamBow ? 2 : 0) + // next 2 chests (bridge and stalfos head room)
(key >= 2 || key == 1 && hamBow ? 3 : 0) + // next 3 chests (turtle room and dark room)
(key >= 3 || key == 2 && hamBow ? 2 : 0) + // next 2 chests (dark maze)
(bigKey && (key >= 3 || key == 2 && hamBow) ? 1 : 0) + // big chest
(key >= 4 || key == 3 && hamBow ? 1 : 0) + // additional chest (harmless h or BK chest)
(key >= 5 || key == 4 && hamBow ? 1 : 0) + // additional chest (harmless h or BK chest)
(key >= 5 && bigKey && hamBow ? 1 : 0) : // boss
0;
} else if (settings.keyMode == 2) {
if (items.keyShopFound.val) { // RETRO LOGIC - INFINITE KEYS
boss = fightHelm ? // need for boss
lamp ? 1 : 2 : // checks if player has to go through dark
0;
min = entry ?
3 + // first 3 chests
(bow ? 2 : 0) + // mimic chests
(bow && lamp ? 6 : 0) + // dark rooms
(bow && lamp && hammer ? 1 : 0) : // boss
0;
max = entry ?
10 + // can just about clean the place out just by getting inside
(bow ? 1 : 0) : // but you'll need the bow for at least one thing
0;
} else { // RETRO LOGIC - LIMITED KEYS
maxKey = items.keyAny.val
- (settings.openMode == 0 ? 1 : 0) // if standard, you must have used a key at Hyrule Castle
- 2; // if less than 5 shops accessible, must have come via Agahnim
minKey = Math.max(0, // subtracts the other places you might have spent your keys, if they are accessible
items.keyAny.val
- 1 // Hyrule Castle
- (logic.entry1() ? 1 : 0) // Desert Palace
- (logic.entry2() ? 1 : 0) // Tower of Hera
- (logic.entry4() ? 1 : 0) // Swamp Palace
- 2 // Agahnim
);
boss = entry && hamBow && maxKey >= 1 ? // need to have at least 1 key
minKey >= 6 ?
lamp ? 1 : 2 : // checks if player has to go through dark
3 : // if less than 6 guaranteed keys, boss status unknown
0;
min = entry ?
(minKey >= 2 ? 1 : 0) +
(minKey >= 4 ? 1 : 0) +
(minKey >= 5 ? 1 : 0) +
(minKey == 0 && hamBow ? 2 : 0) +
(bow ? 1 : 0) +
((minKey == 1 || minKey == 3 || minKey == 4 || minKey == 6) && bow ? 1 : 0) +
(minKey >= 3 && lamp ? 1 : 0) +
(minKey >= 4 && lamp ? 2 : 0) +
(minKey >= 5 && lamp ? 1 : 0) +
(minKey >= 6 && lamp ? 1 : 0) +
((minKey == 2 || minKey == 5) && bow && !hammer ? 1 : 0) +
(minKey == 2 && hamBow && lamp ? 1 : 0) +
(minKey == 3 && lamp && !hamBow ? 2 : 0) +
(minKey == 3 && lamp && !hammer && !bow ? 1 : 0) +
(minKey == 5 && lamp && !hamBow ? 1 : 0) +
(minKey == 6 && hamBow && lamp ? 1 : 0) :
0;
max = entry ?
1 +
(maxKey >= 1 || maxKey == 0 && hamBow ? 2 : 0) +
(maxKey >= 2 || maxKey == 1 && hamBow ? 3 : 0) +
(maxKey >= 3 || maxKey == 2 && hamBow ? 2 : 0) +
(maxKey >= 4 || maxKey == 3 && hamBow ? 1 : 0) +
(maxKey >= 5 ? 1 : 0) +
(bow ? 1 : 0) +
(maxKey <= 4 && bow ? 1 : 0) :
0;
}
} else { // REGULAR LOGIC
boss = fightHelm ? // need for boss
lamp ? 1 : 2 : // checks if player has to go through dark
0;
min = entry && bow && lamp ? // if fully equipped, can do whole dungeon except boss
hammer ? 5 : 4 : // if hammer, can do boss too
0;
max = entry ? 5 : 0; // can possibly get this many just by entering
}
return { boss: boss, max: max, min: min }
},
4: function () { //Swamp Palace
var entry = logic.entry4(),
hammer = items.hammer.val,
hookshot = items.hookshot.val,
fightArrg = entry && hookshot && hammer,
key = items.key4.val,
bigKey = items.bigKey4.val
;
if (settings.keyMode == 1) { // KEY-SANITY LOGIC
boss = fightArrg && key ? 1 : 0; // all you need
min = entry ?
1 + // entrance
(key ? 1 : 0) + // ledge Chest
(key && hammer ? 3 : 0) + // main Dungeon
(key && hammer && bigKey ? 1 : 0) + // big Chest
(key && hammer && hookshot ? 4 : 0) : // back of dungeon
0;
max = min; // accessible items are the same no matter what
} else if (settings.keyMode == 2) {
if (items.keyShopFound.val) { // RETRO LOGIC - INFINITE KEYS
boss = fightArrg ? 1 : 0;
min = entry && hammer ?
3 + // main dungeon access guarantees 3
(hookshot ? 4 : 0) : // can clear full dungeon
0;
max = entry ?
2 + // first 2 chests
(hammer ? 3 : 0) + // main dungeon
(hammer && hookshot ? 2 : 0) : // complete dungeon
0;
} else { // RETRO LOGIC - LIMITED KEYS
maxKey = items.keyAny.val
- (settings.openMode == 0 ? 1 : 0) // if standard, you must have used a key at Hyrule Castle
- 2; // if less than 5 shops accessible, must have come via Agahnim
minKey = Math.max(0, // subtracts the other places you might have spent your keys, if they are accessible
items.keyAny.val
- 1 // Hyrule Castle
- (logic.entry1() ? 1 : 0) // Desert Palace
- (logic.entry2() ? 1 : 0) // Tower of Hera
- (logic.entry3() ? 6 : 0) // Palace of Darkness
- 2 // Agahnim
);
boss = fightArrg && maxKey >= 1 ?
minKey >= 1 ? 1 : 3 : // if 1 key not guaranteed, boss state unknown
0;
min = entry && minKey >= 1 ?
(hammer ? 3 : 0) + // main dungeon access guarantees 3
(hammer && hookshot ? 4 : 0) : // can clear full dungeon
0;
max = entry ?
1 + // first chest
(maxKey >= 1 ? 1 : 0) + // map chest
(maxKey >= 1 && hammer ? 3 : 0) + // main dungeon
(maxKey >= 1 && hammer && hookshot ? 2 : 0) : // can clear full dungeon
0;
}
} else { // REGULAR LOGIC
boss = fightArrg ? 1 : 0;
min = entry ?
(hammer ? 2 : 0) + // main dungeon access guarantees 2
(hammer && hookshot ? 4 : 0) : // can clear full dungeon
0;
max = entry ?
1 + // map chest
(hammer ? 3 : 0) + // 3 more possible with main dungeon access
(hammer && hookshot ? 2 : 0) : // can clear full dungeon
0;
}
return { boss: boss, max: max, min: min }
},
5: function () { // Skull Woods
var entry = logic.entry5(),
firerod = items.firerod.val,
sword = items.sword.val >= 1,
fightMoth = entry && firerod && sword,
key = items.key5.val,
bigKey = items.bigKey5.val
;
if (settings.keyMode == 1) { // KEY-SANITY LOGIC
boss = fightMoth ? 1 : 0; //boss reqs
min = entry ?
5 + // base access
(bigKey ? 1 : 0) + // big chest
(firerod ? 1 : 0) + // phase 3 chest
(fightMoth ? 1 : 0) : //Boss
0;
max = min; //no variation in availability
} else if (settings.keyMode == 2) { // RETRO LOGIC
boss = fightMoth ? 1 : 0; //boss reqs
min = entry ?
3 + // guaranteed 3 in 1st/2nd phase
(firerod ? 1 : 0) + // guaranteed a 4th
(firerod && sword ? 1 : 0) : // can complete full dungeon
0;
max = entry ?
4 + // max 4 in 1st/2nd phases
(firerod ? 1 : 0) : // can get 5th in phase 3
0;
} else { // REGULAR LOGIC
boss = fightMoth ? 1 : 0; //boss reqs
min = entry && firerod ?
1 + // both might be in phase 3
(sword ? 1 : 0) : // last might be on boss
0;
max = entry ? 2 : 0; // chance of finding both in 1st/2nd phases
}
return { boss: boss, max: max, min: min }
},
6: function () { // Thieves Town
var entry = logic.entry6(),
hammer = items.hammer.val,
fightBlind = entry && (items.sword.val >= 1 || hammer || logic.cane()),
key = items.key6.val,
bigKey = items.bigKey6.val
;
if (settings.keyMode == 1) { // KEY-SANITY LOGIC
boss = fightBlind && bigKey ? 1 : 0;
min = entry ?
4 + // base access
(bigKey ? 2 : 0) + // upstairs and jail chests
(fightBlind && bigKey ? 1 : 0) + // boss
(hammer && key && bigKey ? 1 : 0) : // big chest
0;
max = min;
} else if (settings.keyMode == 2) { // RETRO LOGIC
boss = fightBlind ? 1 : 0; //boss reqs
min = entry ?
3 + // guaranteed 3 from access
(hammer ? 1 : 0) + // big chest
(fightBlind ? 1 : 0) : // boss
0;
max = entry ? 5 : 0; // possible to get 5 from first 6 chests
} else { // REGULAR LOGIC
boss = fightBlind ? 1 : 0; //boss reqs
min = entry ?
2 + // guaranteed 2 from access
(hammer ? 1 : 0) + // big chest
(fightBlind ? 1 : 0) : // boss
0;
max = entry ? 4 : 0; // possible to get 4 from first 6 chests
}
return { boss: boss, max: max, min: min }
},
7: function () { //Ice Palace
var entry = logic.entry7(),
hookshot = items.hookshot.val,
hammer = items.hammer.val,
somaria = items.somaria.val,
spikeWalk = items.byrna.val || items.cape.val || hookshot,
fightKhold = entry && hammer,
key = items.key7.val,
bigKey = items.bigKey7.val
;
if (settings.keyMode == 1) { // KEY-SANITY LOGIC
boss = fightKhold ?
bigKey && key >= 1 && ((spikeWalk && somaria) || (spikeWalk && key == 2) || (somaria && key == 2)) ? 1 : 3 : //boss reqs; need 2 out of 3-- 2nd key, somaria, and/or spikeWalk to get a free key with
0;
min = entry ?
3 + // compass chest, freezor chest, ice T chest
(bigKey ? 1 : 0) + // big chest
((key == 0 && hookshot) || (key >= 1 && spikeWalk) ? 1 : 0) + // spike chest -- specifically need hookshot if 0 keys, otherwise any spike safety will do
(hammer && ((key == 0 && hookshot) || (key >= 1 && spikeWalk)) ? 2 : 0) + // map chest, BK chest -- specifically need hookshot if 0 keys, otherwise any spike safety will do
(key >= 1 && hammer && ((spikeWalk && somaria) || (spikeWalk && key == 2) || (somaria && key == 2)) ? 1 : 0) : //boss: need 2 out of 3-- 2nd key, somaria, and/or spikeWalk to get a free key with
0;
max = entry ?
4 + // base access + spike chest (can use free key for it)
(bigKey ? 1 : 0) + // big chest
(hammer ? 3 : 0) : // map chest, BK chest, boss
0;
} else if (settings.keyMode == 2) { // RETRO LOGIC
boss = fightKhold ? //boss reqs
spikeWalk ? 1 : 3 : //big key might be past spikes
0;
min = entry ?
1 + // guaranteed 1 item from first 4 chests
(hammer ? 1 : 0) + // 3 items might be behind hammer
(hookshot || spikeWalk ? 1 : 0) + // 2 items might be past spike/hammer area
(hammer && (hookshot || spikeWalk) ? 2 : 0) : // can get everything
0;
max = entry ?
hammer ? 5 : 4 : // if hammer, can get all; otherwise best case is 4
0;
} else { // REGULAR LOGIC
boss = fightKhold ?
hookshot ? 1 : 3 : // big key might be past spikes
0;
min = entry ?
(hammer && hookshot ? 2 : 0) + // hammer and hookshot guarantee all chests
(hammer && spikeWalk ? 1 : 0) : // hammer and other form of spikeWalk guarantee one
0;
max = entry ? 3 : 0; // first three chests could have items
}
return { boss: boss, max: max, min: min }
},
8: function () { //Misery Mire
var entry = logic.entry8(),
lamp = items.lamp.val,
somaria = items.somaria.val,
firerod = items.firerod.val,
fire = firerod || lamp,
spikeWalk = items.byrna.val || items.cape.val,
key = items.key8.val,
bigKey = items.bigKey8.val,
fightVit = entry && somaria && (items.sword.val >= 1 || items.bow.val >= 2),
medallion = logic.medallion(8)
;
if (settings.keyMode == 1) { // KEY-SANITY LOGIC
boss = fightVit && bigKey ?
medallion == 1 ?
lamp ? 1 : 2 :
medallion :
0;
max = entry ?
4 + //Bridge Chest, Spike Chest, Map Chest, Main Room
(fire ? 2 : 0) + //Compass Chest, Big Key Chest
(bigKey ? 1 : 0) + //Big Chest
(fightVit && bigKey ? 1 : 0) : //Boss
0;
min = entry ?
3 + //Bridge Chest, Map Chest, Main Room
(spikeWalk ? 1 : 0) + //Spike Chest
(fire ? 2 : 0) + //Compass Chest, Big Key Chest
(bigKey ? 1 : 0) + //Big Chest
(fightVit && bigKey && lamp ? 1 : 0) : //Boss
0;
} else if (settings.keyMode == 2) { // RETRO LOGIC