forked from LegendaryPKMN/ivcalc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ivcalcxy.html
1916 lines (1839 loc) · 111 KB
/
ivcalcxy.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
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<!--
This program has been written by Heracles Papatheodorou a.k.a Arty2, webmaster of LegendaryPKMN.net
You can contact the author via email: contact {at} LegendaryPKMN {dot} net
Please pardon the code mess that follows since it's always a work in progress :]
Be my guest if you think you can improve one of the following algorithms; I am not a programmer by profession.
I tried to provide subtle documentation here and there; the complex parts are at least covered.
Source is uncompressed, for educational (?) purposes.
The latest version of this program can always be found at https://legendarypkmn.github.io/ivcalcxy.html
-->
<title>XY Individual Value & Stat Calculator - LegendaryPKMN.net</title>
<meta name="Author" content="Heracles Papatheodorou" />
<meta name="keywords" content="Pokemon, IVs, IV, Calculator, Individual, Values, Stats, Stat, Hidden Power" />
<meta name="description" content="This IV Calculator / Stat Calculator / Hidden Power Calculator aims to help Pokemon trainers calculate the attributes of their Pokemon." />
<link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAFFJREFUOMu1kjEOACAIA/ng/f87Lo4WimgTo4M9G0vEWexlCbG3hDiPE5A81E5DcVeaEJ9KBcAAxFdABsFtBSOJVV0KYAq46Zuno2xNl2tsmxeYhhbdfJzuqAAAAABJRU5ErkJggg==" />
<style title="default" media="all" type="text/css">
body {
background: #b5bdb9;
margin: 0;
padding: 0;
text-align: center;
}
#calculator * { /* global styles */
font: 12px Verdana, Geneva, Kalimati, sans-serif;
-moz-border-radius: 3px;
-webkit-border-radius: 3px; -webkit-background-clip: padding-box !important;
border-radius: 3px;
border-color: inherit;
line-height: 14px;
margin: 0;
padding: 0;
}
#calculator {
background: #b5bdb9;
border-bottom: 1px dotted; /* remove this when including */
border-color: #838986; /* universal border color */
color: #3e4340;
padding-top: 15px;
text-align: center;
/*text-shadow: #b5bdb9 1px 1px 0px;
text-shadow: rgba(255, 255, 255, 0.5) 1px 1px 0px;*/
}
#calculator ::-moz-selection { background:#e4287c; color:#fff; }
#calculator ::selection { background:#e4287c; color:#fff; }
#calculator strong { font-weight: bold !important; }
#calculator em { font-style: italic !important; }
#calculator img { border: none; }
#calculator input, #calculator select {
background-color: #fff;
border: 1px solid;
border-color: #737b76; /* universal input color */
color: #000;
padding: 1px;
text-align: right;
text-shadow: none;
-moz-transition: border-color 0.2s ease-in-out;
-webkit-transition: border-color 0.2s ease-in-out;
-o-transition: border-color 0.2s ease-in-out;
transition: border-color 0.2s ease-in-out;
}
#calculator select {
height: 18px;
text-align: left;
width: 100%;
}
#calculator optgroup {
font-weight: bold;
margin: 4px 0 0 0;
}
#calculator option { padding: 0 0 0 4px; }
#calculator #pot1 { height: auto; }
#calculator input:focus, #calculator select:focus {
outline: 3px double #e4287c;
border-color: #fff;
-moz-border-radius: 0 !important;
-webkit-border-radius: 0 !important;
border-radius: 0 !important;
position: relative;
text-decoration: none;
}
#calculator .radio {
-moz-border-radius: 10px !important;
-webkit-border-radius: 10px !important;
border-radius: 10px !important;
}
#calculator a {
color: inherit;
font-style: italic;
text-decoration: none;
}
#calculator table {
border-collapse: collapse;
border-spacing: 0;
table-layout: fixed;
width: 100%;
}
#calculator td {
padding: 3px;
text-align: center;
}
#calculator dt, #calculator #documentation h3 {
font-weight: bold !important;
text-align: left;
}
#calculator p, #calculator dd {
text-align: left;
margin: 3px 0 3px 15px !important;
}
#calculator h1 {
font: small-caps bold 15px sans-serif !important;
margin: 3px;
}
#calculator h2 {
border-bottom: 1px dotted;
font: bold 11px Verdana, Geneva, Kalimati, sans-serif;
text-align: left;
text-transform: uppercase;
}
#calculator h3 {
border-bottom: 1px dotted;
font: small-caps bold 12px Verdana, Geneva, Kalimati, sans-serif;
}
#calculator #documentation h3 { margin: 5px 0 0 0; }
#calculator #documentation h2 { margin: 10px 0 3px 0; }
#calculator h4 {
font: bold 11px Arial, sans-serif;
text-align: right !important;
}
#calculator #head td { vertical-align: middle; }
#calculator #documentation td { padding: 0 5px !important; }
#calculator #documentation a { text-shadow: 1px 1px 2px #3e4340; color: #fff; }
#calculator #documentation a:hover { color: #e4287c; }
#toggleinstructions, #togglehistory, #toggleinfo, .button, .btn { cursor: pointer; }
#status { cursor: text; }
#controls {
border-top: 2px dotted;
border-color: inherit;
}
#bar {
border-bottom: 2px solid;
border-top: 1px dashed;
border-color: inherit;
}
#nickname {
background: none !important;
color: #3e4340 !important;
border-style: dotted !important;
}
#calculator .loading {
background: url('data:image/png;base64,R0lGODlhDwAPAIABAP///////yH/C05FVFNDQVBFMi4wAwEAAAAh+QQJGQABACwAAAAADwAPAAACGoyPqQGLzQx00c0q6aU47c+F4vaImheS5lEAACH5BAkZAAEALAAAAAAPAA8AAAIZjI+pAYv9nIwOzjutAbxrDFLLF24JeZZLAQAh+QQJGQABACwAAAAADwAPAAACGIyPqQGL/ZyMDs47rdGs4i1pYnhBZvlJBQAh+QQFGQABACwAAAAADwAPAAACGYyPqQGL/ZyMDs47gd7WdAxSyxd6CXmWSwEAOw==') 50% 100% no-repeat;
display: inline-block;
padding: 0 0 25px 0;
}
#calculator .button {
background: #ced2d0 url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAWCAYAAAABxvaqAAAAGUlEQVQY02P8////GUYg8YxkogFOMBBLAACNTUydrXmzbAAAAABJRU5ErkJggg==') 50% 50% repeat-x;
border: 2px solid;
color: #606762;
font-size: 10px;
font-weight: bold;
height: 25px;
text-align: center;
text-shadow: 1px 1px 1px #fff;
width: 100%;
}
#calculator .button:focus, #calculator .button:active {
background-image: none;
border-color: #e4287c;
}
#calculator input:disabled {
background: none;
border-width: 1px;
border-style: dashed;
box-shadow: none !important;
text-shadow: none !important;
}
#calculator .button:hover { border-color: #e4287c; }
#calculator .btn { font-weight: bold !important; }
#calculator .block {
border: 2px solid;
border-color: inherit;
background: #9aa7a0; /* primary color */
margin: 0 auto 20px auto !important;
width: 750px;
}
#calculator .primary {
border-right: 2px solid;
border-color: inherit;
vertical-align: top;
width: 57% !important;
}
#calculator .secondary {
background: #8e9892; /* secondary color */
border-color: inherit;
vertical-align: top;
}
#calculator .top { vertical-align: top !important; }
#calculator .left { text-align: left !important; }
#calculator .center {
text-align: center !important;
vertical-align: middle !important;
}
#calculator .right {
text-align: right !important;
vertical-align: top !important;
padding-right: 6px !important;
}
#calculator #tooltip {
background: #eee;
border-radius: 3px; -moz-border-radius: 3px; -webkit-border-radius: 3px; -webkit-background-clip: padding-box !important;
box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.5); -moz-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.5); -webkit-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.5);
color: #777;
display: none;
font-size: 9px;
margin: 0 30px;
padding: 3px;
text-align: left;
text-shadow: none;
position: absolute;
z-index: 1000;
}
#calculator .error {
color: #f00 !important;
border-color: #f00 !important;
font-weight: bold !important;
text-shadow: rgba(0, 0, 0, 0.5) 1px 1px 1px !important;
}
#calculator .ok {
color: #8d6 !important;
font-weight: bold !important;
text-shadow: rgba(0, 0, 0, 0.5) 1px 1px 1px !important;
}
#calculator .new {
background: #eee;
color: #000;
}
#calculator #sprite img {
/*image-rendering: pixelated;*/
max-height: 120px;
max-width: 120px;
}
/* SPP Theme */
.spp { background: #383838 !important; }
.spp * { border-color: #404040 !important; text-shadow: none !important; }
.spp ::-moz-selection { background:#cb7 !important; color:#444 !important; }
.spp ::selection { background:#cb7 !important; color:#444 !important; }
.spp #documentation a { border-bottom: 1px solid #cb7 !important; }
.spp #documentation a:hover { color: #cb7 !important; }
.spp #bar, .spp #controls { border: none; }
.spp table { border-collapse: separate !important; border-spacing: 3px !important; }
.spp .block, .spp .primary, .spp #documentation .secondary { background: #404040 !important; border: none; color: #fff !important; }
.spp .secondary { background: #6f9a4c !important; color: #444; border-radius: 5px !important; }
.spp input, .spp select { background: #cb7 !important; border-color: #3b3b3b !important; color: #444 !important; }
.spp input:focus, .spp select:focus { outline: 3px solid #8d6 !important; border-color: #8d6 !important; -moz-border-radius: 0 !important; -webkit-border-radius: 0 !important; border-radius: 0 !important; text-decoration: none; position: relative; }
.spp .button:hover { border-color: #8d6 !important; color: #000 !important; }
.spp .button:disabled { background: none !important; }
.spp .new { background: #ba6 !important; }
/* isotope Theme */
.isotope { background: #4c7da2 !important; }
.isotope * { border-color: #f0f0f0 !important; color: #2d2e2f !important; text-shadow: none !important; }
.isotope ::-moz-selection { color: #000 !important; background: #b6d796 !important; }
.isotope ::selection { color: #000 !important; background: #b6d796!important; }
.isotope #documentation a { color: #47a4fb !important; }
.isotope #documentation a:hover { color: #b5d594 !important; }
.isotope table { border-collapse: separate !important; border-spacing: 3px !important; }
.isotope .block { background: #f0f0f0 !important; border: 4px solid #f0f0f0 !important; border-radius: 3px; -moz-border-radius: 3px; -webkit-border-radius: 3px; box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.5); -moz-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.5); -webkit-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.5); }
.isotope .primary { background: #f0f0f0 !important; }
.isotope .secondary { background: #e9e9e9 !important; border: 2px solid #e9e9e9 !important; border-radius: 5px !important; -moz-border-radius: 4px; -webkit-border-radius: 4px; }
.isotope #bar { background: #b6d796 !important; border: 2px solid #aacd8b !important; border-radius: 5px !important; -moz-border-radius: 4px; -webkit-border-radius: 4px; }
.isotope input, .isotope select { border-color: #d6d6d6 !important; color: #000 !important; }
.isotope #controls { border: none !important; background: none !important; }
.isotope .button { background: #dfdfdf !important; border-color: #888 !important; color: #555 !important; }
.isotope input:focus, .isotope select:focus { outline: 3px double #b5d594 !important; border-color: #47a4fb !important; -moz-border-radius: 0 !important; -webkit-border-radius: 0 !important; border-radius: 0 !important; text-decoration: none; position: relative; }
.isotope .button:hover { border-color: #47a4fb !important; color: #000 !important; }
.isotope input:disabled { background: none !important; }
.isotope h1, .isotope h2, .isotope h3 { border: none !important; font-family: Century Gothic, Andale Mono, Futura, sans-serif !important; }
/* Simplex Theme */
.simplex .ext { display: none; }
/* td { outline: 1px dotted red !important; } *//* DEBUG */
</style>
<style media="print" type="text/css">
#calculator * {
background: #fff;
border: none !important;
box-shadow: 0px 0px 0px #ffffff !important; -moz-box-shadow: 0px 0px 0px #ffffff !important; -webkit-box-shadow: 0px 0px 0px #ffffff !important;
color: #000 !important;
text-shadow: none !important;
}
#calculator #head {
border-bottom: 3px solid #000 !important;
padding-bottom: 1em;
}
#calculator .block { width: 100%; }
#calculator #controls, #documentation, #btn-addeps, #times, #name, #charn { display: none; }
#calculator h2 { border-bottom: 1px solid #000 !important; }
</style>
<style type="text/css" id="thema">/* required for the "Colorize" functionality */</style>
</head>
<body>
<div id="calculator"> <!-- Start here if you want to include this in your page -->
<script type="text/javascript">
<!--//--><![CDATA[//><!--
/* Generic functions */
function $() {
var elements = [];
for (var i=0, j=arguments.length; i < j; i++) {
var element = arguments[i];
if (typeof element == 'string')
element = document.getElementById(element);
if (j == 1)
return element;
elements.push(element);
}
return elements;
}
function $c(classname, node) { //Get elements by class
if(!node) node = document.getElementsByTagName('body')[0];
var a = [];
var re = new RegExp('\\b' + classname + '\\b');
var els = node.getElementsByTagName("*");
for(var i=0, j=els.length; i<j; i++)
if(re.test(els[i].className))a.push(els[i]);
return a;
}
function event_add(obj,type,fn) {
if (obj.addEventListener) obj.addEventListener(type,fn,false );
else if (obj.attachEvent) {
obj["e"+type+fn] = fn;
obj.attachEvent( "on"+type, function() { obj["e"+type+fn](); } );
}
}
function event_del(obj,type,fn) {
if (obj.removeEventListener) obj.removeEventListener(type,fn,false);
else if (obj.detachEvent) {
obj.detachEvent( "on"+type, obj["e"+type+fn] );
obj["e"+type+fn] = null;
}
}
function cookie_create(name,value,days) {
if (location.protocol == 'data:') { return null; } //prevents security errors
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = '; expires='+date.toGMTString();
}
else var expires = '';
document.cookie = name+'='+value+expires+'; path=/';
}
function cookie_read(name) {
if (location.protocol == 'data:') { return null; }
var name = name+'=', ca = document.cookie.split(';');
for(var i=0, j=ca.length;i < j;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
}
return null;
}
function toggle(el) {
if ( el.style.display != 'none' ) { el.style.display = 'none'; }
else { el.style.display = ''; }
}
function autocomplete(field,select,property,forcematch) { // <input/> -> <select>
var f = false;
for (var i=0, j=select.options.length; i < j; i++) {
if (select.options[i][property].toUpperCase().indexOf(field.value.toUpperCase()) == 0) {
f=true; break;
}
}
if (forcematch && !f) {
field.value = field.value.slice(0,field.value.length-1);
autocomplete(field,select,property,forcematch);
return false;
}
if (f) { select.selectedIndex = i; }
else { select.selectedIndex = 0; }
}
function vv(e,min,max,evt,r) { //Field Value Validation (numeric only)
if (r != undefined && $('act-'+r).checked == 0) { row_act(r); }
if ($(e).title == '') {
$(e).autocomplete = 'off';
$(e).title = '('+min+' - '+max+') Use up/down arrow keys to increase/decrease.';
}
var r = $(e).id.split('-')[1], v = $(e).value;
var k = window.event?event.keyCode:evt.keyCode; // alert(k); //DEBUG
switch(k) {
case 9: return false; break; //tab
case 8: return false; break; //backspace
case 46: return false; break; //delete
case 13: calc_ivs((mode==2 && act>-1?act:0)); break; //enter
case 38: //Up key, increase
$(e).value = v<max?(1*v)+1:v;
break;
case 40: //Down key, decrease
$(e).value = v>min?(1*v)-1:v;
break;
default:
$(e).value = isNaN(v)?min:Math.min(v,max);
}
}
function tooltips() { // inspired by http://qrayg.com/learn/code/qtip
if (!$('tooltip')) { var e = el_add($('calculator'),'div',{className:'a',id:'tooltip'});
event_add(document, "mousemove", function(evt) {
var de = document.documentElement;
$('tooltip').style.left = (document.all?((de && de.scrollLeft)?de.scrollLeft:document.body.scrollLeft)+window.event.clientX:evt.pageX)+'px';
$('tooltip').style.top = (document.all?((de && de.scrollTop)?de.scrollTop:document.body.scrollTop)+window.event.clientY:evt.pageY)+'px';
});
}
var elements = $c('tooltip');
var i=elements.length-1; do {
var e = elements[i];
if(e.title && !e.tooltip) {
e.tooltip = e.title;
e.title = ''; e.alt = ''; //prevent default behaviour
event_add(e, "mouseover", function() { $('tooltip').innerHTML = this.tooltip; $('tooltip').style.display = 'block'; });
event_add(e, "mouseout", function() { $('tooltip').innerHTML = ''; $('tooltip').style.display = 'none'; });
}
} while(i--);
}
function el_add(el,tag,attr,txt) { //Appends element - el_add(el,'div',{className:'a',id:'b'},'text');
var i='',e=document.createElement(tag);
if (attr) {
for (i in attr) {
e[i] = attr[i];
}
}
e.innerHTML = txt || '';
el.appendChild(e);
return e;
}
function el_del(el) { //Removes all element children of el
while (el.firstChild) {
el.removeChild(el.firstChild);
}
return this;
}
function array_intersect(a, b) { //arrays must be sorted, a and b are destructed afterwards
var r=[];
while( a.length > 0 && b.length > 0 ) {
if (a[0] < b[0] ){ a.shift(); }
else if (a[0] > b[0] ){ b.shift(); }
else {
r.push(a.shift());
b.shift();
}
}
return r;
}
if (!Array.prototype.map) {
Array.prototype.map = function(fn, thisObj) {
var scope = thisObj || window;
var a = [];
for (var i=0, j=this.length; i < j; ++i) {
a.push(fn.call(scope, this[i], i, this));
}
return a;
};
}
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function(el, start) {
var start = start || 0;
for (var i=0, j=this.length; i < j; ++i) { //rewrite using while do?
if (this[i] === el ) {
return i;
}
}
return -1;
};
}
Array.prototype.sum = function() {
var sum=0,i=this.length-1; do {
sum += this[i];
} while(i--);
return sum;
};
Array.prototype.sortnum = function() {
return this.sort( function (a,b) { return a-b; } );
};
Array.prototype.style = function(p,v) {
var i=this.length-1; do {
this[i].style[p] = v;
} while(i--);
};
Array.prototype.unique = function() {
var a = [];
var l = this.length;
for(var i=0; i<l; i++) {
for(var j=i+1; j<l; j++) {
if (this[i] === this[j])
j = ++i;
}
a.push(this[i]);
}
return a;
};
/* Pokemon Data and retrieval functions */
//Pokemon Name:Number - email the author for a precompiled list of the names in other languages
pkmns='Bulbasaur:1|Ivysaur:2|Venusaur:3|Charmander:4|Charmeleon:5|Charizard:6|Squirtle:7|Wartortle:8|Blastoise:9|Caterpie:10|Metapod:11|Butterfree:12|Weedle:13|Kakuna:14|Beedrill:15|Pidgey:16|Pidgeotto:17|Pidgeot:18|Rattata:19|Raticate:20|Spearow:21|Fearow:22|Ekans:23|Arbok:24|Pikachu:25|Raichu:26|Sandshrew:27|Sandslash:28|Nidoran♀:29|Nidorina:30|Nidoqueen:31|Nidoran♂:32|Nidorino:33|Nidoking:34|Clefairy:35|Clefable:36|Vulpix:37|Ninetales:38|Jigglypuff:39|Wigglytuff:40|Zubat:41|Golbat:42|Oddish:43|Gloom:44|Vileplume:45|Paras:46|Parasect:47|Venonat:48|Venomoth:49|Diglett:50|Dugtrio:51|Meowth:52|Persian:53|Psyduck:54|Golduck:55|Mankey:56|Primeape:57|Growlithe:58|Arcanine:59|Poliwag:60|Poliwhirl:61|Poliwrath:62|Abra:63|Kadabra:64|Alakazam:65|Machop:66|Machoke:67|Machamp:68|Bellsprout:69|Weepinbell:70|Victreebel:71|Tentacool:72|Tentacruel:73|Geodude:74|Graveler:75|Golem:76|Ponyta:77|Rapidash:78|Slowpoke:79|Slowbro:80|Magnemite:81|Magneton:82|Farfetch’d:83|Doduo:84|Dodrio:85|Seel:86|Dewgong:87|Grimer:88|Muk:89|Shellder:90|Cloyster:91|Gastly:92|Haunter:93|Gengar:94|Onix:95|Drowzee:96|Hypno:97|Krabby:98|Kingler:99|Voltorb:100|Electrode:101|Exeggcute:102|Exeggutor:103|Cubone:104|Marowak:105|Hitmonlee:106|Hitmonchan:107|Lickitung:108|Koffing:109|Weezing:110|Rhyhorn:111|Rhydon:112|Chansey:113|Tangela:114|Kangaskhan:115|Horsea:116|Seadra:117|Goldeen:118|Seaking:119|Staryu:120|Starmie:121|Mr. Mime:122|Scyther:123|Jynx:124|Electabuzz:125|Magmar:126|Pinsir:127|Tauros:128|Magikarp:129|Gyarados:130|Lapras:131|Ditto:132|Eevee:133|Vaporeon:134|Jolteon:135|Flareon:136|Porygon:137|Omanyte:138|Omastar:139|Kabuto:140|Kabutops:141|Aerodactyl:142|Snorlax:143|Articuno:144|Zapdos:145|Moltres:146|Dratini:147|Dragonair:148|Dragonite:149|Mewtwo:150|Mew:151|Chikorita:152|Bayleef:153|Meganium:154|Cyndaquil:155|Quilava:156|Typhlosion:157|Totodile:158|Croconaw:159|Feraligatr:160|Sentret:161|Furret:162|Hoothoot:163|Noctowl:164|Ledyba:165|Ledian:166|Spinarak:167|Ariados:168|Crobat:169|Chinchou:170|Lanturn:171|Pichu:172|Cleffa:173|Igglybuff:174|Togepi:175|Togetic:176|Natu:177|Xatu:178|Mareep:179|Flaaffy:180|Ampharos:181|Bellossom:182|Marill:183|Azumarill:184|Sudowoodo:185|Politoed:186|Hoppip:187|Skiploom:188|Jumpluff:189|Aipom:190|Sunkern:191|Sunflora:192|Yanma:193|Wooper:194|Quagsire:195|Espeon:196|Umbreon:197|Murkrow:198|Slowking:199|Misdreavus:200|Unown:201|Wobbuffet:202|Girafarig:203|Pineco:204|Forretress:205|Dunsparce:206|Gligar:207|Steelix:208|Snubbull:209|Granbull:210|Qwilfish:211|Scizor:212|Shuckle:213|Heracross:214|Sneasel:215|Teddiursa:216|Ursaring:217|Slugma:218|Magcargo:219|Swinub:220|Piloswine:221|Corsola:222|Remoraid:223|Octillery:224|Delibird:225|Mantine:226|Skarmory:227|Houndour:228|Houndoom:229|Kingdra:230|Phanpy:231|Donphan:232|Porygon2:233|Stantler:234|Smeargle:235|Tyrogue:236|Hitmontop:237|Smoochum:238|Elekid:239|Magby:240|Miltank:241|Blissey:242|Raikou:243|Entei:244|Suicune:245|Larvitar:246|Pupitar:247|Tyranitar:248|Lugia:249|Ho-Oh:250|Celebi:251|Treecko:252|Grovyle:253|Sceptile:254|Torchic:255|Combusken:256|Blaziken:257|Mudkip:258|Marshtomp:259|Swampert:260|Poochyena:261|Mightyena:262|Zigzagoon:263|Linoone:264|Wurmple:265|Silcoon:266|Beautifly:267|Cascoon:268|Dustox:269|Lotad:270|Lombre:271|Ludicolo:272|Seedot:273|Nuzleaf:274|Shiftry:275|Taillow:276|Swellow:277|Wingull:278|Pelipper:279|Ralts:280|Kirlia:281|Gardevoir:282|Surskit:283|Masquerain:284|Shroomish:285|Breloom:286|Slakoth:287|Vigoroth:288|Slaking:289|Nincada:290|Ninjask:291|Shedinja:292|Whismur:293|Loudred:294|Exploud:295|Makuhita:296|Hariyama:297|Azurill:298|Nosepass:299|Skitty:300|Delcatty:301|Sableye:302|Mawile:303|Aron:304|Lairon:305|Aggron:306|Meditite:307|Medicham:308|Electrike:309|Manectric:310|Plusle:311|Minun:312|Volbeat:313|Illumise:314|Roselia:315|Gulpin:316|Swalot:317|Carvanha:318|Sharpedo:319|Wailmer:320|Wailord:321|Numel:322|Camerupt:323|Torkoal:324|Spoink:325|Grumpig:326|Spinda:327|Trapinch:328|Vibrava:329|Flygon:330|Cacnea:331|Cacturne:332|Swablu:333|Altaria:334|Zangoose:335|Seviper:336|Lunatone:337|Solrock:338|Barboach:339|Whiscash:340|Corphish:341|Crawdaunt:342|Baltoy:343|Claydol:344|Lileep:345|Cradily:346|Anorith:347|Armaldo:348|Feebas:349|Milotic:350|Castform:351|Kecleon:352|Shuppet:353|Banette:354|Duskull:355|Dusclops:356|Tropius:357|Chimecho:358|Absol:359|Wynaut:360|Snorunt:361|Glalie:362|Spheal:363|Sealeo:364|Walrein:365|Clamperl:366|Huntail:367|Gorebyss:368|Relicanth:369|Luvdisc:370|Bagon:371|Shelgon:372|Salamence:373|Beldum:374|Metang:375|Metagross:376|Regirock:377|Regice:378|Registeel:379|Latias:380|Latios:381|Kyogre:382|Groudon:383|Rayquaza:384|Jirachi:385|Deoxys:386|Turtwig:387|Grotle:388|Torterra:389|Chimchar:390|Monferno:391|Infernape:392|Piplup:393|Prinplup:394|Empoleon:395|Starly:396|Staravia:397|Staraptor:398|Bidoof:399|Bibarel:400|Kricketot:401|Kricketune:402|Shinx:403|Luxio:404|Luxray:405|Budew:406|Roserade:407|Cranidos:408|Rampardos:409|Shieldon:410|Bastiodon:411|Burmy:412|Wormadam .Plant:413|Mothim:414|Combee:415|Vespiquen:416|Pachirisu:417|Buizel:418|Floatzel:419|Cherubi:420|Cherrim:421|Shellos:422|Gastrodon:423|Ambipom:424|Drifloon:425|Drifblim:426|Buneary:427|Lopunny:428|Mismagius:429|Honchkrow:430|Glameow:431|Purugly:432|Chingling:433|Stunky:434|Skuntank:435|Bronzor:436|Bronzong:437|Bonsly:438|Mime Jr.:439|Happiny:440|Chatot:441|Spiritomb:442|Gible:443|Gabite:444|Garchomp:445|Munchlax:446|Riolu:447|Lucario:448|Hippopotas:449|Hippowdon:450|Skorupi:451|Drapion:452|Croagunk:453|Toxicroak:454|Carnivine:455|Finneon:456|Lumineon:457|Mantyke:458|Snover:459|Abomasnow:460|Weavile:461|Magnezone:462|Lickilicky:463|Rhyperior:464|Tangrowth:465|Electivire:466|Magmortar:467|Togekiss:468|Yanmega:469|Leafeon:470|Glaceon:471|Gliscor:472|Mamoswine:473|Porygon-Z:474|Gallade:475|Probopass:476|Dusknoir:477|Froslass:478|Rotom:479|Uxie:480|Mesprit:481|Azelf:482|Dialga:483|Palkia:484|Heatran:485|Regigigas:486|Giratina .Altered:487|Cresselia:488|Phione:489|Manaphy:490|Darkrai:491|Shaymin .Land:492|Arceus:493|Victini:494|Snivy:495|Servine:496|Serperior:497|Tepig:498|Pignite:499|Emboar:500|Oshawott:501|Dewott:502|Samurott:503|Patrat:504|Watchog:505|Lillipup:506|Herdier:507|Stoutland:508|Purrloin:509|Liepard:510|Pansage:511|Simisage:512|Pansear:513|Simisear:514|Panpour:515|Simipour:516|Munna:517|Musharna:518|Pidove:519|Tranquill:520|Unfezant:521|Blitzle:522|Zebstrika:523|Roggenrola:524|Boldore:525|Gigalith:526|Woobat:527|Swoobat:528|Drilbur:529|Excadrill:530|Audino:531|Timburr:532|Gurdurr:533|Conkeldurr:534|Tympole:535|Palpitoad:536|Seismitoad:537|Throh:538|Sawk:539|Sewaddle:540|Swadloon:541|Leavanny:542|Venipede:543|Whirlipede:544|Scolipede:545|Cottonee:546|Whimsicott:547|Petilil:548|Lilligant:549|Basculin .Red:550|Sandile:551|Krokorok:552|Krookodile:553|Darumaka:554|Darmanitan:555|Maractus:556|Dwebble:557|Crustle:558|Scraggy:559|Scrafty:560|Sigilyph:561|Yamask:562|Cofagrigus:563|Tirtouga:564|Carracosta:565|Archen:566|Archeops:567|Trubbish:568|Garbodor:569|Zorua:570|Zoroark:571|Minccino:572|Cinccino:573|Gothita:574|Gothorita:575|Gothitelle:576|Solosis:577|Duosion:578|Reuniclus:579|Ducklett:580|Swanna:581|Vanillite:582|Vanillish:583|Vanilluxe:584|Deerling:585|Sawsbuck:586|Emolga:587|Karrablast:588|Escavalier:589|Foongus:590|Amoonguss:591|Frillish:592|Jellicent:593|Alomomola:594|Joltik:595|Galvantula:596|Ferroseed:597|Ferrothorn:598|Klink:599|Klang:600|Klinklang:601|Tynamo:602|Eelektrik:603|Eelektross:604|Elgyem:605|Beheeyem:606|Litwick:607|Lampent:608|Chandelure:609|Axew:610|Fraxure:611|Haxorus:612|Cubchoo:613|Beartic:614|Cryogonal:615|Shelmet:616|Accelgor:617|Stunfisk:618|Mienfoo:619|Mienshao:620|Druddigon:621|Golett:622|Golurk:623|Pawniard:624|Bisharp:625|Bouffalant:626|Rufflet:627|Braviary:628|Vullaby:629|Mandibuzz:630|Heatmor:631|Durant:632|Deino:633|Zweilous:634|Hydreigon:635|Larvesta:636|Volcarona:637|Cobalion:638|Terrakion:639|Virizion:640|Tornadus:641|Thundurus:642|Reshiram:643|Zekrom:644|Landorus:645|Kyurem:646|Keldeo .Ordinary:647|Meloetta .Aria:648|Genesect:649|Chespin:650|Quilladin:651|Chesnaught:652|Fennekin:653|Braixen:654|Delphox:655|Froakie:656|Frogadier:657|Greninja:658|Bunnelby:659|Diggersby:660|Fletchling:661|Fletchinder:662|Talonflame:663|Scatterbug:664|Spewpa:665|Vivillon:666|Litleo:667|Pyroar:668|Flabébé:669|Floette:670|Florges:671|Skiddo:672|Gogoat:673|Pancham:674|Pangoro:675|Furfrou:676|Espurr:677|Meowstic ♂:678|Honedge:679|Doublade:680|Aegislash:681|Spritzee:682|Aromatisse:683|Swirlix:684|Slurpuff:685|Inkay:686|Malamar:687|Binacle:688|Barbaracle:689|Skrelp:690|Dragalge:691|Clauncher:692|Clawitzer:693|Helioptile:694|Heliolisk:695|Tyrunt:696|Tyrantrum:697|Amaura:698|Aurorus:699|Sylveon:700|Hawlucha:701|Dedenne:702|Carbink:703|Goomy:704|Sliggoo:705|Goodra:706|Klefki:707|Phantump:708|Trevenant:709|Pumpkaboo .Average:710|Gourgeist .Average:711|Bergmite:712|Avalugg:713|Noibat:714|Noivern:715|Xerneas:716|Yveltal:717|Zygarde:718|Diancie:719|Hoopa:720|Volcanion:721|Deoxys .ATK:386.1|Deoxys .DEF:386.2|Deoxys .SPD:386.3|Wormadam .Sandy:413.1|Wormadam .Trash:413.2|Shaymin .Sky:492.1|Giratina .Origin:487.1|Rotom .Heat:479.1|Rotom .Wash:479.2|Rotom .Frost:479.3|Rotom .Fan:479.4|Rotom .Mow:479.5|Castform .Sun:351.1|Castform .Rain:351.2|Castform .Snow:351.3|Basculin .Blue:550.1|Darmanitan .Zen:555.1|Meloetta .Pirouette:648.1|Kyurem .White:646.1|Kyurem .Black:646.2|Keldeo .Resolute:647.1|Tornadus .Therian:641.1|Thundurus .Therian:642.1|Landorus .Therian:645.1|Floette .Eternal:670.1|Meowstic ♀:678.1|Aegislash .Blade:681.1|Pumpkaboo .Small:710.1|Pumpkaboo .Large:710.2|Pumpkaboo .Super:710.3|Gourgeist .Small:711.1|Gourgeist .Large:711.2|Gourgeist .Super:711.3|Venusaur .Mega:3.1|Charizard .Mega X:6.1|Charizard .Mega Y:6.2|Blastoise .Mega:9.1|Alakazam .Mega:65.1|Gengar .Mega:94.1|Kangaskhan .Mega:115.1|Pinsir .Mega:127.1|Gyarados .Mega:130.1|Aerodactyl .Mega:142.1|Mewtwo .Mega X:150.1|Mewtwo .Mega Y:150.2|Ampharos .Mega:181.1|Scizor .Mega:212.1|Heracross .Mega:214.1|Houndoom .Mega:229.1|Tyranitar .Mega:248.1|Blaziken .Mega:257.1|Gardevoir .Mega:282.1|Mawile .Mega:303.1|Aggron .Mega:306.1|Medicham .Mega:308.1|Manectric .Mega:310.1|Banette .Mega:354.1|Absol .Mega:359.1|Latias .Mega:380.1|Latios .Mega:381.1|Garchomp .Mega:445.1|Lucario .Mega:448.1|Abomasnow .Mega:460.1|Beedrill .Mega:15.1|Pidgeot .Mega:18.1|Slowbro .Mega:80.1|Steelix .Mega:208.1|Sceptile .Mega:254.1|Swampert .Mega:260.1|Sableye .Mega:302.1|Sharpedo .Mega:319.1|Camerupt .Mega:323.1|Altaria .Mega:334.1|Glalie .Mega:362.1|Salamence .Mega:373.1|Metagross. Mega:376.1|Kyogre. Primal:382.1|Groudon. Primal:383.1|Rayquaza. Mega:384.1|Lopunny. Mega:428.1|Gallade. Mega:475.1|Audino. Mega:531.1|Diancie. Mega:719.1|Hoopa. Unbound:720.1';
//Compressed Pokemon data: HP/ATK/DEF/SP.ATK/SP.DEF/SPD/Type1/Type2/Egg1/Egg2/EPs2/EPs1 - national order + forms
pkmn=' 3vv//3.*#< #)SP00).*#< !0sW440.*#< 9νY`)(/;;#AB QBQ0/0;;#AB#VyVγ84;&#A *UJ/(B`""#&> kP0/0Q""#&>$cW48CV""#& 63?@II399**# (I1MM?99**H )3(50,9&** 92@?II(9***B 3M(MM@9***H /523079***-$232@@a &$$B P)1((e &$$F W07,,ι &$$z ?a@M@R !!B 1m)(,| !!F 2)?ΑΑ, &$$B /5/dd4 &$$F @)U2t1**!A$ )8l/c0**!A- @12((566!9F )5150D66!9z (78I?2$$!!> 74D31/$$!!H 1ζY22q**#!# ,SX11a**++& 5iη78^*$++* βj222(**#!$ dRj11/**#!- mΓ]878*$#!6 ,3J)/@GG99& :,g:5)GG99* nq2(//;;!!B g^7m44;;!!B$K3I3MI G99& _,38(3 G99* 23@?21*&$$B 70,/75*&$$F 3(17/?.*<< #)/,872.*<< &708D5(.*<< *@,131M9.*<$ ):0)0?9.*<ρ )1(2139*** $,/)5759***B#"1M@3:$$!!B @0((,E$$!!F 23@225 !!B /,)//K !!F (YJ/(1""&! #0sV:08""&! &20@@3,##!!$ /C)),:##!!- 1,3,();;!!$ 5D040:;;!!- 2(2225""&&B ///((5""&&F 5::,5,"#&&J MI+C15==-- #2@?E,C==-- &1(3Z:E==-- *,0(@@@##--$ 04,()3##--- 5L0/81##--6 (7@,?2.*<<$ /5(831.*<<- 0C/4,,.*<<6 22@(4,"*;; $0,/0E4"*;; -204??I!$""> 1:K33@!$""H 0EL1/3!$""J (81//5;;!!B /4,00C;;!!F 5//22+"=#&# :7D40?"=#&H M@,:136-"" #():E,,6-"" &Y/1QS) &$!$ @83@@7 &$$$ )D,))4 &$$- /313,3""&! $5,0,:,"A&! -00(2(M**..# CC7/4(**..! ?/43M2"";;> (:δ83,"A;;H ?@?4@0<*.. #3(3K1:<*.. &)/)L7D<*.. *@3u?3,!$""> )J3`5f==-- $8g,gKX==-- -?C5MM("";;$ 1LK((7"";;- 2?(11466""B )(,00_66""F )20)32.=<<> ::8N/1.=<< &((:2(@$$##> )0D(03$$##H (Eh@Dη##--- (Cc@D^##-- -517)7? ##& 2/:)3@**..> /5E8,)**..H 08:??M$!#!> CLE332$!#!- ά!!@C( 99& /1K42)..<<> C:0205 ##& ?2,,M)""&A #1/::38""&A>#3X)@(P""66$ 0i//0T""66- ?31,18"";;B )7848K"=;;F 23/4E5=G-- -,D010C9&**$ /(@K::A=-- &/Wj:8C66--F /:j48Ι;;-- &/N41,899**- 74:2,D !!T I"1+I0""6AB :Nc)4m"&6A- L808:)"A#&& JJJJJJ ==# 11(3/1 !! $L/)D:/""!!& //)D:L66!!F /L):D/;;!!- /),872 "" #@2451@!"&;> ,)NK,1!"&;H ?05131!"&;> )KC/,0!"&;- 0C/)7L!&$$F uD//D? ##& 584:N8A&++ 6558N546&++ *545N85;&++ *qB3(((++&A$ dy/,,,++&A- oΥ:440+&&A6 }D5Θ5L==++ *444444==++* 3v/v/3..#< $)S0P0)..#<>$0s4W40..#<>-νY`)(/;;!!B QBQ0/0;;!!B#VyVγ84;;!! *(/BUJ`""#&$ /00kPQ""#&I 8C4cWV""#&ρ @βΒ@3I !!$ 8^B315 !!F )??%a( &$$# 4((^Τ, &$$& 2I?2019&** $1@(1D89&** -2)222?9***$ ,5,))29***- 850,0L*&$$z 7nnaaX"666# NQQ^^X"666& I2+@@)66++B (Mφ31+GG++ $5?+2I+ G++# @I/2/IGG++ $1280C2G&$9 -2(3,3,=&$$ #/7,:,:=&$$B#122/3@66#! #,110)366#! &578K5166#! *70:54(..<< 6,I(I(2"G&9& 4(0)0("G&9* ,4K?/?!!""H 57754,""&& 6@@2@1(.&9< $13(3/0.&9<F 71,1:D.&9<z 1,1218 !!B ??????..<< #771C8?..<< &//373:9&**B 133MM+"$&!# :88//@"$&!& //)L:D==!! &:/D)L/>>!! -)8f8fo>&$$B :704D?"=#& 6)))888<<.. $JRJRJJ==++$#ςυQυQυ==..& ,0/5/8 =!! &(/5@@+99**> 75_))29-**H 4,,//3 !!# /7C@/8$&**> 78Ξ1/?-$""H )0(22?GG!9$ 5E7))3GG!9- /:7118"*66$ ,L410/9-**- I"Ν"Ν!9!**>$0N72:89#**- 1:1@7K>A!!B )0(((2 !!$ 5L7771 !!- 222,2I;;.. #((E00?;!..H ((2??(A$!!$ 440))(A$!!! 118/8@"!&;>$@/@/@/""&6 #7C7C73""&6$#313/37A&&!B /2,0_,"&&& -/0_2,,-&$$H 3)?0(/>;!! #75(D0:>;!! &7::::8"+&A$!5))222$$!!# 5EE))($$!!I 805C:) "" &g:S8/8 !!$ 1I@I37 !!B @@@@@@##++$ (::@D,##-- -3?+8//A=++ #3P~/1:66++B 37~,1W;;++B :0C2,4 !!H έ""7Z1 99* 587K4K66++F#KK8574;;++; 47K5K8""++>-(B(3(q!$##$ ,y,/,θ!$##- 4ΥD:4d!>##6 }5L5ΘD=&++ 6}L5DΘ5;&++ 6444444=.++* 23@/1,..#AB (/38/:..#AF ,8/C8E..#Az 3)2,(3;;!! #)8)8)1;#!!$#0E,D,0;#!!6 (,(((2""#&$ ,8,),("$#&- 4D585)"$#&6 @1@??@>>!!$ ,5,)),>>!!- n?q?q) !!B V,d(d4 !!F 33@I?I99**# (@1MM+99**H ),(4(/9&** *(@1MM+99**H )(,(5/9*** 62??2(?".&< $)((),(".&< -0,,54,".&< 622(???..!<> ,,2)2).>!<- 54)5)0.>!<6 21???8 &$$B )8)((N &$$F 2??1?8"&&$B )(48,/"&&$H φMM3@2=G.. #n@@/1(=G.. &T//NK0=G.. *2?H(Y/9"&*B ,)S0s)9&&* !)2)2)@..9<# )L0)),.#9<- )))@@? !!# 000115 !!F Ou4:/4 !!* Α35??29$**> d53((u9&**F #53??29<""& Bθμθμφ #!# ye`e`J #!& οoPogT #!* R)?I?M##--# ήE)2)(##--& (I2I2I G++# ?3Z35?!!""> (33@@( !9B ,//11, !9/ (77//(><--I (8811(-G!9I (,422?-!##> )5_((2-!##H ,Dδ))(-!##J ?2121)#=--B ))7)70#=--F 232/2/66!!B ,7)C)C66!!F )(287:6699B )2(78:6699B /g1ζ7899*-B /ζ1g7899*-B ()340/.*9< &,`h`h2**..# 4gWgW1**..& 35I/I/">66$ ,E2:2:">66- L,@,@)""!6# ω5353)""!6& ))2/3@;$!! #,4,C72;$!!$#,8_8,I;;!!H )M@,0)==!! $03/5D0==!! -)))))) !- #34333"$$**$ (,(((,$+**T 040004$+**Σ (8282@..<- #,K)K)1.><-$#32)27( &$A $7,5,C0+&$A -gK)))5 !!- g4)4)/**!A$#,1/:8,!="" &,:81/,!=""- (J`βq)"$66# DVg^e)"$66& `0/(@@""&;$ PE8511">&;- 2212,1$="" $),C,E7$="" -bq]dημ!.;; $[m|mw`!.;; -3:(2(7!9;;$ 7N4,03!9;;- I+I"10""&AB :)c4Nm""&A -,,,,,, 9.# )5,)E2 !! $U7@Pυ3<<..$ BK/WP/<<..- I25?5M<<.. $2,L)LM<<..>$κTWRηθ.&#<& /(,:0/==.. !/L)7)7>>!!- :μJμJμ==++# ((((((AA9"# 000000AA9"& ,2(1(MA"&!# 5),7,3A"&!& D05:5/A"&!* @B8p1H""&&> 1οCχ7Y""&&I 1yCΛ7Y""&& &45L3/1"!&6G `?12/|""66B 37)2?(++AA$ /:4)((++AAH :Z0D04+&AA6 210@)?-=""> )7410(-=""H 0ZL:5,-=""J 04Ξ(4(!!++J 0(44Ξ(AA++ 607O7O(--++H$005DLD+=++ 6050LDD+=++ *445O_5""++ *4O_455$$++6 CO5O5:+&++-#444444-=++* (O(O(O==++T#1TB31Α..#<$ 7α81/%..#<I :γC78a.$#<ρ UQUQUd;;!-B BVYVYm;#!-B#^οeοer;#!-T#hθhda2""&! #BbTm^(""&! &y[λΗι)"-&! *21???) &$$B 17(220 &$$F 8E,()4 &$$6 k32@2Α &!# c8)1)e "&!- ~MqMqM99**> ]8θ1θ/99**- 3/Β2Β366!!$ )8v)v)66!!- 0Ec:c,66!!6 2?@(,1.*++ #),/NC5.*9< *XN2??Q!!##$ |ψ)/(Q!!##- ?fΠfλ?!-##> )Yίζό?!-##H 2Δ3Δ3%99** $)k8cC%9.** -,χ(χ(b9&**$#??f?f,9&**B ,0Γ0Γ29&**>$)3,35:66!9B 1/@)?8""&!B 8C18(K""&!F 3@[email protected]< #,),ηV8..9< &^JJjSΒ""&.# ΗWTisν"$&.& 74b)bK !!F 5(Β)U,<&..# O0U5t0<&..& 1bUUa8 !-B /^ytΤC !-F )))CCC<<.. !4NYCYe>&$$- v1ff~8 !!B esBBkπ !!F 3?(/(3==++ #PPζqqp*>!!B εΙXedy*>!!& jρ[ρ[μ-=""> Xασcσυ-="">$(0:"3"!!++> IM3,5)=G++ $4!!+/? ++# ^/3ifo &$$$ (irir@<>..>$Q,323f+$#A$ T5/(1s+$#A- rL:08Γ+$#A6 Z8228! ++# 2,2@2)##++$ ,D,K,5#-!-$#TRVnfH$$!!> rπΠTRζ$$!!H 2(5?1/*9*;> ,5D)7:*>*;H Jd2d2(*#--$ W}/[/8*#--- p4R5Rβ..<<- vvavdb""66B ll^l[o""66F 3I()E("&++ $)S(S)2.A#<$ 5i7i8).A#<$#,E/38N>A!!T ,,KL5)6-"" *D8:0:( ##* K_L112$!#!6 44ND((..<<H 7ξX:8:66--6 7:XN:W;;-- *8(:EK0G&$9 9[^[σa:9&**- /DL)/:..!!H /)DL:/AA!! &7:N37:$&**H DL0,)0A$!!6 80,Z75 "" *TN//K0=#..6 )1{7O2!-"">-34Z/Z3<<..>-,0,0,DA<9"F ((]:]o6<..B#77L7L:==++H$0CCCC0==++$!7N,N,K==++-#4EEO45-+++ *5E4OE4"+++ *o5}L}];-++ *DuD0D4 ++6 O4E4E5<+++* E,E7L8==++ 6000000""&9# 444444""&9* ,55Z5N>>++B&444444..++* EEEEEE ++* 444444=;++* 33131P..!<B ))7)7W..!<F 77:7:Ψ..!<z /P3333;;!!# 5Ι1,11;#!!- Dξ/4//;#!!6 113P33""!! #77)W))""!! &:48r,,""!! *31ν@νf !!$ )8l)l] !!- 3)3M31 !!$ /0/@/) !!- 8D5350 !!6 q(~(~b>>!!B Bλ(λ(}>>!!F (hJhJB..!!B 7xPxPι..!!F (hJhJB;;!!B 7xPxPι;;!!F (hJhJB""!!B 7xPxPι""!!F ^M3X1ρ==!!# σ18w:Δ==!!& (1(%?` &$$$ S]S(f/ &$$- 0K0/1Ι &$$6 3)H(H^66!!B 74P0Pσ66!!F 178MM+!!""> ,CC(2I!!""I 8ZL)0M!!""6 13`1`R=&!$B Xj1]1Λ=&!$F )82?3T$$!!$ DZ)(/λ$-!!- ε)[)[( 99& 701M@@##--$ 8C82(2##--- C_:1/3##--6 ((2(2B""&&B 7/1/1l"$&&& C:787p"$&&* E48?83##--& 7N7?78##--- 3h,2)f9.**> 1P5(0f9.**H 7ε0,0i9.**6 ?3k?νj9***> 21κ2cζ9***H )4α1lπ9***z 2Ο)~(b.G<9B )X8]7σ.G<9F 3@(,(?..<< #,)7D75..<< &,i/01x""66F (R@@@/$>!!$ )s333p$>!!- :Ρ0/,i$>!!6 ,53+3(;;!!$ C_1?1:;;!!- 7[X}X)..<< &(/8@@19!*"> ,:N/739!*"H (7,@,J>#!A$ /5K3KQ>#!A>$RQ0ε0|=&$$ &n?81/?<<".> Q({:C?<<".H tVεh3Φ"!&;> prύW/H"!&;H 1π3p3,!&$;$ 7_/π/D!&$;- ((S2S/**""B 0:s)s7**""- 2/202/>>!! #)C)E)C>>!! &1(2227 !!B 7:)/)K !!F 3?(1/3==-- $)3,781==-- -,1::D/==-- 63?2C(I==.. #/2(N)?==.. &D/7N8?==.. *SU(U(1"&&$# 7ηPηPx"&&$F %((/)UAA"" #θ//07kAA"" &e:8D:cAA"" *))(2(7 .!!B 04,),: .!!- 17)7)ε6&!!F (7323)99**$ ,ZC)CI9-**- l1311+.*<<# Λ8,80?.*<<& 12(/82"<.. $4),8C)"<.. -ψ7023/""&6& (ζ(j(/96**B ,])|)r96**F U(oρ[".-<"> pχΕtσI.-<"H 21,3)?--""> )0:,8(--""H )4K,85--""J @1232)66..B /8,7,266..- 8K0C0(66..6 11181?==-- #777N:2==-- &(?1/1I<;.. #)2):)1<;.. &)15{50<;.. *βη)?2j++#A$ bΡ,2(X++#A- ^ώ5),|++#A6 1,2)22AA!!$ :D0,0(AA!!- ,(?:ZCAA"" -(282/M99**> 0,24){99**F γbymκH$6&.& 38(1(/##!-$ /N):)C##!-- ]E5)5J++A#- kp(@(@$<""$ αΧ0101$<""- 38,22)>---$ /N4),,>---- :D:2:1 !!- ,W(~() &$$$ 4ξ7j70 &$$- ,173/)>&$$> D/C1:0>&$$ &8|bCb/;;!! &QγπJJγ9-**H Y/(3(n>+AA$ R8,/,Q>+AA- iC5N5x>+AA *181(1)9;**$ 8)/ZC49;** *o5Ζ5Rr-#++J oΖ5R5r!#++6 o5R5Ζr.#++ 6cK,N0Η&&++6 cK,N0Η6&++6 4E4OE5+;++ *4OEE45+6++6 αN5K0ι$&++ *NL5L5:+A++!#oR5Ζ5r"#++ *4]]FF5 =++B!eE:E:κ9-++T#ad/J3n..!!> dV:aQj..!!H λwτp7B.#!!J 232S));;!! #kkQ5,g;;!! &7lRΛ4ο;=!! *qa2SUe""&&B tPYWa|""&&F R:Xεeτ">&&z n%nH%j !!B 8a](]V $!!& 3(`2nS &$$B Sg1aYy;&$$B VmeplΚ;&$$F n@2ΟM@99**> 3Φ)Ο?Δ99**> 0Y(5(α9&**> S(QgtR; !! #[TRγb}; !! &UnνdcfGG99 $t3ζ7xYGG99 -V/TπΘ7GG99 6b/JSjY..!!# ξ4S|mT..!!& XsSβJ`##!-$ :ΧVleQ#>!-- 70)/5Γ !! $SJtP)T==!!B pJ^Wmο==!!F 304@~φ-<""H kDO3v@-<""H )(O(O)-<""J VY)P/μGG99# ιRRκαΔGG99& SJbkjvGG99> s0[87RGG99H hth~β3>=&6$ [iλT7g>=&6$ fYXνa(!";;$ RCKt[T!";;- ())))?*"&A #/75|ξU*+&A &(hSQPU""&; #egλEαk""&; #Unυd`,6 #AB S1Yγχγ6 #AF Qα]33J!+#A$ sΜϊlke!+#A6 ]k(XPβ!A### ξ]RκiQ!A##& ://DL)GG!! -Vi7pPΠ#&--- XQjmXι6G!9F ((O(O(!G9">$3(@172++AA $T7hWΨ)++AA -54,DO0++AA 6j0o0η7-G""> `,J()n<.<.$ 8D^/sa<.<.- vb,U1θ<...> /5τQ7y<...H 1l8H@φAA##> :ΡϋUβφAA##H 2?@321&+$$B 8,0|0ξ&+$$F ΚΕ:ΕxκGG++* ΚΕ:Εxκ>&++* r4Μm::+$++* (4O4O(!G++ 0D)OL,=<++ 0DEL5,;"++ (δIδIO==++-#(,u,u5==++H$(:5:5δ==++z )cCk8%9$**H )l:l:%9-**>$4ε7E7ΐ.&++z OE4E45<+++* (/wCw[6;..B#(/wCw[6"..B#(/wCw[6A..B#(/wCw[6&..B#(/wCw[6...B#,,,,,,;;9.# ,,,,,,""9.# ,,,,,,AA9.# ,i/01x""66F C?C_C1;=!! &4F5]]F #++y NE5ω4:+A++ *Nω4E5:+A++6 oR5Ζ5r"#++ *c40D5Μ&&++z cC,{0ι6&++ *α{5C0o$&++6 p/XNFiGG++ -pJ^Wmο==!!F )O(O()-<""J Ub,U1a<...> tb,U1β<...> kb,U1q<...> 18τQ7κ<...> 7:τQ7l<...> 84τQ7t<...> 04ξτE0.*#< 9VLΗL84;+#A *VοVàK4;&#A *cεEZKV""#& 61(/á:O==-- *)/0ω:L<*.. *CN4)44 ##& /ΩE/5C9&**- :Ωγ,Lm">6A- 0Z8,:O!&$$F }ς4Θ4L=#++ *}O,âE_==++ *5:CψD36+#! *,O_/479-**- 0ãK2C79#**- 755_5K>;!! &4äO:Ee!>##6 0u0L04;#!!6 T8/ψZ4=G.. *(CN1:(-G!9I ,_Ν)0(--##J )48084#=--F ,70Z0Z66!!F Bψ7ΙW7<<..- /O)K)K>>!!- 04E_OD+=++ 60L4uED+=++ *rωKE:i+$#A6 ,{λ_,π#-!-$#5ΣCΣC?.A#<$#/O2+0{9***-$W00Z0Μ &$$z :7δL0?"=#&H 7NΝ1:?-$""H ,D7{8{.+#Az 4OD:D,"$#&6 (8N8KI><--I ,_,D/C">66- ,E4{CI;$!!$#7DDDC0+G$A -0E0E04AA9"& :{LE5E+&AA6 0{OCDD-=""J 4O5δu5""++ *4δuO55$;++6 Cδ4δ4K+&++-#/åχtΤZ #!-F Tψ:/KD=#..6 ε)Κ0Κ( G99& (uDuDD!G++>-0u)ωL0=>++ *';
//Decompression Arrays
pk='00,05,0a,01,04,02,32,3c,03,0f,46,08,0b,41,50,37,28,2d,64,5a,0c,4b,55,06,5f,09,07,0d,10,1e,23,0e,40,69,6e,78,80,11,20,14,30,73,82,19,7d,96,3f,3a,48,3e,44,2c,4e,53,43,34,87,56,4d,4c,8c,2b,38,42,4f,3d,47,2a,49,35,5c,39,3b,45,51,26,5b,4a,29,6c,52,36,a0,31,6b,62,54,c0,91,61,6a,25,24,59,2e,6d,b4,67,2f,57,33,65,63,58,17,27,7b,68,70,18,74,7a,21,1c,5e,a5,aa,1f,22,66,1d,83,81,6f,9a,5d,7e,72,79,e6,c8,1b,76,75,84,60,86,16,7c,71,9b,be,fa,ff,90,a8,8a,85,93,77,b8,7f,9f,af,c2,b9,a4,88'; pk=pk.split(',');
mn=' !"#$&()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~%αβγδεζηθικλμνξοπρστυφχψωΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩςάέήίόύώϊϋΐàáâãäå';
mn=mn.split(''); base=[];
forms_after = 721;
forms = {386.1:722,386.2:723,386.3:724,413.1:725,413.2:726,492.1:727,487.1:728,479.1:729,479.2:730,479.3:731,479.4:732,479.5:733,351.1:734,351.2:735,351.3:736,550.1:737,555.1:738,648.1:739,646.1:740,646.2:741,647.1:742,641.1:743,642.1:744,645.1:745,670.1:746,678.1:747,681.1:748,710.1:749,710.2:750,710.3:751,711.1:752,711.2:753,711.3:754,3.1:755,6.1:756,6.2:757,9.1:758,65.1:759,94.1:760,115.1:761,127.1:762,130.1:763,142.1:764,150.1:765,150.2:766,181.1:767,212.1:768,214.1:769,229.1:770,248.1:771,257.1:772,282.1:773,303.1:774,306.1:775,308.1:776,310.1:777,354.1:778,359.1:779,380.1:780,381.1:781,445.1:782,448.1:783,460.1:784,15.1:785,18.1:786,80.1:787,208.1:788,254.1:789,260.1:790,302.1:791,319.1:792,323.1:793,334.1:794,362.1:795,373.1:796,736.1:797,382.1:798,383.1:799,384.1:800,428.1:801,475.1:802,531.1:803,719.1:804,720.1:805};
function get_base(p,s) { //Returns values from pkmn
if (p.indexOf('.') > -1) {
p = forms[p];
}
if (!base[p]) {
base[p]=pkmn.slice(12*p,12*p+12).split('').map(function(v,i){v=pk[mn.indexOf(v)];if(i<10)v=parseInt(v,16);return v});
base[p].push(('000000000000000'+parseInt(base[p].pop()+''+base[p].pop(),16).toString(2)).split('').reverse().join('').substr(0,12).split('').reverse().join('').match(new RegExp(".{1,"+2+"}", "g")).reverse().map(function (v) { return parseInt(v,2); }));
base[p][10].push(base[p][10].splice(3,1)[0]);
}
return base[p][s];
}
//Add a custom Pokemon by modifying and un-commenting the following lines.
//Format is HP,ATK,DEF,SP.ATK,SP.DEF,SPD,Type1,Type2,Egg1,Egg2,[HP EPs,ATK EPs,DEF EPs,SP.ATK EPs,SP.DEF EPs,SPD EPs]
/*
pkmns = pkmns+'|Bulbasaur:1';
base[1] = [45, 49, 49, 65, 65, 45, 12, 3, 1, 7,[0, 0, 0, 1, 0, 0]];
*/
//ATK/DEF/SP.ATK/SP.DEF/SPD / Bashful 1, Docile 2, Hardy 3, Serious 4, Quirky 5, Bold 6, Modest 7, Calm 8, Timid 9, Lonely 10, Mild 11, Gentle 12, Hasty 13, Adamant 14, Impish 15, Careful 16, Jolly 17, Naughty 18, Lax 19, Rash 20, Naive 21, Brave 22, Relaxed 23, Quiet 24, Sassy 25
natures = [[],[1,1,1,1,1],[1,1,1,1,1],[1,1,1,1,1],[1,1,1,1,1],[1,1,1,1,1],[0.9,1.1,1,1,1],[0.9,1,1.1,1,1],[0.9,1,1,1.1,1],[0.9,1,1,1,1.1],[1.1,0.9,1,1,1],[1,0.9,1.1,1,1],[1,0.9,1,1.1,1],[1,0.9,1,1,1.1],[1.1,1,0.9,1,1],[1,1.1,0.9,1,1],[1,1,0.9,1.1,1],[1,1,0.9,1,1.1],[1.1,1,1,0.9,1],[1,1.1,1,0.9,1],[1,1,1.1,0.9,1],[1,1,1,0.9,1.1],[1.1,1,1,1,0.9],[1,1.1,1,1,0.9],[1,1,1.1,1,0.9],[1,1,1,1.1,0.9]];
natures[-1] = [1,1,1,1,1]; //neutral
natures['max'] = [1.1,1.1,1.1,1.1,1.1]; //all max
natures['min'] = [0.9,0.9,0.9,0.9,0.9]; //all max
//Type affinity no fg fl po gu ro bu gh st fi wa gs el ps ic dr da fa
damage = [[1,1,1,1,1,0.5,1,0,0.5,1,1,1,1,1,1,1,1,1],[2,1,0.5,0.5,1,2,0.5,0,2,1,1,1,1,0.5,2,1,2,0.5],[1,2,1,1,1,0.5,2,1,0.5,1,1,2,0.5,1,1,1,1,1],[1,1,1,0.5,0.5,0.5,1,0.5,0,1,1,2,1,1,1,1,1,2],[1,1,0,2,1,2,0.5,1,2,2,1,0.5,2,1,1,1,1,1],[1,0.5,2,1,0.5,1,2,1,0.5,2,1,1,1,1,2,1,1,1],[1,0.5,0.5,0.5,1,1,1,0.5,0.5,0.5,1,2,1,2,1,1,2,0.5],[0,1,1,1,1,1,1,2,1,1,1,1,1,2,1,1,0.5,1],[1,1,1,1,1,2,1,1,0.5,0.5,0.5,1,0.5,1,2,1,1,2],[1,1,1,1,1,0.5,2,1,2,0.5,0.5,2,1,1,2,0.5,1,1],[1,1,1,1,2,2,1,1,1,2,0.5,0.5,1,1,1,0.5,1,1],[1,1,0.5,0.5,2,2,0.5,1,0.5,0.5,2,0.5,1,1,1,0.5,1,1],[1,1,2,1,0,1,1,1,1,1,2,0.5,0.5,1,1,0.5,1,1],[1,2,1,2,1,1,1,1,0.5,1,1,1,1,0.5,1,1,0,1],[1,1,2,1,2,1,1,1,0.5,0.5,0.5,2,1,1,0.5,2,1,1],[1,1,1,1,1,1,1,1,0.5,1,1,1,1,1,1,2,1,0],[1,0.5,1,1,1,1,1,2,1,1,1,1,1,2,1,1,0.5,0.5],[1,2,1,0.5,1,1,1,1,0.5,0.5,1,1,1,1,1,2,2,1]];
ivr = [0,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];
stats = ['HP','Attack','Defense','Sp.Attack','Sp.Defense','Speed','—'];
types = ['Normal','Fighting','Flying','Poison','Ground','Rock','Bug','Ghost','Steel','Fire','Water','Grass','Electric','Psychic','Ice','Dragon','Dark','Fairy'];
eggs = ['???','Monster','Water1','Bug','Flying','Ground','Fairy','Plant','Humanshape','Water3','Mineral','Indeterminate','Water2','Ditto','Dragon','No Eggs'];
typeshp = ['Fighting','Flying','Poison','Ground','Rock','Bug','Ghost','Steel','Fire','Water','Grass','Electric','Psychic','Ice','Dragon','Dark'];
hps = ['0,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']; //possible Hidden Power "types"
/* UI specific functions */
function get_text(id,n) { //Returns text associated with n value from id (<select/>)
var a = $(id).value;
$(id).value = n;
var b = $(id).options[$(id).selectedIndex].text;
$(id).value = a;
return b;
}
pkmns=pkmns.split('|');
pkmns.sort(); //Sort names alphabetically
function pop_species() { //Populates the species list
var a = document.createDocumentFragment();
var i=0,j=pkmns.length; do {
var b = pkmns[i].split(':');
var c = el_add(a,"option",{value:b[1]},b[0]);
if ((b[1] > 649 && b[1] <= forms_after) || forms[b[1]] > 746) { c.className = 'new'; } //show new species
i++;
} while (i<j);
$('species').appendChild(a);
}
online = 0; //global- online status
function online_check() { //Checks if there's an internet connection alive
if (navigator.onLine) {
if (online == 1) { return true; }
online = 1;
add_sprite();
//Version Check - DO NOT change the following
$('version').innerHTML = '<a href="https://legendarypkmn.github.io/ivcalcxy.html"><img id="verchk" alt=""/></a><span class="error">Ø</span> <strong>There is a <a href="https://legendarypkmn.github.io/ivcalcxy.html">newer version</a> available!</strong>';
var verchk = $('verchk');
verchk.src = 'https://legendarypkmn.github.io/ivcalcxy_20171203.png?p='+ Math.floor(Math.random( )*100);
verchk.onload = function() { if (verchk.width==1) { $('version').innerHTML = '<span class="ok">OK!</span> You are using the latest version!'; } }
}
else { $('version').innerHTML = '<span class="error">Ø</span> Browser is <strong>offline</strong>! Unable to check for updates.'; }
}
themes = ['isotope','spp','simplex']; //define your own themes here, feel free to edit this
themed = themes.indexOf('none'); //global- set default theme here
theme = (!cookie_read('theme')?themed:cookie_read('theme'));
function toggle_theme() {
$('calculator').className = themes[theme];
display_status('The active theme has been changed to "'+themes[theme]+'".<br/><span class="btn" onclick="toggle_simple();">Simplify?</span>');
if (theme == -1 && (navigator.userAgent.indexOf('MSIE ') == -1)) {
display_status('The active theme has been changed to "Colorize".<br/>Select Hue, Saturation and Brightness:');
var c = cookie_read('color') || 'd';
if (c.charAt(0) == ',') {
c = c.split(',');
thema(c[1],c[2],c[3]);
}
$('status').innerHTML += '<br/><br/><input id="hue" type="range" min="0" max="360" value="150" />';
$('status').innerHTML += '<br/><input id="sat" type="range" min="0" max="100" value="4" />';
$('status').innerHTML += '<br/><input id="lit" type="range" min="0" max="100" value="74" />';
event_add($('hue'),"change", function () { thema($('hue').value,$('sat').value,$('lit').value); });
event_add($('sat'),"change", function () { thema($('hue').value,$('sat').value,$('lit').value); });
event_add($('lit'),"change", function () { thema($('hue').value,$('sat').value,$('lit').value); });
event_add($('hue'),"keyup", function (evt) { vv(this.id,0,360,evt); thema($('hue').value,$('sat').value,$('lit').value); });
event_add($('sat'),"keyup", function (evt) { vv(this.id,0,100,evt); thema($('hue').value,$('sat').value,$('lit').value); });
event_add($('lit'),"keyup", function (evt) { vv(this.id,0,100,evt); thema($('hue').value,$('sat').value,$('lit').value); });
}
cookie_create('theme',theme,60);
theme = (theme == themes.length?-1:theme*1+1);
}
function toggle_simple() {
$('calculator').className += ' simplex';
toggle($('info')); toggle($('instructions'));
display_status('All is plain and neat now!<br/>(refresh page to restore defaults)');
}
function thema(h,s,l) { //Color theming, does not work in IE8
var bg = 'hsl('+h+', '+s+'%, '+l+'%)';
var bd = 'hsl('+h+', '+s+'%, '+(l-20)+'%)';
var bd2 = 'hsl('+h+', '+s+'%, '+(l-26)+'%)';
var bp = 'hsl('+h+', '+s+'%, '+(l-9)+'%)';
var bs = 'hsl('+h+', '+s+'%, '+(l-16)+'%)';
$('thema').innerHTML = '#calculator{background:'+bg+';border-color:'+bd+';}#calculator .primary{background:'+bp+';}#calculator .secondary{background:'+bs+';}#calculator input,#calculator select,#calculator .button{border-color:'+bd2+';color:'+bd2+';}#calculator .button {background-color:'+bg+';}'; //dibs on this method
cookie_create('color',','+h+','+s+','+l,60);
}
eps = 1; //global- EPs enabled
function toggle_evs() { //Enable/Disable EV functions
switch(eps) {
case 1:
eps = 0; $('btn-evs').value = 'EVs: OFF';
break;
case 0:
eps = 1; $('btn-evs').value = 'EVs: ON';
break;
}
var j = $c('eps').slice();
var i = j.length-1; do {
toggle(j[i]);
} while(i--);
display_base();
}
mode = 0; //global- Single enabled
function toggle_mode(m) { //Single/Team/Row mode
var m = m || mode;
switch(m) {
case 0:
mode = 1;
$('btn-mode').value = 'Team Calculation';
$('mode0').style.display='none';
$('mode1').style.display='';
$('btn-hp').disabled = 'disabled';
$('btn-stats').disabled = 'disabled';
$('btn-eps').disabled = 'disabled';
display_status('Mode has been changed to <strong>Team Calculation</strong>.');
break;
case 1:
mode = 2;
$('btn-mode').value = 'Row Calculation';
$('mode0').style.display='';
$('mode1').style.display='none';
$('btn-hp').disabled = '';
$('btn-stats').disabled = '';
display_status('Mode has been changed to <strong>Row Calculation</strong>.');
break;
default:
mode = 0;
$('btn-mode').value = 'Single Pokémon';
$('mode0').style.display='';
$('mode1').style.display='none';
$('btn-hp').disabled = '';
$('btn-stats').disabled = '';
$('btn-eps').disabled = '';
display_status('Mode has been changed to <strong>Single Pokémon</strong>.');
}
display_sprite();
display_effectiveness($('number-'+(act>-1?act:0)).value);
}
/* Save & Load functionality */
function code_load(c) { //Loads a SaveCode
//var c = prompt('Input SaveCode or [Cancel] to load from URL:') || location.search;
//var c = location.search;
display_status('<span class="loading">Loading SaveCode...</span>');
if (c == undefined || c.indexOf('?sc=') == -1) { display_status('Cannot load improper SaveCode.'); return NULL; }
c = c.replace(/%20/gi,'').substring(1).split('!');
if (c.length < 2) { display_status('Cannot load improper SaveCode.'); return; }
var i = c.length-1; do { c[i] = c[i].split(','); } while(i--);
//Check if SaveCodeVersion is compatible (may change with Black/White)
if (c[0][0] > 1) { display_status('Cannot load incompatible SaveCode.'); return; }
//Check if SaveCodeUI is compatible, and restore UI
if (c[0][1] == 0) {
if (c[0][2] == 0 && eps == 1) { toggle_evs(); }
var i = c[0][3]*1;
if(mode!=i) { if(mode==2) { mode = 0; } toggle_mode(i-1); }
display_status('<span class="loading">Loading SaveCode...</span>');
mode = i;
$('nickname').value = unescape(c[0][4]);
}
//Load user entered IVs
$('statlvl').value = c[1][6]; $('hiddent').innerHTML=''; $('hiddenp').innerHTML='';
var i=5; do {
ivs[i] = ivr.slice();
$('med'+i+'-0').value = c[1][i]*1;
$('spr'+i+'-0').innerHTML = '';
$('plv'+i+'-0').innerHTML = '';
$('stats'+i).innerHTML = '';
} while(i--);
//Load row data
$('statrows').style.display = 'none';
el_del($('statrows'));act=-1;actp=0;rn=1;rs=[0];ivs=[];
var i=2, r=i-2; l=c.length;
if (l > 2) {
do {
if (r!=0) { row_add(0,c[i][1]); };
$('level-'+r).value = c[i][1]*1; $('number-'+r).value = c[i][0]*1; $('nat-'+r).value = c[i][14]*1; $('char-'+r).value = c[i][15]; $('hpt-'+r).value = c[i][16]*1;
$('pot0-'+r).value = c[i][17]*1; $('pot1-'+r).value = c[i][18]; $('pot2-'+r).value = c[i][19]*1;
var j=5; do {
$('stat'+j+'-'+r).value = c[i][j+2]*1;
$('ep'+j+'-'+r).value = c[i][j+8]*1;
} while(j--);
display_eps();
i++; r++;
} while (i<l);
}
//Restore focus and set active row
$('act-0').checked = 1; act=0; actp=0; row_sync();
$('statrows').style.display = '';
display_effectiveness($('number-'+act).value);
tooltips();
display_status('Loaded SaveCode successfully!');
$('btn-ivs').focus();
}
function code_save() { //Displays a SaveCode
var c = '?sc=0,0,'; //Data/SaveCode version
c += eps+',';
c += mode+',';
c += escape($('nickname').value)+'!';
c += $('med0-0').value+',';
c += $('med1-0').value+',';
c += $('med2-0').value+',';
c += $('med3-0').value+',';
c += $('med4-0').value+',';
c += $('med5-0').value+',';
c += $('statlvl').value+'';
var s = $c('statrow'), i = (mode==2?0:s.length), r = (mode==2 && act>-1?act:0); s.reverse();
do {
c += '!'+$('number-'+r).value+','+$('level-'+r).value+','+$('stat0-'+r).value+','+$('stat1-'+r).value+','+$('stat2-'+r).value+','+$('stat3-'+r).value+','+$('stat4-'+r).value+','+$('stat5-'+r).value+','+$('ep0-'+r).value+','+$('ep1-'+r).value+','+$('ep2-'+r).value+','+$('ep3-'+r).value+','+$('ep4-'+r).value+','+$('ep5-'+r).value+','+$('nat-'+r).value+','+$('char-'+r).value+','+$('hpt-'+r).value+','+$('pot0-'+r).value+','+$('pot1-'+r).value+','+$('pot2-'+r).value;
if (i > 0) { r = s[i-1].id.split('-')[1]; }
} while (i--);
display_status('<a href="'+c+'">SaveCode</a> (<a href="http://j.mp/https://legendarypkmn.github.io/ivcalcxy.html'+c+'">shorten</a>):<br/>'+c.split('!').join('! '));
$('contact').href = 'https://legendarypkmn.net/contact?topic=IV%20Calculator&text='+escape('My browser is: '+navigator.userAgent+'\nMy savecode is: '+c+'\n\n');
//window.location += c; //Uncomment for old behaviour
}
/* Row functions */
act = 0; actp = 0; //global- active row; previous active row
rn = 1; rs = [0]; //global- new row counter; array of current rows
error = 1; //global- error flag, default: true
function row_act(n) { //Makes n row active
if ($('act-'+n).value == act) {
actp = act;
act = -1;
$('act-'+n).checked = 0;
$('name').focus();
$('ept').style.visibility = '';
if (online == 1) { display_sprite(); }
display_effectiveness($('number').value);
return false;
}
act = n;
actp = 0;
$('act-'+n).checked = 1;
/*$('number-'+n).readonly = 'readonly'; $('number-'+n).disabled = ''; //look into this
$('number-'+actp).readonly = ''; $('number-'+actp).disabled = 'disabled';*/
$('ept').style.visibility = 'hidden';
row_sync();
}
function row_sync() { //Syncs the display with active row
var n=act, t=$('pot1-'+n).value.split('.');
$('number').value = Math.floor($('number-'+n).value);
$('species').value = $('number-'+n).value;
$('nat').value = $('nat-'+n).value;
$('char').value = $('char-'+n).value;
$('hpt').value = $('hpt-'+n).value;
$('pot0').value = $('pot0-'+n).value;
$('pot2').value = $('pot2-'+n).value;
var i=5; do {
$('pot1').options[(i+1)].selected = (t.indexOf(i.toString()) > -1?true:false);
} while(i--);
display_effectiveness($('number-'+n).value);
display_base();
display_nature();
display_char();
if (mode == 2) { calc_ivs(n); }
if (online == 1) { display_sprite(); }
}
function row_edit() { //Makes active row editable
var n=act, t=[];
if (n == -1) { return false; }
$('number-'+n).value = $('species').value;
$('nat-'+n).value = $('nat').value;
$('char-'+n).value = $('char').value;
$('hpt-'+n).value = $('hpt').value;
$('pot0-'+n).value = $('pot0').value;
var i=6; do {
if ($('pot1').options[i].selected && t.indexOf(i-1) == -1 ) { t.push(i-1); }
} while(i--);
$('pot1-'+n).value = t.join('.');
$('pot2-'+n).value = $('pot2').value;
}
function row_up(r) { //Moves row upwards
var t=[], n=[], p=rs[rs.indexOf(r)-1];
if ($('act-'+p).checked == 0) { row_act(p); }
else if (online == 1) { display_sprite(); }
p = $('level-'+p,'stat0-'+p,'stat1-'+p,'stat2-'+p,'stat3-'+p,'stat4-'+p,'stat5-'+p,'number-'+p,'nat-'+p,'char-'+p,'hpt-'+p,'pot0-'+p,'pot1-'+p,'pot2-'+p,'ep0-'+p,'ep1-'+p,'ep2-'+p,'ep3-'+p,'ep4-'+p,'ep5-'+p);
n = $('level-'+r,'stat0-'+r,'stat1-'+r,'stat2-'+r,'stat3-'+r,'stat4-'+r,'stat5-'+r,'number-'+r,'nat-'+r,'char-'+r,'hpt-'+r,'pot0-'+r,'pot1-'+r,'pot2-'+r,'ep0-'+r,'ep1-'+r,'ep2-'+r,'ep3-'+r,'ep4-'+r,'ep5-'+r);
p.map(function(v){t.push(v.value); });
n.map(function(v,i){p[i].value=v.value;v.value=t[i];});
display_eps(r);
row_sync();
}
function row_del(n) { //Removes n row
rs.splice(rs.indexOf(n),1);
if (act==n) { row_act(0); }
$('statrows').removeChild($('statrow-'+n));
$('statrows').removeChild($('eprow-'+n));
row_sync();
}
function row_add(n,lvl) { //Appends a new row
if (n > 0) { rn = (rs.length == 1?1:n); }
if (!lvl && mode==0) {
var lvl = $('level-'+rs[(rs.length-1)]).value;
lvl = (lvl<100?lvl*1+1:100);
}
lvl = lvl || 100;
var ep = [0,0,0,0,0,0];
if (mode==0) {
var p = rs[(rs.length-1)];
var ep = [$('ep0-'+p).value,$('ep1-'+p).value,$('ep2-'+p).value,$('ep3-'+p).value,$('ep4-'+p).value,$('ep5-'+p).value,];
}
rs.push(rn);
var a = document.createDocumentFragment();
var b = el_add(a,"tr",{id:'statrow-'+rn,className:'statrow'});
el_add(b,"td",'','<input type="radio" class="radio tooltip" name="act" id="act-'+rn+'" value="'+rn+'" onclick="row_act('+rn+');" title="(De)Activate this row."/> <span class="btn tooltip" onclick="row_del('+rn+');" title="Delete this row.">-</span>');
el_add(b,"td",'','<input type="text" id="level-'+rn+'" name="level-'+rn+'" maxlength="3" size="3" value="'+lvl+'" onkeyup="vv(this.id,0,100,event,'+rn+');" />');
el_add(b,"td",{},'<span class="btn tooltip" onclick="row_up('+rn+');" title="Move row upwards.">^</span>');
var i = 0; do {
el_add(b,"td",'','<input type="text" name="stat'+i+'-'+rn+'" id="stat'+i+'-'+rn+'" maxlength="3" size="3" value="" onkeyup="vv(this.id,0,999,event,'+rn+');" />');
i++;
} while (i<6);
el_add(b,"td",'','<input type="text" disabled="disabled" id="number-'+rn+'" name="number-'+rn+'" maxlength="3" size="3" value="'+$('number').value+'" /><input type="hidden" id="nat-'+rn+'" name="nat-'+rn+'" value="'+$('nat').value+'" /><input type="hidden" id="char-'+rn+'" name="char-'+rn+'" value="'+$('char').value+'" /><input type="hidden" id="hpt-'+rn+'" name="hpt-'+rn+'" value="'+$('hpt').value+'" /><input type="hidden" id="pot0-'+rn+'" name="pot0-'+rn+'" value="'+$('pot0').value+'" /><input type="hidden" id="pot1-'+rn+'" name="pot1-'+rn+'" value="'+$('pot1').value+'" /><input type="hidden" id="pot2-'+rn+'" name="pot2-'+rn+'" value="'+$('pot2').value+'" />');
var c = el_add(a,"tr",{id:'eprow-'+rn,className:'eps'});
if (eps == 0) { c.style.display = 'none'; }
el_add(c,"td");
el_add(c,"td",{id:'eps-'+rn,value:ep.sum()});
el_add(c,"td");
var i = 0; do {
el_add(c,"td",'','<input type="text" name="ep'+i+'-'+rn+'" id="ep'+i+'-'+rn+'" maxlength="3" size="3" value="'+ep[i]+'" onkeyup="vv(this.id,0,255,event,'+rn+');display_eps();" />');
i++;
} while (i<6);
el_add(c,"td");
$('statrows').appendChild(a);
row_act(rn);
rn++;
}
function add_eps() { //adds provided effort points to Pokemon's Effort Values
function validate_eps(ep1,ep2) { //EPs limits | ep1 = current EPs | ep2 = EPs to be added
var n = actp;
var eps = 1*$('eps-'+n).innerHTML;
epsum = 1*ep1 + 1*ep2;
epsum2 = 1*ep1 + (510-1*eps);
if (ep2 < 0 && epsum > 0) { return epsum; }
if (eps < 510 && ep1 < 255) {
ep3 = (eps + 1*ep2 < 510)?((epsum < 255)?epsum:255):((epsum2 < 255)?epsum2:255);
return ((ep3 < 0)?0:ep3);
}
else { return ep1; }
}
display_base();
var n = actp; //active row
var i=5; do {
$('ep'+i+'-'+n).value = validate_eps($('ep'+i+'-'+n).value,$('eff'+i+'').innerHTML);
} while(i--);
display_eps();
$('name').focus(); //return focus to input
}
/* Calculation functions */
function calc_effectiveness(typ,type1,type2) { //Calculates effectiveness
var mul = damage[typ][type1];
if (type2 != type1) { mul = mul * damage[typ][type2]; }
return mul;
}
function calc_hiddenp() { //Calculates Hidden Power's power
return 60; //Obsolete since XY
var a = arguments;
return Math.floor((0.5*(a[0]&2)+1*(a[1]&2)+2*(a[2]&2)+4*(a[5]&2)+8*(a[3]&2)+16*(a[4]&2))*40/63 + 30);
//return (((((a[4]&2)<<1) + (a[3]&2) + ((a[5]&2)>>>1))*10 + (a[2]&2)*3 + (a[0]&2) + (a[1]&2)) >>> 1)+30; //alternate, by Chase
}
function calc_hiddent() { //Calculates Hidden Power's type
var a = arguments;
return Math.floor(((a[0]&1)+2*(a[1]&1)+4*(a[2]&1)+8*(a[5]&1)+16*(a[3]&1)+32*(a[4]&1))*15/63);
//return (a[2] & 1) + ((a[5] & 1) << 1) + ((a[3] & 1) << 2) + ((a[4] & 1) << 3); //alternate, by Chase, uses the main types[]
}
function calc_hidden(n) { //Displays all possible Hidden Powers
//d = new Date(); time = d.getTime(); //DEBUG
function display_hp() {
t.reverse().sort(); //p.sortnum();
$('hiddent').innerHTML = t.join(', ');
$('hiddenp').innerHTML = 60; //p.join(', ');
//array_intersect(ivs[i],eo[ivhss[i][0]].slice());
//d = new Date(); display_status((d.getTime()-time)/1000); return true; //DEBUG
display_text(n);
}
display_status('<span class="loading">Calculating <em>Hidden Power</em>...</span>');
if ($('medl').checked) {
var t = [typeshp[calc_hiddent($('med0-0').value,$('med1-0').value,$('med2-0').value,$('med3-0').value,$('med4-0').value,$('med5-0').value)]];
//var p = [calc_hiddenp($('med0-0').value,$('med1-0').value,$('med2-0').value,$('med3-0').value,$('med4-0').value,$('med5-0').value)];
display_hp(); return true;
}
if (error != 0) { display_status('Does not compute!<br/>Properly input or Calculate IVs first.'); return false; }
var a = [], b = $('hpt-'+n).value, t = [], p = [], i0=ivs[0].length-1;
do { //must optimize this further
a[0] = ivs[0][i0];
var i1=ivs[1].length-1;
do {
a[1] = ivs[1][i1];
var i2=ivs[2].length-1;
do {
a[2] = ivs[2][i2];
var i3=ivs[3].length-1;
do {
a[3] = ivs[3][i3];
var i4=ivs[4].length-1;
do {
a[4] = ivs[4][i4];
var i5=ivs[5].length-1;
do {
a[5] = ivs[5][i5];
var c = typeshp[calc_hiddent(a[0],a[1],a[2],a[3],a[4],a[5])];
if (b == -1 || c == typeshp[b]) {
if (t.indexOf(c) == -1) { t.push(c); }
//var d = calc_hiddenp(a[0],a[1],a[2],a[3],a[4],a[5]);
//if (p.indexOf(d) == -1) { p.push(d); }
}
if (p.length == 41 && t.length == 16) { display_hp(); return true; } //exit loops if all possible
} while (i5--);
} while (i4--);
} while (i3--);
} while (i2--);
} while (i1--);
} while (i0--);
display_hp();
}
function calc_stat(species,pstat,stativ,statev,pokelvl,nature) { //Calculates Pokemon stats
var basestat = get_base(species,pstat);
var bonus = natures[nature][(pstat-1)];
if (eps == 0) { var statev = 0; }
if (pstat == 0) { //HP uses a different formula
var result = (Math.floor(((basestat*2 + (stativ/1) + Math.floor(statev/4))*pokelvl)/100)) + (pokelvl/1) + 10;
if (species == 292) { return 1; } //Shedinja Case
}
else { var result = Math.floor((Math.floor(((basestat*2 + (stativ/1) + Math.floor(statev/4))*pokelvl)/100) + 5)*bonus); }
return result;
}
ivs = [ivr.slice(),ivr.slice(),ivr.slice(),ivr.slice(),ivr.slice(),ivr.slice()]; //global- IVs array
function calc_stativ(species,pstat,stat,statev,pokelvl,nature,chara,pot1,pot2) { //Calculates Pokemon IVs - brute force
var chara = chara.split('.');
var pot1 = pot1.split('.');
var charas = [[0,5,10,15,20,25,30],[1,6,11,16,21,26,31],[2,7,12,17,22,27],[3,8,13,18,23,28],[4,9,14,19,24,29]];
var pots = [[0,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]];
ivs[pstat] = [-1];
var i=31; do {
if (calc_stat(species,pstat,i,statev,pokelvl,nature) == stat) { ivs[pstat].unshift(i); }
} while(i--);
if (pstat == 0 && species == 292) { ivs[pstat] = ivr.slice(); } //Shedinja Case
if (chara[0] == pstat && chara != -1) {
ivs[pstat] = array_intersect(ivs[pstat],charas[chara[1]]);
maxiv = ivs[pstat][ivs[pstat].length-1]; //global maximum IV
}
if (pot1.indexOf(pstat.toString()) != -1 && pot2 != -1) {
ivs[pstat] = array_intersect(ivs[pstat],pots[pot2]);
}