added dialogue for modifying damage rolls

This commit is contained in:
The Last Scrub
2020-11-28 21:33:44 -08:00
parent d0f7d90d09
commit 83574242f0
6 changed files with 103 additions and 6 deletions
+52
View File
@@ -233,4 +233,56 @@ export function sendPercentileTestToChat(actor, skill, target){
}
}
).render(true);
}
export async function showModifyDamageRollDialogue(actor, label, originalFormula){
let template = "systems/deltagreen/templates/dialog/modify-damage-roll.html";
let backingData = {
data:{
label: label,
originalFormula: originalFormula,
outerModifier: "2 * ",
innerModifier: "+ 0"
},
};
let html = await renderTemplate(template, backingData);
new Dialog({
content: html,
title: game.i18n.localize("DG.ModifySkillRollDialogue.Title"),
default: "roll",
buttons: {
roll:{
label: game.i18n.translations.DG.Roll.Roll,
callback: html => {
try{
let outerModifier = html.find("[name='outerModifier']").val(); // this is text as a heads up
let innerModifier = html.find("[name='innerModifier']").val(); // this is text as a heads up
let modifiedBaseRoll = html.find("[name='originalFormula']").val(); // this is text as a heads up
if(innerModifier.replace(" ", "") === "+0"){
innerModifier = "";
}
let newRoll = "";
if(outerModifier.trim() != ""){
newRoll += outerModifier + "(" + modifiedBaseRoll + innerModifier.trim() + ")";
}
else{
newRoll += modifiedBaseRoll + innerModifier.trim();
}
sendDamageRollToChat(actor, label, newRoll);
}
catch(ex){
console.log(ex);
}
}
}
}
}
).render(true);
}