-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
leagueRanks.html
690 lines (634 loc) · 29.9 KB
/
leagueRanks.html
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
<!DOCTYPE html>
<html lang="en-US" class="dark">
<head>
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-TDF58VB');</script>
<!-- End Google Tag Manager -->
<meta charset="UTF-8">
<link rel="canonical" href="https://pvpivs.com/leagueRanks.html" />
<!-- Include pre-loads to reduce/optimize page load time-->
<link rel="preload" href="https://pvpivs.com/includes/style.css" as="style">
<link rel="preload" href="https://pvpivs.com/includes/darkLightThemes.js" as="script">
<link rel="preload" href="https://pvpivs.com/includes/collapsible.js" as="script">
<link rel="preload" href="https://pvpivs.com/includes/calculate.js" as="script">
<link rel="preload" href="https://pvpivs.com/includes/pokeListObj.js" as="script">
<title>PvP IVs - League Rankings</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="PvP IVs lookup tool for Pokémon Go™ to help compare your Pokémon's PvP IVs to ideal PvP IVs. Finds PvP IVs for any wild-caught, weather boosted, traded, raided, hatched, and even purified Pokémon! Did you catch the very best?"/>
<link rel="icon"
type="image/png"
href="https://pvpivs.com/includes/favicon.png">
<link rel="stylesheet" href="https://pvpivs.com/includes/style.css">
<style>
#myProgress {
width: 100%;
background-color: var(--navBackground);
}
#myBar {
width: 0%;
height: 30px;
background-color: var(--navActive);
text-align: center;
line-height: 30px;
color: var(--navActiveText);
}
button {
font-size: large;
background-color: var(--navActive);
color: var(--navActiveText);
padding: 5px 5px;
}
</style>
<!-- Begin Playwire Head -->
<script>window.ramp=window.ramp ||{}; window.ramp.que=window.ramp.que || []; </script> <script async src="//cdn.intergient.com/1025030/74482/ramp_config.js"></script> <script>window._pwGA4PageviewId=''.concat(Date.now()); window.dataLayer=window.dataLayer || []; window.gtag=window.gtag || function (){dataLayer.push(arguments);}; gtag('js', new Date()); gtag('config', 'G-JD7R9RWFZL',{'send_page_view': false}); gtag( 'event', 'ramp_js',{'send_to': 'G-JD7R9RWFZL', 'pageview_id': window._pwGA4PageviewId}); </script>
<!-- End Playwire Head -->
</head>
<body onload="checkURI()">
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-TDF58VB"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
<header>
<ul class="header">
<li class="dropdown left">
<a href="javascript:void(0)" class="dropbtn active">PvP IVs</a>
<div class="dropdown-content">
<a href="/">Rankings (Single)</a>
<a href="/indexTest.html">Rankings (Beta)</a>
<a href="/leagueRanks.html" class="active">Rankings (League)</a>
<a href="/searchStr.html">Search Strings</a>
<a href="/calculator.html">Calculator</a>
</div>
</li>
<li class="dropdown left">
<a href="javascript:void(0)" class="dropbtn">Typing</a>
<div class="dropdown-content">
<a href="/typeLookup.html">Chart</a>
<a href="/typeQuiz.html">Quiz</a>
</div>
</li>
<li class="flat right">
<div class="theme-toggle-div">
<img id="theme-toggle-icon" src="https://pvpivs.com/includes/sun.svg" aria-label="Change to light theme" alt="Sun icon" width="22" height="22">
</div>
</li>
<li class="dropdown right">
<a href="javascript:void(0)" class="dropburger"><div class="container"><div class="bar"></div><div class="bar"></div><div class="bar"></div></div></a>
<div class="dropdown-content dropdown-content-right">
<a href="/about.html">About PvP IVs</a>
<a href="/contribute.html">Contribute</a>
<a href="/contact.html">Contact Us</a>
<a href="/privacy.html">Privacy Policy</a>
<a href="/cookies.html">Cookie Policy</a>
</div>
</li>
</ul>
</header>
<br />
<section>
<label>League:<select id="league">
<option value="500" label="Little Leagues">Little Leagues</option>
<option value="1500" selected label="Great League">Great League</option>
<option value="2500" label="Ultra League">Ultra League</option>
<option value="false" label="Master League">Master League</option>
</select></label><br />
<label>Max Level:<select title="What Level Ceiling to Search?" id="maxLvl">
<option value="1">1: Wild Caught</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15: Research Reward</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20: Raid Reward</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25: Purified</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
<option value="32">32</option>
<option value="33">33</option>
<option value="34">34</option>
<option value="35">35</option>
<option value="36">36</option>
<option value="37">37</option>
<option value="38">38</option>
<option value="39">39</option>
<option value="40">40</option>
<option value="41">41</option>
<option value="42">42</option>
<option value="43">43</option>
<option value="44">44</option>
<option value="45">45</option>
<option value="46">46</option>
<option value="47">47</option>
<option value="48">48</option>
<option value="49">49</option>
<option value="50">50</option>
<option selected value="51">51: Best Buddy</option>
<option value="52">52 (SPECULATIVE)</option>
<option value="53">53 (SPECULATIVE)</option>
<option value="54">54 (SPECULATIVE)</option>
<option value="55">55 (SPECULATIVE)</option>
</select></label><br />
<h3>Advanced:<button id="advButton" onclick="collapsible('advCollapsible','advArrow')" style="background-color:transparent; border:none; width:33px; height:33px;"><i id="advArrow" class="arrow down"></i></button></h3>
<div id=advCollapsible hidden>
<label>Include Mega Evolutions:<input id="mega" type="checkbox"></label><br />
<label>Include Entire Pokedex:<input id="all" type="checkbox"></label><br />
<label>Include Top <input type="number" value="10" id="limit" min="1" max="4096"> Buckets:<input id="buckets" type="checkbox"></label><br />
<label>Include Impossible IVs:<input id="impossible" type="checkbox"></label><br />
</div>
<br /><button onclick="start()">Calculate</button>
</section>
<div id="feedbackBox"></div>
<div style="overflow-x:auto; text-align: center;" id="outputBox"><i><br/>Press Calculate Button to Begin...</i></div>
<div style="overflow-x:auto;" id="chart_div"></div>
<div id="myProgress">
<div id="myBar">0%</div>
</div>
<script async defer src="https://pvpivs.com/includes/darkLightThemes.js"></script>
<script async defer src="https://pvpivs.com/includes/collapsible.js"></script>
<script src="https://pvpivs.com/includes/calculate.js"></script>
<script src="https://pvpivs.com/includes/pokeListObj.js"></script>
<script>
var perfTiming = false; /* used for timing execution */
var lastPercent;
function start() {
if (true) {var startT0 = performance.now();}
var monNames = Object.keys(pokeListObj);
/* Ensure we've successfully loaded pokeListObj, and converted to list for awesomplete */
if (monNames.length<1000) /* At time of writing, monNames.length was 1025 */
{
console.log("ERROR: Failed to load pokeListObj!");
}
/* Yes we have the valid pokeListObj, build results */
var output = document.getElementById('outputBox');
output.innerHTML = ""; /*ensure we clear the prior output between runs*/
var uri;
var maxLvl = document.getElementById('maxLvl').value;
console.log("maxLvl read as:"+maxLvl);
var maxLvlCPM = Math.max(0, (maxLvl - 1) * 2); /* use half-levels */
var league = document.getElementById('league').value;
var leagueName = document.getElementById('league').options[document.getElementById('league').selectedIndex].innerHTML;
console.log("leagueName: "+JSON.stringify(leagueName));
var mega = document.getElementById('mega').checked;
var all = document.getElementById('all').checked;
var elem = document.getElementById("myBar");
var feedback = document.getElementById('feedbackBox');
var buckets = document.getElementById('buckets').checked;
var limit = document.getElementById('limit').value;
var impossible = document.getElementById('impossible').checked;
var i = 0;
/* Reset progress bar between runs */
elem.style.width = '0%';
elem.innerHTML = "0%";
lastPercent = 0;
/* creates a <table> element and a <tbody> element */
/* https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Traversing_an_HTML_table_with_JavaScript_and_DOM_Interfaces */
var tbl = document.createElement("table");
var tblBody = document.createElement("tbody");
tbl.setAttribute("id", "outTable");
var header = tbl.createTHead();
var headerRow = header.insertRow(0);
headerRow.innerHTML = "<tr><th>Dex</th><th>Mon</th><th>Lvl</th><th>CP</th><th>Atk IV</th><th>Def IV</th><th>Sta IV</th><th>Apr</th><th>Perfect</th>";
/*include XL candy costs if Max Level > 41*/
if (maxLvl > 41) {headerRow.innerHTML+="<th>XL</th>";}
headerRow.innerHTML += "<th>PvP Atk</th><th>PvP Def</th><th>PvP HP</th><th>Stat Prod</th></tr>";
if (buckets) {headerRow.innerHTML += "<th>a0</th><th>a1</th><th>a2</th><th>a3</th><th>a4</th><th>d0</th><th>d1</th><th>d2</th><th>d3</th><th>d4</th><th>s0</th><th>s1</th><th>s2</th><th>s3</th><th>s4</th></tr>";}
var tooSmallMons = "";
var tooBigMons = "";
/* Support new IV search buckets */
atkBuckets = new Array(5).fill(0);
defBuckets = new Array(5).fill(0);
staBuckets = new Array(5).fill(0);
/* Initialize 3D ivBuckets Array */
var ivBuckets = new Array(5).fill(0);
for (j=0;j<5;j++) {
ivBuckets[j] = new Array(5).fill(0);
}
for (j=0;j<5;j++) {
for (k=0; k<5;k++) {
ivBuckets[j][k] = new Array(5).fill(0);
}
}
/*update the URL with search parameters*/
var URL = window.location.href.split("?")[0];
uri = URL + "?";
if (league/1!=1500) {uri+="cp="+league;}
if (maxLvl/1!=51) {uri+="&max="+maxLvl;}
if (mega) {uri+="&mega="+mega;}
if (all) {uri+="&all="+all;}
if (buckets) {uri += "&buckets="+buckets+"&limit="+limit;}
if (impossible) {uri += "&impossible="+impossible;}
uri = encodeURI(uri);
var newTitle = "PvP IVs - "+leagueName+" Rankings (Level "+maxLvl+")";
document.title = newTitle;
window.history.pushState(null, newTitle, uri);
/* Function that is called recursively to create cells and update progress of rank calculations */
(function leagueRanks() {
/* Skip all Megas if box is checked */
if (monNames[i].includes("Mega_") && !mega) {
console.log("Skipping "+monNames[i]);
} else {
var monStats = pokeListObj[monNames[i]].split(',');
var maxCP = Math.max(10, Math.floor((parseInt(monStats[1]) + 15) * Math.sqrt(parseInt(monStats[2]) + 15) * Math.sqrt(parseInt(monStats[3]) + 15) * cpm[maxLvlCPM] * cpm[maxLvlCPM] / 10));
/* Skip filter if user checks box for ALL results or Level 1 */
if ((all) || (maxLvl == 1) ||
/* Filter out too low of max CP values to increase calculation speed */
/* Include Wobbuffet (max 1160CP) for Great League cutoff, and */
/* Altaria (2266), Dewgong (2245), and Quagsire (2252) for Ultra */
((league == 500 && maxCP > 410) ||
(league == 1500 && maxCP > 1150) ||
(league == 2500 && maxCP > 2200) ||
(maxCP > 2500))) {
var row = document.createElement("tr");
/* Check for higher minIVs or minLvls for non-wild spawning mon */
const [minIVs, minLvl] = adjustFloors(monNames[i], maxLvl, impossible);
/* Do the rank calculations for each mon */
var ranks = calculate(parseInt(monStats[1]), parseInt(monStats[2]), parseInt(monStats[3]), minIVs, minLvl, maxLvl, false, league, monNames[i]);
var keys = Object.keys(ranks);
var maxStatProd = keys[0].split(".")[0];
if (ranks.numRanks/1 >0) {
progress(monNames[i], (pokeListObj[monNames[i]].split(",")[0]).split("b")[0].split("&")[0], maxLvl, Math.round(i/monNames.length*100), feedback, elem, row, ranks[keys[0]][0], parseFloat(100*(keys[0].split(".")[0])/maxStatProd).toFixed(3), keys[0].split(".")[0], ranks.numRanks/1);
if (buckets) {calculateBuckets(ranks, keys, limit, atkBuckets, defBuckets, staBuckets, row, ivBuckets, monNames[i])};
/* add the row to the end of the table body */
tblBody.appendChild(row);
} else {
tooBigMons += monNames[i]+"(L"+minLvl+"+), ";
}
} else {
tooSmallMons += monNames[i]+"("+maxCP+"), ";
}
}
/* Are we done, or keep calculating? */
if (i<monNames.length-1) {
setTimeout(leagueRanks, 0);
}
else{
console.log("i: "+i);
/* We are done calculating, time to finish */
feedback.innerHTML = "<p><i>Complete!</i></p><br />";
if (buckets) {feedback.innerHTML +="<p>atkBuckets: "+JSON.stringify(atkBuckets)+", defBuckets: "+JSON.stringify(defBuckets)+", staBuckets: "+JSON.stringify(staBuckets)+"</p><br />";}
/* put the <tbody> in the <table> */
tbl.appendChild(tblBody);
/* appends <table> into <body> and adds a break after for footer spacing*/
document.getElementById('outputBox').appendChild(tbl);
document.getElementById('outputBox').innerHTML += "<br /><br />";
/*make table sortable by clicking on any header*/
/*https://stackoverflow.com/a/49041392*/
const getCellValue = (tr, idx) => tr.children[idx].innerText || tr.children[idx].textContent;
const comparer = (idx, asc) => (a, b) => ((v1, v2) =>
v1 !== '' && v2 !== '' && !isNaN(v1.replace("%", "")) && !isNaN(v2.replace("%", "")) ? v1.replace("%", "") - v2.replace("%", "") : v1.toString().localeCompare(v2)
)(getCellValue(asc ? a : b, idx), getCellValue(asc ? b : a, idx));
/*do the work... (tbody version) */
/* https://stackoverflow.com/a/53880407 */
document.querySelectorAll('th').forEach(th => th.addEventListener('click', (() => {
const table = th.closest('table');
const tbody = table.querySelector('tbody');
Array.from(tbody.querySelectorAll('tr'))
.sort(comparer(Array.from(th.parentNode.children).indexOf(th), this.asc = !this.asc))
.forEach(tr => tbody.appendChild(tr) );
})));
var skippedMessage = "Skipped all CPs below ";
if (league == 500) {skippedMessage+="400 ";} else
if (league == 1500) {skippedMessage+="1300 ";} else
if (league == 2500) {skippedMessage+="2300 ";} else
{skippedMessage+="2500 ";}
skippedMessage += tooSmallMons + ". Removed all too big mon: " + tooBigMons;
console.log(skippedMessage);
skippedMessage = "";
if (buckets) {
console.log("atkBuckets: "+JSON.stringify(atkBuckets));
console.log("defBuckets: "+JSON.stringify(defBuckets));
console.log("staBuckets: "+JSON.stringify(staBuckets));
console.log("ivBuckets: "+JSON.stringify(ivBuckets));
var trashString = "";
for (i=0;i<5;i++){
for (j=0;j<5;j++){
if (!(ivBuckets[i][j][0]) && !(ivBuckets[i][j][1]) && !(ivBuckets[i][j][2]) && !(ivBuckets[i][j][3]) && !(ivBuckets[i][j][4])) {
trashString += i+"attack&"+j+"defense&"+"0-4hp,";
continue;
} else if (!(ivBuckets[i][j][0]) && !(ivBuckets[i][j][1]) && !(ivBuckets[i][j][2]) && !(ivBuckets[i][j][3]) && (ivBuckets[i][j][4])) {
trashString += i+"attack&"+j+"defense&"+"0-3hp,";
continue;
} else if (!(ivBuckets[i][j][0]) && !(ivBuckets[i][j][1]) && !(ivBuckets[i][j][2]) && ivBuckets[i][j][3] && ivBuckets[i][j][4]) {
trashString += i+"attack&"+j+"defense&"+"0-2hp,";
continue;
} else if (!(ivBuckets[i][j][0]) && !(ivBuckets[i][j][1]) && ivBuckets[i][j][2] && ivBuckets[i][j][3] && ivBuckets[i][j][4]) {
trashString += i+"attack&"+j+"defense&"+"0-1hp,";
continue;
}
for(k=0;k<5;k++){
if (!(ivBuckets[i][j][k])) {
trashString += i+"attack&"+j+"defense&"+k+"hp,";
/*console.log("Safe to trash "+i+"attack&"+j+"defense"+k+"hp");*/
}
}
} /* Line break for search string output by attack IV*/
trashString += "<br />"
}
}
if (buckets) {feedback.innerHTML +="<p>"+trashString+"</p><br />";}
/* Compute total execution time */
if (true) {var startT1 = performance.now();
console.log("start: Execution took "+(startT1-startT0).toFixed(1)+"ms");}
return true;
}
i++;
})();
}
function progress(monName, dexNum, maxLvl, percent, feedback, elem, row, stats, perfect, statProd, numRanks) {
feedback.innerHTML = "<p><i>Calculating "+monName+", please wait...</i></p>";
/* Update progress bar */
if (percent > lastPercent+1) {
lastPercent = percent;
elem.style.width = percent + "%";
elem.innerHTML = percent + "%";
}
/* write cells for this row */
outCell(dexNum, row); /*Dex#*/
outCell(monName, row); /*Mon*/
outCell(stats.L, row); /*Level*/
outCell(stats.CP, row); /*Final CP*/
outCell(stats.IVs.A, row); /*Atk IV*/
outCell(stats.IVs.D, row); /*Def IV*/
outCell(stats.IVs.S, row); /*Sta IV*/
outCell(stats.IVs.star, row); /*Star Appraisal*/
outCell(perfect+"%", row); /*Perfection*/
if (maxLvl > 41) { /* XL Candy costs */
outCell(XLcandy(stats.L/1 - 40), row);
}
outCell(numOut(stats.battle.A,1), row); /*GL Atk Total*/
outCell(numOut(stats.battle.D,1), row); /*GL Def Total*/
outCell(stats.battle.S, row); /*GL HP*/
outCell(statProd, row); /*Stat Product*/
}
/*returns minIVs, minLvl*/
function adjustFloors(monName, maxLvl, impossible) {
/* ensure that the user wants us to exclude impossible IVs */
if (!(impossible)) {
/*check if we need to adjust IV Floor or Min Level*/
if (boxRewrd.includes(monName)) {
console.log("Detected box reward mon:"+monName);
/*set min IVs to 1 and min Level to 15*/
return [1, 15];
} else
if (raidOnly.includes(monName)) {
console.log("Detected Raid+Trade mon:"+monName);
/*set min IVs to 1 and min Level to 20*/
return [1, 20];
} else
if (boxMyth.includes(monName)) {
console.log("Detected Mythical mon:"+monName);
/*set min IVs to 10 and min Level to 15*/
return [10, 15];
} else
if (raidMyth.includes(monName)) {
console.log("Detected Raid no Trade mon:"+monName);
/*set min IVs to 10 and min Level to 20*/
return [10, 20];
}
}
if (maxLvl/1 == 1) {
/*support Level One league*/
return [15,1];
} else {
/* Otherwise, return zeros */
return [0, 0];
}
}
/* Returns calculated XL candy costs based on https://i.redd.it/kb4pu1kxu9061.png */
function XLcandy(xlev) {
switch (xlev) {
case 11:
return 296;
case 10.5:
return 276;
case 10:
return 296;
case 9.5:
return 276;
case 9:
return 256;
case 8.5:
return 236;
case 8:
return 216;
case 7.5:
return 199;
case 7:
return 182;
case 6.5:
return 165;
case 6:
return 148;
case 5.5:
return 133;
case 5:
return 118;
case 4.5:
return 103;
case 4:
return 88;
case 3.5:
return 76;
case 3:
return 64;
case 2.5:
return 52;
case 2:
return 40;
case 1.5:
return 30;
case 1:
return 20;
case 0.5:
return 10;
default:
return 0;
}
}
function outCell(contents, row) {
/* Create a <td> element and a text node, make the text node the */
/* contents of the <td>, and put the <td> at the end of the table row */
var cell = document.createElement("td");
var cellText = document.createTextNode(contents);
cell.appendChild(cellText);
row.appendChild(cell);
}
function numOut(num, decimals) {
switch (decimals) {
case 1:
return (Math.trunc(num*10)/10).toFixed(decimals);
default:
console.log("ERROR: numOut: unsupported decimal place:"+decimals);
return false;
}
}
function calculateBuckets(ranks, keys, limit, atkBuckets, defBuckets, staBuckets, row, ivBuckets, monName) {
if (perfTiming) {var calculateBucketst0 = performance.now();}
var i=0,j=0,counted=0;
var a0=0,a1=0,a2=0,a3=0,a4=0;
var d0=0,d1=0,d2=0,d3=0,d4=0;
var s0=0,s1=0,s2=0,s3=0,s4=0;
/*walk all (4096) entries in ranks and compare*/
for (i=0; (i<limit && (keys[i].indexOf(".")>-1) && counted<limit); i++) {
for (j=0; j<ranks[keys[i]].length && j<limit && counted<limit; j++) {
var atk = ranks[keys[i]][j].IVs.A;
var def = ranks[keys[i]][j].IVs.D;
var sta = ranks[keys[i]][j].IVs.S;
var atkBkt = 0, defBkt = 0, hpBkt = 0;
/* Update IV search bucket counters*/
/* 0 is 0IV, 1 is 1-5IV, 2 is 6-10IV, 3 is 11-14IV, 4 is 15IV */
if (atk/1==15) {atkBuckets[4]++;a4++;atkBkt=4;}
else if (atk/1>10) {atkBuckets[3]++;a3++;atkBkt=3;}
else if (atk/1>5) {atkBuckets[2]++;a2++;atkBkt=2;}
else if (atk/1>0) {atkBuckets[1]++;a1++;atkBkt=1;}
else if (atk/1===0) {atkBuckets[0]++;a0++;atkBkt=0;}
else console.error("Invalid atk ("+atk+")");
if (def/1==15) {defBuckets[4]++;d4++;defBkt=4;}
else if (def/1>10) {defBuckets[3]++;d3++;defBkt=3;}
else if (def/1>5) {defBuckets[2]++;d2++;defBkt=2;}
else if (def/1>0) {defBuckets[1]++;d1++;defBkt=1;}
else if (def/1===0) {defBuckets[0]++;d0++;defBkt=0;}
else console.error("Invalid def ("+def+")");
if (sta/1==15) {staBuckets[4]++;s4++;hpBkt=4;}
else if (sta/1>10) {staBuckets[3]++;s3++;hpBkt=3;}
else if (sta/1>5) {staBuckets[2]++;s2++;hpBkt=2;}
else if (sta/1>0) {staBuckets[1]++;s1++;hpBkt=1;}
else if (sta/1===0) {staBuckets[0]++;s0++;hpBkt=0;}
else console.error("Invalid sta ("+sta+")");
/* Mark this specific IV set as "used" */
ivBuckets[atkBkt][defBkt][hpBkt] = true;
if (atkBkt===0 && defBkt===0 && hpBkt===0) {
console.log("Found a 0-0-0 IV spread: rank "+i+" "+monName);
}
if (atkBkt>1 && defBkt<3 && hpBkt<3) {
console.log("Found a "+atk+"-"+def+"-"+sta+" IV spread: rank "+i+" "+monName);
}
counted++;
}
}
/* Write this mon's output to row */
outCell(a0, row);
outCell(a1, row);
outCell(a2, row);
outCell(a3, row);
outCell(a4, row);
outCell(d0, row);
outCell(d1, row);
outCell(d2, row);
outCell(d3, row);
outCell(d4, row);
outCell(s0, row);
outCell(s1, row);
outCell(s2, row);
outCell(s3, row);
outCell(s4, row);
if (perfTiming) {var calculateBucketst1 = performance.now();
console.log("calculateBuckets: Execution took "+(calculateBucketst1-calculateBucketst0).toFixed(1)+"ms");}
}
function checkURI() {
if (perfTiming) {var checkURIt0 = performance.now();}
var URL = window.location.href.split("?")[1];
var validParams = false;
if (URL)
{
URL = decodeURI(URL);
console.log("Read URL as: "+URL);
var values = URL.split("&");
console.log("Values array as: "+JSON.stringify(values));
for (var i=0; i<values.length; i++)
{
switch (values[i].split("=")[0]) {
case "cp":
document.getElementById('league').value = values[i].split("=")[1];
validParams = true;
break;
case "max":
document.getElementById('maxLvl').value = values[i].split("=")[1];
validParams = true;
break;
case "all":
document.getElementById('all').checked = values[i].split("=")[1] == "true" ? true : false;
validParams = true;
collapsible("advCollapsible","advArrow");
break;
case "mega":
document.getElementById('mega').checked = values[i].split("=")[1] == "true" ? true : false;
validParams = true;
collapsible("advCollapsible","advArrow");
break;
case "buckets":
document.getElementById('buckets').checked = values[i].split("=")[1] == "true" ? true : false;
validParams = true;
collapsible("advCollapsible","advArrow");
break;
case "limit":
document.getElementById('limit').value = values[i].split("=")[1];
validParams = true;
collapsible("advCollapsible","advArrow");
break;
case "impossible":
document.getElementById('impossible').checked = values[i].split("=")[1] == "true" ? true : false;
validParams = true;
collapsible("advCollapsible","advArrow");
break;
case "t": /* Enable performance timing output in console for debugging */
perfTiming = values[i].split("=")[1];
break;
}
}
if (perfTiming) {var checkURIt1 = performance.now();
console.log("checkURI: Execution took "+(checkURIt1-checkURIt0).toFixed(1)+"ms");}
if (validParams == true) {
console.log("Found at least one valid URL parameter, starting calculations...");
start();
} else {
console.log("Only found invalid URL parameters, waiting for user to click Calculate button to start");
}
return true;
}
else
{
console.log("No inputs detected, awaiting user input");
if (perfTiming) {var checkURIt1 = performance.now();
console.log("checkURI: Execution took "+(checkURIt1-checkURIt0).toFixed(1)+"ms");}
return false;
}
}
</script>
<br />
<div style="overflow-x:auto; max-width:474px; margin-left:auto; margin-right:auto;">
<p style="color:var(--tableHeaderText); font-size:0.8em">© 2024 PvP IVs | <a href="https://pvpivs.com/privacy">Privacy Policy</a> | <a href="https://pvpivs.com/contact">Contact Us</a></p>
<p style="color:var(--tableDividers); font-size:0.6em">Pokémon and Pokémon GO are copyright of The Pokémon Company, Niantic, Inc., and Nintendo. All trademarked images and names are property of their respective owners, and any such material is used on this site for educational purposes only. PvP IVs has no affiliation with The Pokémon Company, Niantic, Inc., or Nintendo.</p>
</div><br /><br /><br /><br />
<footer>
<!-- Begin Playwire Footer -->
<script data-cfasync="false" async src="https://cdn.intergient.com/ramp_core.js"></script>
<!-- End Playwire Footer -->
</footer>
</body>
</html>