if (!this.item.name.includes("(") || this.item.system.tests.value.includes("Terrain") || this.item.system.tests.value.toLowerCase().includes("(any)")) { let tests = this.item.system.tests.value let name = this.item.name // If name already specifies, make sure Tests value reflects that if (name.includes("(") && !name.toLowerCase().includes("(any)")) { let terrain = name.split("(")[1].split(")")[0] tests = tests.replace("the Terrain", terrain) } else // If no sense specified, provide dialog choice { let choice = await ItemDialog.create(ItemDialog.objectToArray({ coastal: "Littoral", deserts: "Déserts", marshes: "Marécages", rocky: "Rocailleux", tundra: "Toundra", woodlands: "Régions boisées" }, this.item.img), 1, "Choisissez un Terrain"); if (choice[0]) { name = `${name.split("(")[0].trim()} (${choice[0].name})` tests = tests.replace("Terrain", choice[0].name + " Terrain") } } this.effect.updateSource({ name }) this.item.updateSource({ name, "system.tests.value": tests }) }