forked from simonw/tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherepublik-air-damage-calculator.html
More file actions
884 lines (780 loc) · 36.5 KB
/
erepublik-air-damage-calculator.html
File metadata and controls
884 lines (780 loc) · 36.5 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>eRepublik Air Damage Calculator</title>
<link rel="stylesheet" href="styles.css">
<style>
:root {
--gap: clamp(0.75rem, 2vw, 1.25rem);
}
body {
max-width: 960px;
margin: 0 auto;
padding: 24px 20px 48px;
}
.page-header {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.site-link {
font-weight: 600;
color: var(--foreground-subtle);
text-decoration: none;
}
.site-link:hover,
.site-link:focus-visible {
color: var(--foreground);
}
main {
display: grid;
gap: 1.5rem;
}
.tool-card {
padding: clamp(1.25rem, 3vw, 2rem);
}
.result-display {
display: flex;
flex-direction: column;
gap: 0.75rem;
}
.result-value {
font-size: clamp(2rem, 4vw, 2.75rem);
font-weight: 700;
letter-spacing: 0.01em;
}
.result-metrics-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
gap: clamp(0.75rem, 2vw, 1.25rem);
align-items: start;
}
.result-value--compact {
font-size: clamp(1.4rem, 3vw, 1.85rem);
}
.result-group {
display: flex;
flex-direction: column;
gap: 0.25rem;
}
.result-with-tooltip {
display: inline-flex;
align-items: center;
gap: 0.4rem;
width: fit-content;
}
.tooltip-target {
cursor: help;
text-decoration: underline;
text-decoration-style: dotted;
text-underline-offset: 0.12em;
}
.tooltip-icon {
inline-size: 1.5rem;
block-size: 1.5rem;
display: grid;
place-items: center;
font-size: 0.85rem;
font-weight: 700;
border-radius: 999px;
border: 1px solid var(--tx-3);
background: var(--ui);
color: var(--foreground);
box-shadow: 0 2px 6px hsl(0 0% 0% / 0.08);
transition: transform 0.2s ease, background 0.2s ease;
}
.tooltip-icon:hover {
transform: translateY(-2px);
background: var(--bg);
}
.tooltip-icon:focus-visible {
outline: 2px solid var(--link);
outline-offset: 2px;
}
.tooltip-popover {
position: absolute;
z-index: 10;
max-inline-size: min(28rem, 90vw);
padding: 0.75rem 0.9rem;
border-radius: 0.75rem;
border: 1px solid var(--tx-3);
background: var(--surface, white);
box-shadow: 0 10px 30px hsl(0 0% 0% / 0.08);
color: var(--foreground);
white-space: pre-wrap;
font-size: 0.95rem;
line-height: 1.5;
display: none;
}
.tooltip-popover[data-visible="true"] {
display: block;
}
form {
display: grid;
gap: var(--gap);
}
.inputs-grid {
display: grid;
gap: var(--gap);
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.checkbox-row {
display: grid;
gap: 0.5rem;
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.helper-text {
color: var(--foreground-subtle);
margin: 0;
}
.hover-note {
text-decoration: underline;
text-decoration-style: dotted;
text-underline-offset: 0.15em;
}
.status-banner {
display: inline-flex;
align-items: center;
gap: 0.5rem;
padding: 0.6rem 0.75rem;
border-radius: 0.75rem;
border: 1px dashed var(--tx-3);
background: var(--ui);
}
.status-indicator {
width: 0.75rem;
height: 0.75rem;
border-radius: 50%;
background: var(--gr-2);
}
.status-text {
margin: 0;
}
.status-banner.warning {
border-color: var(--or-2);
color: var(--or);
}
.status-banner.warning .status-indicator {
background: var(--or-2);
}
.result-info {
display: grid;
gap: 0.35rem;
font-size: 0.95rem;
color: var(--foreground-subtle);
margin-top: 0.35rem;
}
.result-info__item {
margin: 0;
}
@media (max-width: 720px) {
body {
padding: 20px 16px 40px;
}
}
</style>
</head>
<body>
<header class="page-header">
<a class="site-link" href="https://tools.mathspp.com/" aria-label="Back to tools.mathspp.com">←
tools.mathspp.com</a>
<h1>eRepublik Air Damage Calculator</h1>
<p class="lead">Compute expected air battle damage using rank, weapons, boosters, and bonuses.</p>
</header>
<main>
<section class="surface tool-card" aria-live="polite">
<div class="result-display">
<div class="result-with-tooltip" id="final-damage-wrapper">
<div class="result-value tooltip-target" id="final-damage" tabindex="0">0</div>
<span class="tooltip-icon" aria-hidden="true">?</span>
<p class="helper-text">final damage</p>
</div>
<p class="helper-text" id="breakdown"></p>
<div class="result-metrics-grid">
<div class="result-group">
<div class="result-with-tooltip result-with-tooltip--compact" id="time-wrapper">
<div class="result-value result-value--compact tooltip-target" id="time-estimate" tabindex="0">≈0s</div>
<span class="tooltip-icon" aria-hidden="true">?</span>
<p class="helper-text">time to deploy</p>
</div>
<p class="helper-text" id="time-breakdown"></p>
</div>
<div class="result-group">
<div class="result-with-tooltip result-with-tooltip--compact" id="rank-wrapper">
<div class="result-value result-value--compact tooltip-target" id="rank-value" tabindex="0">0</div>
<span class="tooltip-icon" aria-hidden="true">?</span>
<p class="helper-text">rank points</p>
</div>
<p class="helper-text" id="rank-breakdown"></p>
</div>
<div class="result-group">
<div class="result-with-tooltip result-with-tooltip--compact" id="influence-wrapper">
<div class="result-value result-value--compact tooltip-target" id="influence" tabindex="0">0</div>
<span class="tooltip-icon" aria-hidden="true">?</span>
<p class="helper-text">influence</p>
</div>
<p class="helper-text" id="influence-breakdown"></p>
</div>
</div>
<div class="result-info" id="result-info" aria-live="polite"></div>
</div>
</section>
<section class="surface tool-card">
<form id="calculator" aria-label="Air damage calculator">
<div class="inputs-grid">
<div class="form-group">
<label for="energy">Total <a href="#energy">energy to spend</a></label>
<input id="energy" name="energy" type="number" min="0" step="10" value="10" required>
</div>
<div class="form-group">
<label for="rank">Aircraft rank</label>
<select id="rank" name="rank"></select>
</div>
<div class="form-group">
<label for="weapon">Weapon</label>
<select id="weapon" name="weapon">
<option value="none" selected>No weapon</option>
<option value="q1">Q1 weapon</option>
<option value="q2">Q2 weapon</option>
<option value="q3">Q3 weapon</option>
<option value="q4">Q4 weapon</option>
<option value="q5">Q5 weapon</option>
<option value="stinger">Stinger</option>
</select>
</div>
<div class="form-group">
<label for="protector">Protector level (0–50)</label>
<input id="protector" name="protector" type="number" min="0" max="50" step="1" value="0"
required>
</div>
<div class="form-group">
<label for="booster">Damage booster</label>
<select id="booster" name="booster">
<option value="0" selected>0%</option>
<option value="20">20%</option>
<option value="50">50%</option>
<option value="100">100%</option>
</select>
</div>
<div class="form-group">
<label for="damage-accelerator">Damage accelerator</label>
<select id="damage-accelerator" name="damage-accelerator">
<option value="1" selected>None (x1)</option>
<option value="2">x2</option>
<option value="5">x5</option>
</select>
</div>
<div class="form-group">
<label for="influence-booster">Influence booster</label>
<select id="influence-booster" name="influence-booster">
<option value="0" selected>0%</option>
<option value="10">10%</option>
<option value="20">20%</option>
<option value="30">30%</option>
</select>
</div>
<div class="form-group">
<label for="determination">Determination bonus</label>
<input id="determination" name="determination" type="number" min="1" step="0.01" value="1.00">
</div>
<div class="form-group">
<label for="rank-booster">Rank booster</label>
<select id="rank-booster" name="rank-booster">
<option value="0" selected>0%</option>
<option value="10">10%</option>
<option value="20">20%</option>
<option value="30">30%</option>
</select>
</div>
</div>
<div class="checkbox-row">
<label class="checkbox">
<input type="checkbox" id="natural-enemy" name="natural-enemy">
<span>Fighting against natural enemy</span>
</label>
<label class="checkbox">
<input type="checkbox" id="level-100" name="level-100">
<span>Player is level 100+</span>
</label>
<label class="checkbox">
<input type="checkbox" id="snow-fight" name="snow-fight">
<span>Active snow fight token</span>
</label>
</div>
</form>
</section>
<section class="surface tool-card" id="energy">
<div class="result-display">
<div class="status-banner" id="consumables-status" role="status" aria-live="polite">
<span class="status-indicator" aria-hidden="true"></span>
<p class="status-text" id="consumables-status-text">Fill in consumables to update energy
automatically.</p>
</div>
</div>
<form id="energy-packs" class="inputs-grid" aria-label="Energy from consumables">
<div class="form-group">
<label for="ebs">EBs</label>
<input id="ebs" name="ebs" type="number" min="0" step="1" value="">
</div>
<div class="form-group">
<label for="ebs2">x2 EBs</label>
<input id="ebs2" name="ebs2" type="number" min="0" step="1" value="">
</div>
<div class="form-group">
<label for="ebs3">x3 EBs</label>
<input id="ebs3" name="ebs3" type="number" min="0" step="1" value="">
</div>
<div class="form-group">
<label for="treats"><span class="hover-note"
title="Treaks, pumpkins, ice creams, and other consumables that restore 50 energy">50-energy
consumables</span></label>
<input id="treats" name="treats" type="number" min="0" step="1" value="">
</div>
</form>
</section>
<section class="surface tool-card" aria-label="Contact information">
<p>For any questions, requests, or suggestions, reach out to <a
href="https://www.erepublik.com/en/citizen/profile/9712341">rodrigogs</a> on
erepublik.</p>
</section>
</main>
<footer class="page-footer">
<p>Built with ❤️, 🤖, and 🐍, by <a href="https://mathspp.com/">Rodrigo Girão Serrão</a></p>
</footer>
<script>
(function () {
const ranksAscending = [
'Airman',
'Airman 1st Class',
'Airman 1st Class*',
'Airman 1st Class**',
'Airman 1st Class***',
'Airman 1st Class****',
'Airman 1st Class*****',
'Senior Airman',
'Senior Airman*',
'Senior Airman**',
'Senior Airman***',
'Senior Airman****',
'Senior Airman*****',
'Staff Sergeant',
'Staff Sergeant*',
'Staff Sergeant**',
'Staff Sergeant***',
'Staff Sergeant****',
'Staff Sergeant*****',
'Aviator',
'Aviator*',
'Aviator**',
'Aviator***',
'Aviator****',
'Aviator*****',
'Flight Lieutenant',
'Flight Lieutenant*',
'Flight Lieutenant**',
'Flight Lieutenant***',
'Flight Lieutenant****',
'Flight Lieutenant*****',
'Squadron Leader',
'Squadron Leader*',
'Squadron Leader**',
'Squadron Leader***',
'Squadron Leader****',
'Squadron Leader*****',
'Chief Master Sergeant',
'Chief Master Sergeant*',
'Chief Master Sergeant**',
'Chief Master Sergeant***',
'Chief Master Sergeant****',
'Chief Master Sergeant*****',
'Wing Commander',
'Wing Commander*',
'Wing Commander**',
'Wing Commander***',
'Wing Commander****',
'Wing Commander*****',
'Group Captain',
'Group Captain*',
'Group Captain**',
'Group Captain***',
'Group Captain****',
'Group Captain*****',
'Air Commodore',
'Air Commodore*',
'Air Commodore**',
'Air Commodore***',
'Air Commodore****',
'Air Commodore*****',
'Air Vice Marshal',
'Air Vice Marshal*',
'Air Vice Marshal**',
'Air Vice Marshal***',
'Air Vice Marshal****',
'Air Vice Marshal*****',
'Air Marshal',
'Air Marshal*',
'Air Marshal**',
'Air Marshal***',
'Air Marshal****',
'Air Marshal*****',
'Air Chief Marshal',
'Air Chief Marshal*',
'Air Chief Marshal**',
'Air Chief Marshal***',
'Air Chief Marshal****',
'Air Chief Marshal*****'
].map((name, index) => ({ name, rankValue: index + 1 }));
const storageKeys = {
rank: 'erep-air-rank',
level100: 'erep-air-level-100'
};
const safeGetStorageItem = (key) => {
try {
return window.localStorage.getItem(key);
} catch (error) {
return null;
}
};
const safeSetStorageItem = (key, value) => {
try {
window.localStorage.setItem(key, value);
} catch (error) {
// Ignore storage errors.
}
};
const rankSelect = document.getElementById('rank');
ranksAscending
.slice()
.reverse()
.forEach((rank) => {
const option = document.createElement('option');
option.value = String(rank.rankValue);
option.textContent = rank.name;
if (rank.name === 'Air Commodore') {
option.selected = true;
}
rankSelect.appendChild(option);
});
const energyInput = document.getElementById('energy');
const weaponSelect = document.getElementById('weapon');
const protectorInput = document.getElementById('protector');
const boosterSelect = document.getElementById('booster');
const damageAcceleratorSelect = document.getElementById('damage-accelerator');
const influenceBoosterSelect = document.getElementById('influence-booster');
const rankBoosterSelect = document.getElementById('rank-booster');
const determinationInput = document.getElementById('determination');
const naturalEnemyCheckbox = document.getElementById('natural-enemy');
const level100Checkbox = document.getElementById('level-100');
const snowFightCheckbox = document.getElementById('snow-fight');
const storedRank = safeGetStorageItem(storageKeys.rank);
if (storedRank && ranksAscending.some((rank) => String(rank.rankValue) === storedRank)) {
rankSelect.value = storedRank;
}
const storedLevel100 = safeGetStorageItem(storageKeys.level100);
if (storedLevel100 !== null) {
level100Checkbox.checked = storedLevel100 === 'true';
}
const finalDamageWrapper = document.getElementById('final-damage-wrapper');
const finalDamage = document.getElementById('final-damage');
const rankWrapper = document.getElementById('rank-wrapper');
const rankValueElement = document.getElementById('rank-value');
const influenceWrapper = document.getElementById('influence-wrapper');
const influenceValue = document.getElementById('influence');
const timeWrapper = document.getElementById('time-wrapper');
const timeEstimate = document.getElementById('time-estimate');
const resultInfo = document.getElementById('result-info');
const ebInput = document.getElementById('ebs');
const eb2Input = document.getElementById('ebs2');
const eb3Input = document.getElementById('ebs3');
const treatsInput = document.getElementById('treats');
const consumablesStatus = document.getElementById('consumables-status');
const consumablesStatusText = document.getElementById('consumables-status-text');
const tooltipPopover = document.createElement('div');
tooltipPopover.id = 'tooltip-popover';
tooltipPopover.className = 'tooltip-popover';
tooltipPopover.setAttribute('role', 'tooltip');
tooltipPopover.setAttribute('aria-hidden', 'true');
document.body.appendChild(tooltipPopover);
const setTooltipContent = (wrapper, valueElement, content) => {
wrapper.title = content;
valueElement.title = content;
valueElement.setAttribute('aria-label', content);
wrapper.dataset.tooltipContent = content;
};
const tooltipIcons = Array.from(document.querySelectorAll('.result-with-tooltip .tooltip-icon'));
tooltipIcons.forEach((icon) => {
icon.setAttribute('role', 'button');
icon.setAttribute('tabindex', '0');
icon.setAttribute('aria-label', 'Show calculation details');
});
let activeTooltipTarget = null;
const hidePopover = () => {
tooltipPopover.dataset.visible = 'false';
tooltipPopover.setAttribute('aria-hidden', 'true');
tooltipPopover.textContent = '';
activeTooltipTarget = null;
};
const showPopover = (trigger, content) => {
const rect = trigger.getBoundingClientRect();
tooltipPopover.textContent = content;
tooltipPopover.style.top = `${rect.bottom + window.scrollY + 10}px`;
tooltipPopover.style.left = `${rect.left + window.scrollX}px`;
tooltipPopover.dataset.visible = 'true';
tooltipPopover.setAttribute('aria-hidden', 'false');
activeTooltipTarget = trigger;
};
document.addEventListener('click', (event) => {
if (!activeTooltipTarget) return;
if (event.target === activeTooltipTarget || tooltipPopover.contains(event.target)) return;
if (activeTooltipTarget.contains(event.target)) return;
hidePopover();
});
document.addEventListener('keydown', (event) => {
if (event.key === 'Escape') {
hidePopover();
}
});
const handleTooltipTrigger = (event) => {
const trigger = event.currentTarget;
const wrapper = trigger.closest('.result-with-tooltip');
if (!wrapper || !wrapper.dataset.tooltipContent) return;
showPopover(trigger, wrapper.dataset.tooltipContent);
};
tooltipIcons.forEach((icon) => {
icon.addEventListener('click', handleTooltipTrigger);
icon.addEventListener('keydown', (event) => {
if (event.key === 'Enter' || event.key === ' ') {
event.preventDefault();
handleTooltipTrigger(event);
}
});
});
const weaponMultipliers = {
none: 1,
q1: 1.2,
q2: 1.4,
q3: 1.6,
q4: 1.8,
q5: 2,
stinger: 1
};
const formatNumber = (value) => {
return Number.isFinite(value) ? value.toLocaleString(undefined, { maximumFractionDigits: 2 }) : '0';
};
const formatDeployTime = (seconds) => {
const wholeSeconds = Math.max(0, Math.ceil(seconds));
if (wholeSeconds < 60) {
return `≈${formatNumber(wholeSeconds)}s`;
}
const minutes = Math.floor(wholeSeconds / 60);
const remainingSeconds = String(wholeSeconds % 60).padStart(2, '0');
return `≈${formatNumber(minutes)}m:${remainingSeconds}s`;
};
const formatDuration = (seconds) => {
const wholeSeconds = Math.max(0, Math.ceil(seconds));
const minutes = Math.floor(wholeSeconds / 60);
const remainingSeconds = String(wholeSeconds % 60).padStart(2, '0');
return `${minutes}m${remainingSeconds}s`;
};
const clampNumber = (value, min, max) => {
if (Number.isNaN(value)) return min;
if (typeof max === 'number') {
return Math.min(Math.max(value, min), max);
}
return Math.max(value, min);
};
const getInfluenceRankMultiplier = (rankValue) => {
if (rankValue < 20) return 0.01;
if (rankValue <= 38) {
const stepsFromAviator = rankValue - 20;
return 0.05 + (stepsFromAviator * 0.05);
}
return 1;
};
let updatingEnergyFromPacks = false;
const packInputs = [ebInput, eb2Input, eb3Input, treatsInput];
const setConsumablesStatus = (mode) => {
if (mode === 'manual') {
consumablesStatusText.textContent = 'Energy set manually — consumable inputs are cleared and not being used.';
consumablesStatus.classList.add('warning');
} else {
consumablesStatusText.textContent = 'Fill in consumables to update energy automatically.';
consumablesStatus.classList.remove('warning');
}
};
const resetEnergyPackInputs = () => {
packInputs.forEach((input) => {
input.value = '';
});
};
const updateEnergyFromPacks = () => {
const eb = clampNumber(parseInt(ebInput.value, 10), 0);
const eb2 = clampNumber(parseInt(eb2Input.value, 10), 0);
const eb3 = clampNumber(parseInt(eb3Input.value, 10), 0);
const treats = clampNumber(parseInt(treatsInput.value, 10), 0);
ebInput.value = eb;
eb2Input.value = eb2;
eb3Input.value = eb3;
treatsInput.value = treats;
const energyFromPacks = (eb * 100) + (eb2 * 200) + (eb3 * 300) + (treats * 50);
updatingEnergyFromPacks = true;
energyInput.value = energyFromPacks;
calculateDamage();
updatingEnergyFromPacks = false;
setConsumablesStatus('auto');
};
function calculateDamage() {
const energy = clampNumber(parseInt(energyInput.value, 10), 0);
if (energyInput.value === '') energyInput.value = energy;
const protectorLevel = clampNumber(parseInt(protectorInput.value, 10), 0, 50);
if (protectorInput.value === '') protectorInput.value = protectorLevel;
protectorInput.value = protectorLevel;
const weapon = weaponSelect.value;
const boosterPercent = Number(boosterSelect.value) || 0;
const damageAcceleratorMultiplier = Number(damageAcceleratorSelect.value) || 1;
const influenceBoosterPercent = Number(influenceBoosterSelect.value) || 0;
const rankBoosterPercent = Number(rankBoosterSelect.value) || 0;
const determinationBonus = clampNumber(parseFloat(determinationInput.value), 1);
determinationInput.value = determinationBonus.toFixed(2);
const isStinger = weapon === 'stinger';
const rankValue = Number(rankSelect.value) || 1;
const baseDamage = isStinger ? 1000 : 10;
const hits = energy / 10;
const baseHitsPerSecond = isStinger ? 1 : 3;
const actualHitsPerSecond = baseHitsPerSecond * damageAcceleratorMultiplier;
const rankMultiplier = isStinger ? 1 : 1 + (rankValue / 5);
const weaponMultiplier = weaponMultipliers[weapon] ?? 1;
const protectorMultiplier = 1 + protectorLevel / 100;
const boosterMultiplier = 1 + boosterPercent / 100;
const influenceBoosterMultiplier = 1 + influenceBoosterPercent / 100;
const rankBoosterMultiplier = 1 + rankBoosterPercent / 100;
const naturalEnemyMultiplier = naturalEnemyCheckbox.checked ? 1.1 : 1;
const level100Multiplier = level100Checkbox.checked ? 1.1 : 1;
const snowFightMultiplier = snowFightCheckbox.checked ? 1.1 : 1;
const influenceRankMultiplier = getInfluenceRankMultiplier(rankValue);
const result = Math.floor(hits
* baseDamage
* rankMultiplier
* weaponMultiplier
* protectorMultiplier
* boosterMultiplier
* naturalEnemyMultiplier
* level100Multiplier
* snowFightMultiplier);
finalDamage.textContent = formatNumber(result);
const damageFormula = [
'Final damage = floor(',
` ${formatNumber(hits)} hits`,
`× ${formatNumber(baseDamage)} base damage`,
`× rank ×${formatNumber(rankMultiplier)}`,
`× ${weapon === 'stinger' ? 'stinger damage' : 'weapon'} ×${formatNumber(weaponMultiplier)}`,
`× protector ×${formatNumber(protectorMultiplier)}`,
`× booster ×${formatNumber(boosterMultiplier)}`,
`× ${naturalEnemyCheckbox.checked ? 'natural enemy bonus ×1.1' : 'no natural enemy bonus ×1'}`,
`× ${level100Checkbox.checked ? 'level 100+ bonus ×1.1' : 'no level 100 bonus ×1'}`,
`× ${snowFightCheckbox.checked ? 'snow fight token ×1.1' : 'no snow fight token ×1'}`,
`) = ${formatNumber(result)}`
].join('\n');
const timeSeconds = hits / actualHitsPerSecond;
const timeSecondsRounded = Math.ceil(timeSeconds);
timeEstimate.textContent = formatDeployTime(timeSecondsRounded);
const timeFormula = [
'Time = ceil(hits ÷ (hits per second × accelerator))',
`= ceil(${formatNumber(hits)} ÷ (${formatNumber(baseHitsPerSecond)} × ${formatNumber(damageAcceleratorMultiplier)}))`,
`= ceil(${formatNumber(timeSeconds)} seconds)`,
`= ${formatDeployTime(timeSecondsRounded)}`
].join('\n');
const rankFromDamage = result * 0.1;
const rankTotal = Math.floor(rankFromDamage * rankBoosterMultiplier);
rankValueElement.textContent = formatNumber(rankTotal);
const rankFormula = [
'Rank points = floor(',
` ${formatNumber(result)} damage × 0.1`,
`× rank booster ×${formatNumber(rankBoosterMultiplier)}`,
`) = ${formatNumber(rankTotal)}`,
`Base rank points before booster: ${formatNumber(rankFromDamage)}`
].join('\n');
const influence = Math.floor(result
* influenceBoosterMultiplier
* determinationBonus
* influenceRankMultiplier);
influenceValue.textContent = formatNumber(influence);
const influenceFormula = [
'Influence = floor(',
` ${formatNumber(result)} final damage`,
`× influence booster ×${formatNumber(influenceBoosterMultiplier)}`,
`× determination ×${determinationBonus.toFixed(2)}`,
`× rank influence ×${formatNumber(influenceRankMultiplier)}`,
`) = ${formatNumber(influence)}`
].join('\n');
setTooltipContent(finalDamageWrapper, finalDamage, damageFormula);
setTooltipContent(timeWrapper, timeEstimate, timeFormula);
setTooltipContent(rankWrapper, rankValueElement, rankFormula);
setTooltipContent(influenceWrapper, influenceValue, influenceFormula);
if (activeTooltipTarget) {
const activeWrapper = activeTooltipTarget.closest('.result-with-tooltip');
if (activeWrapper && activeWrapper.dataset.tooltipContent) {
tooltipPopover.textContent = activeWrapper.dataset.tooltipContent;
}
}
const infoMessages = [];
const weaponQuality = {
q1: 1,
q2: 2,
q3: 3,
q4: 4,
q5: 5
}[weapon];
if (weaponQuality) {
const weaponsNeeded = Math.ceil(hits / weaponQuality);
infoMessages.push(`${formatNumber(weaponsNeeded)} weapons required to deploy ${formatNumber(energy)} energy`);
}
if (isStinger) {
const stingersNeeded = Math.ceil(hits / 3);
infoMessages.push(`${formatNumber(stingersNeeded)} stingers required to deploy ${formatNumber(energy)} energy`);
}
const boostersSelected = boosterPercent > 0
|| influenceBoosterPercent > 0
|| rankBoosterPercent > 0;
const boostersDurationSeconds = 10 * 60;
if (boostersSelected && timeSecondsRounded > boostersDurationSeconds) {
const boostersNeeded = Math.ceil(timeSecondsRounded / boostersDurationSeconds);
infoMessages.push(`You may need ${formatNumber(boostersNeeded)}+ boosters because the deploy time is ${formatDuration(timeSecondsRounded)} (assuming each booster lasts 10m)`);
}
const damageAcceleratorDurationSeconds = 5 * 60;
if (damageAcceleratorMultiplier > 1 && timeSecondsRounded > damageAcceleratorDurationSeconds) {
const acceleratorsNeeded = Math.ceil(timeSecondsRounded / damageAcceleratorDurationSeconds);
infoMessages.push(`You may need ${formatNumber(acceleratorsNeeded)}+ damage accelerators because the deploy time is ${formatDuration(timeSecondsRounded)} (assuming each accelerator lasts 5m)`);
}
resultInfo.innerHTML = '';
infoMessages.forEach((message) => {
const item = document.createElement('p');
item.className = 'result-info__item';
item.textContent = message;
resultInfo.appendChild(item);
});
}
energyInput.addEventListener('input', () => {
if (!updatingEnergyFromPacks) {
resetEnergyPackInputs();
setConsumablesStatus('manual');
}
});
packInputs.forEach((input) => {
input.addEventListener('input', updateEnergyFromPacks);
});
rankSelect.addEventListener('change', () => {
safeSetStorageItem(storageKeys.rank, rankSelect.value);
});
level100Checkbox.addEventListener('change', () => {
safeSetStorageItem(storageKeys.level100, String(level100Checkbox.checked));
});
document.getElementById('calculator').addEventListener('input', calculateDamage);
setConsumablesStatus('auto');
calculateDamage();
})();
</script>
</body>
</html>