diff --git a/module/item-sheet.js b/module/item-sheet.js
index 229df96a..c2873161 100644
--- a/module/item-sheet.js
+++ b/module/item-sheet.js
@@ -73,7 +73,7 @@ export class RdDItemSheet extends ItemSheet {
console.log(formData.competences);
}
if ( formData.type == 'recettealchimique' ) {
- RdDAlchimie.processManipulation(formData.item, this.actor && this.actor.id );
+ RdDAlchimie.processManipulation(objectData, this.actor && this.actor.id );
}
if ( this.actor ) {
formData.isOwned = true;
diff --git a/module/rdd-alchimie.js b/module/rdd-alchimie.js
index 4028bc1d..6ceff48f 100644
--- a/module/rdd-alchimie.js
+++ b/module/rdd-alchimie.js
@@ -1,51 +1,46 @@
/* -------------------------------------------- */
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 ) {
+ static processManipulation(recetteData, actorId = undefined) {
//console.log("CALLED", recette, recette.isOwned, actorId );
- let manip = duplicate(recette.data.manipulation);
- let reg1 = new RegExp(/@(\w*){([\w\-]+)}/ig);
- let matchArray = manip.match( reg1 );
- if ( matchArray ) {
- for( let matchStr of matchArray) {
- let reg2 = new RegExp(/@(\w*){([\w\-]+)}/i);
- let result = matchStr.match(reg2);
+ let manip = recetteData.data.manipulation;
+ let matchArray = manip.match(matchOperations);
+ if (matchArray) {
+ for (let matchStr of matchArray) {
+ let result = matchStr.match(matchOperationTerms);
//console.log("RESULT ", result);
- 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);
+ if (result[1] && result[2]) {
+ let commande = Misc.upperFirst(result[1]);
+ let replacement = this[`_alchimie${commande}`](recetteData, result[2], actorId);
+ manip = manip.replace(result[0], replacement);
}
}
}
- recette.data.manipulation_update = manip;
+ recetteData.data.manipulation_update = manip;
}
/* -------------------------------------------- */
- static _alchimieCouleur( recette, couleurs, actorId ) {
- let replacement
- if ( actorId ) {
- replacement = `couleur ${couleurs}`;
+ static _alchimieCouleur(recette, couleurs, actorId) {
+ if (actorId) {
+ return `couleur ${couleurs}`;
} else {
- replacement = `couleur ${couleurs} `;
+ return `couleur ${couleurs} `;
}
- return replacement;
}
/* -------------------------------------------- */
- static _alchimieConsistance( recette, consistances, actorId ) {
- let replacement
- if ( actorId ) {
- replacement = `consistance ${consistances}`;
+ static _alchimieConsistance(recette, consistances, actorId) {
+ if (actorId) {
+ return `consistance ${consistances}`;
} else {
- replacement = `consistance ${consistances} `;
+ return `consistance ${consistances} `;
}
- return replacement;
-
}
/* -------------------------------------------- */
diff --git a/templates/item-recettealchimique-sheet.html b/templates/item-recettealchimique-sheet.html
index 5eda4bcf..e308176d 100644
--- a/templates/item-recettealchimique-sheet.html
+++ b/templates/item-recettealchimique-sheet.html
@@ -43,5 +43,5 @@
-
+