2024-05-16 17:57:51 +02:00
|
|
|
let choice1 = [
|
2024-05-17 12:46:44 +02:00
|
|
|
{
|
|
|
|
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
|
|
|
]
|
|
|
|
let choice2 = [
|
2024-05-17 12:46:44 +02:00
|
|
|
{
|
|
|
|
type: "armour",
|
|
|
|
name: "Chausses de Mailles"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: "armour",
|
|
|
|
name: "Cotte de Mailles"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: "armour",
|
|
|
|
name: "Coiffe de Mailles"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: "armour",
|
|
|
|
name: "Jambières de Cuir"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: "armour",
|
|
|
|
name: "Calotte de Cuir"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: "armour",
|
|
|
|
name: "Veste de Cuir"
|
|
|
|
},
|
2024-05-16 17:57:51 +02:00
|
|
|
]
|
|
|
|
let choice3 = [
|
2024-05-17 12:46:44 +02:00
|
|
|
{
|
|
|
|
type: "armour",
|
|
|
|
name: "Plastron d'acier"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: "armour",
|
|
|
|
name: "Brassards"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: "armour",
|
|
|
|
name: "Heaume"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: "armour",
|
|
|
|
name: "Jambières d'acier"
|
|
|
|
},
|
2024-05-16 17:57:51 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
let choice = await new Promise((resolve, reject) => {
|
2024-05-17 12:46:44 +02:00
|
|
|
new Dialog({
|
|
|
|
title: "Choix",
|
|
|
|
content:
|
|
|
|
`<p>
|
|
|
|
Selectionnez votre choix
|
2024-05-16 17:57:51 +02:00
|
|
|
</p>
|
|
|
|
<ol>
|
2024-05-17 12:46:44 +02:00
|
|
|
<li>Mailles</li>
|
|
|
|
<li>Mailles & Cuir</li>
|
|
|
|
<li>Plates</li>
|
2024-05-16 17:57:51 +02:00
|
|
|
</ol>
|
|
|
|
`,
|
2024-05-17 12:46:44 +02:00
|
|
|
buttons: {
|
|
|
|
1: {
|
|
|
|
label: "Mailles",
|
|
|
|
callback: () => {
|
|
|
|
resolve(choice1)
|
2024-05-16 17:57:51 +02:00
|
|
|
}
|
2024-05-17 12:46:44 +02:00
|
|
|
},
|
|
|
|
2: {
|
|
|
|
label: "Mailles & Cuir",
|
|
|
|
callback: () => {
|
|
|
|
resolve(choice2)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
3: {
|
|
|
|
label: "Plates",
|
|
|
|
callback: () => {
|
|
|
|
resolve(choice3)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}).render(true)
|
|
|
|
})
|
2024-05-16 17:57:51 +02:00
|
|
|
|
|
|
|
let updateObj = this.actor.toObject();
|
|
|
|
let items = []
|
2024-05-17 12:46:44 +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-05-17 12:46:44 +02:00
|
|
|
}
|
2024-05-16 17:57:51 +02:00
|
|
|
|
2024-05-17 12:46:44 +02:00
|
|
|
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 || {})))
|
2024-05-16 17:57:51 +02:00
|
|
|
}
|
2024-05-17 12:46:44 +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);
|
|
|
|
|
2024-05-17 12:46:44 +02:00
|
|
|
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
|
2024-05-16 17:57:51 +02:00
|
|
|
}
|