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

128 lines
2.5 KiB
JavaScript
Raw Normal View History

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