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,
|
||||
|
@ -106,7 +106,7 @@ export class RdDItemSigneDraconique extends RdDItem {
|
||||
}
|
||||
|
||||
static async randomSigneDescription() {
|
||||
return await RdDRollTables.drawTextFromRollTable("Signes draconiques", false);
|
||||
return await RdDRollTables.drawTextFromRollTable("Signes draconiques", {toChat:false});
|
||||
}
|
||||
|
||||
}
|
@ -472,15 +472,15 @@ export class RdDCombat {
|
||||
/* -------------------------------------------- */
|
||||
static registerChatCallbacks(html) {
|
||||
for (let button of [
|
||||
'#parer-button',
|
||||
'#esquiver-button',
|
||||
'#particuliere-attaque',
|
||||
'#encaisser-button',
|
||||
'#appel-chance-defense',
|
||||
'#appel-destinee-defense',
|
||||
'#appel-chance-attaque',
|
||||
'#appel-destinee-attaque',
|
||||
'#echec-total-attaque',
|
||||
'.parer-button',
|
||||
'.esquiver-button',
|
||||
'.particuliere-attaque',
|
||||
'.encaisser-button',
|
||||
'.appel-chance-defense',
|
||||
'.appel-destinee-defense',
|
||||
'.appel-chance-attaque',
|
||||
'.appel-destinee-attaque',
|
||||
'.echec-total-attaque',
|
||||
]) {
|
||||
html.on("click", button, event => {
|
||||
const rddCombat = RdDCombat.rddCombatForAttackerAndDefender(
|
||||
@ -539,22 +539,22 @@ export class RdDCombat {
|
||||
const compId = event.currentTarget.attributes['data-compid']?.value;
|
||||
|
||||
switch (button) {
|
||||
case '#particuliere-attaque': return await this.choixParticuliere(attackerRoll, event.currentTarget.attributes['data-mode'].value);
|
||||
case '#parer-button': return this.parade(attackerRoll, armeParadeId);
|
||||
case '#esquiver-button': return this.esquive(attackerRoll, compId, competence);
|
||||
case '#encaisser-button': return this.encaisser(attackerRoll, defenderRoll);
|
||||
case '#echec-total-attaque': return this._onEchecTotal(attackerRoll);
|
||||
case '.particuliere-attaque': return await this.choixParticuliere(attackerRoll, event.currentTarget.attributes['data-mode'].value);
|
||||
case '.parer-button': return this.parade(attackerRoll, armeParadeId);
|
||||
case '.esquiver-button': return this.esquive(attackerRoll, compId, competence);
|
||||
case '0encaisser-button': return this.encaisser(attackerRoll, defenderRoll);
|
||||
case '.echec-total-attaque': return this._onEchecTotal(attackerRoll);
|
||||
|
||||
case '#appel-chance-attaque': return this.attacker.rollAppelChance(
|
||||
case '.appel-chance-attaque': return this.attacker.rollAppelChance(
|
||||
() => this.attaqueChanceuse(attackerRoll),
|
||||
() => this._onEchecTotal(attackerRoll));
|
||||
case '#appel-chance-defense': return this.defender.rollAppelChance(
|
||||
case '.appel-chance-defense': return this.defender.rollAppelChance(
|
||||
() => this.defenseChanceuse(attackerRoll, defenderRoll),
|
||||
() => this.afficherOptionsDefense(attackerRoll, defenderRoll, { defenseChance: true }));
|
||||
case '#appel-destinee-attaque': return this.attacker.appelDestinee(
|
||||
case '.appel-destinee-attaque': return this.attacker.appelDestinee(
|
||||
() => this.attaqueSignificative(attackerRoll),
|
||||
() => { });
|
||||
case '#appel-destinee-defense': return this.defender.appelDestinee(
|
||||
case '.appel-destinee-defense': return this.defender.appelDestinee(
|
||||
() => this.defenseDestinee(defenderRoll),
|
||||
() => { });
|
||||
}
|
||||
@ -967,7 +967,6 @@ export class RdDCombat {
|
||||
async _onAttaqueEchec(rollData) {
|
||||
console.log("RdDCombat.onAttaqueEchec >>>", rollData);
|
||||
await RdDResolutionTable.displayRollData(rollData, this.attacker, 'chat-resultat-attaque.html');
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { RdDTextEditor } from "./apps/rdd-text-roll-editor.js";
|
||||
import { CompendiumTable, CompendiumTableHelpers, SystemCompendiums } from "./settings/system-compendiums.js";
|
||||
|
||||
export class RdDRollTables {
|
||||
@ -28,8 +29,8 @@ export class RdDRollTables {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async drawTextFromRollTable(tableName, toChat) {
|
||||
const drawResult = await RdDRollTables.genericGetTableResult(tableName, toChat);
|
||||
static async drawTextFromRollTable(tableName, options = {}) {
|
||||
const drawResult = await RdDRollTables.genericGetTableResult(tableName, options.toChat);
|
||||
return drawResult.text;
|
||||
}
|
||||
|
||||
@ -101,9 +102,10 @@ export class RdDRollTables {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async getMaladresse(options = { toChat: false, arme: false }) {
|
||||
return await RdDRollTables.drawTextFromRollTable(
|
||||
const maladresse = await RdDRollTables.drawTextFromRollTable(
|
||||
options.arme ? "Maladresse armé" : "Maladresses non armé",
|
||||
options.toChat);
|
||||
options);
|
||||
return await RdDTextEditor.enrichHTML(maladresse, undefined, {showLink:false})
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -699,7 +699,6 @@ export class RdDUtility {
|
||||
RdDCoeur.registerChatCallbacks(html)
|
||||
RdDTextEditor.registerChatCallbacks(html)
|
||||
|
||||
|
||||
// Gestion spécifique message passeurs
|
||||
html.on("click", '.tmr-passeur-coord a', event => {
|
||||
let coord = event.currentTarget.attributes['data-tmr-coord'].value;
|
||||
|
Reference in New Issue
Block a user