Tâches sans compétences

This commit is contained in:
Vincent Vandemeulebrouck 2022-10-31 15:19:08 +01:00
parent 269b4ec0ca
commit f1d7cfa1f8
3 changed files with 27 additions and 9 deletions

View File

@ -219,8 +219,8 @@ export class RdDItemCompetence extends Item {
/* -------------------------------------------- */ /* -------------------------------------------- */
static findCompetence(list, idOrName, options = {}) { static findCompetence(list, idOrName, options = {}) {
if (idOrName == undefined) { if (idOrName == undefined || idOrName == "") {
return undefined; return RdDItemCompetence.sansCompetence();
} }
options = mergeObject(options, { preFilter: it => it.isCompetence(), description: 'compétence' }, { overwrite: false }); options = mergeObject(options, { preFilter: it => it.isCompetence(), description: 'compétence' }, { overwrite: false });
return RdDItemCompetence.findFirstItem(list, idOrName, options); return RdDItemCompetence.findFirstItem(list, idOrName, options);
@ -231,6 +231,23 @@ export class RdDItemCompetence extends Item {
return Misc.findAllLike(name, list, { filter: it => it.isCompetence(), description: 'compétence' }); return Misc.findAllLike(name, list, { filter: it => it.isCompetence(), description: 'compétence' });
} }
static sansCompetence() {
return {
name: "Sans compétence",
type: "competence",
img: "systems/foundryvtt-reve-de-dragon/icons/templates/icone_parchement_vierge.webp",
system: {
niveau: 0,
default_diffLibre: 0,
base: 0,
categorie: "Aucune",
description: "",
descriptionmj: "",
defaut_carac: "",
}
};
}
static findFirstItem(list, idOrName, options) { static findFirstItem(list, idOrName, options) {
return list.find(it => it.id == idOrName && options.preFilter(it)) return list.find(it => it.id == idOrName && options.preFilter(it))
?? Misc.findFirstLike(idOrName, list, options); ?? Misc.findFirstLike(idOrName, list, options);

View File

@ -746,9 +746,9 @@
"carac": "", "carac": "",
"competence": "", "competence": "",
"periodicite": "", "periodicite": "",
"fatigue": 0, "fatigue": 1,
"difficulte": 0, "difficulte": 0,
"points_de_tache": 0, "points_de_tache": 4,
"points_de_tache_courant": 0, "points_de_tache_courant": 0,
"nb_jet_echec": 0, "nb_jet_echec": 0,
"nb_jet_succes": 0, "nb_jet_succes": 0,

View File

@ -16,6 +16,7 @@
<label for="xp">Compétence</label> <label for="xp">Compétence</label>
<select name="system.competence" id="competenceselect" data-dtype="String"> <select name="system.competence" id="competenceselect" data-dtype="String">
{{#select system.competence}} {{#select system.competence}}
<option value="">Sans compétence</option>
{{#each competences as |competence key|}} {{#each competences as |competence key|}}
<option value="{{competence.name}}">{{competence.name}}</option> <option value="{{competence.name}}">{{competence.name}}</option>
{{/each}} {{/each}}