mirror of
https://github.com/migatu/conjurer.git
synced 2026-07-14 21:38:38 +00:00
38 lines
2.1 KiB
JavaScript
38 lines
2.1 KiB
JavaScript
// 💥 Quick Damage — supports Tearing, Proven(X), Primitive(X), flat mod
|
|
new Dialog({
|
|
title:"💥 Damage Roller",
|
|
content: `
|
|
<form>
|
|
<div class="form-group"><label>Flat modifier (e.g., +3)</label><input name="mod" type="number" value="0"/></div>
|
|
<div class="form-group"><label>Traits</label>
|
|
<label><input type="checkbox" name="tear"> Tearing</label>
|
|
<label><input type="checkbox" name="prov"> Proven</label>
|
|
<input name="provV" type="number" value="0" style="width:60px" placeholder="X"/>
|
|
<label><input type="checkbox" name="prim"> Primitive</label>
|
|
<input name="primV" type="number" value="0" style="width:60px" placeholder="X"/>
|
|
</div>
|
|
</form>`,
|
|
buttons:{
|
|
go:{label:"Roll", callback: async html=>{
|
|
const mod = Number(html.find('[name="mod"]').val());
|
|
const tearing = html.find('[name="tear"]')[0].checked;
|
|
const proven = html.find('[name="prov"]')[0].checked ? Number(html.find('[name="provV"]').val()) : 0;
|
|
const primitive = html.find('[name="prim"]')[0].checked ? Number(html.find('[name="primV"]').val()) : 0;
|
|
// base die (d10) with tearing (best of 2)
|
|
const r1 = await (new Roll("1d10")).roll({async:true});
|
|
const r2 = tearing ? await (new Roll("1d10")).roll({async:true}) : null;
|
|
let die = tearing ? Math.max(r1.total, r2.total) : r1.total;
|
|
// apply Proven/Primitive
|
|
if (proven>0) die = Math.max(die, proven);
|
|
if (primitive>0) die = Math.min(die, primitive);
|
|
const rf = (die===10); // potential Zealous Hatred trigger
|
|
const total = die + mod;
|
|
let flavor = `💥 <b>Damage</b><br/>Die: ${die}${tearing?` (Tearing ${r1.total}/${r2.total.total})`:''} + Mod ${mod} = <b>${total}</b>`;
|
|
if (proven>0) flavor += `<br/>Proven(${proven}) zastosowano`;
|
|
if (primitive>0) flavor += `<br/>Primitive(${primitive}) zastosowano`;
|
|
if (rf) flavor += `<br/><b>⚡ Natural 10</b> — rozważ Zealous Hatred.`;
|
|
ChatMessage.create({speaker: ChatMessage.getSpeaker(), content: flavor});
|
|
}}
|
|
}
|
|
}).render(true);
|
|
|