Fix v12 warnings

This commit is contained in:
2024-06-06 22:46:40 +02:00
parent 2c5ff15830
commit 8a5c62fafd
14 changed files with 96 additions and 107 deletions

View File

@@ -1,30 +1,30 @@
let choice1 = [
{
type : "skill",
name : "Projectiles (Arc)",
diff : {
system : {
advances : {
value : 10
}
}
{
type: "skill",
name: "Projectiles (Arc)",
diff: {
system: {
advances: {
value: 10
}
},
{
type : "weapon",
name : "Arc long",
},
{
type : "ammunition",
name : "Flèche",
}
}
},
{
type: "weapon",
name: "Arc long",
},
{
type: "ammunition",
name: "Flèche",
}
]
let choice2 = [
]
let choice = await Dialog.wait({
title : "Option",
content :
title: "Option",
content:
`<p>
Ajouter l'ption?
</p>
@@ -32,59 +32,53 @@ let choice = await Dialog.wait({
<li>Ranged (Bow) +10 and a Longbow with 12 Arrows</li>
</ol>
`,
buttons : {
1 : {
label : "Oui",
callback : () => {
return choice1;
}
},
2 : {
label : "Non",
callback : () => {
return choice2;
}
}
buttons: {
1: {
label: "Oui",
callback: () => {
return choice1;
}
},
2: {
label: "Non",
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
}
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 ${talent}`, {permanent : true})
if (!existing) {
let item = await game.wfrp4e.utility.find(c.name, c.type)
if (item) {
item = item.toObject()
equip(item);
items.push(foundry.utils.mergeObject(item, (c.diff || {})))
}
else
ui.notifications.warn(`Impossible de trouver ${talent}`, { permanent: true })
}
}
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
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
}