Skip to content

Commit 42e3124

Browse files
Add contextual info panel to air damage results (#100)
- add a result info section beneath the calculator outputs with smaller helper text - compute required weapons or stingers based on selected quality and energy entered - surface booster and damage accelerator needs when deploy times exceed their durations ------ [Codex Task](https://chatgpt.com/codex/tasks/task_e_6946fa9ffc9c83258d6bc1ad5cb0cb95)
1 parent 351f1ff commit 42e3124

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

erepublik-air-damage-calculator.html

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,18 @@
189189
background: var(--or-2);
190190
}
191191

192+
.result-info {
193+
display: grid;
194+
gap: 0.35rem;
195+
font-size: 0.95rem;
196+
color: var(--foreground-subtle);
197+
margin-top: 0.35rem;
198+
}
199+
200+
.result-info__item {
201+
margin: 0;
202+
}
203+
192204
@media (max-width: 720px) {
193205
body {
194206
padding: 20px 16px 40px;
@@ -240,6 +252,7 @@ <h1>eRepublik Air Damage Calculator</h1>
240252
<p class="helper-text" id="influence-breakdown"></p>
241253
</div>
242254
</div>
255+
<div class="result-info" id="result-info" aria-live="polite"></div>
243256
</div>
244257
</section>
245258

@@ -527,6 +540,7 @@ <h1>eRepublik Air Damage Calculator</h1>
527540
const influenceValue = document.getElementById('influence');
528541
const timeWrapper = document.getElementById('time-wrapper');
529542
const timeEstimate = document.getElementById('time-estimate');
543+
const resultInfo = document.getElementById('result-info');
530544
const ebInput = document.getElementById('ebs');
531545
const eb2Input = document.getElementById('ebs2');
532546
const eb3Input = document.getElementById('ebs3');
@@ -629,6 +643,13 @@ <h1>eRepublik Air Damage Calculator</h1>
629643
return `≈${formatNumber(minutes)}m:${remainingSeconds}s`;
630644
};
631645

646+
const formatDuration = (seconds) => {
647+
const wholeSeconds = Math.max(0, Math.ceil(seconds));
648+
const minutes = Math.floor(wholeSeconds / 60);
649+
const remainingSeconds = String(wholeSeconds % 60).padStart(2, '0');
650+
return `${minutes}m${remainingSeconds}s`;
651+
};
652+
632653
const clampNumber = (value, min, max) => {
633654
if (Number.isNaN(value)) return min;
634655
if (typeof max === 'number') {
@@ -789,6 +810,49 @@ <h1>eRepublik Air Damage Calculator</h1>
789810
tooltipPopover.textContent = activeWrapper.dataset.tooltipContent;
790811
}
791812
}
813+
814+
const infoMessages = [];
815+
const weaponQuality = {
816+
q1: 1,
817+
q2: 2,
818+
q3: 3,
819+
q4: 4,
820+
q5: 5
821+
}[weapon];
822+
823+
if (weaponQuality) {
824+
const weaponsNeeded = Math.ceil(energy / weaponQuality);
825+
infoMessages.push(`${formatNumber(weaponsNeeded)} weapons required to deploy ${formatNumber(energy)} energy`);
826+
}
827+
828+
if (isStinger) {
829+
const stingersNeeded = Math.ceil(energy / 3);
830+
infoMessages.push(`${formatNumber(stingersNeeded)} stingers required to deploy ${formatNumber(energy)} energy`);
831+
}
832+
833+
const boostersSelected = boosterPercent > 0
834+
|| influenceBoosterPercent > 0
835+
|| rankBoosterPercent > 0;
836+
837+
const boostersDurationSeconds = 10 * 60;
838+
if (boostersSelected && timeSecondsRounded > boostersDurationSeconds) {
839+
const boostersNeeded = Math.ceil(timeSecondsRounded / boostersDurationSeconds);
840+
infoMessages.push(`You may need ${formatNumber(boostersNeeded)}+ boosters because the deploy time is ${formatDuration(timeSecondsRounded)} (assuming each booster lasts 10m)`);
841+
}
842+
843+
const damageAcceleratorDurationSeconds = 5 * 60;
844+
if (damageAcceleratorMultiplier > 1 && timeSecondsRounded > damageAcceleratorDurationSeconds) {
845+
const acceleratorsNeeded = Math.ceil(timeSecondsRounded / damageAcceleratorDurationSeconds);
846+
infoMessages.push(`You may need ${formatNumber(acceleratorsNeeded)}+ damage accelerators because the deploy time is ${formatDuration(timeSecondsRounded)} (assuming each accelerator lasts 5m)`);
847+
}
848+
849+
resultInfo.innerHTML = '';
850+
infoMessages.forEach((message) => {
851+
const item = document.createElement('p');
852+
item.className = 'result-info__item';
853+
item.textContent = message;
854+
resultInfo.appendChild(item);
855+
});
792856
}
793857

794858
energyInput.addEventListener('input', () => {

0 commit comments

Comments
 (0)