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

43 lines
1.4 KiB
JavaScript
Raw Permalink Normal View History

2024-05-16 17:57:51 +02:00
let caster = this.effect.sourceActor
let targetedItem = this.actor.items.get(this.effect.flags.wfrp4e.itemTargets[0])
let qualities = foundry.utils.deepClone(game.wfrp4e.config.itemQualities);
let flaws = foundry.utils.deepClone(game.wfrp4e.config.itemFlaws);
if (targetedItem.type == "weapon")
{
mergeObject(qualities, game.wfrp4e.config.weaponQualities)
mergeObject(flaws, game.wfrp4e.config.weaponFlaws)
}
else if (targetedItem.type == "armour")
{
mergeObject(qualities, game.wfrp4e.config.armorQualities)
mergeObject(flaws, game.wfrp4e.config.armorFlaws)
}
for(let q in qualities)
{
// If the weapon already has a flaw, don't put it in the dialog
if (targetedItem.system.properties.qualities[q])
{
delete qualities[q]
}
}
for(let f in flaws)
{
// If a weapon doesn't have a flaw, don't put it in the dialog
if (!targetedItem.system.properties.flaws[f])
{
delete flaws[f]
}
}
let added = await ItemDialog.create(ItemDialog.objectToArray(qualities), "unlimited", "Choisissez la Qualité à ajouter");
2024-05-16 17:57:51 +02:00
let removed = []
if (!foundry.utils.isEmpty(flaws))
{
removed = await ItemDialog.create(ItemDialog.objectToArray(flaws), "unlimited", "Choisissez le Défaut à enlever");
2024-05-16 17:57:51 +02:00
}
this.effect.updateSource({"flags.wfrp4e.propertiesChanged" : {added : added.map(i => i.id), removed : removed.map(i => i.id)}})