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

133 lines
2.6 KiB
JavaScript
Raw Permalink Normal View History

2024-05-16 17:57:51 +02:00
let choice1 = [
{
type : "armour",
name : "Chausses de Mailles"
2024-05-16 17:57:51 +02:00
},
{
type : "armour",
name : "Cotte de Mailles"
2024-05-16 17:57:51 +02:00
},
{
type : "armour",
name : "Coiffe de Mailles"
2024-05-16 17:57:51 +02:00
},
]
let choice2 = [
{
type : "armour",
name : "Chausses de Mailles"
},
{
type : "armour",
name : "Cotte de Mailles"
},
{
type : "armour",
name : "Coiffe de Mailles"
},
{
2024-05-16 17:57:51 +02:00
type : "armour",
name : "Jambières de Cuir"
2024-05-16 17:57:51 +02:00
},
{
type : "armour",
name : "Calotte de Cuir"
2024-05-16 17:57:51 +02:00
},
{
type : "armour",
name : "Veste de Cuir"
2024-05-16 17:57:51 +02:00
},
]
let choice3 = [
{
type : "armour",
name : "Plastron d'acier"
2024-05-16 17:57:51 +02:00
},
{
type : "armour",
name : "Brassards"
2024-05-16 17:57:51 +02:00
},
{
type : "armour",
name : "Heaume"
2024-05-16 17:57:51 +02:00
},
{
type : "armour",
name : "Jambières d'acier"
2024-05-16 17:57:51 +02:00
},
]
let choice = await Dialog.wait({
title : "Choix",
2024-05-16 17:57:51 +02:00
content :
`<p>
Sélectionnez votre choix
2024-05-16 17:57:51 +02:00
</p>
<ol>
<li>Mailles</li>
<li>Mailles & Cuir</li>
<li>Plates</li>
2024-05-16 17:57:51 +02:00
</ol>
`,
buttons : {
1 : {
label : "Mailles",
2024-05-16 17:57:51 +02:00
callback : () => {
return choice1
}
},
2 : {
label : "Mailles & Cuir",
2024-05-16 17:57:51 +02:00
callback : () => {
return choice2
}
},
3 : {
label : "Plates",
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)
{
item = item.toObject()
equip(item);
items.push(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);
function equip(item)
{
if (item.type == "armour")
item.system.worn.value = true
else if (item.type == "weapon")
item.system.equipped = true
else if (item.type == "trapping" && item.system.trappingType.value == "clothingAccessories")
item.system.worn = true
}