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]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-17 01:07:37 +02:00
|
|
|
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))
|
|
|
|
{
|
2024-05-17 01:07:37 +02:00
|
|
|
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)}})
|