added dialogue for modifying damage rolls
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { sendPercentileTestToChat, sendLethalityTestToChat, sendDamageRollToChat, showModifyPercentileTestDialogue } from "../roll/roll.js"
|
||||
import { sendPercentileTestToChat, sendLethalityTestToChat, sendDamageRollToChat, showModifyPercentileTestDialogue, showModifyDamageRollDialogue } from "../roll/roll.js"
|
||||
/**
|
||||
* Extend the basic ActorSheet with some very simple modifications
|
||||
* @extends {ActorSheet}
|
||||
@@ -344,7 +344,7 @@ export class DeltaGreenActorSheet extends ActorSheet {
|
||||
|
||||
if(isDamageRoll){
|
||||
if(requestedModifyRoll){
|
||||
// TO DO: Damage roll modifier dialogue
|
||||
showModifyDamageRollDialogue(this.actor, label, dataset.roll);
|
||||
}
|
||||
else{
|
||||
sendDamageRollToChat(this.actor, label, dataset.roll);
|
||||
@@ -362,7 +362,6 @@ export class DeltaGreenActorSheet extends ActorSheet {
|
||||
else{
|
||||
sendPercentileTestToChat(this.actor, label, targetVal);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user