Widget:Calculator/Combat/Max Hit: Difference between revisions
No edit summary |
No edit summary |
||
(4 intermediate revisions by the same user not shown) | |||
Line 18: | Line 18: | ||
<td> | <td> | ||
<span class="max-hit-calc__stat-label"> | <span class="max-hit-calc__stat-label"> | ||
Strength Level | Strength Level | ||
</span> | </span> | ||
Line 29: | Line 28: | ||
<td> | <td> | ||
<span class="max-hit-calc__stat-label"> | <span class="max-hit-calc__stat-label"> | ||
Strength Bonus | Strength Bonus | ||
</span> | </span> | ||
Line 40: | Line 38: | ||
<td> | <td> | ||
<span class="max-hit-calc__stat-label"> | <span class="max-hit-calc__stat-label"> | ||
Training Style | Training Style | ||
</span> | </span> | ||
Line 71: | Line 68: | ||
let strengthBonus = parseInt(strengthBonusInput.value, 10) || 0; | let strengthBonus = parseInt(strengthBonusInput.value, 10) || 0; | ||
const trainingStyle = trainingStyleSelect.value; | const trainingStyle = trainingStyleSelect.value; | ||
// | // Clamp values | ||
strengthLevel = Math.max(1, Math.min(100, strengthLevel)); | strengthLevel = Math.max(1, Math.min(100, strengthLevel)); | ||
strengthBonus = Math.max(0, strengthBonus); | strengthBonus = Math.max(0, strengthBonus); | ||
// | // Base effective strength | ||
let effectiveStrength; | let effectiveStrength = strengthLevel + 8; | ||
// Extra +3 only if "Strength" training style is selected | |||
if (trainingStyle === 'strength') { | if (trainingStyle === 'strength') { | ||
effectiveStrength = | effectiveStrength += 3; | ||
} | } | ||
const calculatedHit = | // Apply formula | ||
const calculatedHit = 1 + ((effectiveStrength * (strengthBonus + 64)) / 640); | |||
const maxHit = Math.floor(calculatedHit); | |||
); | |||
maxHitResultEl.textContent = maxHit; | maxHitResultEl.textContent = maxHit; | ||
} | } | ||
document.addEventListener('DOMContentLoaded', () => { | document.addEventListener('DOMContentLoaded', () => { | ||
strengthLevelInput.addEventListener('input', calculateMaxHit); | strengthLevelInput.addEventListener('input', calculateMaxHit); | ||
strengthBonusInput.addEventListener('input', calculateMaxHit); | strengthBonusInput.addEventListener('input', calculateMaxHit); | ||
trainingStyleSelect.addEventListener('change', calculateMaxHit); | trainingStyleSelect.addEventListener('change', calculateMaxHit); | ||
calculateMaxHit(); | calculateMaxHit(); | ||
}); | }); | ||
})(); | })(); | ||
</script> | </script> |