Fix recherche competence

La recherche de compétence cherchait dans tous les items (y compris les
armes), ce qui affichait des messages ui
This commit is contained in:
Vincent Vandemeulebrouck
2021-11-20 01:04:22 +01:00
parent 0f655bd89d
commit f91dfd04a2
4 changed files with 73 additions and 40 deletions

View File

@ -313,13 +313,19 @@ export class RdDActor extends Actor {
return Misc.templateData(this).compteurs.surenc?.value ?? 0;
}
/* -------------------------------------------- */
getCompetence(name) {
return RdDItemCompetence.findCompetence(this.data.items, name);
getCompetence(idOrName, options={}) {
return RdDItemCompetence.findCompetence(this.data.items, idOrName, options);
}
getCompetences(name) {
return RdDItemCompetence.findCompetences(this.data.items, name);
}
/* -------------------------------------------- */
getObjet(id) {
return id ? this.data.items.find(it => it.id == id) : undefined;
}
listItemsData(type) {
return this.filterItemsData(it => it.type == type);
}
@ -329,16 +335,12 @@ export class RdDActor extends Actor {
filterItems(filter) {
return this.data.items.filter(it => filter(Misc.data(it)));
}
getItemOfType(id, type) {
if (id && type) {
let itemById = this.data.items.find(it => it.id == id);
const itemData = Misc.data(itemById);
if (itemData.type == type) {
return itemById;
}
}
return undefined;
getItemOfType(idOrName, type) {
return this.data.items.find(it => it.id == idOrName && it.type == type)
?? Misc.findFirstLike(idOrName, this.data.items,{filter: it => it.type == type, description: type});
}
getMonnaie(id) {
return this.getItemOfType(id, 'monnaie');
}
@ -3077,7 +3079,7 @@ export class RdDActor extends Actor {
case 'chance-actuelle': case 'chance actuelle':
return carac.chance;
}
let entry = Misc.findFirstLike(name, Object.entries(carac), it => it[1].label, 'caractéristiques');
let entry = Misc.findFirstLike(name, Object.entries(carac), {mapper:it => it[1].label, description: 'caractéristique'});
return entry.length>0 ? carac[entry[0]] : undefined;
}