Fix: lien jets de dés

- les boutons pour envoyer dans le tchat sont affichés
- les jets de carac utilisent bien les compétences et difficulté
This commit is contained in:
Vincent Vandemeulebrouck 2025-01-13 19:24:21 +01:00
parent 135e5e46a0
commit 8406c8434a
3 changed files with 10 additions and 7 deletions

View File

@ -9,16 +9,17 @@ import { TextRollManager } from "./textroll/text-roll-formatter.js";
const TEXT_ROLL_MANAGERS = [ const TEXT_ROLL_MANAGERS = [
new TextRollAlchimie(), new TextRollAlchimie(),
new TextRollCaracCompetence(), new TextRollCaracCompetence(),
new TextRollFormula()]; new TextRollFormula()]
export class RdDTextEditor { export class RdDTextEditor {
static registerChatCallbacks(html) { static registerChatCallbacks(html) {
html.on("click", '.roll-text', async event => await RdDTextEditor.rollText(event)) html.on("click", '.roll-text', async event => await RdDTextEditor.rollText(event))
} }
static async enrichHTML(text, object, options = {}) { static async enrichHTML(text, object, options = {showlink:true}) {
const context = { const context = {
text, object, text,
object,
options, options,
competences: await SystemCompendiums.getCompetences(ACTOR_TYPES.personnage), competences: await SystemCompendiums.getCompetences(ACTOR_TYPES.personnage),
} }
@ -29,7 +30,6 @@ export class RdDTextEditor {
context.text = await manager.onReplaceRoll(context); context.text = await manager.onReplaceRoll(context);
} }
// TEXT_ROLL_MANAGERS.forEach(async manager => await RdDTextEditor._applyReplaceAll(manager, context))
return await TextEditor.enrichHTML(context.text, { return await TextEditor.enrichHTML(context.text, {
relativeTo: object, relativeTo: object,
secrets: object?.isOwner, secrets: object?.isOwner,

View File

@ -5,7 +5,10 @@ import { RdDItemCompetence } from "../../item-competence.js";
import { RdDUtility } from "../../rdd-utility.js"; import { RdDUtility } from "../../rdd-utility.js";
import { TextRollManager } from "./text-roll-formatter.js"; import { TextRollManager } from "./text-roll-formatter.js";
const REGEXP_ROLL_CARAC_COMP = "(?<carac>[A-Za-zÀ-ÖØ-öø-ÿ\\s\\-]+)(\\/(?<competence>[A-Za-zÀ-ÖØ-öø-ÿ\\s\\-]+))?(/(?<diff>[\\+\\-]?\\d+))?" const REGECP_CARAC = "(?<carac>[A-Za-zÀ-ÖØ-öø-ÿ\\s\\-]+)"
const REGEXP_COMP = "(\\/(?<competence>[A-Za-zÀ-ÖØ-öø-ÿ\\s\\-]+))?"
const REGEXP_DIFF = "(/(?<diff>[\\+\\-]?\\d+))?"
const REGEXP_ROLL_CARAC_COMP = REGECP_CARAC + REGEXP_COMP + REGEXP_DIFF
const XREGEXP_ROLL_CARAC_COMP = XRegExp("@roll\\[" + REGEXP_ROLL_CARAC_COMP + "\\]", 'giu') const XREGEXP_ROLL_CARAC_COMP = XRegExp("@roll\\[" + REGEXP_ROLL_CARAC_COMP + "\\]", 'giu')
/** /**

View File

@ -2,8 +2,8 @@
data-code="{{param.code}}" data-code="{{param.code}}"
data-json="{{json-stringify param}}" data-json="{{json-stringify param}}"
data-carac-code="{{param.carac.code}}" data-carac-code="{{param.carac.code}}"
{{#if competence}}data-competence="{{param.competence}}"{{/if~}} {{#if param.competence}}data-competence="{{param.competence}}"{{/if~}}
{{#if diff}}data-diff="{{param.diff}}"{{/if~}}> {{#if param.diff}}data-diff="{{param.diff}}"{{/if~}}>
<a class="roll-text"> <a class="roll-text">
{{~uppercase param.carac.label~}} {{~uppercase param.carac.label~}}
{{#if param.competence}} / {{upperFirst param.competence}}{{/if~}} {{#if param.competence}} / {{upperFirst param.competence}}{{/if~}}