2024-05-16 17:57:51 +02:00
|
|
|
let choice1 = [
|
|
|
|
{
|
|
|
|
type : "skill",
|
2024-10-08 20:52:09 +02:00
|
|
|
name : "Melee (Basic)",
|
2024-05-16 17:57:51 +02:00
|
|
|
diff : {
|
|
|
|
system : {
|
|
|
|
advances : {
|
|
|
|
value : 10
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
let choice2 = [
|
|
|
|
{
|
|
|
|
type : "skill",
|
2024-10-08 20:52:09 +02:00
|
|
|
name : "Melee (Polearm)",
|
2024-05-16 17:57:51 +02:00
|
|
|
diff : {
|
|
|
|
system : {
|
|
|
|
advances : {
|
|
|
|
value : 10
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
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>Melee (Basic)</li>
|
|
|
|
<li>Melee (Polearm)</li>
|
2024-05-16 17:57:51 +02:00
|
|
|
</ol>
|
|
|
|
`,
|
|
|
|
buttons : {
|
|
|
|
1 : {
|
|
|
|
label : "Basic",
|
|
|
|
callback : () => {
|
|
|
|
return choice1;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
2 : {
|
2024-10-08 20:52:09 +02:00
|
|
|
label : "Polearm",
|
2024-05-16 17:57:51 +02:00
|
|
|
callback : () => {
|
|
|
|
return choice2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
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
|
2024-05-17 01:07:37 +02:00
|
|
|
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);
|