Fix alchimie
This commit is contained in:
parent
62e0153d0d
commit
3691775da0
@ -73,7 +73,7 @@ export class RdDItemSheet extends ItemSheet {
|
|||||||
console.log(formData.competences);
|
console.log(formData.competences);
|
||||||
}
|
}
|
||||||
if ( formData.type == 'recettealchimique' ) {
|
if ( formData.type == 'recettealchimique' ) {
|
||||||
RdDAlchimie.processManipulation(formData.item, this.actor && this.actor.id );
|
RdDAlchimie.processManipulation(objectData, this.actor && this.actor.id );
|
||||||
}
|
}
|
||||||
if ( this.actor ) {
|
if ( this.actor ) {
|
||||||
formData.isOwned = true;
|
formData.isOwned = true;
|
||||||
|
@ -1,51 +1,46 @@
|
|||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
import { Misc } from "./misc.js";
|
import { Misc } from "./misc.js";
|
||||||
|
|
||||||
|
const matchOperations = new RegExp(/@(\w*){([\w\-]+)}/ig);
|
||||||
|
const matchOperationTerms = new RegExp(/@(\w*){([\w\-]+)}/i);
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
export class RdDAlchimie {
|
export class RdDAlchimie {
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static processManipulation( recette, actorId = undefined ) {
|
static processManipulation(recetteData, actorId = undefined) {
|
||||||
//console.log("CALLED", recette, recette.isOwned, actorId );
|
//console.log("CALLED", recette, recette.isOwned, actorId );
|
||||||
let manip = duplicate(recette.data.manipulation);
|
let manip = recetteData.data.manipulation;
|
||||||
let reg1 = new RegExp(/@(\w*){([\w\-]+)}/ig);
|
let matchArray = manip.match(matchOperations);
|
||||||
let matchArray = manip.match( reg1 );
|
|
||||||
if (matchArray) {
|
if (matchArray) {
|
||||||
for (let matchStr of matchArray) {
|
for (let matchStr of matchArray) {
|
||||||
let reg2 = new RegExp(/@(\w*){([\w\-]+)}/i);
|
let result = matchStr.match(matchOperationTerms);
|
||||||
let result = matchStr.match(reg2);
|
|
||||||
//console.log("RESULT ", result);
|
//console.log("RESULT ", result);
|
||||||
if (result[1] && result[2]) {
|
if (result[1] && result[2]) {
|
||||||
let commande = Misc.upperFirst(result[1]);
|
let commande = Misc.upperFirst(result[1]);
|
||||||
let replacement = this[`_alchimie${commande}`](recette, result[2], actorId);
|
let replacement = this[`_alchimie${commande}`](recetteData, result[2], actorId);
|
||||||
manip = manip.replace(result[0], replacement);
|
manip = manip.replace(result[0], replacement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
recette.data.manipulation_update = manip;
|
recetteData.data.manipulation_update = manip;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static _alchimieCouleur(recette, couleurs, actorId) {
|
static _alchimieCouleur(recette, couleurs, actorId) {
|
||||||
let replacement
|
|
||||||
if (actorId) {
|
if (actorId) {
|
||||||
replacement = `<span class="alchimie-tache"><a data-recette-id="${recette._id}" data-actor-id="${actorId}" data-alchimie-tache="couleur" data-alchimie-data="${couleurs}">couleur ${couleurs}</a></span>`;
|
return `<span class="alchimie-tache"><a data-recette-id="${recette._id}" data-actor-id="${actorId}" data-alchimie-tache="couleur" data-alchimie-data="${couleurs}">couleur ${couleurs}</a></span>`;
|
||||||
} else {
|
} else {
|
||||||
replacement = `<span class="alchimie-tache">couleur ${couleurs} </span>`;
|
return `<span class="alchimie-tache">couleur ${couleurs} </span>`;
|
||||||
}
|
}
|
||||||
return replacement;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static _alchimieConsistance(recette, consistances, actorId) {
|
static _alchimieConsistance(recette, consistances, actorId) {
|
||||||
let replacement
|
|
||||||
if (actorId) {
|
if (actorId) {
|
||||||
replacement = `<span class="alchimie-tache"><a data-recette-id="${recette._id}" data-actor-id="${actorId}" data-alchimie-tache="consistance" data-alchimie-data="${consistances}">consistance ${consistances}</a></span>`;
|
return `<span class="alchimie-tache"><a data-recette-id="${recette._id}" data-actor-id="${actorId}" data-alchimie-tache="consistance" data-alchimie-data="${consistances}">consistance ${consistances}</a></span>`;
|
||||||
} else {
|
} else {
|
||||||
replacement = `<span class="alchimie-tache">consistance ${consistances} </span>`;
|
return `<span class="alchimie-tache">consistance ${consistances} </span>`;
|
||||||
}
|
}
|
||||||
return replacement;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
Loading…
Reference in New Issue
Block a user