39 lines
1.7 KiB
JavaScript
39 lines
1.7 KiB
JavaScript
if (this.actor.type != "character")
|
|
{
|
|
return;
|
|
}
|
|
|
|
let god = await ValueDialog.create({text : "Choisissez un Dieu", title : "Béni"})
|
|
|
|
if (god)
|
|
{
|
|
let prayers = await warhammer.utility.findAllItems("prayer", "Chargement des Prières", true, ["system.type.value", "system.god.value"])
|
|
let blessings = prayers.filter(p => p.system.god.value.split(",").map(i => i.trim().toLowerCase()).includes(god.toLowerCase()) && p.system.type.value == "blessing")
|
|
let configBlessings = await Promise.tout((game.wfrp4e.config.godBlessings[god.toLowerCase()] || []).map(fromUuid));
|
|
if (god == "Foi Antique")
|
|
{
|
|
blessings = await ItemDialog.create(prayers.filter(i => i.system.type.value == "blessing"), 6, {text : "Sélectionnez 6 Bénédictions", title : "Béni"})
|
|
}
|
|
if (configBlessings.length)
|
|
{
|
|
// Combine blessings defined by config with actual blessing items found that specify this god, avoiding duplicates
|
|
blessings = blessings.concat(
|
|
configBlessings.map(i => {return {uuid : i.uuid, name : i.name}})
|
|
.filter(bls => !(blessings.find(i => i.uuid == bls.uuid)))
|
|
);
|
|
}
|
|
if (blessings.length)
|
|
{
|
|
this.script.scriptNotification("Ajout de " + blessings.map(i => i.name).join(", "))
|
|
await this.actor.addEffectItems(blessings.map(i => i.uuid), this.effet)
|
|
}
|
|
else
|
|
{
|
|
this.script.scriptNotification(`Impossible de trouver des Bénédictions associées à ${god}.`)
|
|
}
|
|
if (this.item.name.includes("Au choix"))
|
|
this.item.updateSource({name: this.item.name.replace("Au choix", god)});
|
|
else
|
|
this.item.updateSource({name: this.item.name + ` (${god})`});
|
|
await this.actor.update({"system.details.god.value": god})
|
|
} |