mirror of
https://github.com/migatu/conjurer.git
synced 2026-07-14 21:38:38 +00:00
28 lines
1.3 KiB
JavaScript
28 lines
1.3 KiB
JavaScript
// 🩹 Toggle conditions on selected tokens (Foundry v13)
|
|
const choices = [
|
|
{id:"fatigued", label:"Fatigued"},
|
|
{id:"stunned", label:"Stunned"},
|
|
{id:"prone", label:"Prone"},
|
|
{id:"frightened", label:"Frightened (Fear)"}
|
|
];
|
|
const opts = choices.map(c=>`<label><input type="checkbox" name="c" value="${c.id}"> ${c.label}</label>`).join("<br/>");
|
|
new Dialog({
|
|
title:"🩹 Conditions",
|
|
content:`<form>${opts}<div class="form-group"><label>Mode</label>
|
|
<select name="mode"><option value="toggle">Toggle</option><option value="on">Apply</option><option value="off">Remove</option></select></div></form>`,
|
|
buttons:{
|
|
go:{label:"Apply",callback: html=>{
|
|
const ids = Array.from(html.find('input[name="c"]:checked')).map(e=>e.value);
|
|
const mode = html.find('[name="mode"]').val();
|
|
const getEf = id => CONFIG.statusEffects.find(e=>e.id===id) ?? {id};
|
|
canvas.tokens.controlled.forEach(t=>{
|
|
ids.forEach(id=>{
|
|
if (mode==="toggle") t.toggleEffect(getEf(id));
|
|
else if (mode==="on") t.actor?.effects?.some(e=>e.getFlag("core","statusId")===id) ? null : t.toggleEffect(getEf(id));
|
|
else if (mode==="off") t.actor?.effects?.some(e=>e.getFlag("core","statusId")===id) ? t.toggleEffect(getEf(id)) : null;
|
|
});
|
|
});
|
|
}}
|
|
}
|
|
}).render(true);
|
|
|