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

75 lines
1.6 KiB
JavaScript

let addOption = await foundry.applications.api.DialogV2.confirm({
window : {title : "Option"},
content :
`
Ajouter une option?
<p>
Projectile (Arc) +10 et un Arc long avec 12 flèches
</p>
`,
})
let choice = []
if (addOption)
{
choice = [
{
type : "skill",
name : "Projectile (Arc)",
diff : {
system : {
advances : {
value : 10
}
}
}
},
{
type : "weapon",
name : "Arc long",
},
{
type : "ammunition",
name : "Flèche",
}
];
}
let updateObj = this.actor.toObject();
let items = []
for (let c of choice)
{
let existing
if (c.type == "skill")
{
existing = updateObj.items.find(i => i.name == c.name && i.type == c.type)
if (existing && c.diff?.system?.advances?.value)
{
existing.system.advances.value += c.diff.system.advances.value
}
}
if (!existing)
{
let item = await game.wfrp4e.utility.find(c.name, c.type)
if (item)
{
let equip = item.system.tags.has("equippable");
item = item.toObject()
if (equip)
{
item.system.equipped.value = true;
}
items.push(foundry.utils.mergeObject(item, (c.diff || {})))
}
else
ui.notifications.warn(`Impossible de trouver ${talent}`, {permanent : true})
}
}
await this.actor.update(updateObj)
this.actor.createEmbeddedDocuments("Item", items);