Gestion des blocs secrets dans les descriptions

This commit is contained in:
Vincent Vandemeulebrouck 2025-01-11 02:19:56 +01:00
parent b87f406093
commit 7e736a00d7
7 changed files with 22 additions and 17 deletions

View File

@ -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

View File

@ -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(),

View File

@ -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
}

View File

@ -7,10 +7,14 @@ import { ACTOR_TYPES } from "../item.js";
const XREGEXP_ROLL = XRegExp("@roll\\[(?<carac>[A-Za-zÀ-ÖØ-öø-ÿ\\s\\-]+)(\\/(?<competence>[A-Za-zÀ-ÖØ-öø-ÿ\\s\\-]+))?(/(?<diff>[\\+\\-]?\\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) {

View File

@ -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();

View File

@ -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()

View File

@ -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) {