foundryvtt-wh4-lang-fr-fr/scripts/IupskvzvoGyD2H5o.js

32 lines
1.3 KiB
JavaScript
Raw Normal View History

2024-05-16 17:57:51 +02:00
if (this.actor.type != "character")
{
return;
}
2024-10-08 20:52:09 +02:00
let god = await ValueDialog.create({text : "Enter a Deity", title : "Blessed"})
2024-05-16 17:57:51 +02:00
if (god)
{
2024-10-08 20:52:09 +02:00
let prayers = await warhammer.utility.findAllItems("prayer", "Loading Prayers")
2024-05-16 17:57:51 +02:00
let blessings = prayers.filter(p => p.system.god.value.split(",").map(i => i.trim().toLowerCase()).includes(god.toLowerCase()) && p.system.type.value == "blessing")
2024-10-08 20:52:09 +02:00
let godBlessings = game.wfrp4e.config.godBlessings[god.toLowerCase()] || [];
if (god == "Old Faith")
{
blessings = await ItemDialog.create(prayers.filter(i => i.system.type.value == "blessing"), 6, {text : "Select any 6 Blessings", title : "Blessed"})
}
if (godBlessings.length)
{
blessings = blessings.concat(await Promise.all(godBlessings.filter(bls => !(blessings.map(i => i.uuid).includes(bls.uuid))).map(fromUuid)));
}
2024-05-16 17:57:51 +02:00
if (blessings.length)
{
2024-10-08 20:52:09 +02:00
this.script.notification("Adding " + blessings.map(i => i.name).join(", "))
2024-05-16 17:57:51 +02:00
await this.actor.createEmbeddedDocuments("Item", blessings, {fromEffect : this.effect.id})
}
else
{
2024-10-08 20:52:09 +02:00
this.script.notification(`Impossible de trouver any Blessings associated with ${god}.`)
2024-05-16 17:57:51 +02:00
}
2024-10-08 20:52:09 +02:00
this.item.updateSource({name : this.item.name.replace("Any", god)})
2024-05-16 17:57:51 +02:00
await this.actor.update({"system.details.god.value": god})
}