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

29 lines
970 B
JavaScript

if (this.item.name.includes("("))
{
let trade = this.item.parenthesesText;
if (trade?.toLowerCase() != "any")
return this.item.updateSource({"system.tests.value" : this.item.system.tests.value.replace("any one", trade)})
}
let index = game.packs
.filter(i => i.metadata.type == "Item")
.reduce((acc, pack) => acc.concat(pack.index.contents), [])
.filter(i => i.type == "skill" && i.name.includes(game.i18n.localize("NAME.Trade")))
.map(i => {
i.id = i._id
return i
})
let choice = await ItemDialog.create(index, 1, "Choose a Trade Skill")
let text;
if (!choice[0])
{
let custom = await ValueDialog.create("Enter Custom Trade Skill", "Custom Trade");
text = custom || ""
}
else
{
text = game.wfrp4e.utility.extractParenthesesText(choice[0].name)
}
await this.item.updateSource({name : this.item.name.replace("(Any)", "").replace("(any)", "").trim() + ` (${text})`, "system.tests.value" : this.item.system.tests.value.replace("any one", text)});