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

115 lines
2.6 KiB
JavaScript
Raw Permalink Normal View History

2024-05-16 17:57:51 +02:00
let choice1 = [
{
type : "skill",
name : "Corps à corps (Base)",
2024-05-16 17:57:51 +02:00
diff : {
system : {
advances : {
value : 20
}
}
}
}
]
let choice2 = [
{
type : "skill",
name : "Corps à corps (Armes d'hast)",
2024-05-16 17:57:51 +02:00
diff : {
system : {
advances : {
value : 20
}
}
}
}
]
let choice3 = [
{
type : "skill",
name : "Corps à corps (A deux mains)",
2024-05-16 17:57:51 +02:00
diff : {
system : {
advances : {
value : 20
}
}
}
}
]
let choice = await Dialog.wait({
title : "Choice",
content :
`<p>
Faites un choix
2024-05-16 17:57:51 +02:00
</p>
<ol>
<li>Corps à corps (Base)</li>
<li>Corps à corps (Armes d'hast)</li>
<li>Corps à corps (A deux mains)</li>
2024-05-16 17:57:51 +02:00
</ol>
`,
buttons : {
1 : {
label : "Base",
2024-05-16 17:57:51 +02:00
callback : () => {
return choice1
}
},
2 : {
label : "Armes d'hast",
2024-05-16 17:57:51 +02:00
callback : () => {
return choice2
}
},
3 : {
label : "A deux mains",
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);
2024-06-06 22:46:40 +02:00
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);
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
}