Files
conjurer/rpg/inititative.js
T
gitea a6ed8723a5 Tag: 1.27
Intermediate commits (oldest → newest):
- Merge branch 'main' of https://github.com/migatu/conjurer
- Update AI and librarian commands to use 'GENERAL' context"
- Added the following changes to the codebase:
- bgfx
- fx and upgd
- Latex incoming changes
- installer fix
- var fx
- fx to fx
- don't trust ai
- tectonic
- debug
- debug
- disable exc masking
- upgrade
- rollback
- Figure out
- aaa
2025-10-30 16:59:21 +01:00

12 lines
852 B
JavaScript

// 🚦 Initiative for selected tokens (1d10 + AG Bonus prompt)
if (!canvas.tokens.controlled.length) return ui.notifications.warn("Zaznacz co najmniej jeden token.");
const combat = game.combat ?? await Combat.implementation.create({});
for (const t of canvas.tokens.controlled){
if (!combat.combatants.some(c=>c.tokenId===t.id)) await combat.createEmbeddedDocuments("Combatant",[ {tokenId:t.id, sceneId: canvas.scene.id, hidden:false} ]);
const ag = Number(await Dialog.prompt({title:`AG Bonus for ${t.name}`, content:`<input type="number" value="4">`, label:"OK"}));
const r = await (new Roll(`1d10 + ${ag}`)).roll({async:true});
await combat.setInitiative(combat.combatants.find(c=>c.tokenId===t.id).id, r.total);
r.toMessage({flavor:`🚦 <b>Initiative</b> — ${t.name}: ${r.total}`});
}
ui.notifications.info("Inicjatywy ustawione.");