Files
foundryvtt-wh4-lang-fr-fr/scripts/zL7ECmBBMAqf5Esn.js

30 lines
1.1 KiB
JavaScript

let hasMagazine = await foundry.applications.api.DialogV2.confirm({window : {title : this.effect.name}, content: "<p>Le navire a-t-il un magasin ou tout autre type de réserve pour la poudre noire ?</p>"});
if (!hasMagazine) return;
let roll = new Roll("d10");
await roll.evaluate();
// await roll.toMessage();
let anchor = roll.toAnchor();
let crits = [];
for (let i = 0; i < roll.total; i++) {
let result = await WFRP_Tables.rollTable('crithull');
let collection = game.packs.get(result.object.documentCollection)
if (collection)
await collection.getDocuments()
if (!collection)
collection = game.items;
let item = collection.get(result.object.documentId)
if (item)
crits.push(item);
}
const items = await this.actor.createEmbeddedDocuments("Item", crits);
const speaker = ChatMessage.getSpeaker({actor: this.actor});
const uuids = items.map(i => `@UUID[${i.uuid}]`);
this.script.message(`<p><b>${this.item.name}</b> provoque un nombre supplémentaire de ${anchor.outerHTML} Coups Critiques à la Coque!</p><ul><li>${uuids.join('<li>')}</ul>`)