Support des maladresses
This commit is contained in:
@ -12,10 +12,14 @@ const TEXT_ROLL_MANAGERS = [
|
||||
new TextRollFormula()];
|
||||
|
||||
export class RdDTextEditor {
|
||||
static registerChatCallbacks(html) {
|
||||
html.on("click", '.roll-text', async event => await RdDTextEditor.rollText(event))
|
||||
}
|
||||
|
||||
static async enrichHTML(text, object) {
|
||||
static async enrichHTML(text, object, options = {}) {
|
||||
const context = {
|
||||
text, object,
|
||||
options,
|
||||
competences: await SystemCompendiums.getCompetences(ACTOR_TYPES.personnage),
|
||||
}
|
||||
|
||||
@ -59,14 +63,16 @@ export class RdDTextEditor {
|
||||
const param = node.data('json')
|
||||
const manager = TEXT_ROLL_MANAGERS.find(it => it.code == code)
|
||||
|
||||
const text = await TextRollManager.createRollText(manager.template,
|
||||
param, false)
|
||||
const text = await TextRollManager.createRollText(
|
||||
{
|
||||
code,
|
||||
template: manager.template,
|
||||
options: { showLink: false }
|
||||
},
|
||||
param)
|
||||
ChatMessage.create({
|
||||
content: text
|
||||
})
|
||||
}
|
||||
}
|
||||
static registerChatCallbacks(html) {
|
||||
html.find('.roll-text').click(async event => await RdDTextEditor.rollText(event))
|
||||
}
|
||||
}
|
@ -67,7 +67,7 @@ class AlchimieTextBuilder {
|
||||
const carac = RdDCarac.caracDetails(RdDAlchimie.getCaracTache(manip))
|
||||
const diff = RdDAlchimie.getDifficulte(termes)
|
||||
const recette = (this.context.object instanceof Item && this.context.object.type == ITEM_TYPES.recettealchimique) ? this.context.object : undefined
|
||||
const replacement = await TextRollManager.createRollText(this.context.template,
|
||||
const replacement = await TextRollManager.createRollText(this.context,
|
||||
{
|
||||
code: this.context.code,
|
||||
manip, termes, carac, diff, recetteid: recette?.id,
|
||||
|
@ -74,7 +74,7 @@ class CaracCompetenceTextBuilder {
|
||||
const carac = RdDCarac.caracDetails(rollMatch.carac)
|
||||
if (carac) {
|
||||
const competence = rollMatch.competence ? RdDItemCompetence.findCompetence(this.context.competences, rollMatch.competence) : undefined
|
||||
const replacement = await TextRollManager.createRollText(this.context.template,
|
||||
const replacement = await TextRollManager.createRollText(this.context,
|
||||
{
|
||||
code: this.context.code,
|
||||
carac: carac,
|
||||
|
@ -1,11 +1,10 @@
|
||||
|
||||
export class TextRollManager {
|
||||
|
||||
static async createRollText(template, param, showLink = true) {
|
||||
return await renderTemplate(template, {
|
||||
param: param,
|
||||
options: { showlink: showLink }
|
||||
})
|
||||
static async createRollText(context, param) {
|
||||
return await renderTemplate(context.template, {
|
||||
param, options: context.options
|
||||
})
|
||||
}
|
||||
|
||||
static getNode(event) {
|
||||
|
@ -40,7 +40,7 @@ class FormulaTextBuilder {
|
||||
|
||||
async replaceMatch(rollMatch, i) {
|
||||
if (rollMatch.formula) {
|
||||
const replacement = await TextRollManager.createRollText(this.context.template,
|
||||
const replacement = await TextRollManager.createRollText(this.context,
|
||||
{
|
||||
code: this.context.code,
|
||||
formula: rollMatch.formula,
|
||||
|
Reference in New Issue
Block a user