-
Notifications
You must be signed in to change notification settings - Fork 5
/
HydraCalculator2.html
1547 lines (1479 loc) · 54.7 KB
/
HydraCalculator2.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>
<html lang="en">
<head>
<title>Hero Wars Hydra Calculator</title>
<meta charset="utf-8" />
<meta name="author" content="HumanExhaust" />
<meta name="description" content="Hydra Calculator for Hero Wars" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous" />
<link rel="stylesheet" href=" https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" />
<style>
table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 100%;
}
td,
th {
border: 1px solid #dddddd;
text-align: center;
font-weight: bold;
padding: 8px;
}
th {
background-color: white;
}
img {
border: 1px solid #ddd;
border-radius: 4px;
padding: 5px;
width: 100px;
margin-right: auto;
margin-left: auto;
}
button {
font-weight: bold;
}
input {
border-radius: 0 !important;
text-align: center;
}
.red {
background-color: red;
color: white;
font-weight: bold;
}
.green {
background-color: green;
color: white;
font-weight: bold;
}
.attack1 {
background-color: #ffdaf9 !important;
}
.attack2 {
background-color: #ff74e9 !important;
}
.hydra-darkness {
background-color: #638fa8;
color: black;
font-weight: bold;
}
.hydra-water {
background-color: #29feff;
color: black;
font-weight: bold;
}
.hydra-earth {
background-color: #afd64a;
color: black;
font-weight: bold;
}
.hydra-light {
background-color: #fffb90;
color: black;
font-weight: bold;
}
.hydra-wind {
background-color: #9984cc;
color: black;
font-weight: bold;
}
.hydra-fire {
background-color: #ffd250;
color: black;
font-weight: bold;
}
.hydra-common-toggle.active {
border-width: thick;
font-weight: bold;
font-size: 1.4em;
}
.hydra-common-toggle {
background-color: #638fa8;
border-color: #add5e0;
text-align: center;
vertical-align: middle;
color: white;
font-size: 1em;
}
.hydra-elder-toggle.active {
border-width: thick;
font-weight: bold;
font-size: 1.4em;
}
.hydra-elder-toggle {
background-color: #0f4002;
border-color: #9dec8d;
text-align: center;
vertical-align: middle;
color: white;
font-size: 1em;
}
.hydra-ancient-toggle.active {
border-width: thick;
font-weight: bold;
font-size: 1.4em;
}
.hydra-ancient-toggle {
background-color: #002c86;
border-color: #d3dfff;
text-align: center;
vertical-align: middle;
color: white;
font-size: 1em;
}
.hydra-dreadful-toggle.active {
border-width: thick;
font-weight: bold;
font-size: 1.4em;
}
.hydra-dreadful-toggle {
background-color: #5f0173;
border-color: #e9caf5;
text-align: center;
vertical-align: middle;
color: white;
font-size: 1em;
}
.hydra-legendary-toggle.active {
border-width: thick;
font-weight: bold;
font-size: 1.4em;
}
.hydra-legendary-toggle {
background-color: #603c00;
border-color: #ffec5f;
text-align: center;
vertical-align: middle;
color: white;
font-size: 1em;
}
.common-attack1 {
background-color: #638fa8 !important;
color: white;
}
.common-attack2 {
background-color: #add5e0 !important;
}
.elder-attack1 {
background-color: #0f4002 !important;
color: white;
}
.elder-attack2 {
background-color: #9dec8d !important;
}
.ancient-attack1 {
background-color: #002c86 !important;
color: white;
}
.ancient-attack2 {
background-color: #d3dfff !important;
}
.dreadful-attack1 {
background-color: #5f0173 !important;
color: white;
}
.dreadful-attack2 {
background-color: #e9caf5 !important;
}
.legendary-attack1 {
background-color: #603c00 !important;
color: white;
}
.legendary-attack2 {
background-color: #ffec5f !important;
}
/*range slider*/
.range-wrap {
position: relative;
margin: 0 auto 3rem;
}
input[type="range"] {
-webkit-appearance: none;
margin: 20px 0;
width: 100%;
}
input[type="range"]:focus {
outline: none;
}
input[type="range"]::-webkit-slider-runnable-track {
width: 100%;
height: 4px;
cursor: pointer;
animate: 0.2s;
background: #060607;
border-radius: 25px;
}
input[type="range"]::-webkit-slider-thumb {
height: 20px;
width: 20px;
border-radius: 50%;
background: #fff;
box-shadow: 0 0 4px 0 rgba(0, 0, 0, 1);
cursor: pointer;
-webkit-appearance: none;
margin-top: -8px;
}
input[type="range"]:focus::-webkit-slider-runnable-track {
background: #000000;
}
.range-wrap {
position: relative;
}
.range-value {
position: absolute;
top: -50%;
}
.range-value span {
min-width: 30px;
height: 24px;
line-height: 24px;
text-align: center;
background: #03a9f4;
color: #fff;
font-size: 12px;
display: block;
position: absolute;
left: 50%;
transform: translate(-50%, 0);
border-radius: 6px;
padding: 0 5px 0 5px;
}
.range-value span:before {
content: "";
position: absolute;
width: 0;
height: 0;
border-top: 10px solid #03a9f4;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
top: 100%;
left: 50%;
margin-left: -5px;
margin-top: -1px;
}
</style>
</head>
<body>
<div class="jumbotron text-center">
<h1>Hero Wars Hydra Calculator</h1>
<p>This takes data from users and calculates the best outcome with the given input.</p>
<p>Be sure to select the correct hydra as you are entering data.</p>
<button class="navbar-toggler toggler-example" type="button" data-toggle="modal" data-target="#myModal" aria-controls="myModal">
<span class="dark-blue-text"><i class="fas fa-bars fa-1x"></i></span>
</button>
<br />
<br />
<div class="radio">
<div class="btn-group btn-group-toggle" data-toggle="buttons">
<label class="btn hydra-common-toggle active"> <input type="radio" name="hydra-toggle" id="common-toggle" value="common" autocomplete="off" onchange="displayPlayers();" checked /> Common Hydra </label>
<label class="btn hydra-elder-toggle"> <input type="radio" name="hydra-toggle" id="elder-toggle" value="elder" autocomplete="off" onchange="displayPlayers();" /> Elder Hydra </label>
<label class="btn hydra-ancient-toggle"> <input type="radio" name="hydra-toggle" id="ancient-toggle" value="ancient" autocomplete="off" onchange="displayPlayers();" /> Ancient Hydra </label>
<label class="btn hydra-dreadful-toggle"> <input type="radio" name="hydra-toggle" id="dreadful-toggle" value="dreadful" autocomplete="off" onchange="displayPlayers();" /> Dreadful Hydra </label>
<label class="btn hydra-legendary-toggle"> <input type="radio" name="hydra-toggle" id="legendary-toggle" value="legendary" autocomplete="off" onchange="displayPlayers();" /> Legendary Hydra </label>
</div>
</div>
<table id="allPlayers">
<thead>
<tr>
<th class="p-0">Player</th>
<th class="p-0">Attacks + Golden Horns</th>
<th class="p-0 hydra-darkness">
Maximum <br />
Darkness Damage
</th>
<th class="p-0 hydra-water">
Maximum <br />
Water Damage
</th>
<th class="p-0 hydra-earth">
Maximum <br />
Earth Damage
</th>
<th class="p-0 hydra-light">
Maximum <br />
Light Damage
</th>
<th class="p-0 hydra-wind">
Maximum <br />
Wind Damage
</th>
<th class="p-0 hydra-fire">
Maximum <br />
Fire Damage
</th>
<th class="p-0">Controls</th>
</tr>
</thead>
<tbody></tbody>
</table>
<div class="input-group mb-3">
<input type="text" class="form-control" id="player[name]" name="player[name]" placeholder="Add Player" aria-label="Add Player" aria-describedby="basic-addon2" onkeydown="setPlayer()"/>
<div class="input-group-append">
<button class="btn btn-outline-secondary" type="button" onclick="setPlayer();"><i class="fas fa-user-plus"></i></button>
</div>
</div>
</div>
<div class="container">
<p><strong>Current head damage</strong></p>
<p>These sliding controls are to "pre-set" the heads damage in the event a player has already attacked.</p>
<p>Set these to the correct current damage per head and make sure to remove the players that have already attacked above before calculating.</p>
<div class="row">
<div class="col-lg-1 text-right text-middle">
<label for="range-darkness">Darkness</label>
</div>
<div class="col-lg-11">
<div class="range-wrap">
<div class="range-value" id="rangeV-darkness"></div>
<input id="range-darkness" type="range" min="0" step="1" />
</div>
</div>
</div>
<div class="row">
<div class="col-lg-1 text-right text-middle">
<label for="range-water">Water</label>
</div>
<div class="col-lg-11">
<div class="range-wrap">
<div class="range-value" id="rangeV-water"></div>
<input id="range-water" type="range" min="0" step="1" />
</div>
</div>
</div>
<div class="row">
<div class="col-lg-1 text-right text-middle">
<label for="range-earth">Earth</label>
</div>
<div class="col-lg-11">
<div class="range-wrap">
<div class="range-value" id="rangeV-earth"></div>
<input id="range-earth" type="range" min="0" step="1" />
</div>
</div>
</div>
<div class="row">
<div class="col-lg-1 text-right text-middle">
<label for="range-light">Light</label>
</div>
<div class="col-lg-11">
<div class="range-wrap">
<div class="range-value" id="rangeV-light"></div>
<input id="range-light" type="range" min="0" step="1" />
</div>
</div>
</div>
<div class="row">
<div class="col-lg-1 text-right text-middle">
<label for="range-wind">Wind</label>
</div>
<div class="col-lg-11">
<div class="range-wrap">
<div class="range-value" id="rangeV-wind"></div>
<input id="range-wind" type="range" min="0" step="1" />
</div>
</div>
</div>
<div class="row">
<div class="col-lg-1 text-right text-middle">
<label for="range-fire">Fire</label>
</div>
<div class="col-lg-11">
<div class="range-wrap">
<div class="range-value" id="rangeV-fire"></div>
<input id="range-fire" type="range" min="0" max="1000000" value="200" step="1" />
</div>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-sm-12 text-center">
<p>Once you have your maximum scores set for each player let's see what the attack prediction is.</p>
<button type="button" class="btn btn-default" onclick="getBestTest();">Calculate Attacks</button>
</div>
</div>
</div>
<div id="warResults" class="container-fluid" style="display: none;">
<div class="row">
<div class="col-sm-4">
<h2>Player Assigned Targets</h2>
<table id="assignedPlayers">
<thead>
<tr>
<th>Player</th>
<th>Attack</th>
<th>Hydra Target</th>
<th>Expected Damage</th>
<th>Hydra's Expected Damage</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
<div class="col-sm-4">
<h2>Left over attacks for cleanup</h2>
<table id="leftOverAttacks">
<thead>
<tr>
<th>Player</th>
<th>Attacks Left</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
<div class="col-sm-4">
<h2>Hydra Damage Stats</h2>
<table>
<thead>
<tr>
<th style="width: 25%;">Hydra</th>
<th>Projected Damage</th>
</tr>
</thead>
<tbody>
<tr>
<td id="darkness-head">
<div class="head_image">
<div><img src="https://cdn2.omg.rocks/content/herowars/hydra/darkness.png" alt="Darkness" /></div>
</div>
</td>
<td>
<div class="progress">
<div id="darknessProgress" class="progress-bar progress-bar-striped bg-success" role="progressbar" style="width: 0%;" aria-valuenow="0" aria-valuemin="0" aria-valuemax="0">0</div>
<div id="darknessProgressDamage" class="progress-bar progress-bar-striped bg-danger" role="progressbar" style="width: 100%;" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100">0</div>
<div id="darknessProgressHealth" class="progress-bar progress-bar-striped bg-dark" role="progressbar" style="width: 100%;" aria-valuenow="0" aria-valuemin="0" aria-valuemax="0">0</div>
</div>
</td>
</tr>
<tr>
<td id="water-head">
<div class="head_image">
<div><img src="https://cdn2.omg.rocks/content/herowars/hydra/water.png" alt="Water" /></div>
</div>
</td>
<td>
<div class="progress">
<div id="waterProgress" class="progress-bar progress-bar-striped bg-success" role="progressbar" style="width: 0%;" aria-valuenow="0" aria-valuemin="0" aria-valuemax="0">0</div>
<div id="waterProgressDamage" class="progress-bar progress-bar-striped bg-danger" role="progressbar" style="width: 100%;" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100">0</div>
<div id="waterProgressHealth" class="progress-bar progress-bar-striped bg-dark" role="progressbar" style="width: 100%;" aria-valuenow="0" aria-valuemin="0" aria-valuemax="0">0</div>
</div>
</td>
</tr>
<tr>
<td id="earth-head">
<div class="head_image">
<div><img src="https://cdn2.omg.rocks/content/herowars/hydra/earth.png" alt="Earth" /></div>
</div>
</td>
<td>
<div class="progress">
<div id="earthProgress" class="progress-bar progress-bar-striped bg-success" role="progressbar" style="width: 0%;" aria-valuenow="0" aria-valuemin="0" aria-valuemax="0">0</div>
<div id="earthProgressDamage" class="progress-bar progress-bar-striped bg-danger" role="progressbar" style="width: 100%;" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100">0</div>
<div id="earthProgressHealth" class="progress-bar progress-bar-striped bg-dark" role="progressbar" style="width: 100%;" aria-valuenow="0" aria-valuemin="0" aria-valuemax="0">0</div>
</div>
</td>
</tr>
<tr>
<td id="light-head">
<div class="head_image">
<div><img src="https://cdn2.omg.rocks/content/herowars/hydra/light.png" alt="Light" /></div>
</div>
</td>
<td>
<div class="progress">
<div id="lightProgress" class="progress-bar progress-bar-striped bg-success" role="progressbar" style="width: 0%;" aria-valuenow="0" aria-valuemin="0" aria-valuemax="0">0</div>
<div id="lightProgressDamage" class="progress-bar progress-bar-striped bg-danger" role="progressbar" style="width: 100%;" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100">0</div>
<div id="lightProgressHealth" class="progress-bar progress-bar-striped bg-dark" role="progressbar" style="width: 100%;" aria-valuenow="0" aria-valuemin="0" aria-valuemax="0">0</div>
</div>
</td>
</tr>
<tr>
<td id="wind-head">
<div class="head_image">
<div><img src="https://cdn2.omg.rocks/content/herowars/hydra/wind.png" alt="Wind" /></div>
</div>
</td>
<td>
<div class="progress">
<div id="windProgress" class="progress-bar progress-bar-striped bg-success" role="progressbar" style="width: 0%;" aria-valuenow="0" aria-valuemin="0" aria-valuemax="0">0</div>
<div id="windProgressDamage" class="progress-bar progress-bar-striped bg-danger" role="progressbar" style="width: 100%;" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100">0</div>
<div id="windProgressHealth" class="progress-bar progress-bar-striped bg-dark" role="progressbar" style="width: 100%;" aria-valuenow="0" aria-valuemin="0" aria-valuemax="0">0</div>
</div>
</td>
</tr>
<tr>
<td id="fire-head">
<div class="head_image">
<div><img src="https://cdn2.omg.rocks/content/herowars/hydra/fire.png" alt="Fire" /></div>
</div>
</td>
<td>
<div class="progress">
<div id="fireProgress" class="progress-bar progress-bar-striped bg-success" role="progressbar" style="width: 0%;" aria-valuenow="0" aria-valuemin="0" aria-valuemax="0">0</div>
<div id="fireProgressDamage" class="progress-bar progress-bar-striped bg-danger" role="progressbar" style="width: 100%;" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100">0</div>
<div id="fireProgressHealth" class="progress-bar progress-bar-striped bg-dark" role="progressbar" style="width: 100%;" aria-valuenow="0" aria-valuemin="0" aria-valuemax="0">0</div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<!-- Footer -->
<footer class="text-center text-lg-start bg-light text-muted mt-5">
<div class="text-center p-3" style="background-color: rgba(0, 0, 0, 0.2);">
DISCLAIMER: I know that each attack is different depending on the Hero lineups. This calculator has some buffer allowance for this and should be used as a guide and not an absolutely accurate tool. <br />
Original Author: HumanExhaust @ <a href="https://discord.com/channels/@me" target="_blank">Discord: humanexhaust#4630</a>
</div>
</footer>
<!-- Modal -->
<div class="modal" id="myModal">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">Settings</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<!-- Modal body -->
<div class="modal-body">
<div>
<h4>Update Hydra Total Scores</h4>
<p>
Here you can adjust each Hydra's total score. I have noticed that it can change from time to time when Nexters decide that a certain hero is too powerful for the Hydra. If the game is updated, you can modify
the values here.
</p>
<p>
The Hydra Attack Buffer is here to give you control of how the algorithms choose which player to assign a hydra at the end of its total power. If a hydra head is 1,000 points from being destroyed this value
prevents someone that does a lot of damage being used. Let us say the players attack would be 2,000,000 and the buffer is set to 1,000,000. This player would not be applied and another player that would do
5,000 damage would be chosen. You can play with these numbers for each hydra until you get results you like.
</p>
<table>
<thead>
<tr>
<th style="width: 25%;">Hydra</th>
<th>Total Strength</th>
<th>Hydra Attack Buffer</th>
</tr>
</thead>
<tbody>
<tr>
<td class="p-0">Common Hydra</td>
<td class="p-0">
<input onchange="updateHydra();" class="form-control p-0" type="number" min="0" id="hydra[common]" name="hydra[common]" value="0" placeholder="0" />
</td>
<td class="p-0">
<input onchange="updateHydra();" class="form-control p-0" type="number" min="0" id="hydraBuffer[common]" name="hydraBuffer[common]" value="0" placeholder="0" />
</td>
</tr>
<tr>
<td class="p-0">Elder Hydra</td>
<td class="p-0">
<input onchange="updateHydra();" class="form-control p-0" type="number" min="0" id="hydra[elder]" name="hydra[elder]" value="0" placeholder="0" />
</td>
<td class="p-0">
<input onchange="updateHydra();" class="form-control p-0" type="number" min="0" id="hydraBuffer[elder]" name="hydraBuffer[elder]" value="0" placeholder="0" />
</td>
</tr>
<tr>
<td class="p-0">Ancient Hydra</td>
<td class="p-0">
<input onchange="updateHydra();" class="form-control p-0" type="number" min="0" id="hydra[ancient]" name="hydra[ancient]" value="0" placeholder="0" />
</td>
<td class="p-0">
<input onchange="updateHydra();" class="form-control p-0" type="number" min="0" id="hydraBuffer[ancient]" name="hydraBuffer[ancient]" value="0" placeholder="0" />
</td>
</tr>
<tr>
<td class="p-0">Dreadful Hydra</td>
<td class="p-0">
<input onchange="updateHydra();" class="form-control p-0" type="number" min="0" id="hydra[dreadful]" name="hydra[dreadful]" value="0" placeholder="0" />
</td>
<td class="p-0">
<input onchange="updateHydra();" class="form-control p-0" type="number" min="0" id="hydraBuffer[dreadful]" name="hydraBuffer[dreadful]" value="0" placeholder="0" />
</td>
</tr>
<tr>
<td class="p-0">Legendary Hydra</td>
<td class="p-0">
<input onchange="updateHydra();" class="form-control p-0" type="number" min="0" id="hydra[legendary]" name="hydra[legendary]" value="0" placeholder="0" />
</td>
<td class="p-0">
<input onchange="updateHydra();" class="form-control p-0" type="number" min="0" id="hydraBuffer[legendary]" name="hydraBuffer[legendary]" value="0" placeholder="0" />
</td>
</tr>
</tbody>
</table>
<hr />
<h4>User Preferences</h4>
<hr />
<p><strong>Number Display</strong></p>
<p>This setting determines number output format. The numbers for each input must remain unformatted due to the nature of form controls.</p>
<div class="form-check">
<input class="form-check-input" type="radio" name="numberFormat" value="full" id="fullNumberFormat" onchange="updateSettings();" />
<label class="form-check-label" for="fullNumberFormat">
View full number format
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="numberFormat" value="abbr" id="abbrNumberFormat" onchange="updateSettings();" />
<label class="form-check-label" for="abbrNumberFormat">
View abbreviated number format
</label>
</div>
</div>
</div>
<!-- Modal footer -->
<div class="modal-footer justify-content-between">
<button type="button" class="btn btn-primary" onclick="randomMessage()">Click Me</button>
<span id="randomMessage"></span>
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<script>
// parse number into shorthand
function shpn(num) {
if (num > 999 && num < 1000000) {
return (num / 1000).toFixed(1) + "K"; // convert to K for number from > 1000 < 1 million
} else if (num > 1000000) {
return (num / 1000000).toFixed(1) + "M"; // convert to M for number from > 1 million
} else if (num > 1000000000) {
return (num / 1000000000).toFixed(1) + "B"; // convert to M for number from > 1 billion
} else if (num < 900) {
return num; // if value < 1000, nothing to do
}
}
// parse number into formatted number
function pn(num) {
if (JSON.parse(localStorage.getItem("settings"))["displayNumberFormat"] == "abbr") {
return shpn(num);
} else {
let num_parts = num.toString().split(".");
num_parts[0] = num_parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
return num_parts.join(".");
}
}
function sortObjByKey(obj, order) {
"use strict";
let key,
tempArry = [],
i,
tempObj = {};
for (key in obj) {
tempArry.push(key);
}
tempArry.sort(function (a, b) {
return a.toLowerCase().localeCompare(b.toLowerCase());
});
if (order === "desc") {
for (i = tempArry.length - 1; i >= 0; i--) {
tempObj[tempArry[i]] = obj[tempArry[i]];
}
} else {
for (i = 0; i < tempArry.length; i++) {
tempObj[tempArry[i]] = obj[tempArry[i]];
}
}
return tempObj;
}
function displayHydra() {
let fullHydras = JSON.parse(localStorage.getItem("hydras")),
fullHydrasBuffer = JSON.parse(localStorage.getItem("overageHydraBuffer"));
document.getElementById("hydra[common]").value = fullHydras["common"];
document.getElementById("hydra[elder]").value = fullHydras["elder"];
document.getElementById("hydra[ancient]").value = fullHydras["ancient"];
document.getElementById("hydra[dreadful]").value = fullHydras["dreadful"];
document.getElementById("hydra[legendary]").value = fullHydras["legendary"];
document.getElementById("hydraBuffer[common]").value = fullHydrasBuffer["common"];
document.getElementById("hydraBuffer[elder]").value = fullHydrasBuffer["elder"];
document.getElementById("hydraBuffer[ancient]").value = fullHydrasBuffer["ancient"];
document.getElementById("hydraBuffer[dreadful]").value = fullHydrasBuffer["dreadful"];
document.getElementById("hydraBuffer[legendary]").value = fullHydrasBuffer["legendary"];
}
function updateHydra() {
let fullHydras = JSON.parse(localStorage.getItem("hydras")),
fullHydrasBuffer = JSON.parse(localStorage.getItem("overageHydraBuffer"));
fullHydras["common"] = returnInt(document.getElementById("hydra[common]").value);
fullHydras["elder"] = returnInt(document.getElementById("hydra[elder]").value);
fullHydras["ancient"] = returnInt(document.getElementById("hydra[ancient]").value);
fullHydras["dreadful"] = returnInt(document.getElementById("hydra[dreadful]").value);
fullHydras["legendary"] = returnInt(document.getElementById("hydra[legendary]").value);
fullHydrasBuffer["common"] = returnInt(document.getElementById("hydraBuffer[common]").value);
fullHydrasBuffer["elder"] = returnInt(document.getElementById("hydraBuffer[elder]").value);
fullHydrasBuffer["ancient"] = returnInt(document.getElementById("hydraBuffer[ancient]").value);
fullHydrasBuffer["dreadful"] = returnInt(document.getElementById("hydraBuffer[dreadful]").value);
fullHydrasBuffer["legendary"] = returnInt(document.getElementById("hydraBuffer[legendary]").value);
localStorage.setItem("hydras", JSON.stringify(fullHydras));
localStorage.setItem("overageHydraBuffer", JSON.stringify(fullHydrasBuffer));
}
function updateSettings() {
let settings = JSON.parse(localStorage.getItem("settings"));
settings["displayNumberFormat"] = $("input[name=numberFormat]:checked").val();
localStorage.setItem("settings", JSON.stringify(settings));
}
function displayPlayers() {
let players = sortObjByKey(JSON.parse(localStorage.getItem("players")), "asc"),
hydra = $('input[name="hydra-toggle"]:checked').val();
$("#allPlayers").find("tr:gt(0)").remove();
for (let key in players) {
let html = "";
if (players.hasOwnProperty(key)) {
let name = players[key].name.replace(/ /g, "-");
var canAttack = players[key]["allowed_targets"][hydra];
html += "<tr>";
html +=
'<td class="p-0"><div class="form-check"><input onchange="updatePlayer(\'' +
name +
'\');" class="form-check-input" type="checkbox" value="" id="playerIncluded[' +
hydra +
"][" +
key +
']" ><label class="form-check-label" for="playerIncluded[' +
hydra +
"][" +
key +
']">' +
players[key].name +
"</label></div></th>";
html +=
'<td class="p-0"><input onchange="updatePlayer(\'' +
name +
'\');" class="form-control p-0" type="number" min="0" id="' +
name +
'[attacks]" name="' +
name +
'[attacks]" value="' +
players[key].attacks +
'" placeholder="3" /></td>';
html +=
'<td class="p-0"><input onchange="updatePlayer(\'' +
name +
'\');" class="form-control p-0 hydra-darkness" type="number" min="0" id="' +
name +
'[darkness]" name="' +
name +
'[darkness]" value="' +
players[key][hydra].darkness +
'" placeholder="0" /></td>';
html +=
'<td class="p-0"><input onchange="updatePlayer(\'' +
name +
'\');" class="form-control p-0 hydra-water" type="number" min="0" id="' +
name +
'[water]" name="' +
name +
'[water]" value="' +
players[key][hydra].water +
'" placeholder="0" /></td>';
html +=
'<td class="p-0"><input onchange="updatePlayer(\'' +
name +
'\');" class="form-control p-0 hydra-earth" type="number" min="0" id="' +
name +
'[earth]" name="' +
name +
'[earth]" value="' +
players[key][hydra].earth +
'" placeholder="0" /></td>';
html +=
'<td class="p-0"><input onchange="updatePlayer(\'' +
name +
'\');" class="form-control p-0 hydra-light" type="number" min="0" id="' +
name +
'[light]" name="' +
name +
'[light]" value="' +
players[key][hydra].light +
'" placeholder="0" /></td>';
html +=
'<td class="p-0"><input onchange="updatePlayer(\'' +
name +
'\');" class="form-control p-0 hydra-wind" type="number" min="0" id="' +
name +
'[wind]" name="' +
name +
'[wind]" value="' +
players[key][hydra].wind +
'" placeholder="0" /></td>';
html +=
'<td class="p-0"><input onchange="updatePlayer(\'' +
name +
'\');" class="form-control p-0 hydra-fire" type="number" min="0" id="' +
name +
'[fire]" name="' +
name +
'[fire]" value="' +
players[key][hydra].fire +
'" placeholder="0" /></td>';
html += '<td class="p-0"><button type="button" class="btn btn-default ml-2 mr-2 pt-0 pb-0 pl-1 pr-1 red" onclick="deletePlayer(\'' + name + '\');"><i class="fas fa-user-minus"></i></button></td>';
html += "</tr>";
}
$("#allPlayers tr:last").after(html);
document.getElementById("playerIncluded[" + hydra + "][" + key + "]").checked = canAttack;
}
displayHydraDamageSliders();
//$('#myCheckbox').prop('checked', false); // Unchecks it
}
function returnInt(value) {
if (value == "" || value == null) {
return 0;
}
return parseInt(value, 10);
}
function setPlayer() {
if(event.key !== 'Enter') {
return;
}
if (document.getElementById("player[name]").value == "") {
alert("Your Player must have a name.");
return;
}
let players = JSON.parse(localStorage.getItem("players")),
name = document.getElementById("player[name]").value.replace(/ /g, "-");
players[name] = {
name: document.getElementById("player[name]").value,
attacks: 3,
attacks_left: 3,
allowed_targets: {
common: true,
elder: true,
ancient: true,
dreadful: true,
legendary: true,
},
common: {
darkness: 0,
water: 0,
earth: 0,
light: 0,
wind: 0,
fire: 0,
},
elder: {
darkness: 0,
water: 0,
earth: 0,
light: 0,
wind: 0,
fire: 0,
},
ancient: {
darkness: 0,
water: 0,
earth: 0,
light: 0,
wind: 0,
fire: 0,
},
dreadful: {
darkness: 0,
water: 0,
earth: 0,
light: 0,
wind: 0,
fire: 0,
},
legendary: {
darkness: 0,
water: 0,
earth: 0,
light: 0,
wind: 0,
fire: 0,
},
};
localStorage.setItem("players", JSON.stringify(players));
// reset inputs
document.getElementById("player[name]").value = "";
displayPlayers();
}
function updatePlayer(name) {
let players = JSON.parse(localStorage.getItem("players")),
hydra = $('input[name="hydra-toggle"]:checked').val(),
checked = false;
players[name]["name"] = players[name]["name"];
players[name]["attacks"] = returnInt(document.getElementById(name + "[attacks]").value);
players[name]["attacks_left"] = returnInt(document.getElementById(name + "[attacks]").value);
players[name][hydra] = {
darkness: returnInt(document.getElementById(name + "[darkness]").value),
water: returnInt(document.getElementById(name + "[water]").value),
earth: returnInt(document.getElementById(name + "[earth]").value),
light: returnInt(document.getElementById(name + "[light]").value),
wind: returnInt(document.getElementById(name + "[wind]").value),
fire: returnInt(document.getElementById(name + "[fire]").value),
};
if (document.getElementById("playerIncluded[" + hydra + "][" + name + "]").checked) {
checked = true;
}
players[name]["allowed_targets"][hydra] = checked;
localStorage.setItem("players", JSON.stringify(players));
}
function deletePlayer(name) {
let players = JSON.parse(localStorage.getItem("players"));
delete players[name];
localStorage.setItem("players", JSON.stringify(players));
displayPlayers();
}
function sortHydras(obj, dir = "desc") {
// convert object into array
let sortable = [];
for (let key in obj) {
if (obj.hasOwnProperty(key)) {
sortable.push([key, obj[key]]); // each item is an array in format [key, value]
}
}
// sort items by value
if (dir == "desc") {
sortable.sort(function (a, b) {
return b[1] - a[1]; // compare numbers
});
} else {
sortable.sort(function (a, b) {
return a[1] - b[1]; // compare numbers
});
}
return sortable; // array in format [ [ key1, val1 ], [ key2, val2 ], ... ]