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

88 lines
2.4 KiB
JavaScript
Raw Permalink Normal View History

2024-05-16 17:57:51 +02:00
let specification = this.item.system.specification.value;
let choice = [];
if (!specification || specification == "Compétences entraînées")
2024-05-16 17:57:51 +02:00
{
choice = await ItemDialog.create(ItemDialog.objectToArray({
broken: "Dompté",
drive: "Trait",
entertain: "Divertir",
fetch: "Rapporter",
guard: "Garder",
home: "Revenir à la maison",
magic: "Magie",
mount: "Monture",
war: "Guerre"
}, this.effect.img), "unlimited", "Choisissez un Dressage");
2024-05-16 17:57:51 +02:00
}
else
{
choice = specification.split(", ").map(i => {
return {
id : i.toLowerCase(),
name : i
}
});
}
if (choice.length)
{
let changes = foundry.utils.deepClone(this.effect.changes);
for(let training of choice)
{
switch(training.id)
{
case "broken" :
let roll = await new Roll("2d10").roll();
roll.toMessage(this.script.getChatData());
changes.push({value : roll.total, mode : 2, key : "system.characteristics.fel.modifier"})
if (this.actor.type == "creature")
{
let bestial = this.actor.itemTypes.trait.find(i => i.name == "Bestial");
if (bestial)
{
bestial.update({"system.disabled" : true})
}
}
break;
case "drive" :
break;
case "entertain" :
break;
case "fetch" :
break;
case "guard" :
let territorial = await fromUuid("Compendium.wfrp4e-core.items.Item.JIAe7i7dqTQBu4do");
await this.actor.createEmbeddedDocuments("Item", [territorial], {fromEffect: this.effect.id})
setProperty(args, "options.keepId", true);
break;
case "home" :
break;
case "magic" :
break;
case "mount" :
break;
case "war" :
changes.push({value : 10, mode : 2, key : "system.characteristics.ws.modifier"})
break;
}
}
this.effect.updateSource({name : `${this.effect.name} (${choice.map(i => i.name).join(", ")})`, changes, "flags.wfrp4e.trained" : choice.map(i => i.id)})
this.item.updateSource({"system.specification.value" : `${choice.map(i => i.name).join(", ")}`})
}