-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
calculator.html
451 lines (434 loc) · 20.8 KB
/
calculator.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
<!DOCTYPE html>
<html lang="en-US" class="dark">
<head>
<!-- GA4 Tag -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-LQY2YVNT21"></script><script>window.dataLayer=window.dataLayer || []; function gtag(){dataLayer.push(arguments);}gtag('js', new Date()); gtag('config', 'G-LQY2YVNT21');</script>
<!-- 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/calculator.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/calculate.js" as="script">
<link rel="preload" href="https://cdnjs.cloudflare.com/ajax/libs/awesomplete/1.1.5/awesomplete.min.css" as="style">
<link rel="preload" href="https://cdnjs.cloudflare.com/ajax/libs/awesomplete/1.1.5/awesomplete.min.js" as="script">
<link rel="preload" href="https://pvpivs.com/includes/pokeListObj.js" as="script">
<link rel="preload" href="https://code.jquery.com/jquery-3.7.1.slim.min.js" as="script" integrity="sha256-kmHvs0B+OpCW5GVHUNjv9rOmY0IvSIRcf7zGUDTDQM8=" crossorigin="anonymous">
<title>PvP IVs - Calculator</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description"
content="PvP IVs CP, Level, and IV Calculator for Pokémon Go™ to help you understand more about the Pokémon you just caught. Finds CPs, Level, or even IVs for any Pokémon you've caught, traded, raided, or hatched! Did you catch the very best?" />
<link rel="icon"
type="image/png"
href="https://pvpivs.com/includes/favicon.png">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/awesomplete/1.1.5/awesomplete.min.css">
<link rel="stylesheet" href="https://pvpivs.com/includes/style.css">
<style>
input[type=number] {
width: 44px;
}
input[id=pokeList] {
width: 111px;
}
#ivInputTable, #lvlSelect, #cpInput {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
margin-left:auto;
margin-right:auto;
}
</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>
<!-- 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">Rankings (League)</a>
<a href="/searchStr.html">Search Strings</a>
<a href="/calculator.html" class="active">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>
<input id="pokeList" onfocus="this.value=''" placeholder="Pokémon"/>
<br /><br />
<table id="ivInputTable">
<tr>
<td title="Your Attack IV">Atk</td>
<td title="Your Defense IV">Def</td>
<td title="Your Stamina IV">Sta</td>
</tr>
<tr>
<td>
<select title="Your Attack IV" class="aIV" id="aIV">
<option value=""></option>
<option value="15">15</option>
<option value="14">14</option>
<option value="13">13</option>
<option value="12">12</option>
<option value="11">11</option>
<option value="10">10</option>
<option value="9">9</option>
<option value="8">8</option>
<option value="7">7</option>
<option value="6">6</option>
<option value="5">5</option>
<option value="4">4</option>
<option value="3">3</option>
<option value="2">2</option>
<option value="1">1</option>
<option value="0">0</option>
</select>
</td>
<td>
<select title="Your Defense IV" id="dIV">
<option value=""></option>
<option value="15">15</option>
<option value="14">14</option>
<option value="13">13</option>
<option value="12">12</option>
<option value="11">11</option>
<option value="10">10</option>
<option value="9">9</option>
<option value="8">8</option>
<option value="7">7</option>
<option value="6">6</option>
<option value="5">5</option>
<option value="4">4</option>
<option value="3">3</option>
<option value="2">2</option>
<option value="1">1</option>
<option value="0">0</option>
</select></td>
<td>
<select title="Your Stamina IV" id="sIV">
<option value=""></option>
<option value="15">15</option>
<option value="14">14</option>
<option value="13">13</option>
<option value="12">12</option>
<option value="11">11</option>
<option value="10">10</option>
<option value="9">9</option>
<option value="8">8</option>
<option value="7">7</option>
<option value="6">6</option>
<option value="5">5</option>
<option value="4">4</option>
<option value="3">3</option>
<option value="2">2</option>
<option value="1">1</option>
<option value="0">0</option>
</select></td>
</tr>
</table>
<br /><label for="level" id="lvlSelect">Level: </label>
<select title="Your Level" id="level">
<option value=""></option>
<option value="51">51</option>
<option value="50.5">50.5</option>
<option value="50">50</option>
<option value="49.5">49.5</option>
<option value="49">49</option>
<option value="48.5">48.5</option>
<option value="48">48</option>
<option value="47.5">47.5</option>
<option value="47">47</option>
<option value="46.5">46.5</option>
<option value="46">46</option>
<option value="45.5">45.5</option>
<option value="45">45</option>
<option value="44.5">44.5</option>
<option value="44">44</option>
<option value="43.5">43.5</option>
<option value="43">43</option>
<option value="42.5">42.5</option>
<option value="42">42</option>
<option value="41.5">41.5</option>
<option value="41">41</option>
<option value="40.5">40.5</option>
<option value="40">40</option>
<option value="39.5">39.5</option>
<option value="39">39</option>
<option value="38.5">38.5</option>
<option value="38">38</option>
<option value="37.5">37.5</option>
<option value="37">37</option>
<option value="36.5">36.5</option>
<option value="36">36</option>
<option value="35.5">35.5</option>
<option value="35">35</option>
<option value="34.5">34.5</option>
<option value="34">34</option>
<option value="33.5">33.5</option>
<option value="33">33</option>
<option value="32.5">32.5</option>
<option value="32">32</option>
<option value="31.5">31.5</option>
<option value="31">31</option>
<option value="30.5">30.5</option>
<option value="30">30</option>
<option value="29.5">29.5</option>
<option value="29">29</option>
<option value="28.5">28.5</option>
<option value="28">28</option>
<option value="27.5">27.5</option>
<option value="27">27</option>
<option value="26.5">26.5</option>
<option value="26">26</option>
<option value="25.5">25.5</option>
<option value="25">25</option>
<option value="24.5">24.5</option>
<option value="24">24</option>
<option value="23.5">23.5</option>
<option value="23">23</option>
<option value="22.5">22.5</option>
<option value="22">22</option>
<option value="21.5">21.5</option>
<option value="21">21</option>
<option value="20.5">20.5</option>
<option value="20">20</option>
<option value="19.5">19.5</option>
<option value="19">19</option>
<option value="18.5">18.5</option>
<option value="18">18</option>
<option value="17.5">17.5</option>
<option value="17">17</option>
<option value="16.5">16.5</option>
<option value="16">16</option>
<option value="15.5">15.5</option>
<option value="15">15</option>
<option value="14.5">14.5</option>
<option value="14">14</option>
<option value="13.5">13.5</option>
<option value="13">13</option>
<option value="12.5">12.5</option>
<option value="12">12</option>
<option value="11.5">11.5</option>
<option value="11">11</option>
<option value="10.5">10.5</option>
<option value="10">10</option>
<option value="9.5">9.5</option>
<option value="9">9</option>
<option value="8.5">8.5</option>
<option value="8">8</option>
<option value="7.5">7.5</option>
<option value="7">7</option>
<option value="6.5">6.5</option>
<option value="6">6</option>
<option value="5.5">5.5</option>
<option value="5">5</option>
<option value="4.5">4.5</option>
<option value="4">4</option>
<option value="3.5">3.5</option>
<option value="3">3</option>
<option value="2.5">2.5</option>
<option value="2">2</option>
<option value="1.5">1.5</option>
<option value="1">1</option>
</select><br/>
<br /><label for="cp" id="cpInput">CP: </label><input type="number" id="cp" min="10">
<label for="hp" id="hpInput">HP: </label><input type="number" id="hp" min="10">
<br /><br />
<span style="overflow-x:auto;" id="outputBox"><i>Please enter a valid Pokémon above to
continue...</i></span>
<br />
<script async defer src="https://pvpivs.com/includes/darkLightThemes.js"></script>
<script src="https://pvpivs.com/includes/calculate.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/awesomplete/1.1.5/awesomplete.min.js"></script>
<script src="https://pvpivs.com/includes/pokeListObj.js"></script>
<script src="https://code.jquery.com/jquery-3.7.1.slim.min.js" integrity="sha256-kmHvs0B+OpCW5GVHUNjv9rOmY0IvSIRcf7zGUDTDQM8=" crossorigin="anonymous"></script>
<script>
var perfTiming = false; /* used for timing execution */
$( document ).ready(function() {
/* Run main() whenever user adds new input */
$("#aIV, #dIV, #sIV, #level, #cp, #hp").on( "change", function() {main();} );
var input = document.getElementById("pokeList");
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.error("monNames.length (" + monNames.length + ") shorter than expected (1000), check pokeListObj load");
document.getElementById('feedbackBox').innerHTML = "<p><i>ERROR: Failed to load, please try again.<br>If this issue persists, please <a href='https://discord.gg/UD4Temq'>contact us on Discord</i></p>";
console.log("pokeListObj: " + JSON.stringify(pokeListObj));
console.log("monNames: " + JSON.stringify(monNames));
} else {
new Awesomplete(input, { list: monNames });
/*https://github.com/LeaVerou/awesomplete/issues/16438#issuecomment-195921708*/
Awesomplete.$.bind(input, {
"awesomplete-selectcomplete": function (evt) {
/*console.log("User Selected "+evt.text.label+", passing to main and exiting Awesomplete");*/
main();
}
});
/* end Awesomeplete https://leaverou.github.io/awesomplete/ */
}
});
function main() {
let pokemon = document.getElementById("pokeList")?.text?.label;
if (!pokemon) pokemon = document.getElementById("pokeList")?.value;
if (pokemon && pokeListObj[pokemon]) {
calcCP(pokemon);
} else {
console.log("calcCP: Still waiting for pokemon input, read: "+pokemon);
}
}
function calcCP(pokemon) {
var T0;
if (perfTiming) {T0 = performance.now();}
const aIV = $("#aIV").val();
const dIV = $("#dIV").val();
const sIV = $("#sIV").val();
const level = $("#level").val();
const cp = $("#cp").val();
const hp = $("#hp").val();
/*console.log("calcCP: Received "+pokemon+" inputs: aIV: "+aIV+", dIV: "+dIV+", sIV: "+sIV+", level: "+level+", cp: "+cp+", hp: "+hp);*/
if ((aIV && sIV && dIV && (level || cp)) || (level && cp)) {
const monInfo = pokeListObj[pokemon].split(',');
const baseAtk = parseInt(monInfo[1], 10);
const baseDef = parseInt(monInfo[2], 10);
const baseSta = parseInt(monInfo[3], 10);
if (level) {
if (cp/1>=10) {
/* Calculate IVs from level and CP */
const cpmIndex = Math.round((level - 1) * 2);
var possibleIVs = [];
for (var a=15; a>=0; a--) {
for (var d=15; d>=0; d--) {
for (var s=15; s>=0; s--) {
const computedCP = Math.max(10, Math.floor((baseAtk + a/1) * Math.sqrt(baseDef + d/1) * Math.sqrt(baseSta + s/1) * cpm[cpmIndex] * cpm[cpmIndex] / 10));
const computedHP = Math.max(10, Math.floor((baseSta + s/1)*cpm[cpmIndex]));
if (cp/1 == computedCP/1) {
if (hp/1>=10) {
if (hp/1 == computedHP/1) {
/* Matched HP and CP! */
possibleIVs.push([a,d,s]);
}
} else {
/* Matched CP, no HP input */
possibleIVs.push([a,d,s]);
}
}
}
}
}
/*console.log("Found possible IVs: "+JSON.stringify(possibleIVs));*/
$("#outputBox").text(`${pokemon} Possible IVs: ${JSON.stringify(possibleIVs)}`);
} else {
/* Did not receive CP, need to compute CP instead */
const cpmIndex = Math.round((level - 1) * 2);
const computedCP = Math.max(10, Math.floor((baseAtk + aIV/1) * Math.sqrt(baseDef + dIV/1) * Math.sqrt(baseSta + sIV/1) * cpm[cpmIndex] * cpm[cpmIndex] / 10));
$("#outputBox").text(`${pokemon} CP: ${computedCP}`);
}
} else if (cp/1>=10) {
/* TODO: Reverse formula to solve for level rather than brute force looping to find level*/
var foundCP = false;
for (var i=0; i<cpm.length; i++) {
var computedCP = Math.max(10, Math.floor((baseAtk + aIV/1) * Math.sqrt(baseDef + dIV/1) * Math.sqrt(baseSta + sIV/1) * cpm[i] * cpm[i] / 10));
if (computedCP == cp) {
var computedLevel = i/2 + 1;
$("#outputBox").text(`${pokemon} Level: ${computedLevel}`);
foundCP = true;
break;
} else if (computedCP/1 > cp/1) {
console.log("calcCP: Already overshot target CP("+cp+") with computedCP("+computedCP+"), exiting loop");
$("#outputBox").text("Unable to find correct level, please check your inputs and try again");
if (perfTiming) {stopTiming(T0, "calcCP");}
return;
}
}
if (foundCP == false) {
$("#outputBox").text("Unable to find correct level, please check your inputs and try again");
}
}
} else {
console.log("calcCP: Missing one or more required inputs for "+pokemon+": aIV: "+aIV+", dIV: "+dIV+", sIV: "+sIV+", level: "+level+", cp: "+cp);
$("#outputBox").html("<b>Please enter any two of IVs, level, and CP to continue</b><br/><i>If IVs are unknown, HP will help narrow down possibile calcualted IVs</i>");
}
if (perfTiming) {stopTiming(T0, "calcCP");}
return;
}
function calcInputLevel() {
const aIV = parseInt(document.getElementById('levelAttackIV').value, 10);
const dIV = parseInt(document.getElementById('levelDefenseIV').value, 10);
const sIV = parseInt(document.getElementById('levelStaminaIV').value, 10);
const inputCP = parseInt(document.getElementById('combatPowerInput').value, 10);
let pokemon = document.getElementById("pokeList")?.text?.label;
if (!pokemon) pokemon = document.getElementById("pokeList")?.value;
let attack = 0;
let defense = 0;
let stamina = 0;
if (pokemon && pokeListObj[pokemon]) {
const monInfo = pokeListObj[pokemon].split(',');
attack = parseInt(monInfo[1], 10);
defense = parseInt(monInfo[2], 10);
stamina = parseInt(monInfo[3], 10);
const levelElement = document.getElementById("level");
const level = calculateLevel(attack, defense, stamina, aIV, dIV, sIV, inputCP);
if (levelElement) {
if (level >= 1 && level <= 51) {
levelElement.textContent = `Pokemon: ${pokemon} CP: ${inputCP} Level:${level}`;
}
else {
levelElement.textContent = `Pokemon: ${pokemon} CP: ${inputCP} Could not find a matching level`;
}
}
}
}
function stopTiming(startTime, functionName) {
var endTime = performance.now();
console.log(functionName + ": Execution took " + (endTime - startTime).toFixed(1) + "ms");
document.getElementById('timing_outputs').innerHTML += functionName + ": Execution took " + (endTime - startTime).toFixed(1) + "ms<br>";
}
</script>
</section>
<br /><br />
<footer>
<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 />
<!-- Begin Playwire Footer -->
<script data-cfasync="false" async src="https://cdn.intergient.com/ramp_core.js"></script>
<!-- End Playwire Footer -->
</footer>
</body>
</html>