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

85 lines
1.9 KiB
JavaScript
Raw Normal View History

2024-05-16 17:57:51 +02:00
let choice1 = [
{
type : "skill",
name : "Projectiles (Arc)",
2024-05-16 17:57:51 +02:00
diff : {
system : {
advances : {
value : 10
}
}
}
},
{
type : "weapon",
2024-10-08 20:52:09 +02:00
name : "Bow",
2024-05-16 17:57:51 +02:00
},
{
type : "ammunition",
2024-10-08 20:52:09 +02:00
name : "Arrow",
2024-05-16 17:57:51 +02:00
}
]
let choice2 = [
]
let choice = await Dialog.wait({
title : "Option",
content :
`<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>Ranged (Bow) +10 and a Bow with 12 Arrows</li>
2024-05-16 17:57:51 +02:00
</ol>
`,
buttons : {
1 : {
2024-10-08 20:52:09 +02:00
label : "Yes",
2024-05-16 17:57:51 +02:00
callback : () => {
return choice1
}
},
2 : {
2024-10-08 20:52:09 +02:00
label : "No",
2024-05-16 17:57:51 +02:00
callback : () => {
choice2
}
}
}
})
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)
{
2024-10-08 20:52:09 +02:00
let equip = item.system.tags.has("equippable");
2024-05-16 17:57:51 +02:00
item = item.toObject()
2024-10-08 20:52:09 +02:00
if (equip)
{
item.system.equipped.value = true;
}
items.push(foundry.utils.mergeObject(item, (c.diff || {})))
2024-05-16 17:57:51 +02:00
}
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);