From 7e736a00d7fbcbb86270d607317e7d2f5b798eb9 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Sat, 11 Jan 2025 02:19:56 +0100 Subject: [PATCH] Gestion des blocs secrets dans les descriptions --- changelog.md | 1 + module/actor-sheet.js | 4 ++-- module/actor/base-actor-sheet.js | 4 ++-- module/apps/rdd-text-roll.js | 8 ++++++-- module/item-sheet.js | 18 +++++++++--------- module/rdd-main.js | 2 +- module/rdd-utility.js | 2 +- 7 files changed, 22 insertions(+), 17 deletions(-) diff --git a/changelog.md b/changelog.md index 42d945b1..0901f10d 100644 --- a/changelog.md +++ b/changelog.md @@ -3,6 +3,7 @@ - on peut ajouter des liens "jet de dés" dans les descriptions, notes, ... - les liens "jet de dés" peuvent être utilisés pour un acteur, ou les items de l'acteurs - les liens "jet de dés" d'"un item non lié à un acteur agit sur les tokens sélectionnés +- gestion des blocs secrets dans les descriptions ## 12.0.33 - la vieillesse d'Astrobazzarh - retour de l'expérience pour les joueurs diff --git a/module/actor-sheet.js b/module/actor-sheet.js index c96dfc13..257835ab 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -45,8 +45,8 @@ export class RdDActorSheet extends RdDBaseActorSangSheet { cssClass: this.isEditable ? "editable" : "locked", limited: this.actor.limited, owner: this.actor.isOwner, - biographie: await RdDTextEditor.enrichHTML(this.actor.system.biographie), - notes: await RdDTextEditor.enrichHTML(this.actor.system.notes), + biographie: await RdDTextEditor.enrichHTML(this.actor.system.biographie, this.actor), + notes: await RdDTextEditor.enrichHTML(this.actor.system.notes, this.actor), }); foundry.utils.mergeObject(formData.calc, { surenc: this.actor.computeMalusSurEncombrement(), diff --git a/module/actor/base-actor-sheet.js b/module/actor/base-actor-sheet.js index 96b13827..c6a3fb7d 100644 --- a/module/actor/base-actor-sheet.js +++ b/module/actor/base-actor-sheet.js @@ -36,8 +36,8 @@ export class RdDBaseActorSheet extends ActorSheet { img: this.actor.img, name: this.actor.name, system: this.actor.system, - description: await RdDTextEditor.enrichHTML(this.actor.system.description), - notesmj: await RdDTextEditor.enrichHTML(this.actor.system.notesmj), + description: await RdDTextEditor.enrichHTML(this.actor.system.description, this.actor), + notesmj: await RdDTextEditor.enrichHTML(this.actor.system.notesmj, this.actor), options: RdDSheetUtility.mergeDocumentRights(this.options, this.actor, this.isEditable), effects: this.actor.effects } diff --git a/module/apps/rdd-text-roll.js b/module/apps/rdd-text-roll.js index bb9beb11..0dd65f91 100644 --- a/module/apps/rdd-text-roll.js +++ b/module/apps/rdd-text-roll.js @@ -7,10 +7,14 @@ import { ACTOR_TYPES } from "../item.js"; const XREGEXP_ROLL = XRegExp("@roll\\[(?[A-Za-zÀ-ÖØ-öø-ÿ\\s\\-]+)(\\/(?[A-Za-zÀ-ÖØ-öø-ÿ\\s\\-]+))?(/(?[\\+\\-]?\\d+))?\\]", 'giu') export class RdDTextEditor { - static async enrichHTML(text) { + static async enrichHTML(text, object) { const rddTextEditor = new RdDTextEditor(text) const replacedRolls = await rddTextEditor.replaceRolls() - return await TextEditor.enrichHTML(replacedRolls, { async: true }) + return await TextEditor.enrichHTML(replacedRolls, { + relativeTo: object, + secrets: object?.isOwner, + async: true + }) } constructor(text) { diff --git a/module/item-sheet.js b/module/item-sheet.js index 90c3c339..3f2b6bde 100644 --- a/module/item-sheet.js +++ b/module/item-sheet.js @@ -98,8 +98,8 @@ export class RdDItemSheet extends ItemSheet { name: this.item.name, system: this.item.system, actorId: this.actor?.id, - description: await RdDTextEditor.enrichHTML(this.item.system.description), - descriptionmj: await RdDTextEditor.enrichHTML(this.item.system.descriptionmj), + description: await RdDTextEditor.enrichHTML(this.item.system.description, this.item), + descriptionmj: await RdDTextEditor.enrichHTML(this.item.system.descriptionmj, this.item), isComestible: this.item.getUtilisationCuisine(), options: RdDSheetUtility.mergeDocumentRights(this.options, this.item, this.isEditable), competences: await SystemCompendiums.getCompetences(ACTOR_TYPES.personnage), @@ -121,18 +121,18 @@ export class RdDItemSheet extends ItemSheet { formData.competences = formData.competences.filter(it => it.isCompetenceArme()) } if (this.item.type == ITEM_TYPES.recettecuisine) { - formData.ingredients = await RdDTextEditor.enrichHTML(this.object.system.ingredients) + formData.ingredients = await RdDTextEditor.enrichHTML(this.item.system.ingredients, this.item) } if (this.item.type == ITEM_TYPES.extraitpoetique) { - formData.extrait = await RdDTextEditor.enrichHTML(this.object.system.extrait) - formData.texte = await RdDTextEditor.enrichHTML(this.object.system.texte) + formData.extrait = await RdDTextEditor.enrichHTML(this.item.system.extrait, this.item) + formData.texte = await RdDTextEditor.enrichHTML(this.item.system.texte, this.item) } if (this.item.type == ITEM_TYPES.recettealchimique) { const manipulation = RdDAlchimie.processManipulation(this.item, this.actor?.id); - formData.manipulation = await RdDTextEditor.enrichHTML(manipulation) - formData.utilisation = await RdDTextEditor.enrichHTML(this.object.system.utilisation) - formData.enchantement = await RdDTextEditor.enrichHTML(this.object.system.enchantement) - formData.sureffet = await RdDTextEditor.enrichHTML(this.object.system.sureffet) + formData.manipulation = await RdDTextEditor.enrichHTML(manipulation, this.item) + formData.utilisation = await RdDTextEditor.enrichHTML(this.item.system.utilisation, this.item) + formData.enchantement = await RdDTextEditor.enrichHTML(this.item.system.enchantement, this.item) + formData.sureffet = await RdDTextEditor.enrichHTML(this.item.system.sureffet, this.item) } if (this.item.type == ITEM_TYPES.gemme) { formData.gemmeTypeList = RdDGemme.getGemmeTypeOptionList(); diff --git a/module/rdd-main.js b/module/rdd-main.js index 15181c78..5e93c66b 100644 --- a/module/rdd-main.js +++ b/module/rdd-main.js @@ -128,7 +128,7 @@ export class SystemReveDeDragon { console.log(`Initializing Reve de Dragon System Settings`) // preload handlebars templates - RdDUtility.preloadHandlebarsTemplates() + await RdDUtility.preloadHandlebarsTemplates() AppPersonnageAleatoire.preloadHandlebars() RdDItemSort.preloadHandlebars() diff --git a/module/rdd-utility.js b/module/rdd-utility.js index 7dc4774a..85cff4ba 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -339,7 +339,7 @@ export class RdDUtility { Handlebars.registerHelper('typeTmr-name', type => TMRUtility.typeTmrName(type)); Handlebars.registerHelper('effetRencontre-name', coord => TMRUtility.typeTmrName(coord)); - return loadTemplates(templatePaths); + await loadTemplates(templatePaths); } static getItem(itemId, actorId = undefined) {