-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpdps.js
More file actions
737 lines (650 loc) · 27.4 KB
/
pdps.js
File metadata and controls
737 lines (650 loc) · 27.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
const githubBaseUrl = 'https://raw.githubusercontent.com/PathofJS/poepdps/refs/heads/main/';
let pdpsData = {}; // Global variable to store loaded JSON data
document.addEventListener("DOMContentLoaded", async function() {
const wepName = document.querySelector('.wepName');
const baseImg = document.getElementById("baseImg");
baseImg.src = githubBaseUrl + 'img/stone.png';
const selBase = document.getElementById("selBase");
const inpBaseMin = document.getElementById("inpBaseMin");
const inpBaseMax = document.getElementById("inpBaseMax");
const selFlat = document.getElementById("selFlat");
const inpFlatMin = document.getElementById("inpFlatMin");
const inpFlatMax = document.getElementById("inpFlatMax");
const displayTierValues = document.getElementById("displayTierValues");
const selPhys = document.getElementById("selPhys");
const inpPhys = document.getElementById("inpPhys");
const selHyb = document.getElementById("selHyb");
const inpHyb = document.getElementById("inpHyb");
const selSpeed = document.getElementById("selSpeed");
const inpSpeed = document.getElementById("inpSpeed");
const selCrit = document.getElementById("selCrit");
const inpCrit = document.getElementById("inpCrit");
const totalMin = document.getElementById("totalMin");
const totalMax = document.getElementById("totalMax");
const wepAps = document.getElementById("wepAps");
const inpQual = document.getElementById("inpQual");
const wepQual = document.getElementById("wepQual");
const basePdps = document.getElementById("basePdps");
const selEnch = document.getElementById("selEnch");
const inpBaseAps = document.getElementById("inpBaseAps");
const inpEnch1 = document.getElementById("inpEnch1");
const selSynthFlat = document.getElementById("selSynthFlat");
const inpSynthFlatMin = document.getElementById("inpSynthFlatMin");
const inpSynthFlatMax = document.getElementById("inpSynthFlatMax");
const selSynthPhys = document.getElementById("selSynthPhys");
const inpSynthPhys = document.getElementById("inpSynthPhys");
const selSynthSpeed = document.getElementById("selSynthSpeed");
const inpSynthSpeed = document.getElementById("inpSynthSpeed");
const wepEnch = document.getElementById("wepEnch");
const wepSynth1 = document.getElementById("wepSynth1");
const wepSynth2 = document.getElementById("wepSynth2");
const wepSynth3 = document.getElementById("wepSynth3");
const wepPrf1 = document.getElementById("wepPrf1");
const wepPrf2 = document.getElementById("wepPrf2");
const wepPrf3 = document.getElementById("wepPrf3");
const wepSuf1 = document.getElementById("wepSuf1");
const wepSuf2 = document.getElementById("wepSuf2");
const wepSuf3 = document.getElementById("wepSuf3");
const inpHybAS = document.getElementById("inpHybAS");
const hybAsLabel = document.getElementById("hybAsLabel");
const hybAsUnit = document.getElementById("hybAsUnit");
wepName.textContent = "Stone Axe";
try {
const response = await fetch('pdps.json');
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
pdpsData = await response.json();
} catch (error) {
console.error("Failed to load pdps.json:", error);
alert("Error: Could not load data. Please ensure 'pdps.json' is available.");
return;
}
preloadImages(pdpsData.imgPaths);
function preloadImages(imgPaths) {
imgPaths.forEach(path => {
const img = new Image();
img.src = githubBaseUrl + path;
});
}
function getEnchantDescription(enchant) {
if (!enchant) return "No Enchantment";
let description = [];
if (enchant.physMods) {
description.push(`${enchant.physMods}% increased magnitudes of Physical mods`);
}
if (enchant.speedMods) {
description.push(`${enchant.speedMods}% increased Attack Speed`);
}
if (enchant.critMods) {
description.push(`${enchant.critMods}% increased Critical Strike Chance`);
}
if (enchant.physHybBonus) {
description.push(`${enchant.physHybBonus.min}-${enchant.physHybBonus.max}% increased Physical and Hybrid Damage`);
}
return description.join(" and ") || "No Enchantment";
}
function getSynthFlatDescription(tier) {
const synthData = pdpsData.tiersSynthFlat[tier];
if (!synthData || (synthData.min1 === 0 && synthData.min2 === 0)) {
return "No Modifier";
}
return `Adds ${synthData.min1}-${synthData.max1} to ${synthData.min2}-${synthData.max2} Physical Damage`;
}
function getSynthPhysDescription(tier) {
const synthData = pdpsData.tiersSynthPhys[tier];
if (!synthData || synthData.min === 0) {
return "No Modifier";
}
return `${synthData.min}-${synthData.max}% increased Physical Damage`;
}
function getSynthSpeedDescription(tier) {
const synthData = pdpsData.tiersSynthSpeed[tier];
if (!synthData || synthData.min === 0) {
return "No Modifier";
}
return `${synthData.min}-${synthData.max}% increased Attack Speed`;
}
function getFlatAffixDescription() {
const min = parseFloat(inpFlatMin.value) || 0;
const max = parseFloat(inpFlatMax.value) || 0;
if (min === 0 && max === 0) return "";
return `${min}-${max} added Physical`;
}
function getPhysAffixDescription() {
const phys = parseFloat(inpPhys.value) || 0;
const hyb = parseFloat(inpHyb.value) || 0;
const total = phys + hyb;
if (total === 0) return "";
return `${total}% increased Physical Damage`;
}
function getSpeedAffixDescription() {
const value = parseFloat(inpSpeed.value) || 0;
if (value === 0) return "";
return `${value}% increased Attack Speed`;
}
function getCritAffixDescription() {
const value = parseFloat(inpCrit.value) || 0;
if (value === 0) return "";
return `${value}% increased Critical Chance`;
}
function updateModifierDisplays() {
if (wepEnch) wepEnch.innerText = "";
if (wepSynth1) wepSynth1.innerText = "";
if (wepSynth2) wepSynth2.innerText = "";
if (wepSynth3) wepSynth3.innerText = "";
if (wepPrf1) wepPrf1.innerText = "";
if (wepPrf2) wepPrf2.innerText = "";
if (wepPrf3) wepPrf3.innerText = "";
if (wepSuf1) wepSuf1.innerText = "";
if (wepSuf2) wepSuf2.innerText = "";
if (wepSuf3) wepSuf3.innerText = "";
const enchantIndex = parseInt(selEnch.value) || 0;
const enchantData = enchantIndex > 0 ? pdpsData.tiersEnch[enchantIndex - 1] : null;
const enchantText = enchantIndex === 0 ? "No Enchantment" : getEnchantDescription(enchantData);
if (wepEnch) wepEnch.innerText = enchantText;
const synthFlatTier = parseInt(selSynthFlat.value) || 0;
const synthFlatText = getSynthFlatDescription(synthFlatTier);
if (wepSynth1) wepSynth1.innerText = synthFlatText;
const synthPhysTier = parseInt(selSynthPhys.value) || 0;
const synthPhysText = getSynthPhysDescription(synthPhysTier);
if (wepSynth2) wepSynth2.innerText = synthPhysText;
const synthSpeedTier = parseInt(selSynthSpeed.value) || 0;
const synthSpeedText = getSynthSpeedDescription(synthSpeedTier);
if (wepSynth3) wepSynth3.innerText = synthSpeedText;
const flatAffixText = getFlatAffixDescription();
if (wepPrf1 && flatAffixText) wepPrf1.innerText = flatAffixText;
const physAffixText = getPhysAffixDescription();
if (wepPrf2 && physAffixText) wepPrf2.innerText = physAffixText;
const speedAffixText = getSpeedAffixDescription();
if (wepSuf1 && speedAffixText) wepSuf1.innerText = speedAffixText;
const critAffixText = getCritAffixDescription();
if (wepSuf2 && critAffixText) wepSuf2.innerText = critAffixText;
}
function populateSelEnch() {
selEnch.innerHTML = '<option value="0" selected>No Enchantment</option>';
pdpsData.tiersEnch.forEach((enchant, index) => {
const option = document.createElement("option");
option.value = index + 1;
let label = "";
if (enchant.physMods) label += `Phys +${enchant.physMods}%`;
if (enchant.speedMods) label += `${label ? " & " : ""}Speed:${enchant.speedMods}%`;
if (enchant.critMods) label += `${label ? " & " : ""}Crit:${enchant.critMods}%`;
if (enchant.physHybBonus) label += `${label ? " & " : ""}Phys+Hyb:${enchant.physHybBonus.min}-${enchant.physHybBonus.max}%`;
option.textContent = label || `Enchant ${index + 1}`;
selEnch.appendChild(option);
});
selEnch.value = "0";
}
function populateSelSynthFlat() {
selSynthFlat.innerHTML = '<option value="0" selected>No Modifier</option>';
Object.keys(pdpsData.tiersSynthFlat).forEach(tier => {
if (tier !== "0") {
const synthData = pdpsData.tiersSynthFlat[tier];
const option = document.createElement("option");
option.value = tier;
let label = synthData.min1 > 0 || synthData.min2 > 0 ? `Adds ${synthData.min1}-${synthData.max1} to ${synthData.min2}-${synthData.max2} Phys` : "No Modifier";
option.textContent = label;
selSynthFlat.appendChild(option);
}
});
selSynthFlat.value = "0";
updateInpSynthFlatTier(0);
}
function populateSelSynthPhys() {
selSynthPhys.innerHTML = '<option value="0" selected>No Modifier</option>';
Object.keys(pdpsData.tiersSynthPhys).forEach(tier => {
if (tier !== "0") {
const synthData = pdpsData.tiersSynthPhys[tier];
const option = document.createElement("option");
option.value = tier;
let label = synthData.min > 0 ? `${synthData.min}-${synthData.max}% inc Phys` : "No Modifier";
option.textContent = label;
selSynthPhys.appendChild(option);
}
});
selSynthPhys.value = "0";
updateInpSynthPhysTier(0);
}
function populateSelSynthSpeed() {
selSynthSpeed.innerHTML = '<option value="0" selected>No Modifier</option>';
Object.keys(pdpsData.tiersSynthSpeed).forEach(tier => {
if (tier !== "0") {
const synthData = pdpsData.tiersSynthSpeed[tier];
const option = document.createElement("option");
option.value = tier;
let label = synthData.min > 0 ? `${synthData.min}-${synthData.max}% inc Speed` : "No Modifier";
option.textContent = label;
selSynthSpeed.appendChild(option);
}
});
selSynthSpeed.value = "0";
updateInpSynthSpeedTier(0);
}
function populateSelHyb() {
selHyb.innerHTML = '';
for (const key in pdpsData.tiersHyb) {
const option = document.createElement("option");
option.value = key;
let label = key;
if (pdpsData.tiersHyb[key].physDamage) {
label = `${key}: ${pdpsData.tiersHyb[key].physDamage.min}-${pdpsData.tiersHyb[key].physDamage.max}% inc Phys`;
}
if (pdpsData.tiersHyb[key].as1 && pdpsData.tiersHyb[key].as2) {
label += `, ${pdpsData.tiersHyb[key].as1}-${pdpsData.tiersHyb[key].as2}% inc AS`;
}
option.textContent = label;
selHyb.appendChild(option);
}
selHyb.value = "No Hybrid";
updateInpHybTier("No Hybrid");
}
function applyEnchantModifiers() {
const selectedIndex = parseInt(selEnch.value) || 0;
const selectedEnchant = selectedIndex > 0 ? pdpsData.tiersEnch[selectedIndex - 1] : null;
const flatTier = parseInt(selFlat.value) || 0;
const flatData = pdpsData.tiersFlat[flatTier] || { min1: 0, max1: 0, min2: 0, max2: 0 };
let flatMinValue = flatData.max1;
let flatMaxValue = flatData.max2;
const physTier = parseInt(selPhys.value) || 0;
const physData = pdpsData.tiersPhys[physTier] || { min: 0, max: 0 };
let physValue = physData.max;
const hybTierKey = selHyb.value;
const hybData = pdpsData.tiersHyb[hybTierKey];
let hybValue = (hybData && hybData.physDamage) ? hybData.physDamage.max : 0;
const speedTier = parseInt(selSpeed.value) || 0;
const speedData = pdpsData.tiersSpeed[speedTier] || { min: 0, max: 0 };
let speedValue = speedData.max;
const critTier = parseInt(selCrit.value) || 0;
const critData = pdpsData.tiersCrit[critTier] || { min: 0, max: 0 };
let critValue = critData.max;
if (!selectedEnchant) {
if (wepEnch) wepEnch.innerText = "No Enchantment";
inpFlatMin.value = flatMinValue;
inpFlatMax.value = flatMaxValue;
inpPhys.value = physValue;
inpHyb.value = hybValue;
inpSpeed.value = speedValue;
inpCrit.value = critValue;
inpEnch1.value = 0;
inpEnch1.min = 0;
inpEnch1.max = 0;
return;
}
if (wepEnch) wepEnch.innerText = getEnchantDescription(selectedEnchant);
if (selectedEnchant.physHybBonus) {
const bonusMin = selectedEnchant.physHybBonus.min;
const bonusMax = selectedEnchant.physHybBonus.max;
inpEnch1.min = bonusMin;
inpEnch1.max = bonusMax;
const currentEnchValue = parseFloat(inpEnch1.value) || 0;
if (currentEnchValue < bonusMin || currentEnchValue > bonusMax) {
inpEnch1.value = bonusMax;
}
} else {
inpEnch1.value = 0;
inpEnch1.min = 0;
inpEnch1.max = 0;
}
if (selectedEnchant.physMods) {
const physMultiplier = 1 + (selectedEnchant.physMods / 100);
flatMinValue = Math.round(flatMinValue * physMultiplier);
flatMaxValue = Math.round(flatMaxValue * physMultiplier);
physValue = Math.round(physValue * physMultiplier);
hybValue = Math.round(hybValue * physMultiplier);
inpFlatMin.value = flatMinValue;
inpFlatMax.value = flatMaxValue;
inpPhys.value = physValue;
inpHyb.value = hybValue;
} else {
inpFlatMin.value = flatMinValue;
inpFlatMax.value = flatMaxValue;
inpPhys.value = physValue;
inpHyb.value = hybValue;
}
if (selectedEnchant.speedMods) {
const speedMultiplier = 1 + (selectedEnchant.speedMods / 100);
speedValue = Math.round(speedValue * speedMultiplier);
inpSpeed.value = speedValue;
} else {
inpSpeed.value = speedValue;
}
if (selectedEnchant.critMods) {
const critMultiplier = 1 + (selectedEnchant.critMods / 100);
critValue = Math.round(critValue * critMultiplier);
inpCrit.value = critValue;
} else {
inpCrit.value = critValue;
}
}
function updateInpBase(tier) {
const tierData = pdpsData.axeBases[tier];
if (tierData) {
inpBaseMin.value = tierData.min;
inpBaseMax.value = tierData.max;
inpBaseAps.value = tierData.baseAps.toFixed(2);
} else {
console.error("Invalid base tier selected:", tier);
inpBaseMin.value = 0;
inpBaseMax.value = 0;
inpBaseAps.value = 0;
}
}
function updateInpFlatTier(tier) {
const tierData = pdpsData.tiersFlat[tier];
if (tierData) {
inpFlatMin.min = tierData.min1;
inpFlatMin.max = tierData.max1;
inpFlatMin.value = tierData.max1;
inpFlatMax.min = tierData.min2;
inpFlatMax.max = tierData.max2;
inpFlatMax.value = tierData.max2;
displayTierValues.style.display = "none";
} else {
console.error("Invalid flat tier selected:", tier);
displayTierValues.style.display = "none";
}
}
function updateInpPhysTier(tier) {
const tierData = pdpsData.tiersPhys[tier];
if (tierData) {
inpPhys.min = tierData.min;
inpPhys.max = tierData.max;
inpPhys.value = tierData.max;
displayTierValues.style.display = "none";
} else {
console.error("Invalid Phys tier selected:", tier);
displayTierValues.style.display = "none";
}
}
function updateInpHybTier(tierKey) {
const tierData = pdpsData.tiersHyb[tierKey];
if (tierData && tierData.physDamage) {
inpHyb.min = tierData.physDamage.min;
inpHyb.max = tierData.physDamage.max;
inpHyb.value = tierData.physDamage.max;
inpHyb.style.display = "";
inpHyb.nextSibling.textContent = " % Increased Physical Damage";
} else {
inpHyb.value = 0;
inpHyb.style.display = "none";
inpHyb.nextSibling.textContent = "";
}
if (tierData && tierData.as1 && tierData.as2) {
inpHybAS.min = tierData.as1;
inpHybAS.max = tierData.as2;
inpHybAS.value = tierData.as2;
inpHybAS.style.display = "";
hybAsLabel.style.display = "";
hybAsUnit.style.display = "";
inpHybAS.placeholder = `${tierData.as1}-${tierData.as2}`;
} else {
inpHybAS.value = 0;
inpHybAS.style.display = "none";
hybAsLabel.style.display = "none";
hybAsUnit.style.display = "none";
inpHybAS.placeholder = "0-0";
}
if (inpHyb.style.display === "none" && inpHybAS.style.display === "none") {
displayTierValues.style.display = "none";
} else {
displayTierValues.style.display = "none";
}
updateTotalValues();
}
function updateInpSpeedTier(tier) {
const tierData = pdpsData.tiersSpeed[tier];
if (tierData) {
inpSpeed.min = tierData.min;
inpSpeed.max = tierData.max;
inpSpeed.value = Math.round(tierData.max);
} else {
console.error("Invalid Speed tier selected:", tier);
}
}
function updateInpCritTier(tier) {
const tierData = pdpsData.tiersCrit[tier];
if (tierData) {
inpCrit.min = tierData.min;
inpCrit.max = tierData.max;
inpCrit.value = Math.round(tierData.max);
} else {
console.error("Invalid Crit tier selected:", tier);
}
}
function updateInpSynthFlatTier(tier) {
const tierData = pdpsData.tiersSynthFlat[tier];
if (tierData) {
inpSynthFlatMin.min = tierData.min1;
inpSynthFlatMin.max = tierData.max1;
inpSynthFlatMin.value = tierData.max1;
inpSynthFlatMax.min = tierData.min2;
inpSynthFlatMax.max = tierData.max2;
inpSynthFlatMax.value = tierData.max2;
} else {
console.error("Invalid Synth Flat tier selected:", tier);
inpSynthFlatMin.value = 0;
inpSynthFlatMax.value = 0;
}
}
function updateInpSynthPhysTier(tier) {
const tierData = pdpsData.tiersSynthPhys[tier] || { min: 0, max: 0 };
inpSynthPhys.min = tierData.min;
inpSynthPhys.max = tierData.max;
inpSynthPhys.value = tierData.max;
}
function updateInpSynthSpeedTier(tier) {
const tierData = pdpsData.tiersSynthSpeed[tier];
if (tierData) {
inpSynthSpeed.min = tierData.min;
inpSynthSpeed.max = tierData.max;
inpSynthSpeed.value = tierData.max;
} else {
console.error("Invalid Synth Speed tier selected:", tier);
inpSynthSpeed.value = 0;
}
}
function updateTotalValues() {
try {
const baseTier = selBase.value;
const baseData = pdpsData.axeBases[baseTier] || { min: 0, max: 0, baseAps: 0, critc: 0 };
let baseMinValue = parseFloat(inpBaseMin.value) || baseData.min;
let baseMaxValue = parseFloat(inpBaseMax.value) || baseData.max;
const flatTier = parseInt(selFlat.value) || 0;
const flatData = pdpsData.tiersFlat[flatTier] || { min1: 0, max1: 0, min2: 0, max2: 0 };
const flatMinValue = parseFloat(inpFlatMin.value) || flatData.max1;
const flatMaxValue = parseFloat(inpFlatMax.value) || flatData.max2;
const physTier = parseInt(selPhys.value) || 0;
const physData = pdpsData.tiersPhys[physTier] || { min: 0, max: 0 };
const physValue = parseFloat(inpPhys.value) || physData.max;
const hybTierKey = selHyb.value;
const hybData = pdpsData.tiersHyb[hybTierKey];
const hybValue = (hybData && hybData.physDamage) ? (parseFloat(inpHyb.value) || hybData.physDamage.max) : 0;
let hybAttackSpeed = parseFloat(inpHybAS.value) || 0;
const speedTier = parseInt(selSpeed.value) || 0;
const speedData = pdpsData.tiersSpeed[speedTier] || { min: 0, max: 0 };
let speedValue = parseFloat(inpSpeed.value) || speedData.max;
const critTier = parseInt(selCrit.value) || 0;
const critData = pdpsData.tiersCrit[critTier] || { min: 0, max: 0 };
const critValue = parseFloat(inpCrit.value) || critData.max;
const incQual = parseFloat(inpQual.value) || 0;
const qualityMultiplier = 1 + (incQual / 100);
const synthFlatTier = parseInt(selSynthFlat.value) || 0;
const synthFlatData = pdpsData.tiersSynthFlat[synthFlatTier] || { min1: 0, max1: 0, min2: 0, max2: 0 };
const synthFlatMinValue = parseFloat(inpSynthFlatMin.value) || synthFlatData.max1;
const synthFlatMaxValue = parseFloat(inpSynthFlatMax.value) || synthFlatData.max2;
const synthPhysTier = parseInt(selSynthPhys.value) || 0;
const synthPhysData = pdpsData.tiersSynthPhys[synthPhysTier] || { min: 0, max: 0 };
const synthPhysValue = parseFloat(inpSynthPhys.value) || synthPhysData.max;
const synthSpeedTier = parseInt(selSynthSpeed.value) || 0;
const synthSpeedData = pdpsData.tiersSynthSpeed[synthSpeedTier] || { min: 0, max: 0 };
const synthSpeedValue = parseFloat(inpSynthSpeed.value) || synthSpeedData.max;
const selectedIndex = parseInt(selEnch.value) || 0;
const selectedEnchant = selectedIndex > 0 ? pdpsData.tiersEnch[selectedIndex - 1] : null;
let enchBonus = 0;
if (selectedEnchant && selectedEnchant.physHybBonus) {
const bonusMin = selectedEnchant.physHybBonus.min;
const bonusMax = selectedEnchant.physHybBonus.max;
enchBonus = parseFloat(inpEnch1.value) || 0;
enchBonus = Math.max(bonusMin, Math.min(bonusMax, enchBonus));
}
let totalTierValue = physValue + hybValue + synthPhysValue;
if (enchBonus > 0) {
if (physValue === 0 && hybValue === 0 && synthPhysValue === 0) {
const bonusMultiplier = 1 + (enchBonus / 100);
baseMinValue = Math.round(baseMinValue * bonusMultiplier);
baseMaxValue = Math.round(baseMaxValue * bonusMultiplier);
} else {
totalTierValue += enchBonus;
}
}
let minTotal = baseMinValue + flatMinValue + synthFlatMinValue;
let maxTotal = baseMaxValue + flatMaxValue + synthFlatMaxValue;
const tierMultiplier = 1 + (totalTierValue / 100);
minTotal *= tierMultiplier;
maxTotal *= tierMultiplier;
minTotal = Math.round(minTotal * qualityMultiplier);
maxTotal = Math.round(maxTotal * qualityMultiplier);
totalMin.innerText = minTotal;
totalMax.innerText = maxTotal;
wepQual.innerText = incQual;
const baseAps = parseFloat(baseData.baseAps) || 0;
if (!isNaN(baseAps) && baseAps > 0) {
const totalSpeedValue = speedValue + synthSpeedValue + hybAttackSpeed;
const totalAps = baseAps * (1 + (totalSpeedValue / 100));
wepAps.innerText = totalAps.toFixed(2);
} else {
wepAps.innerText = "Base not selected";
inpBaseAps.value = 0;
}
if (document.getElementById("wepCrit")) {
const baseCritChance = baseData.critc || 0;
const totalCritChance = baseCritChance * (1 + (critValue / 100));
document.getElementById("wepCrit").innerText = totalCritChance.toFixed(2) + "%";
}
} catch (error) {
console.error("Error in updateTotalValues:", error);
totalMin.innerText = "Error";
totalMax.innerText = "Error";
wepAps.innerText = "Error";
basePdps.innerText = "0";
}
}
function updatePdps() {
const minPdps = parseFloat(totalMin.innerText) || 0;
const maxPdps = parseFloat(totalMax.innerText) || 0;
const aps = parseFloat(wepAps.innerText) || 0;
const finalDPS = Math.round(((minPdps + maxPdps) / 2) * aps);
basePdps.innerText = isNaN(finalDPS) ? "0" : finalDPS;
}
populateSelEnch();
populateSelSynthFlat();
populateSelSynthPhys();
populateSelSynthSpeed();
populateSelHyb();
applyEnchantModifiers();
updateModifierDisplays();
updateTotalValues();
updatePdps();
selBase.addEventListener("change", () => {
const selectedBase = selBase.value;
updateInpBase(selectedBase);
baseImg.src = githubBaseUrl + `img/${selectedBase}.png`; // <-- IMPORTANT FIX
wepName.textContent = selBase.options[selBase.selectedIndex].text;
applyEnchantModifiers();
updateModifierDisplays();
updateTotalValues();
updatePdps();
});
selFlat.addEventListener("change", () => {
const selectedTier = parseInt(selFlat.value) || 0;
updateInpFlatTier(selectedTier);
applyEnchantModifiers();
updateModifierDisplays();
updateTotalValues();
updatePdps();
});
selPhys.addEventListener("change", () => {
const selectedTier = parseInt(selPhys.value) || 0;
updateInpPhysTier(selectedTier);
applyEnchantModifiers();
updateModifierDisplays();
updateTotalValues();
updatePdps();
});
selHyb.addEventListener("change", () => {
const selectedTierKey = selHyb.value;
updateInpHybTier(selectedTierKey);
applyEnchantModifiers();
updateModifierDisplays();
updateTotalValues();
updatePdps();
});
selSpeed.addEventListener("change", () => {
const selectedTier = parseInt(selSpeed.value) || 0;
updateInpSpeedTier(selectedTier);
applyEnchantModifiers();
updateModifierDisplays();
updateTotalValues();
updatePdps();
});
selCrit.addEventListener("change", () => {
const selectedTier = parseInt(selCrit.value) || 0;
updateInpCritTier(selectedTier);
applyEnchantModifiers();
updateModifierDisplays();
updateTotalValues();
updatePdps();
});
selEnch.addEventListener("change", () => {
applyEnchantModifiers();
updateModifierDisplays();
updateTotalValues();
updatePdps();
});
selSynthFlat.addEventListener("change", () => {
const selectedTier = parseInt(selSynthFlat.value) || 0;
updateInpSynthFlatTier(selectedTier);
applyEnchantModifiers();
updateModifierDisplays();
updateTotalValues();
updatePdps();
});
selSynthPhys.addEventListener("change", () => {
const selectedTier = parseInt(selSynthPhys.value) || 0;
updateInpSynthPhysTier(selectedTier);
applyEnchantModifiers();
updateModifierDisplays();
updateTotalValues();
updatePdps();
});
selSynthSpeed.addEventListener("change", () => {
const selectedTier = parseInt(selSynthSpeed.value) || 0;
updateInpSynthSpeedTier(selectedTier);
applyEnchantModifiers();
updateModifierDisplays();
updateTotalValues();
updatePdps();
});
const inputElements = [
inpFlatMin, inpFlatMax, inpBaseMin, inpBaseMax,
inpPhys, inpHyb, inpSpeed, inpQual, inpCrit, inpEnch1,
inpSynthFlatMin, inpSynthFlatMax, inpSynthPhys, inpSynthSpeed
];
inputElements.forEach(input => {
if (input) {
input.addEventListener('input', () => {
if (input.id === "inpSynthPhys") {
const tier = parseInt(selSynthPhys.value) || 0;
const tierData = pdpsData.tiersSynthPhys[tier] || { min: 0, max: 0 };
if (parseFloat(input.value) > tierData.max || parseFloat(input.value) < tierData.min) {
input.value = tierData.max;
}
}
updateModifierDisplays();
updateTotalValues();
updatePdps();
});
}
});
});