forked from public/foundryvtt-reve-de-dragon
Jets d'alchimie dans descriptions/journaux
On ne se limite plus aux manipulations alchimiques, et les jets apparaissent comme tous les autres types de jets
This commit is contained in:
@ -1,48 +1,8 @@
|
||||
/* -------------------------------------------- */
|
||||
import { Misc } from "./misc.js";
|
||||
|
||||
const matchOperations = new RegExp(/@(\w*){([\w\-]+)}/ig);
|
||||
const matchOperationTerms = new RegExp(/@(\w*){([\w\-]+)}/i);
|
||||
/* -------------------------------------------- */
|
||||
export class RdDAlchimie {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static processManipulation(recette, actorId = undefined) {
|
||||
let manip = recette.system.manipulation;
|
||||
let matchArray = manip.match(matchOperations);
|
||||
if (matchArray) {
|
||||
for (let matchStr of matchArray) {
|
||||
let result = matchStr.match(matchOperationTerms);
|
||||
if (result[1] && result[2]) {
|
||||
let commande = Misc.upperFirst(result[1]);
|
||||
let replacement = this[`_alchimie${commande}`](recette, result[2], actorId);
|
||||
manip = manip.replace(result[0], replacement);
|
||||
}
|
||||
}
|
||||
}
|
||||
return manip;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static _alchimieCouleur(recette, couleurs, actorId) {
|
||||
return RdDAlchimie._alchimieLink(recette, couleurs, actorId, 'couleur', 'Température');
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static _alchimieConsistance(recette, consistances, actorId) {
|
||||
return RdDAlchimie._alchimieLink(recette, consistances, actorId, 'consistance', 'Consistance');
|
||||
}
|
||||
|
||||
static _alchimieLink(recette, termes, actorId, tacheAlchimie, labelTache) {
|
||||
const difficulte = RdDAlchimie.getDifficulte(termes);
|
||||
const link = actorId ? ` <a data-recette-id="${recette._id}" data-actor-id="${actorId}" data-alchimie-tache="${tacheAlchimie}" data-alchimie-data="${termes}">` : '';
|
||||
const endLink = actorId ? '</a>' : '';
|
||||
return `<span class="alchimie-tache">${link}${labelTache} ${termes} (${difficulte})${endLink}</span>`;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static getDifficulte(aspects) {
|
||||
let elements = aspects.split('-');
|
||||
static getDifficulte(termes) {
|
||||
let elements = termes.split('-');
|
||||
let composantes = elements.length;
|
||||
let distincts = Object.keys(Misc.classifyFirst(elements, it => it)).length;
|
||||
if (distincts == 1) {
|
||||
@ -58,5 +18,4 @@ export class RdDAlchimie {
|
||||
}
|
||||
return 'intellect';
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user