Support difficulté numérique
This commit is contained in:
parent
6de19eb357
commit
5ac9c682d9
@ -1,5 +1,4 @@
|
||||
import "../xregexp-all.js";
|
||||
import { ACTOR_TYPES } from "../../item.js";
|
||||
import { RdDCarac } from "../../rdd-carac.js";
|
||||
import { RdDItemCompetence } from "../../item-competence.js";
|
||||
import { RdDUtility } from "../../rdd-utility.js";
|
||||
@ -8,7 +7,6 @@ import { TextRollManager } from "./text-roll-formatter.js";
|
||||
const REGECP_CARAC = "(?<carac>[A-Za-zÀ-ÖØ-öø-ÿ\\s\\-]+)"
|
||||
const REGEXP_COMP = "(\\/(?<competence>[A-Za-zÀ-ÖØ-öø-ÿ\\s\\-]+))?"
|
||||
const REGEXP_DIFF = "(/(?<diff>[\\+\\-]?\\d+(d\\d+)?))?"
|
||||
const REGEX_DICE_DIFF = /[\+\-]?\d+d\d+/;
|
||||
const REGEXP_ROLL_CARAC_COMP = REGECP_CARAC + REGEXP_COMP + REGEXP_DIFF
|
||||
const XREGEXP_ROLL_CARAC_COMP = XRegExp("@roll\\[" + REGEXP_ROLL_CARAC_COMP + "\\]", 'giu')
|
||||
|
||||
@ -38,7 +36,7 @@ export class TextRollCaracCompetence {
|
||||
|
||||
async calculDiff(node) {
|
||||
const diff = node.data('diff') ?? 0
|
||||
if (diff.match(REGEX_DICE_DIFF)) {
|
||||
if (!Number.isInteger(diff)) {
|
||||
const roll = new Roll(diff)
|
||||
await roll.evaluate()
|
||||
await roll.toMessage({ flavor: `La difficulté de ${diff} a donné ${roll.total}` })
|
||||
|
Loading…
x
Reference in New Issue
Block a user