-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
65 lines (63 loc) · 2.93 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
<!DOCTYPE html>
<html>
<head>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-KK94CHFLLe+nY2dmCWGMq91rCGa5gtU4mk92HdvYe+M/SXH301p5ILy+dN9+nJOZ" crossorigin="anonymous">
</head>
<style>
.alert { display: none; }
</style>
<body>
<div class="container">
<div class="row">
<div class="col-xs-12 col-lg-8 offset-lg-2">
<h2 class="mt-5 mb-2">AE stamina calculator</h2>
<form>
<div class="form-group mb-3">
<label class="form-label">Quiet time start</label>
<input id="end-day" class="form-control" type="date" value="2023-07-23"/>
</div>
<div class="form-group mb-3">
<label class="form-label">How much stamina on LOWEST stamina unit in team?</label>
<input type="number" class="form-control" value="0" id="stamina"/>
</div>
<div class="form-group mb-3">
<label class="form-label">Are you a star of dawn?</label>
<br>
<input type="checkbox" class="form-check-input" id="is-sod"/>
</div>
<div id="alert" class="alert alert-success" role="alert">
<span id="results"></span>
</div>
</form>
</div>
</div>
</div>
</body>
<script>
const staminaEle = document.getElementById('stamina');
const isSodEle = document.getElementById('is-sod');
const endDayEle = document.getElementById('end-day');
const resultsEle = document.getElementById('results');
const alertEle = document.getElementById('alert');
const onChange = () => {
const endTime = new Date(endDayEle.value);
const hoursLeft = (endTime - new Date()) / 1000 / 60 / 60;
const staminaGain = isSodEle.checked ? 4 * (1.12 + 0.1) : 4 * 1.12;
const staminaToGain = hoursLeft > 0 ? staminaGain * hoursLeft : 0;
const totalStamina = Math.floor(staminaToGain + (+staminaEle.value));
const remainingFullAttacks = Math.floor(totalStamina / 48);
const residualStamina = totalStamina % 48;
const freeRewinds = Math.floor(residualStamina / 4);
resultsEle.innerText = `
Hours left: ${Math.floor(hoursLeft * 100) / 100}
Your team will be able to attack ${remainingFullAttacks} times, using ${remainingFullAttacks * 48} stamina
You will end up with ${totalStamina} stamina at the beginning of quiet timer.
You can therefore rewind ${freeRewinds} times without losing an attack!
`;
alertEle.classList.add('d-block');
};
staminaEle.oninput = onChange;
isSodEle.onchange = onChange;
endDayEle.onchange = onChange;
</script>
</html>