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

130 lines
2.7 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 : "armour",
name : "Mail Chausses"
},
{
type : "armour",
name : "Mail Coat"
},
{
type : "armour",
name : "Mail Coif"
},
2024-05-16 17:57:51 +02:00
]
let choice2 = [
2024-10-08 20:52:09 +02:00
{
type : "armour",
name : "Mail Chausses"
},
{
type : "armour",
name : "Mail Coat"
},
{
type : "armour",
name : "Mail Coif"
},
{
type : "armour",
name : "Leather Leggings"
},
{
type : "armour",
name : "Leather Skullcap"
},
{
type : "armour",
name : "Leather Jack"
},
2024-05-16 17:57:51 +02:00
]
let choice3 = [
2024-10-08 20:52:09 +02:00
{
type : "armour",
name : "Plate Breastplate"
},
{
type : "armour",
name : "Plate Bracers"
},
{
type : "armour",
name : "Plate Helm"
},
{
type : "armour",
name : "Plate Leggings"
},
2024-05-16 17:57:51 +02:00
]
let choice = await new Promise((resolve, reject) => {
2024-10-08 20:52:09 +02:00
new Dialog({
title : "Choice",
content :
`<p>
Select your choice
2024-05-16 17:57:51 +02:00
</p>
<ol>
2024-10-08 20:52:09 +02:00
<li>Mail</li>
<li>Mail & Leather</li>
<li>Plate</li>
2024-05-16 17:57:51 +02:00
</ol>
`,
2024-10-08 20:52:09 +02:00
buttons : {
1 : {
label : "Mail",
callback : () => {
resolve(choice1)
}
},
2 : {
label : "Mail & Leather",
callback : () => {
resolve(choice2)
}
},
3 : {
label : "Plate",
callback : () => {
resolve(choice3)
}
}
2024-05-16 17:57:51 +02:00
}
2024-10-08 20:52:09 +02:00
}).render(true)
})
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 ${c.name}`, {permanent : true})
2024-05-16 17:57:51 +02:00
}
}
await this.actor.update(updateObj)
this.actor.createEmbeddedDocuments("Item", items);