Files
conjurer/rpg/hit_location.js
T
2025-08-15 19:31:22 +02:00

22 lines
874 B
JavaScript

// 🎯 Hit Location (DH mapping by reversed roll)
new Dialog({
title:"🎯 Hit Location",
content:`<form>
<div class="form-group"><label>Attack d100 roll</label><input name="roll" type="number" value="37"/></div>
</form>`,
buttons:{
go:{label:"Resolve", callback: html=>{
const n = Math.max(1, Math.min(100, Number(html.find('[name="roll"]').val())));
const rev = Number(String(n).padStart(2,"0").split("").reverse().join(""));
let loc = "";
if (rev<=10) loc="Head";
else if (rev<=20) loc="Right Arm";
else if (rev<=30) loc="Left Arm";
else if (rev<=70) loc="Body";
else if (rev<=85) loc="Right Leg";
else loc="Left Leg";
ChatMessage.create({content:`🎯 <b>Hit Location</b>: roll ${n} → reversed ${rev} → <b>${loc}</b>`});
}}
}
}).render(true);