Fix /rdd [carac]
- en cas de carac exact (reve), choisir cette caractéristique (pas de message par rapport à reve-actuel) - support /rdd odorat-gout
This commit is contained in:
@ -1960,7 +1960,7 @@ export class RdDActor extends Actor {
|
||||
ui.notifications.warn(`${this.name} n'a pas de caractéristique correspondant à ${caracName}`)
|
||||
return;
|
||||
}
|
||||
const competence = this.getCompetence(compName);
|
||||
const competence = this.getCompetence(compName);
|
||||
if (compName && !competence) {
|
||||
ui.notifications.warn(`${this.name} n'a pas de compétence correspondant à ${compName}`)
|
||||
return;
|
||||
@ -1970,14 +1970,14 @@ export class RdDActor extends Actor {
|
||||
caracValue: Number(carac.value),
|
||||
selectedCarac: carac,
|
||||
competence: competence,
|
||||
finalLevel: (competence?.data.niveau??0) + diff,
|
||||
finalLevel: (competence?.data.niveau ?? 0) + diff,
|
||||
diffLibre: diff,
|
||||
showDice: true,
|
||||
show: { title: "Jets multiples" }
|
||||
};
|
||||
await RdDResolutionTable.rollData(rollData);
|
||||
this.appliquerExperience(rollData);
|
||||
RdDResolutionTable.displayRollData( rollData, this )
|
||||
RdDResolutionTable.displayRollData(rollData, this)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -2294,7 +2294,7 @@ export class RdDActor extends Actor {
|
||||
if (destinee > 0) {
|
||||
ChatMessage.create({ content: `<span class="rdd-roll-part">${this.name} a fait appel à la Destinée !</span>` });
|
||||
destinee--;
|
||||
await this.updateCompteurValue( "destinee", destinee);
|
||||
await this.updateCompteurValue("destinee", destinee);
|
||||
onSuccess();
|
||||
}
|
||||
else {
|
||||
@ -2345,7 +2345,7 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
if (xpCarac > 0) {
|
||||
let carac = duplicate(Misc.templateData(this).carac);
|
||||
let selectedCarac = RdDActor._findCaracByName(carac, caracName);
|
||||
let selectedCarac = RdDCarac.findCarac(carac, caracName);
|
||||
if (!selectedCarac.derivee) {
|
||||
selectedCarac.xp = Misc.toInt(selectedCarac.xp) + xpCarac;
|
||||
await this.update({ "data.carac": carac });
|
||||
@ -2392,49 +2392,17 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getCaracByName(caracName) {
|
||||
switch (caracName) {
|
||||
case 'reve-actuel': case 'Rêve actuel':
|
||||
return {
|
||||
label: 'Rêve actuel',
|
||||
value: this.getReveActuel(),
|
||||
type: "number"
|
||||
};
|
||||
case 'chance-actuelle': case 'Chance actuelle':
|
||||
return {
|
||||
label: 'Chance actuelle',
|
||||
value: this.getChanceActuel(),
|
||||
type: "number"
|
||||
};
|
||||
}
|
||||
return RdDActor._findCaracByName(Misc.templateData(this).carac, caracName);
|
||||
getCaracAndActuel() {
|
||||
let caracs = {
|
||||
'reve-actuel': { label: 'Rêve actuel', value: this.getReveActuel(), type: "number" },
|
||||
'chance-actuelle': { label: 'Chance actuelle', value: this.getChanceActuel(), type: "number" }
|
||||
};
|
||||
mergeObject(caracs, Misc.templateData(this).carac);
|
||||
return caracs
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static _findCaracByName(carac, name) {
|
||||
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
|
||||
getCaracByName(caracName) {
|
||||
return RdDCarac.findCarac(this.getCaracAndActuel(), caracName);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
Reference in New Issue
Block a user