43 lines
1.2 KiB
JavaScript
43 lines
1.2 KiB
JavaScript
const requestFearRollFromTokens = game.modules.get('swade-mb-helpers').api.requestFearRollFromTokens;
|
|
|
|
async function main() {
|
|
let tokens = Array.from(game.user.targets);
|
|
if (tokens.length < 1) {
|
|
tokens = canvas.tokens.controlled;
|
|
}
|
|
if (tokens.length < 1) {
|
|
ui.notifications.error('Please target or select some tokens');
|
|
return;
|
|
}
|
|
|
|
new foundry.applications.api.DialogV2({
|
|
window: { title: 'Request Fear roll...' },
|
|
content: `
|
|
<form>
|
|
<p>Requesting Fear roll from ${tokens.map((t) => t.name).join(', ')}.</p>
|
|
<div class="form-group">
|
|
<label>Fear Check Penalty
|
|
<input type="number" value="0" name="fear">
|
|
</label>
|
|
</div>
|
|
</form>`,
|
|
buttons: [
|
|
{
|
|
action: "submit",
|
|
label: 'Request Roll',
|
|
callback: (event, button, dialog) => {
|
|
formdata = new foundry.applications.ux.FormDataExtended(button.form).object
|
|
const fear = parseInt(formdata.fear) || 0;
|
|
const options = { targetNumber: 4, fear };
|
|
requestFearRollFromTokens(tokens, options);
|
|
},
|
|
},
|
|
{
|
|
action: "cancel", label: 'Cancel',
|
|
},
|
|
],
|
|
}).render(true);
|
|
}
|
|
|
|
main();
|