This repository has been archived by the owner on Jan 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathview.js
762 lines (703 loc) · 24.8 KB
/
view.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
(function() {
let ownedMods = getOwnedMods();
const MODS = {
'Arcane Buffer': {
'type': 'drop',
'iconName': 'EnergyShield',
'description': 'Monster has augmented Energy Shield powers and releases a stunning nova when Energy Shield breaks',
'rewards': ['Essences']
},
'Berserker': {
'type': 'drop',
'iconName': 'Rage',
'description': 'Monster Enrages as it loses life',
'rewards': ['Uniques']
},
'Bloodletter': {
'type': 'drop',
'description': 'Monster has augmented Bleed powers. Monster Maims nearby enemies',
'effect': 'Items dropped from the Monster and its Minions are Corrupted',
'rewards': ['Weapon', 'Trinkets']
},
'Bombardier': {
'type': 'drop',
'description': 'Monster has augmented Projectile powers and periodically unleashes a barrage of mortars',
'rewards': ['Weapon', 'Armour']
},
'Bonebreaker': {
'type': 'drop',
'description': 'Monster has augmented Stun powers. Monster hits are slower and can\'t be evaded',
'rewards': ['Generic', 'Weapon']
},
'Chaosweaver': {
'type': 'drop',
'iconName': 'Voidtouched',
'description': 'Monster is imbued with Chaos Damage and Resistance',
'rewards': ['Gems']
},
'Consecrator': {
'type': 'drop',
'iconName': 'Consecration',
'description': 'Monster periodically creates Consecrated Ground, healing allies and making them immune to curses and ailments',
'rewards': ['Fragments']
},
'Deadeye': {
'type': 'drop',
'description': 'Monster is Accurate and applies Marks',
'rewards': ['Armour', 'Trinkets']
},
'Dynamo': {
'type': 'drop',
'iconName': 'Shocker',
'description': 'Monster has augmented Shock powers',
'rewards': ['Generic', 'Trinkets']
},
'Echoist': {
'type': 'drop',
'iconName': 'Caster',
'description': 'Monster repeats skills additional times',
'rewards': ['Generic', 'Currency']
},
'Flameweaver': {
'type': 'drop',
'iconName': 'Flametouched',
'description': 'Monster is imbued with Fire Damage and Resistance',
'rewards': ['Weapon']
},
'Frenzied': {
'type': 'drop',
'iconName': 'Rampage',
'description': 'Monster and allies periodically Enrage',
'rewards': ['Generic', 'Uniques']
},
'Frostweaver': {
'type': 'drop',
'iconName': 'Frosttouched',
'description': 'Monster is imbued with Cold Damage and Resistance',
'rewards': ['Armour']
},
'Gargantuan': {
'type': 'drop',
'description': 'Monster is massive, granting more Life, Area of Effect, and Damage',
'rewards': ['Currency']
},
'Hasted': {
'type': 'drop',
'iconName': 'Speed',
'description': 'Monster is faster',
'rewards': ['Generic']
},
'Incendiary': {
'type': 'drop',
'iconName': 'Fire',
'description': 'Monster has augmented Ignite powers',
'rewards': ['Generic', 'Weapon']
},
'Juggernaut': {
'type': 'drop',
'description': 'Monster cannot be Slowed or Stunned. Monster gains Endurance Charges',
'rewards': ['Harbinger']
},
'Malediction': {
'type': 'drop',
'iconName': 'Oppressor',
'description': 'Monster has a weakening Aura',
'rewards': ['DivinationCards']
},
'Opulent': {
'type': 'drop',
'iconName': 'Wealthy',
'description': 'Monster is fabulously wealthy',
'rewards': []
},
'Overcharged': {
'type': 'drop',
'iconName': 'Chargegenerator',
'description': 'Monster grants Charges to itself and Allies over time',
'rewards': ['Trinkets', 'Trinkets']
},
'Permafrost': {
'type': 'drop',
'iconName': 'Freezer',
'description': 'Monster has augmented Freeze and Chill powers',
'rewards': ['Generic', 'Armour']
},
'Sentinel': {
'type': 'drop',
'iconName': 'Defender',
'description': 'Monster is imbued with Block and Spell Block. Monster Triggers Reckoning when hit',
'rewards': ['Armour', 'Armour']
},
'Soul Conduit': {
'type': 'drop',
'description': 'On death, Monster and nearby Allies are revived',
'rewards': ['Maps']
},
'Steel-infused': {
'type': 'drop',
'iconName': 'Steelattuned',
'description': 'Monster is imbued with Physical Damage and Physical Damage Reduction',
'rewards': ['Weapon']
},
'Stormweaver': {
'type': 'drop',
'iconName': 'Stormtouched',
'description': 'Monster is imbued with Lightning Damage and Resistance',
'rewards': ['Trinkets']
},
'Toxic': {
'type': 'drop',
'iconName': 'Poison',
'description': 'Monster has augmented Poison powers',
'rewards': ['Generic', 'Gems']
},
'Vampiric': {
'type': 'drop',
'description': 'Monster has augmented Life Leech powers',
'rewards': ['Fossils']
},
'Assassin': {
'type': 'recipe',
'recipe': ['Deadeye', 'Vampiric'],
'description': 'Monster has augmented Critical powers and has Shroud Walker',
'rewards': ['Currency', 'Currency']
},
'Corpse Detonator': {
'type': 'recipe',
'recipe': ['Necromancer', 'Incendiary'],
'iconName': 'Corpseeploder',
'description': 'Monster detonates nearby Corpses. Monster periodically creates Corpses',
'rewards': ['DivinationCards', 'DivinationCards']
},
'Corrupter': {
'type': 'recipe',
'recipe': ['Bloodletter', 'Chaosweaver'],
'description': 'Monster inflicts Corrupted Blood on Hit and when Hit. Minions create Corrupted Bubbles on death',
'effect': 'Items dropped from the Monster and its Minions are Corrupted',
'rewards': ['Abyss', 'Abyss']
},
'Drought Bringer': {
'type': 'recipe',
'recipe': ['Malediction', 'Deadeye'],
'iconName': 'Flaskdrain',
'description': 'Monster disables Flask effects on hit. Monster has an aura that drains Flask charges and prevents gaining Flask charges',
'rewards': ['Labyrinth', 'Labyrinth']
},
'Entangler': {
'type': 'recipe',
'recipe': ['Toxic', 'Bloodletter'],
'iconName': 'GraspingVines',
'description': 'Monster creates Thorned Vines that slow and deal Chaos Damage over time.',
'rewards': ['Fossils', 'Fossils']
},
'Executioner': {
'type': 'recipe',
'recipe': ['Frenzied', 'Berserker'],
'description': 'Monster gains Damage based on missing enemy Life. Monster has an aura that prevents enemies recovering Life and Energy Shield above 50%',
'rewards': ['Legion', 'Breach']
},
'Flame Strider': {
'type': 'recipe',
'recipe': ['Flameweaver', 'Hasted'],
'iconName': 'Fire',
'description': 'Monster leaves Burning Ground in its wake. Minions create Flame Bearers on death',
'rewards': ['Weapon', 'Weapon', 'Weapon']
},
'Frost Strider': {
'type': 'recipe',
'recipe': ['Frostweaver', 'Hasted'],
'iconName': 'Frostwalker',
'description': 'Monster leaves Chilling Ground in its wake. Minions create Frost Bearers on death',
'rewards': ['Armour', 'Armour', 'Armour']
},
'Heralding Minions': {
'type': 'recipe',
'recipe': ['Dynamo', 'Arcane Buffer'],
'iconName': 'Heraldoftheobelisk',
'description': 'Monster\'s minions summon invulnerable Lightning Totems on death',
'rewards': ['Fragments', 'Fragments']
},
'Hexer': {
'type': 'recipe',
'recipe': ['Chaosweaver', 'Echoist'],
'description': 'Monster is Hexproof. Monster is followed by a Hexing Effigy that creates Hexing areas',
'rewards': ['Essences', 'Essences']
},
'Ice Prison': {
'type': 'recipe',
'recipe': ['Permafrost', 'Sentinel'],
'iconName': 'Cold',
'description': 'Monster periodically entraps players in a cage of ice',
'effect': 'Rewards are rolled 1 additional time, choosing the rarest result',
'rewards': ['Armour', 'Armour']
},
'Magma Barrier': {
'type': 'recipe',
'recipe': ['Incendiary', 'Bonebreaker'],
'iconName': 'Volatileflameblood',
'description': 'Monster is protected by a Magmatic shield that explodes when depleted. Monster periodically creates Volatile Flamebloods',
'effect': 'Rewards are rolled 1 additional time, choosing the rarest result',
'rewards': ['Weapon', 'Weapon']
},
'Mana Siphoner': {
'type': 'recipe',
'recipe': ['Consecrator', 'Dynamo'],
'iconName': 'ManaDonut',
'description': 'Monster is surrounded by a ring that deals Lightning Damage over time as well as draining Mana',
'effect': 'Rewards are rolled 1 additional time, choosing the rarest result',
'rewards': ['Trinkets', 'Trinkets']
},
'Mirror Image': {
'type': 'recipe',
'recipe': ['Echoist', 'Soul Conduit'],
'iconName': 'MirrorImage',
'description': 'Monster can create illusions of itself',
'effect': 'Rewards are rolled 2 additional times, choosing the rarest result',
'rewards': ['Scarabs']
},
'Necromancer': {
'type': 'recipe',
'recipe': ['Bombardier', 'Overcharged'],
'description': 'Monster can raise Undead. Minions are empowered and revive shortly after dying',
'effect': 'Rewards are rolled 2 additional times, choosing the rarest result',
'rewards': ['Generic']
},
'Rejuvenating': {
'type': 'recipe',
'recipe': ['Gargantuan', 'Vampiric'],
'description': 'Monster has Life Regeneration. Periodically releases a wave that heals nearby allies and prevents enemy Life and Energy Shield recovery',
'effect': 'Rewards are rolled 1 additional time, choosing the rarest result',
'rewards': ['Currency']
},
'Storm Strider': {
'type': 'recipe',
'recipe': ['Stormweaver', 'Hasted'],
'iconName': 'Lightningwalker',
'description': 'Monster leaves Shocking Ground in its wake and spawns Lightning Mirages when hit. Minions create Storm Bearers on death',
'rewards': ['Trinkets', 'Trinkets', 'Trinkets']
},
'Crystal-skinned': {
'type': 'recipe',
'recipe': ['Permafrost', 'Rejuvenating', 'Berserker'],
'iconName': 'LivingCrystal',
'description': 'Monster triggers the creation of Crystals when hit. Crystals explode when the Monster dies',
'rewards': ['Harbinger', 'Harbinger']
},
'Effigy': {
'type': 'recipe',
'recipe': ['Hexer', 'Malediction', 'Corrupter'],
'iconName': 'Voodoodoll',
'description': 'Monster creates an Effigy of the player. Damage dealt to the Effigy is also reflected to the bonded player',
'effect': 'Rewards are rolled 1 additional time, choosing the rarest result',
'rewards': ['DivinationCards', 'DivinationCards']
},
'Empowered Elements': {
'type': 'recipe',
'recipe': ['Evocationist', 'Steel-infused', 'Chaosweaver'],
'iconName': 'Cycleofelements',
'description': 'Monster cycles between imbued damage of a particular type and immunity to all other damage types',
'effect': 'Rewards are rolled 1 additional time, choosing the rarest result',
'rewards': ['Uniques', 'Uniques']
},
'Empowering Minions': {
'type': 'recipe',
'recipe': ['Necromancer', 'Executioner', 'Gargantuan'],
'iconName': 'Unionofsouls',
'description': 'Monster\'s minions are empowered. Minions empower the Monster with additional modifiers on death',
'rewards': ['Blight', 'Ritual']
},
'Evocationist': {
'type': 'recipe',
'recipe': ['Flameweaver', 'Frostweaver', 'Stormweaver'],
'iconName': 'Prismatic',
'description': 'Monster is imbued with Elemental Damage, Resistances and Ailments',
'rewards': ['Generic', 'Weapon', 'Armour', 'Trinkets']
},
'Invulnerable': {
'type': 'recipe',
'recipe': ['Sentinel', 'Juggernaut', 'Consecrator'],
'iconName': 'Divinetouched',
'description': 'Monster and its Minions periodically become immune to all Damage. Minions cannot die while Monster is alive',
'rewards': ['Delirium', 'Metamorphosis']
},
'Soul Eater': {
'type': 'recipe',
'recipe': ['Soul Conduit', 'Necromancer', 'Gargantuan'],
'description': 'Monster empowers when nearby allies die. Periodically summons Phantasms',
'rewards': ['Maps', 'Maps']
},
'Temporal Bubble': {
'type': 'recipe',
'recipe': ['Juggernaut', 'Hexer', 'Arcane Buffer'],
'iconName': 'TimeBubble',
'description': 'Monster is protected by a Temporal Bubble that severely slows those in it and cannot be damaged by those outside of it',
'rewards': ['Heist', 'Expedition']
},
'Treant Horde': {
'type': 'recipe',
'recipe': ['Toxic', 'Sentinel', 'Steel-infused'],
'iconName': 'Saplings',
'description': 'Monster\'s minions are replaced with powerful Treants. Some Damage taken from the monster is split between the Treants',
'effect': 'Monster\'s Minions drop a randomly-chosen Reward Type',
'rewards': ['Generic']
},
'Trickster': {
'type': 'recipe',
'recipe': ['Overcharged', 'Assassin', 'Echoist'],
'description': 'Monster has damage avoidance. Monster periodically Flees',
'rewards': ['Currency', 'Uniques', 'DivinationCards']
},
'Abberath-touched': {
'type': 'boss',
'recipe': ['Flame Strider', 'Frenzied', 'Rejuvenating'],
'description': 'Monster uses the abilities of Abberath',
'effect': 'Rewards are rolled 4 additional times, choosing the rarest result',
'rewards': ['Trinkets', 'Trinkets', 'Maps']
},
'Arakaali-touched': {
'type': 'boss',
'recipe': ['Corpse Detonator', 'Entangler', 'Assassin'],
'description': 'Monster uses the abilities of Arakaali',
'effect': 'All Reward Types are Divination Cards',
'rewards': ['DivinationCards']
},
'Brine King-touched': {
'type': 'boss',
'recipe': ['Ice Prison', 'Storm Strider', 'Heralding Minions'],
'description': 'Monster uses the abilities of the Brine King',
'effect': 'Rewards are rolled 6 additional times, choosing the rarest result',
'rewards': ['Armour', 'Armour', 'Armour']
},
'Shakari-touched': {
'type': 'boss',
'recipe': ['Entangler', 'Soul Eater', 'Drought Bringer'],
'description': 'Monster uses the abilities of Shakari',
'effect': 'All Reward Types are Uniques',
'rewards': ['Uniques']
},
'Tukohama-touched': {
'type': 'boss',
'recipe': ['Bonebreaker', 'Executioner', 'Magma Barrier'],
'description': 'Monster uses the abilities of Tukohama',
'effect': 'Rewards are rolled 4 additional times, choosing the rarest result',
'rewards': ['Weapon', 'Weapon', 'Fragments']
},
'Lunaris-touched': {
'type': 'boss',
'recipe': ['Invulnerable', 'Frost Strider', 'Empowering Minions'],
'description': 'Monster uses the abilities of Lunaris',
'effect': 'All Reward Types have an additional reward',
'rewards': ['Uniques']
},
'Solaris-touched': {
'type': 'boss',
'recipe': ['Invulnerable', 'Magma Barrier', 'Empowering Minions'],
'description': 'Monster uses the abilities of Solaris',
'effect': 'All Reward Types have an additional reward',
'rewards': ['Scarabs']
},
'Innocence-touched': {
'type': 'boss',
'recipe': ['Lunaris-touched', 'Solaris-touched', 'Mirror Image', 'Mana Siphoner'],
'description': 'Monster uses the abilities of Innocence',
'effect': 'All Reward Types are Currency',
'rewards': ['Currency', 'Currency', 'Currency']
},
'Kitava-touched': {
'type': 'boss',
'recipe': ['Tukohama-touched', 'Abberath-touched', 'Corrupter', 'Corpse Detonator'],
'description': 'Monster uses the abilities of Kitava',
'effect': 'Rewards are doubled',
'rewards': ['Generic']
}
},
modList = document.querySelector('.mod-list'),
detailTag = document.querySelector('.detail-tag'),
detailIcon = document.querySelector('.detail-icon'),
detailDescription = document.querySelector('.detail-description'),
detailEffect = document.querySelector('.detail-effect'),
detailRewards = document.querySelector('.detail-rewards'),
detailRecipe = document.querySelector('.detail-recipe'),
detailRecipeContainer = document.querySelector('.detail-recipe-container'),
detailUsedIn = document.querySelector('.detail-used-in'),
detailUsedInList = document.querySelector('.detail-used-in-list'),
filterDropOnly = document.querySelector('.filter-droponly'),
filterRecipeOnly = document.querySelector('.filter-recipeonly'),
filterCraftable = document.querySelector('.filter-craftable'),
filterSelectOwned = document.querySelector('.filter-select-owned'),
filterClearOwned = document.querySelector('.filter-clear-owned'),
filterSearch = document.querySelector('.filter-search');
function getOwnedMods() {
const stored = window.localStorage.getItem('owned-mods');
if (!stored) {
return {};
}
return JSON.parse(stored).reduce((agg, mod) => {
agg[mod] = true;
return agg;
}, {});
}
function storeOwned() {
window.localStorage.setItem('owned-mods', JSON.stringify(
Object.entries(ownedMods)
.filter(([, v]) => v)
.map(([k]) => k)
));
}
function escapeRegExp(str) {
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
}
function getModIconUrl(mod) {
let name = MODS[mod].iconName || mod.slice(0, 1) + mod.slice(1).replace(/[^\w]/g, '').toLowerCase(),
type;
switch (MODS[mod].type) {
case 'drop': {
type = 'RareKill';
break;
}
case 'recipe': {
type = 'Recipe';
break;
}
case 'boss': {
type = 'Pantheon';
name = name.replace('touched', '');
break;
}
}
return `https://web.poecdn.com/image/Art/2DItems/Currency/Archnemesis/Mod${type}${name}.png?locale=1&scale=1`;
}
function getRewardIconUrl(reward) {
switch (reward) {
case 'Currency':
return 'https://web.poecdn.com/image/layout/stash/currency-tab-icon.png';
case 'Uniques':
return 'https://web.poecdn.com/image/layout/stash/unique-tab-icon.png';
case 'Fossils':
return 'https://web.poecdn.com/image/layout/stash/delve-tab-icon.png';
case 'Maps':
return 'https://web.poecdn.com/image/layout/stash/map-tab-icon.png';
case 'DivinationCards':
return 'https://web.poecdn.com/image/layout/stash/divination-tab-icon.png';
case 'Fragments':
return 'https://web.poecdn.com/image/layout/stash/fragment-tab-icon.png';
case 'Blight':
return 'https://web.poecdn.com/image/layout/stash/blight-tab-icon.png';
case 'Gems':
return 'https://web.poecdn.com/image/layout/stash/gem-tab-icon.png';
case 'Essences':
return 'https://web.poecdn.com/image/layout/stash/essence-tab-icon.png';
case 'Delirium':
return 'https://web.poecdn.com/image/layout/stash/delirium-tab-icon.png';
case 'Metamorphosis':
return 'https://web.poecdn.com/image/layout/stash/metamorph-tab-icon.png';
case 'Generic':
case 'Weapon':
case 'Trinkets':
case 'Harbinger':
case 'Ritual':
case 'Legion':
case 'Breach':
case 'Labyrinth':
case 'Heist':
case 'Expidition':
case 'Armour':
case 'Abyss':
case 'Scarabs':
default:
return null;
}
}
function buildModItem(mod, clickAction = () => showModDetails(mod)) {
const container = document.createElement('button'),
icon = document.createElement('img'),
tag = document.createElement('span');
icon.className = 'mod-icon';
icon.src = getModIconUrl(mod);
tag.className = 'mod-tag';
tag.innerText = mod;
container.className = 'mod';
container.type = 'button';
container.setAttribute('type', MODS[mod].type);
container.setAttribute('name', mod);
container.appendChild(icon);
container.appendChild(tag);
container.setAttribute('owned', ownedMods[mod] ? 'true': 'false');
container.addEventListener('click', clickAction);
return container;
}
function buildModList() {
Object.keys(MODS).forEach((mod) => {
modList.appendChild(buildModItem(mod, () => onModListClick(mod)));
});
filterDropOnly.addEventListener('click', () => {
if (filterDropOnly.innerText.includes('Hide')) {
filterDropOnly.innerText = filterDropOnly.innerText.replace('Hide', 'Show');
modList.querySelectorAll('.mod[type="drop"]').forEach((el) => {
el.style.display = 'none';
});
} else {
filterDropOnly.innerText = filterDropOnly.innerText.replace('Show', 'Hide');
modList.querySelectorAll('.mod[type="drop"]').forEach((el) => {
el.style.display = '';
});
}
});
filterRecipeOnly.addEventListener('click', () => {
if (filterRecipeOnly.innerText.includes('Hide')) {
filterRecipeOnly.innerText = filterRecipeOnly.innerText.replace('Hide', 'Show');
modList.querySelectorAll('.mod[type="boss"], .mod[type="recipe"]').forEach((el) => {
el.style.display = 'none';
});
} else {
filterRecipeOnly.innerText = filterRecipeOnly.innerText.replace('Show', 'Hide');
modList.querySelectorAll('.mod[type="boss"], .mod[type="recipe"]').forEach((el) => {
el.style.display = '';
});
}
});
filterSearch.addEventListener('input', () => {
const searchQuery = new RegExp(filterSearch.value.toLowerCase().split('').map(escapeRegExp).join('.*'), 'i');
modList.querySelectorAll('.mod').forEach((el) => {
el.style.display = searchQuery.test(el.getAttribute('name')) ? '' : 'none';
});
});
filterCraftable.addEventListener('click', () => {
if (filterCraftable.innerText.includes('Hide')) {
filterCraftable.innerText = filterCraftable.innerText.replace('Hide', 'Show');
} else {
filterCraftable.innerText = filterCraftable.innerText.replace('Show', 'Hide');
}
updateCraftableFilter();
});
filterSelectOwned.addEventListener('click', () => {
if (filterSelectOwned.innerText.includes('Select')) {
filterSelectOwned.innerText = filterSelectOwned.innerText.replace('Select', 'Stop selecting');
modList.setAttribute('mode', 'owned');
filterClearOwned.style.display = '';
} else {
filterSelectOwned.innerText = filterSelectOwned.innerText.replace('Stop selecting', 'Select');
modList.setAttribute('mode', 'details');
filterClearOwned.style.display = 'none';
}
});
filterClearOwned.addEventListener('click', () => {
clearOwned();
})
}
function updateCraftableFilter() {
if (filterCraftable.innerText.includes('Hide')) {
modList.querySelectorAll('.mod').forEach((el) => {
el.style.display = el.getAttribute('type') === 'drop' || canCraft(el.getAttribute('name'))
? '' : 'none';
});
} else {
modList.querySelectorAll('.mod').forEach((el) => {
el.style.display = '';
});
}
}
function canCraft(mod) {
return MODS[mod].recipe && MODS[mod].recipe.every((m) => ownedMods[m] || canCraft(m));
}
function onModListClick(mod) {
switch (modList.getAttribute('mode')) {
case 'owned': {
toggleOwned(mod);
return;
}
case 'details':
default: {
showModDetails(mod);
return;
}
}
}
function toggleOwned(mod) {
ownedMods[mod] = !ownedMods[mod];
document.querySelectorAll(`.mod[name="${mod}"]`).forEach((el) => {
el.setAttribute('owned', ownedMods[mod] ? 'true': 'false');
});
storeOwned();
updateCraftableFilter();
}
function clearOwned() {
ownedMods = {};
document.querySelectorAll('.mod[owned="true"]').forEach((el) => {
el.setAttribute('owned', 'false');
});
storeOwned();
updateCraftableFilter();
}
function showUsedIn(mod) {
const usedInMods = Object.entries(MODS).filter(([, {recipe}]) => recipe && recipe.includes(mod)).map(([m]) => m);
if (usedInMods.length === 0) {
detailUsedIn.style.display = 'none';
return;
}
detailUsedInList.innerHTML = '';
usedInMods.forEach((mod) => {
detailUsedInList.appendChild(buildModItem(mod));
});
detailUsedIn.style.display = '';
}
function buildRecipeTree(mod) {
const container = document.createElement('div'),
modWrapper = document.createElement('div');
container.className = 'recipe';
modWrapper.className = 'recipe-mod';
modWrapper.appendChild(buildModItem(mod));
container.appendChild(modWrapper);
if (MODS[mod].recipe) {
const ingredientContainer = document.createElement('div');
ingredientContainer.className = 'recipe-ingredients';
MODS[mod].recipe.forEach((m) => {
ingredientContainer.appendChild(buildRecipeTree(m));
});
container.appendChild(ingredientContainer);
}
return container;
}
function showRecipeTree(mod) {
const recipe = MODS[mod].recipe;
if (!recipe) {
detailRecipe.style.display = 'none';
return;
}
detailRecipeContainer.innerHTML = '';
detailRecipeContainer.appendChild(buildRecipeTree(mod));
detailRecipe.style.display = '';
}
function buildReward(reward) {
const container = document.createElement('span');
container.className = 'reward';
const iconUrl = getRewardIconUrl(reward);
if (iconUrl) {
const icon = document.createElement('img');
icon.src = iconUrl;
icon.className = 'reward-icon';
icon.title = reward;
icon.alt = reward;
container.appendChild(icon);
} else {
container.innerText += reward;
}
return container;
}
function showRewards(mod) {
detailRewards.innerHTML = '';
MODS[mod].rewards.forEach((reward) => {
detailRewards.appendChild(buildReward(reward));
});
}
function showModDetails(mod) {
detailIcon.src = getModIconUrl(mod);
detailTag.innerText = mod;
detailDescription.innerText = MODS[mod].description || '';
detailEffect.innerText = MODS[mod].effect || '';
showRewards(mod);
showRecipeTree(mod);
showUsedIn(mod);
}
buildModList();
}());