44 lines
1.2 KiB
JavaScript
44 lines
1.2 KiB
JavaScript
new foundry.applications.api.DialogV2({
|
|
window: { title: "Damage Roll Configuration" },
|
|
content: `
|
|
<form>
|
|
<div class="form-group">
|
|
<label>Damage Roll:</label>
|
|
<input type="text" name="damageRoll" value="2d4x" />
|
|
</div>
|
|
<div class="form-group">
|
|
<label>AP:</label>
|
|
<input type="number" name="ap" value="0" />
|
|
</div>
|
|
<div class="form-group">
|
|
<label>Flavor:</label>
|
|
<input type="text" name="flavor" value="" />
|
|
</div>
|
|
</form>
|
|
`,
|
|
buttons: [
|
|
{
|
|
action: "ok",
|
|
label: "Roll Damage",
|
|
callback: (event, button, dialog) => {
|
|
const form = new foundry.applications.ux.FormDataExtended(button.form);
|
|
console.log(form)
|
|
const damageRoll = form.object.damageRoll;
|
|
let flavor = form.object.flavor;
|
|
const ap = parseInt(form.object.ap) || 0;
|
|
const options = {};
|
|
if (ap > 0) {
|
|
flavor = `${flavor ? flavor + " - " : ""}AP: ${ap}`
|
|
options.ap = ap;
|
|
}
|
|
// Perform the damage roll and send the message
|
|
new CONFIG.Dice.DamageRoll(damageRoll, null, options).toMessage({ flavor });
|
|
},
|
|
},
|
|
{
|
|
action: "cancel",
|
|
label: "Cancel",
|
|
},
|
|
],
|
|
}).render(true);
|