Ajout d'un Actor commerce

This commit is contained in:
2023-01-01 22:21:30 +01:00
parent 5972db035d
commit ee42bdcf83
17 changed files with 296 additions and 46 deletions

View File

@ -170,6 +170,8 @@ export class RdDUtility {
'systems/foundryvtt-reve-de-dragon/templates/actor/liens-animaux.html',
'systems/foundryvtt-reve-de-dragon/templates/actor/liens-suivants.html',
'systems/foundryvtt-reve-de-dragon/templates/actor/liens-vehicules.html',
'systems/foundryvtt-reve-de-dragon/templates/actor/commerce-inventaire.html',
'systems/foundryvtt-reve-de-dragon/templates/actor/commerce-inventaire-item.html',
//Items
'systems/foundryvtt-reve-de-dragon/templates/scripts/autocomplete-script.hbs',
'systems/foundryvtt-reve-de-dragon/templates/scripts/autocomplete.hbs',
@ -296,7 +298,7 @@ export class RdDUtility {
Handlebars.registerHelper('apostrophe', (article, str) => Grammar.apostrophe(article, str));
Handlebars.registerHelper('un', str => Grammar.articleIndetermine(str));
Handlebars.registerHelper('accord', (genre, ...args) => Grammar.accord(genre, args));
Handlebars.registerHelper('buildConteneur', (objet, tplItem) => { return new Handlebars.SafeString(RdDUtility.buildConteneur(objet, 1, tplItem)); });
Handlebars.registerHelper('buildConteneur', (objet, templateItem, options) => { return new Handlebars.SafeString(RdDUtility.buildConteneur(objet, 1, templateItem, options)); });
Handlebars.registerHelper('buildContenu', (objet) => { return new Handlebars.SafeString(RdDUtility.buildContenu(objet, 1, true)); });
Handlebars.registerHelper('caseTmr-label', coord => TMRUtility.getTMRLabel(coord));
Handlebars.registerHelper('caseTmr-type', coord => TMRUtility.getTMRType(coord));
@ -472,33 +474,34 @@ export class RdDUtility {
/** Construit la structure récursive des conteneurs, avec imbrication potentielle
*
*/
static buildConteneur(objet, profondeur, tplItem) {
static buildConteneur(objet, profondeur, templateItem, options) {
if (!profondeur) profondeur = 1;
if (!tplItem) tplItem = 'actor/inventaire-item.html'
if (!templateItem) templateItem = 'actor/inventaire-item.html'
objet.niveau = profondeur;
const isConteneur = objet.type == 'conteneur';
const isOuvert = isConteneur && this.getAfficheContenu(objet._id);
const isVide = isConteneur && objet.system.contenu.length == 0;
const conteneur = Handlebars.partials[`systems/foundryvtt-reve-de-dragon/templates/${tplItem}`]({
const conteneur = Handlebars.partials[`systems/foundryvtt-reve-de-dragon/templates/${templateItem}`]({
item: objet,
vide: isVide,
ouvert: isOuvert
ouvert: isOuvert,
options: options
});
const contenu = isConteneur ? RdDUtility.buildContenu(objet, profondeur, isOuvert, tplItem) : '';
const contenu = isConteneur ? RdDUtility.buildContenu(objet, profondeur, isOuvert, templateItem, options) : '';
return conteneur + contenu;
}
/* -------------------------------------------- */
static buildContenu(objet, profondeur, afficherContenu, tplItem) {
static buildContenu(objet, profondeur, afficherContenu, templateItem, options) {
if (!profondeur) profondeur = 1;
if (!tplItem) tplItem = 'actor/inventaire-item.html'
if (!templateItem) templateItem = 'actor/inventaire-item.html'
objet.niveau = profondeur;
const display = afficherContenu ? 'item-display-show' : 'item-display-hide';
let strContenu = `<ul class='item-list alterne-list ${display} list-item-margin${Math.min(profondeur,6)}'>`;
for (let subItem of objet.subItems) {
strContenu += this.buildConteneur(subItem, profondeur + 1);
strContenu += this.buildConteneur(subItem, profondeur + 1, templateItem, options);
}
return strContenu + "</ul>";
}