-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
1400 lines (1181 loc) · 43.6 KB
/
index.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
<!--
``.``.`.-../--::/o+/+/++/++/-.```
+ssyyyhhhhhysyyyyhhhhhhhhyyyyyyhhhhhhys+:-`
/syyyyyyhhyyyyyssssyhyhhyhhyyysyhhddddhhyhyy+-```
`.+sysyyyyyhyyhhhyyssyyhhyyyyyyysoosyhhhhhhhyysssyyyyso/-
.--./+shhhhhddddddddddddhhhhhyysysssssoooosyyyyyhhyyhhyyssysyyy+
`.`-:-/+oyyhhhhhhhhhhdddddddhhdddhhhyyyyysssssssooyyyhhyyyhhhhhhyyssysooyy/`
`:shhdhhyhhhhhhyyyhhdddddddhddhddddhhdddhhyyysosysysshhhdddddhhyyyssoossoosyy.
.ymmmhhhhddddddhhhyhhddmmmmmmddhdddhddddhddddhhhhyyhhyyyyyddmddddhhhhhysssoooshh.
smmmdddmmmmddhhhhdddmmmmmmmdddhhhhhyyhhyhhhhhhhhhdhhhhhhyhhhddmmmdddhddhyysoooshy-
`hmmdddmmmmddhhhhddmmmmmmmmdddhyyssssssoooosssssyyhhhyyyyyyhhhddmmmdddddmmdhhysoosyy/-`
/dhhddmmmdddddddmmmmmmmmmmddhyssoo++o++////+++oossssyysyysyyyhhhddmmddddmmmmmmddhyoosyh:
./ddddmmmmdddddmmmmmmmmmmmddhhys++///:::::::::////+++ooosssssssyyyhhdmmmddddmmmmmmmmdhsso`
/hhhdmmmmmmddddddmmmmmmddhhysoo+//:-::---.----:::::///++ooooosssssyyhdmmmdhhddmmmmNmmhsoo
`shhddmmmmmdddddddddddhhhysso+///::---------------::::::/++++++oooossyyhddddddmmNNNNmmdyh:
.yyhddmmmmmmddddddhhhhyysoo+//:--...........------:---:::///++++ooossssyhdddddmNNNNNmmdhh/
/yhdmNNNNmmdddddddhyssoo+//--.................--------::://+++oooosssyyyhddddmmNNNNmdyyy/
.hdmNNNNNmmddmmmdhso++//:-...........```........----::::////++ooooossyyyhddhdmmmNNmdhsso/`
/hmNNNNNNmdddmmmhs+//:--..............```......----:::::///+++oooossyyyyhhhhdmmmNmdhhsso:
`yhmmNNNNNNmdddmdy+//:-------.......````````..-------::::///+++++ooosyhhhhhdddmmmmmdhyyyo:`
`ohdmmNNNNNmdhhhho///::------.........````......-----::::://++++++oosyhhhddddmmmmmmdhhhyo`
:hdmNNNNNmmdhhyo//::::------................----::-----:////+++oossyhhdddmmmmmNmdddhhy/ `
.sdmmmNNNmdhhyo///::::-----.....--............--------:://+oooossyyyhdddmmmmNNmmdddhy-
.:ymmNNNNmdhyo+//:::-------.......................-:/+osyhhhyyyyyyyhhddddmNNNNmmmddy.
`odmNNNmmmhs+//::::----............-------:::/+osyhhhdddmdddhhhhhhhhddddmmNmmNNmdy-
`sdmNNNNmhyo+/:::::----.....-----:::/::/+oossyddddddddddddddddmmmmmmhyyyhmNNNNmds. `
`/hmNNNmdyo+////++++++ooosysooo+////://osssyyhhhhhdddhhhyyyyhhdmNNNNNNNNNNNNNmhhy+:.`
`ohmNNmmy+++++ssyhhhhdddddhhyso+/:::/+ossyhhyyhhhysssssyyhyhhddmNNNNNNNNNNNNNddddhhyo+o.
.shNNNmy+++osyssyyyyyyhhhhyysoo///+oyddhhhyyhysoosyhhhhhhhhhdddmmddddddmNNmmmmmmdddddho`
/smNNmyooyyhyyyssyysssyyhhhhdmddmmmmmhyhyyyssyyshdmmdddmmdhhdhmmyhhhhddmmmmmmmmdddddyso.
`oyNNNmdhyyssoooooossyyysssosmNmdhdmNdhhhsssyso/+syyyyyydddhyydhsyyhhddmmmmmmmmmdddhysys
.ydNNNdhoosooosyyyhddmdhsyyoohmo:-:+hmhyssso+++++++ooosyyhhhysmysyhhhddmmmNmmmmmdddhysyh
`:shNNmdh++oooshdhooyhys+/++//yy----:+hmho++////++ooosssyyyssshhosyhddddmmNNmmmmddddhyyhh
./++ydmNdds++oosyys+//++/+++/::h+-.--:+shdho+//::///++++ooosssss+osyhdmmmmmNNmmmmddddhyhds
:ssyyshNmdhsoo+ooo+++++ooo+:--/d/-.--:+syyyhhyo+++++++oooo+++/++oosyhdmmmmmNNNmmmmdddhhdd.
:o//++smmdhhyso+/+/++++/::---+hy:----:/oyyysyhhyso+/:::::://+++oosyhhdmmmmmNNNmmmmmddddds
`+::://hddhyys+/::::----::/oydy/:-..-:/+syhyssossooo+++++++ooossyyhdddmmmmmNNmmmmmmddhdh.
-:--::ydyyhyoo+/++++/++++osss+::-..-:/+oyhssys+/::--...---:/+ossyhddmmmmmmNNmmmmmmddhh-
-:--:odhoo++++///+++++++//:::::...-:/+syyooos+/:--....--::/+oosyhdddmmmmmNmmmmmmmdhy:
.:-:-ydso//+ooo+/:-......-:://::::/+shhhyssss+:------:://+oosyhhddmmmmmNNmmmmmmdhs-
`::-+dho++///:-......----:/oyo/++sshdmNmmdhhy+:---::://++osyyhdddmmmmmmmmmmmmho:`
`/:/ydy+++//::-------::-:ohmdsyhddmmmmmmdddho+:::://++oossyhddddmmmmNNNdo++:.
`++/+sys++++//:::::::::--:+ysoshdmmmmddhyysoo+/////++oossyhhddddmmmmmNN/ `
./o/:+so++o+///////::----:/+++osyhhyyyyssooooo+++++oossssyhddddmmmmmNms
.+//osoo++++++///:::::://+++oosssooossssssssooooosssoosyhddddmmmmmmds
-++sso+++++++///:////+++++++++///+ooosyyyyysssyysooosyhddddmmmmmmd-
`.:ooo++++///////+++o++////:::/oyhhyhhdddddhhhysooosyhdddmmmmmmmh` `
:soo+++/////++osssosyhdddddmmmmmmNNNNmmdhysoooosyhdmmmmmmmmmms
:sooo++////+oshddhdmmmmmmmmddddhhhyyysssooooo+osyhdmmmmmmmmmm-
`oooooo+///+oyys+/++++++//////////+osyso+ooooooshdmmmmmmmmmmd`
+sooooo++++oo+/:/+///:::::://++oosyyysoooo+++oshdmmmmmmmmmy.
.sysooooooo++/://+++++ossssssssssyysoo++o++++oydmmmmmmmms-`
-yhsooooo+++///:/++oosssssooooooo++++++oo+ooyhmmmmmms/-
`/yyooooo+////::://++///:/:////////++ooosshdmmmmh+-
.+hysso++////:::::::::--::////+++++osyhdmmmd+.
`-ossso+++///////:::://////++o+osyhmmmh+`
:yhhyso++///////++++++oossyhdmmy+-
-/sdhysoo++++oooosssyhddmmd+-
.ohddhhyyyyyyhhddmdms+-`
`///oooo/oshy+-``
`
PAPA KAPLAN SAYS TO BUY MORE LOOT BOXES
-->
<!DOCTYPE HTML PUBLIC>
<html lang="en">
<head>
<meta http-equiv="cache-control" content="no-cache, must-revalidate, post-check=0, pre-check=0">
<meta http-equiv="expires" content="Sat, 31 Oct 2014 00:00:00 GMT">
<meta http-equiv="pragma" content="no-cache">
<script src="sorttable.js"></script>
<script src="plotly-latest.min.js"></script>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Item table for Overwatch</title>
<style>
td {
padding-left: 3px;
padding-right: 7px;
padding-top: 3px;
padding-bottom: 2px;
}
table {
border-collapse: collapse;
}
table, th, td {
border: 1px solid black;
font-size:16px;
}
tr:hover {background-color: #f5f5f5}
table th
{
padding-right:30px;
}
body {
font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;
font-size:18px;
line-height:1.42857143;
color:#333;
background-color:#fff;
}
.common {
color: #3a3a3a ;
}
.rare {
color: #27dcf4 ;
}
.epic {
color: #f426f0 ;
}
.legendary {
color: #f4af25 ;
}
.column-left{ float: left; width: 250px; }
.column-center{ float: left; width: 250px; }
.column-right{ display: inline-block; width: 250px; }
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
-webkit-appearance: none;
margin: 0;
}
table.sortable tbody {
counter-reset: sortabletablescope;
}
table.sortable thead tr::before {
content: "";
display: table-cell;
border: 1px solid black;
font-size:16px;
}
table.sortable tbody tr::before {
content: counter(sortabletablescope);
counter-increment: sortabletablescope;
display: table-cell;
border: 1px solid black;
font-size:16px;
}
/* The Modal (background) */
.modal {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: rgb(0,0,0); /* Fallback color */
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
}
/* Modal Content/Box */
.modal-content {
background-color: #fefefe;
margin: 15% auto; /* 15% from the top and centered */
padding: 20px;
border: 1px solid #888;
width: 80%; /* Could be more or less, depending on screen size */
}
/* The Close Button */
.close {
color: #aaa;
float: right;
font-size: 28px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: black;
text-decoration: none;
cursor: pointer;
}
a {
font-size:14px;
color: #6666ff;
text-decoration: none; // changed from text-decoration:underline
}
a:hover {
color: #3333ff;
text-decoration: underline; // changed from text:decoration:none
}
</style>
</head>
<body>
<a href="#" id='hBtn'>Help</a> -
<a href="#" id='fBtn'>Filters</a> -
<a href="#" id='oBtn'>Simulation Options</a> -
<a href="#" id='sBtn'>Spending Strats</a> -
<a href="mailto:[email protected]?Subject=Loot-Box%20websit">Contact/Feedback</a>
<br>
<div class="container">
Show items for: <select id="herodisplay" onclick="updateTable();">
<option value="1">Ana</option>
<option value="2">Bastion</option>
<option value="3">Dva</option>
<option value="4">Genji</option>
<option value="5">Hanzo</option>
<option value="6">Junkrat</option>
<option value="7">Lucio</option>
<option value="8">Mccree</option>
<option value="9">Mei</option>
<option value="10">Mercy</option>
<option value="11">Orisa</option>
<option value="12">Pharah</option>
<option value="13">Reaper</option>
<option value="14">Reinhardt</option>
<option value="15">Roadhog</option>
<option value="16">Soldier-76</option>
<option value="17">Sombra</option>
<option value="18">Symmetra</option>
<option value="19">Torbjorn</option>
<option value="10">Tracer</option>
<option value="21">Widowmaker</option>
<option value="22">Winston</option>
<option value="23">Zarya</option>
<option value="24">Zenyatta</option>
<option value="25">Icons/Sprays (All)</option>
<option value="26">EVERYTHING</option>
</select>
</div>
<span id='urlArea'> </span>
<!--
<button onclick="updateCheckboxes('clearPageHave')">Clear "have it" on this page</button><br>
<button onclick="updateCheckboxes('clearPageWant')">Clear "want it" on this page</button><br> <br>
<button onclick="updateCheckboxes('checkPageHave')">Check "have it" on this page</button><br>
<button onclick="updateCheckboxes('checkPageWant')">Check "want it" on this page</button><br> <br>
<button onclick="clearCookie()">Clear all "have it"</button><br>
<button onclick="clearCookie()">Clear all "want it"</button><br> <br>
<button onclick="clearCookie()">Check all "have it"</button><br>
<button onclick="clearCookie()">Check all "want it"</button><br> <br>
<br>
-->
</div>
<div>
Wanted Commons: <span id='wantedCommons'></span><br>
Wanted Rares: <span id='wantedRares'></span><br>
Wanted Epics: <span id='wantedEpics'></span><br>
Wanted Legendaries: <span id='wantedLegs'></span><br>
Wanted Icons: <span id='wantedIcons'></span><br>
Total cost in gold: <span id='goldNeeded'></span><br>
</div>
<div id='goldAndButton'>
Current gold: <input type="number" id="userGold" value="0" size="10" style="width: 50px"><br>
<button onclick="startSimulating()">Start simulation</button> <br>
</div>
<!-- The Modal -->
<div id="helpModal" class="modal">
<!-- Modal content -->
<div class="modal-content">
<span class="close" id="hclose">×</span>
<p>
This is a website to simulate
how many loot boxes it takes to get any selection
of items in overwatch.
<ol><li> Select the items that you already have ("have it" column).
<li> Select the items that you want ("want it" column).
<li> Input the amount of gold you have.
<li> Click the "start simulation" button and thats it!
</ol>
</p>
<p>
When you click on any check box your selections are saved on a cookie. When you come back, your selections are restored from the cookie. Click the "clear saved checks" button to delete your cookie and then reload the page to start fresh. In addition to a cookie, a link is created that saves your selections. Bookmark this link to save that particular selection.
</p>
</div>
</div>
<div id="filtersModal" class="modal">
<div class="modal-content">
<span class="close" id="fclose">×</span>
<p>
<input type="checkbox" id="showSkins" onclick="updateTable();" checked> Show Skins <br>
<input type="checkbox" id="showEmotes" onclick="updateTable();" checked> Show Emotes <br>
<input type="checkbox" id="showIntros" onclick="updateTable();" checked> Show Highlight Intros <br>
<input type="checkbox" id="showPoses" onclick="updateTable();" checked> Show Victory Poses <br>
<input type="checkbox" id="showVoices" onclick="updateTable();" checked> Show Voice Lines <br>
<input type="checkbox" id="showSprays" onclick="updateTable();" checked> Show Sprays <br>
<input type="checkbox" id="showIcons" onclick="updateTable();" checked> Show Icons <br>
<br>
<input type="checkbox" id="showLegs" onclick="updateTable();" checked> Show Legendaries <br>
<input type="checkbox" id="showEpics" onclick="updateTable();" checked> Show Epics <br>
<input type="checkbox" id="showRares" onclick="updateTable();" checked> Show Rares <br>
<input type="checkbox" id="showCommons" onclick="updateTable();" checked> Show Commons <br>
<br>
<input type="checkbox" id="showNonEvent" onclick="updateTable();" checked> Show Non-event items <br>
<input type="checkbox" id="showUprising" onclick="updateTable();"> Show Uprising <br>
<input type="checkbox" id="showEvents" onclick="updateTable();"> Show Other events <br>
<br>
<input type="checkbox" id="showAchievement" onclick="updateTable();"> Show Achievement items <br>
<input type="checkbox" id="showBlizzcon" onclick="updateTable();"> Show Items from Blizzcon <br>
<input type="checkbox" id="showDefaultItems" onclick="updateTable();"> Show Default items <br>
<input type="checkbox" id="showNormals" onclick="updateTable();" checked> Show Normal items <br>
<br>
</p>
</div>
</div>
<div id="optionsModal" class="modal">
<div class="modal-content">
<span class="close" id="oclose">×</span>
<p>
Max iterations: <input type="number" id="nIterations" value="1500" size="10" style="width: 50px"><br><br>
Max time (sec): <input type="number" id="maxTime" value="1.0" size="10" style="width: 50px"><br>
<br>
Max boxes: <input type="number" id="maxBoxes" value="3500" size="10" style="width: 50px"><br>
<br>
</p>
</div>
</div>
<div id="spendingModal" class="modal">
<div class="modal-content">
<span class="close" id="sclose">×</span>
<p>
<input type="radio" name="spend" value="optimal" onclick="lootBoxesNeeded=[];hideContinueButton();" checked> Optimal spending (buy nothing until you can afford everything)<br>
<input type="radio" name="spend" value="buyHigh" onclick="lootBoxesNeeded=[];hideContinueButton();"> Buy expensive items when you can<br>
<input type="radio" name="spend" value="buyLow" onclick="lootBoxesNeeded=[];hideContinueButton();"> Buy cheap items when you can<br>
<input type="radio" name="spend" value="buyNone" onclick="lootBoxesNeeded=[];hideContinueButton();"> Don't buy anything <br>
<br>
</p>
</div>
</div>
<div id="lootBoxOutputModal" class="modal">
<div class="modal-content">
<span class="close" id="lboclose">×</span>
<div id='simResults'>
The results are in! On average, it took <b><span id='boxesNeededAvg'>0</span> boxes</b> to get the items you wanted.
This is an average, and the actual amount it will take depends on RNGesus!
90 percent of simulations took <b><span id='boxesNeededRange'>0</span> boxes</b> to finish
(with a median of <b><span id='boxesNeededMed'>0</span></b>). The simulation ran for <b><span id='nIterationsOut'>0</span> iterations</b>
and took <b><span id='timeTaken'>0</span> Seconds</b>! <span id='postSimComment' style='color: red;'></span><br>
<br>
<br>
</div>
<div id="myDiv"></div>
<br>
<button onclick="startSimulating(1)" id='continueSimulation'>Continue simulation</button>
</div>
</div>
<script src="item_output.js"></script>
<script>
//table display and selection functions!
var n_items=itemarr.length;
function toggleHelp() {
var x = document.getElementById('helpDiv');
if (x.style.display === 'none') {
x.style.display = 'block';
} else {
x.style.display = 'none';
}
}
function toggleFilters() {
var x = document.getElementById('filters');
if (x.style.display === 'none') {
x.style.display = 'block';
document.getElementById('options').style.display = 'none';
document.getElementById('spendingHabits').style.display = 'none';
} else {
x.style.display = 'none';
}
}
function toggleOptions() {
var x = document.getElementById('options');
if (x.style.display === 'none') {
x.style.display = 'block';
document.getElementById('filters').style.display = 'none';
document.getElementById('spendingHabits').style.display = 'none';
} else {
x.style.display = 'none';
}
}
function toggleSpendingHabits(){
var x = document.getElementById('spendingHabits');
if (x.style.display === 'none') {
x.style.display = 'block';
document.getElementById('filters').style.display = 'none';
document.getElementById('options').style.display = 'none';
} else {
x.style.display = 'none';
}
}
//stuff for checkboxes
//keeps same as checked and disables button
function toggleCheck(checkId,thisId) {
document.getElementById(checkId).checked = document.getElementById(thisId).checked;
document.getElementById(checkId).disabled = document.getElementById(thisId).checked;
}
//keeps same as checked and does not disable button
function checkMatch(checkId,thisId) {
document.getElementById(checkId).checked = document.getElementById(thisId).checked;
}
//update the "ck" value for some item
function addCheckItemArr(num,code){
if (document.getElementById('h'+num).checked==1){
itemarr[num].ck=1;
return
}
if (document.getElementById('w'+num).checked==1){
itemarr[num].ck=2;
return
}
itemarr[num].ck=0;
return
}
//convert a number code to a rarity string.
function numToRarity(num) {
if (num == 0){return '-';}
var rarities=['common','rare','epic','legendary'];
return rarities[num-1];
}
//convert a number code to a type string.
function numToType(num) {
var types=['unknown','icons','sprays','skins','emotes','intros','voicelines','poses'];
return types[num];
}
//convert a number code to an event string.
function numToEvent(num) {
var events=['-','Halloween-16','Summer-16','Uprising-17','Winter-16','Rooster-17'];
return events[num]
}
//convert a number code to a hero string.
function numToHero(num) {
var heroes=['error','ana','bastion','dva','genji',
'hanzo','junkrat','lucio','mccree',
'mei','mercy','orisa','pharah','reaper',
'reinhardt','roadhog','soldier-76','sombra',
'symmetra','torbjorn','tracer','widowmaker',
'winston','zarya','zenyatta','all'];
return heroes[num];
}
//convert a number code to a "special" string.
//num1 = achivement (1 achievement, 2 blizzcon)
//num2 = is true if default item false if not
function numToSpecial(num1,num2) {
if (num1 == 1) {
return 'Achievement';
}
if (num1 == 2) {
return 'Blizzcon';
}
if (num2 == 1) {
return 'Default';
}
return '-';
}
//outputs a checkbox string... this code is awful.
//inputs are default, achievement, itemNumber, event, have (1=have,0=want)
function outputCheckBox(def,ach,num,eve,hav) {
var outstr='<input type="checkbox"';
//its a default item
if (def) {
if (hav) {
outstr+=' id="h'+num+'"';
} else {
outstr+=' id="w'+num+'"';
}
outstr+=' disabled="true" checked>';
return outstr;
}
//its from an achievement
if (ach) {
if (hav) {
outstr+=' id="h'+num+'"';
outstr+=' onclick="checkMatch(\'w'+num+'\',\'h'+num+'\');makeUrl()"';
if (itemarr[num].ck == 1) {
outstr+=' checked>';
} else {
outstr+='>';
}
} else {
outstr+=' id="w'+num+'"';
outstr+=' disabled="true"';
if (itemarr[num].ck == 1) {
outstr+=' checked>';
} else {
outstr+='>';
}
}
return outstr;
}
//normal item
if (eve == 0 || eve == 3) {
if (hav) {
outstr+=' id="h'+num+'"';
outstr+=' onclick="toggleCheck(\'w'+num+'\',\'h'+num+'\');addCheckItemArr('+num+',1);makeUrl();updateDesired();lootBoxesNeeded=[];hideContinueButton();"';
if (itemarr[num].ck == 1) {
outstr+=' checked>';
} else {
outstr+='>';
}
} else {
outstr+=' id="w'+num+'" onclick="addCheckItemArr('+num+',2);makeUrl();updateDesired();lootBoxesNeeded=[];hideContinueButton();"';
if (itemarr[num].ck == 1) {
outstr+=' disabled="true" checked>';
} else {
if ( itemarr[num].ck == 2){
outstr+=' checked>';
} else {
outstr+='>';
}
}
}
return outstr;
}
//other events
if (hav) {
outstr+=' id="h'+num+'"';
outstr+=' onclick="checkMatch(\'w'+num+'\',\'h'+num+'\');makeUrl();updateDesired();"';
if (itemarr[num].ck == 1) {
outstr+=' checked>';
} else {
outstr+='>';
}
} else {
outstr+=' id="w'+num+'"';
outstr+=' disabled="true"';
if (itemarr[num].ck == 1 || itemarr[num].ck == 2) {
outstr+=' checked>';
} else {
outstr+='>';
}
}
return outstr;
}
//output a row in the table.
function makeRow(itemNumber) {
var outputstr='';
console.log('making row for '+itemNumber)
outputstr+="<td>"+outputCheckBox(itemarr[itemNumber].de,itemarr[itemNumber].ac,
itemNumber,itemarr[itemNumber].ev,true)+"</td>";
outputstr+="<td>"+outputCheckBox(itemarr[itemNumber].de,itemarr[itemNumber].ac,
itemNumber,itemarr[itemNumber].ev,false)+"</td>";
outputstr+="<td>"+numToType(itemarr[itemNumber].ty)+"</td>";
outputstr+="<td class='"+numToRarity(itemarr[itemNumber].ra)+"'>"+itemarr[itemNumber].na+"</td>";
outputstr+="<td>"+numToRarity(itemarr[itemNumber].ra)+"</td>";
outputstr+="<td>"+numToEvent(itemarr[itemNumber].ev)+"</td>";
outputstr+="<td>"+numToSpecial(itemarr[itemNumber].ac,itemarr[itemNumber].de)+"</td>";
outputstr+="<td>"+itemarr[itemNumber].co+"</td>";
outputstr+="<td>"+numToHero(itemarr[itemNumber].he)+"</td>";
return outputstr;
}
//output the hero ID that is selected w/ radio button.
function heroSelected() {
return document.getElementById('herodisplay').value;
}
//return true if item should be shown based on its type
function showItemType(i) {
var typestr=numToType(itemarr[i].ty);
if (typestr == 'icons' && document.getElementById('showIcons').checked == true) {
return true;
}
if (typestr == 'sprays' && document.getElementById('showSprays').checked == true) {
return true;
}
if (typestr == 'skins' && document.getElementById('showSkins').checked == true) {
return true;
}
if (typestr == 'emotes' && document.getElementById('showEmotes').checked == true) {
return true;
}
if (typestr == 'intros' && document.getElementById('showIntros').checked == true) {
return true;
}
if (typestr == 'voicelines' && document.getElementById('showVoices').checked == true) {
return true;
}
if (typestr == 'poses' && document.getElementById('showPoses').checked == true) {
return true;
}
return false;
}
//return true if item should be shown based on its event
function showEvent(i) {
var eventstr=numToEvent(itemarr[i].ev);
if (eventstr == 'Uprising-17' && document.getElementById('showUprising').checked == true) {
return true;
}
if (eventstr != '-' && eventstr != 'Uprising-17' && document.getElementById('showEvents').checked == true) {
return true;
}
if (eventstr == '-' && document.getElementById('showNonEvent').checked == true) {
return true;
}
return false;
}
//return true if item should be shown based on its achievement or blizcon or default
function showSpecial(i) {
var specialstr=numToSpecial(itemarr[i].ac,itemarr[i].de);
if (specialstr == 'Blizzcon' && document.getElementById('showBlizzcon').checked == true) {
return true;
}
if (specialstr == 'Achievement' && document.getElementById('showAchievement').checked == true) {
return true;
}
if (specialstr == 'Default' && document.getElementById('showDefaultItems').checked == true) {
return true;
}
if (specialstr == '-' && document.getElementById('showNormals').checked == true) {
return true;
}
return false;
}
//return true if item should be shown based on its achievement or blizcon or default
function showRarity(i) {
var specialstr=numToRarity(itemarr[i].ra);
if (specialstr == 'legendary' && document.getElementById('showLegs').checked == true) {
return true;
}
if (specialstr == 'epic' && document.getElementById('showEpics').checked == true) {
return true;
}
if (specialstr == 'rare' && document.getElementById('showRares').checked == true) {
return true;
}
if (specialstr == 'common' && document.getElementById('showCommons').checked == true) {
return true;
}
return false;
}
function updateCheckboxes(code) {
var displayHeroId=heroSelected();
for (i=0;i<itemarr.length;i++) {
if (code == 'clearPageWant'){
if (displayHeroId == itemarr[i].he || displayHeroId == 26){
if (itemarr[i].ck==2 && showItemType(i) && showEvent(i) && showSpecial(i) && showRarity(i)){itemarr[i].ck=0;}
document.getElementById( "wantLink" ).setAttribute( "onClick", "javascript: updateCheckboxes('checkPageWant');lootBoxesNeeded=[];hideContinueButton();" );
}
}
if (code == 'clearPageHave'){
if (displayHeroId == itemarr[i].he || displayHeroId == 26){
if (itemarr[i].ck==1 && showItemType(i) && showEvent(i) && showSpecial(i) && showRarity(i)){itemarr[i].ck=0;}
}
}
if (code == 'checkPageWant'){
if (displayHeroId == itemarr[i].he || displayHeroId == 26){
if (showItemType(i) && showEvent(i) && showSpecial(i) && showRarity(i)){itemarr[i].ck=2;}
}
document.getElementById( "wantLink" ).setAttribute( "onClick", "javascript: updateCheckboxes('clearPageWant');lootBoxesNeeded=[];hideContinueButton();" );
}
if (code == 'checkPageHave'){
if (displayHeroId == itemarr[i].he || displayHeroId == 26){
if (showItemType(i) && showEvent(i) && showSpecial(i) && showRarity(i)){itemarr[i].ck=1;}
}
}
if (code == 'clearAllWant'){
itemarr[i].ck=1;
}
if (code == 'clearAllHave'){
}
if (code == 'checkAllWant'){
}
if (code == 'checkAllHave'){
}
}
updateTable();
updateDesired();
}
//update the table rows.
function updateTable() {
var outputstr='';
var i=0;
var displayHeroId=heroSelected();
console.log('hero selected id is '+displayHeroId);
for (i=0;i<itemarr.length;i++) {
if (displayHeroId == itemarr[i].he || displayHeroId == 26) {
if (showItemType(i) && showEvent(i) && showSpecial(i) && showRarity(i)){
outputstr+='<tr>'+makeRow(i) +'</tr>';
}
}
}
document.getElementById("tableBody").innerHTML =outputstr;
}
//update item counters
function updateDesired() {
var wantArr=calcWantArr();
var counter=0;
var i=0;
document.getElementById("goldNeeded").innerHTML =calcCost(wantArr);
for (i=0;i<wantArr.length;i++) {
if (numToRarity(itemarr[wantArr[i]].ra) == 'common') {counter++;}
}
document.getElementById("wantedCommons").innerHTML=counter;
counter=0
for (i=0;i<wantArr.length;i++) {
if (numToRarity(itemarr[wantArr[i]].ra) == 'rare') {counter++;}
}
document.getElementById("wantedRares").innerHTML=counter;
counter=0
for (i=0;i<wantArr.length;i++) {
if (numToRarity(itemarr[wantArr[i]].ra) == 'epic') {counter++;}
}
document.getElementById("wantedEpics").innerHTML=counter;
counter=0
for (i=0;i<wantArr.length;i++) {
if (numToRarity(itemarr[wantArr[i]].ra) == 'legendary') {counter++;}
}
document.getElementById("wantedLegs").innerHTML=counter;
counter=0
for (i=0;i<wantArr.length;i++) {
if (itemarr[wantArr[i]].co == 0) {counter++;}
}
document.getElementById("wantedIcons").innerHTML=counter;
}
</script>
<script>
//simulation functions!
var wantArrGlobal=[];
var wantCostArrGlobal=[];
//return random integer including entpoints
function intBetween(bot,top){
return Math.floor(Math.random() * (top - bot + 1) + bot);
}
/*
var probabilities={'common':5866,'rare':2741,'epic':467,'leg':189,
'rare-currency':428,'epic-currency':255,'leg-currency':54,
'p-event':0.3};
*/
/*
//probabilities of getting each item in percent*100
var probAdj={'common':5866,'rare':2741,'epic':467,'leg':189,
'rare-currency':428,'epic-currency':255,'leg-currency':54,
'p-event':0.3};
//adjust probability so that it just increases.
probAdj['rare']=probAdj['rare']+probAdj['common'];
probAdj['epic']=probAdj['epic']+probAdj['rare'];
probAdj['leg']=probAdj['leg']+probAdj['epic'];
probAdj['rare-currency']=probAdj['rare-currency']+probAdj['leg'];
probAdj['epic-currency']=probAdj['epic-currency']+probAdj['rare-currency'];
probAdj['leg-currency']=probAdj['leg-currency']+probAdj['epic-currency'];
*/
//probabilities of getting each item in percent*1000
//common is 0 because it gets adjusted to "fill in"
var probChina={'common':0,'rare':31690,'epic':4545,'leg':1852,
'rare-currency':Math.floor(31690/rarebox.length),'epic-currency':Math.floor(4545/epicbox.length),'leg-currency':Math.floor(1852/legbox.length),
'p-event':0.3};
probChina['leg'] = probChina['leg']-probChina['leg-currency'];
probChina['epic'] = probChina['epic']-probChina['epic-currency'];
probChina['common'] = 100000 - (probChina['leg'] + probChina['epic'] + probChina['rare']
+ probChina['rare-currency'] + probChina['epic-currency'] + probChina['leg-currency']);
console.log('pchina'+probChina['rare-currency']);
console.log('pchina'+probChina['epic-currency']);
console.log('pchina'+probChina['leg-currency']);
console.log('pchina'+probChina['leg']);
console.log('pchina'+probChina['epic']);
console.log('pchina'+probChina['rare']);
console.log('pchina'+probChina['common']);
console.log(legbox.length);
var probAdj=probChina;
//adjust probability so that it just increases.
probAdj['rare']=probAdj['rare']+probAdj['common'];
probAdj['epic']=probAdj['epic']+probAdj['rare'];
probAdj['leg']=probAdj['leg']+probAdj['epic'];
probAdj['rare-currency']=probAdj['rare-currency']+probAdj['leg'];
probAdj['epic-currency']=probAdj['epic-currency']+probAdj['rare-currency'];
probAdj['leg-currency']=probAdj['leg-currency']+probAdj['epic-currency'];
//get new item's rarity
function getNewItemRarity(){
var rand = intBetween(1,probAdj['epic-currency']);
var items=['common','rare','epic','leg','rare-currency','epic-currency','leg-currency'];
for (var i=0; i<items.length;i++){
if (rand < probAdj[items[i]]){
return items[i];
}
}
return 'err';
}
//based on the rarity, get a new item's index
function getNewItemNumber(rarity){
if (rarity == 'common') {
return commonbox[intBetween(0,commonbox.length-1)]
}
if (rarity == 'rare') {
return rarebox[intBetween(0,rarebox.length-1)]
}
if (rarity == 'epic') {
return epicbox[intBetween(0,epicbox.length-1)]
}
if (rarity == 'leg') {
return legbox[intBetween(0,legbox.length-1)]
}
}
//figure out what items the user wants.
function calcWantArr() {
var outarr=[];
for (var i=0;i<itemarr.length;i++){
if (itemarr[i].ck == 2 ) {
outarr.push(i);
}
}
return outarr;
}
//figure out cost of items the user wants.
function calcCostArr() {
var outarr=[];
for (var i=0;i<itemarr.length;i++){
if (itemarr[i].ck == 2 ) {
outarr.push(itemarr[i].co);
}
}
return outarr;
}
//figure out what items the user has.
function calcHaveArr() {
var outarr=[];
for (var i=0;i<itemarr.length;i++){
if (itemarr[i].ck == 1 ) {
outarr.push(i);
}
}
return outarr;
}
//figure out what items the user wants costs
function calcCost(wantArr){
var cost=0;
for (var i=0;i<wantArr.length;i++){
cost += itemarr[wantArr[i]].co; //icons are set to 0
}
return cost;
}
function buyStuff(gold,spendingStr) {
if (spendingStr == 'optimal' || spendingStr == 'buyNone') {return gold;}
if (spendingStr == 'buyLow') {
//icons are listed as 0 cost
//http://stackoverflow.com/questions/10557176/minimum-number-excluding-zero
var minCost=Math.min.apply(null, wantCostArrGlobal.filter(Boolean)); //infinity if all 0's (https://jsfiddle.net/gpLk9ntc/)
if (isFinite(minCost) && gold >= minCost) {
wantArrGlobal.splice(wantCostArrGlobal.indexOf(minCost),1);
wantCostArrGlobal.splice(wantCostArrGlobal.indexOf(minCost),1);
gold=gold-minCost;
}
}
if (spendingStr == 'buyHigh') {
var maxCost=Math.max.apply(Math,wantCostArrGlobal);
if (gold >= maxCost && maxCost > 0) {
wantArrGlobal.splice(wantCostArrGlobal.indexOf(maxCost),1);
wantCostArrGlobal.splice(wantCostArrGlobal.indexOf(maxCost),1);
gold=gold-maxCost;
}
}
return gold;
}
//check if the simulation should be over
function simulationOver(haveArr,gold,spendingStr) {
var i=0;
//check if you have all the items you want
if (wantArrGlobal.includes(haveArr[haveArr.length-1])){
wantCostArrGlobal.splice(wantArrGlobal.indexOf(haveArr[haveArr.length-1]),1);
wantArrGlobal.splice(wantArrGlobal.indexOf(haveArr[haveArr.length-1]),1);
}
if (wantArrGlobal.length == 0) {return true;}
//check if there is an icon that you do not have
for (i=0;i<wantArrGlobal.length;i++) { //cost is 0 for icons
if (itemarr[wantArrGlobal[i]].co == 0) {
return false;
}
}
//check if gold can buy the remaining items
if (spendingStr != 'buyNone' && gold >= calcCost(wantArrGlobal)) {
//console.log('got gold '+gold+' dfsdf '+calcCost(wantArrGlobal));
return true;
}