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

85 lines
1.8 KiB
JavaScript
Raw Permalink Normal View History

2024-05-16 17:57:51 +02:00
let choice1 = [
2024-10-08 20:52:09 +02:00
{
type : "skill",
name : "Projectiles (Arc)",
diff : {
system : {
advances : {
value : 10
}
}
2024-05-16 17:57:51 +02:00
}
2024-10-08 20:52:09 +02:00
},
{
type : "weapon",
name : "Longbow",
},
{
type : "ammunition",
name : "Arrow",
2024-05-16 17:57:51 +02:00
}
]
let choice2 = [
]
let choice = await Dialog.wait({
2024-10-08 20:52:09 +02:00
title : "Option",
content :
2024-05-16 17:57:51 +02:00
`<p>
2024-10-08 20:52:09 +02:00
Ajouter une option?
2024-05-16 17:57:51 +02:00
</p>
<ol>
2024-10-08 20:52:09 +02:00
<li>Projectiles (Arc) +10 et un Arc Long avec 12 flèches</li>
2024-05-16 17:57:51 +02:00
</ol>
`,
2024-10-08 20:52:09 +02:00
buttons : {
1 : {
label : "Yes",
callback : () => {
return choice1;
}
},
2 : {
label : "No",
callback : () => {
return choice2;
}
}
2024-05-16 17:57:51 +02:00
}
})
let updateObj = this.actor.toObject();
let items = []
2024-10-08 20:52:09 +02:00
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
}
2024-05-16 17:57:51 +02:00
}
2024-10-08 20:52:09 +02:00
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})
2024-05-16 17:57:51 +02:00
}
}
await this.actor.update(updateObj)
this.actor.createEmbeddedDocuments("Item", items);