Merge branch 'master' of gitlab.com:LeRatierBretonnien/foundryvtt-reve-de-dragon
This commit is contained in:
commit
2a1495927f
@ -1970,14 +1970,14 @@ export class RdDActor extends Actor {
|
|||||||
caracValue: Number(carac.value),
|
caracValue: Number(carac.value),
|
||||||
selectedCarac: carac,
|
selectedCarac: carac,
|
||||||
competence: competence,
|
competence: competence,
|
||||||
finalLevel: (competence?.data.niveau??0) + diff,
|
finalLevel: (competence?.data.niveau ?? 0) + diff,
|
||||||
diffLibre: diff,
|
diffLibre: diff,
|
||||||
showDice: true,
|
showDice: true,
|
||||||
show: { title: "Jets multiples" }
|
show: { title: "Jets multiples" }
|
||||||
};
|
};
|
||||||
await RdDResolutionTable.rollData(rollData);
|
await RdDResolutionTable.rollData(rollData);
|
||||||
this.appliquerExperience(rollData);
|
this.appliquerExperience(rollData);
|
||||||
RdDResolutionTable.displayRollData( rollData, this )
|
RdDResolutionTable.displayRollData(rollData, this)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@ -2294,7 +2294,7 @@ export class RdDActor extends Actor {
|
|||||||
if (destinee > 0) {
|
if (destinee > 0) {
|
||||||
ChatMessage.create({ content: `<span class="rdd-roll-part">${this.name} a fait appel à la Destinée !</span>` });
|
ChatMessage.create({ content: `<span class="rdd-roll-part">${this.name} a fait appel à la Destinée !</span>` });
|
||||||
destinee--;
|
destinee--;
|
||||||
await this.updateCompteurValue( "destinee", destinee);
|
await this.updateCompteurValue("destinee", destinee);
|
||||||
onSuccess();
|
onSuccess();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -2345,7 +2345,7 @@ export class RdDActor extends Actor {
|
|||||||
}
|
}
|
||||||
if (xpCarac > 0) {
|
if (xpCarac > 0) {
|
||||||
let carac = duplicate(Misc.templateData(this).carac);
|
let carac = duplicate(Misc.templateData(this).carac);
|
||||||
let selectedCarac = RdDActor._findCaracByName(carac, caracName);
|
let selectedCarac = RdDCarac.findCarac(carac, caracName);
|
||||||
if (!selectedCarac.derivee) {
|
if (!selectedCarac.derivee) {
|
||||||
selectedCarac.xp = Misc.toInt(selectedCarac.xp) + xpCarac;
|
selectedCarac.xp = Misc.toInt(selectedCarac.xp) + xpCarac;
|
||||||
await this.update({ "data.carac": carac });
|
await this.update({ "data.carac": carac });
|
||||||
@ -2392,49 +2392,17 @@ export class RdDActor extends Actor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
getCaracByName(caracName) {
|
getCaracAndActuel() {
|
||||||
switch (caracName) {
|
let caracs = {
|
||||||
case 'reve-actuel': case 'Rêve actuel':
|
'reve-actuel': { label: 'Rêve actuel', value: this.getReveActuel(), type: "number" },
|
||||||
return {
|
'chance-actuelle': { label: 'Chance actuelle', value: this.getChanceActuel(), type: "number" }
|
||||||
label: 'Rêve actuel',
|
|
||||||
value: this.getReveActuel(),
|
|
||||||
type: "number"
|
|
||||||
};
|
};
|
||||||
case 'chance-actuelle': case 'Chance actuelle':
|
mergeObject(caracs, Misc.templateData(this).carac);
|
||||||
return {
|
return caracs
|
||||||
label: 'Chance actuelle',
|
|
||||||
value: this.getChanceActuel(),
|
|
||||||
type: "number"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return RdDActor._findCaracByName(Misc.templateData(this).carac, caracName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
getCaracByName(caracName) {
|
||||||
static _findCaracByName(carac, name) {
|
return RdDCarac.findCarac(this.getCaracAndActuel(), caracName);
|
||||||
name = Grammar.toLowerCaseNoAccent(name);
|
|
||||||
switch (name) {
|
|
||||||
case 'reve-actuel': case 'rêve actuel':
|
|
||||||
return carac.reve;
|
|
||||||
case 'chance-actuelle': case 'chance actuelle':
|
|
||||||
return carac.chance;
|
|
||||||
}
|
|
||||||
const keys = Object.entries(carac)
|
|
||||||
.filter(it => it[0].includes(name) || Grammar.toLowerCaseNoAccent(it[0]).includes(name))
|
|
||||||
.map(it => it[0]);
|
|
||||||
if (keys.length>1){
|
|
||||||
const names = keys.reduce((a, b) => `${a}<br>${b}`);
|
|
||||||
ui.notifications.info(`Plusieurs caractéristiques possibles:<br>${names}<br>La première sera choisie.`);
|
|
||||||
}
|
|
||||||
if (keys.length>0){
|
|
||||||
return carac[keys[0]];
|
|
||||||
}
|
|
||||||
// for (const [key, value] of Object.entries(carac)) {
|
|
||||||
// if (key.includes(name) || Grammar.toLowerCaseNoAccent(value.label).includes('name')) {
|
|
||||||
// return carac[key];
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
return undefined; // Per default
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
@ -191,14 +191,14 @@ export class RdDItemCompetence extends Item {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
let competence = competences.find(it => Grammar.toLowerCaseNoAccent(it.name) == name);
|
let competence = competences.find(it => Grammar.toLowerCaseNoAccent(it.name) == name);
|
||||||
if (!competence) {
|
if (competence) {
|
||||||
competence = competences[0];
|
return competence;
|
||||||
|
}
|
||||||
if (competences.length>1) {
|
if (competences.length>1) {
|
||||||
const names = competences.map(it => it.name).reduce((a, b) => `${a}<br>${b}`);
|
const names = competences.map(it => it.name).reduce((a, b) => `${a}<br>${b}`);
|
||||||
ui.notifications.info(`Plusieurs compétences possibles:<br>${names}<br>La première sera choisie: ${competence.name}`);
|
ui.notifications.info(`Plusieurs compétences possibles:<br>${names}<br>La première sera choisie: ${competences[0].name}`);
|
||||||
}
|
}
|
||||||
}
|
return competences[0];
|
||||||
return competence;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
@ -38,6 +38,29 @@ const tableCaracDerivee = {
|
|||||||
|
|
||||||
export class RdDCarac {
|
export class RdDCarac {
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
static findCarac(carac, name) {
|
||||||
|
|
||||||
|
const pairs = Object.entries(carac)
|
||||||
|
.filter(([key, value]) => key.includes(name) || Grammar.toLowerCaseNoAccent(value.label).includes(name));
|
||||||
|
|
||||||
|
let c = pairs.find(([key, value]) => key == name || Grammar.toLowerCaseNoAccent(value.label) == name);
|
||||||
|
if (c) {
|
||||||
|
return c[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
pairs.sort((a, b) => a[0].length- b[0].length);
|
||||||
|
if (pairs.length > 0) {
|
||||||
|
c = pairs[0][1];
|
||||||
|
if (pairs.length > 1) {
|
||||||
|
const labels = pairs.map(pair => pair[1].label).reduce((a, b) => `${a}<br>${b}`);
|
||||||
|
ui.notifications.info(`Plusieurs caractéristiques possibles:<br>${labels}<br>La première sera choisie: ${c.label}.`);
|
||||||
|
}
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
static isAgiliteOuDerivee(selectedCarac) {
|
static isAgiliteOuDerivee(selectedCarac) {
|
||||||
return selectedCarac?.label.match(/(Agilité|Dérobée)/);
|
return selectedCarac?.label.match(/(Agilité|Dérobée)/);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user