Correction sur les liens de jets de dés

- correction jet de rêve actuel
- utilisation du personnage du joueur
This commit is contained in:
2025-01-11 18:59:22 +01:00
parent 792558ac84
commit 551438f514
3 changed files with 21 additions and 4 deletions

View File

@ -3,6 +3,7 @@ import { RdDCarac } from "../rdd-carac.js";
import { SystemCompendiums } from "../settings/system-compendiums.js";
import { RdDItemCompetence } from "../item-competence.js";
import { ACTOR_TYPES } from "../item.js";
import { RdDUtility } from "../rdd-utility.js";
const REGEXP_ROLL_CARAC_COMP = "(?<carac>[A-Za-zÀ-ÖØ-öø-ÿ\\s\\-]+)(\\/(?<competence>[A-Za-zÀ-ÖØ-öø-ÿ\\s\\-]+))?(/(?<diff>[\\+\\-]?\\d+))?"
const XREGEXP_ROLL_CARAC_COMP = XRegExp("@roll\\[" + REGEXP_ROLL_CARAC_COMP + "\\]", 'giu')
@ -29,11 +30,22 @@ class TextRollCaracCompetence {
const diff = event.currentTarget.attributes['data-diff']?.value
const path = RdDCarac.caracDetails(caracCode)?.path
const actors = actor ? [actor] : canvas.tokens.controlled.map(it => it.actor).filter(it => it)
const actors = TextRollCaracCompetence.getSelectedActors(actor)
actors.filter(it => foundry.utils.getProperty(it, path) != undefined)
.forEach(it => it.doRollCaracCompetence(caracCode, competence, diff))
}
}
static getSelectedActors(actor) {
const selected = canvas.tokens.controlled.map(it => it.actor).filter(it => it)
if (selected.length > 0){
return selected
}
actor = actor ?? RdDUtility.getSelectedActor()
if (actor) {
return [actor]
}
return []
}
constructor(text, competences) {
this.text = text

View File

@ -77,7 +77,7 @@ export class RdDCarac {
static caracDetails(name) {
let entry = Misc.findFirstLike(name, LIST_CARAC_ROLL, { mapper: it => it.code, description: 'caractéristique', onMessage: m => { } })
if (entry && entry.length > 0) {
if (entry) {
return entry
}
return Misc.findFirstLike(name, LIST_CARAC_ROLL, { mapper: it => it.label, description: 'caractéristique' })