diff --git a/module/actor-sheet.js b/module/actor-sheet.js index ea8519f2..8045dcc9 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -7,22 +7,23 @@ import { RdDUtility } from "./rdd-utility.js"; import { HtmlUtility } from "./html-utility.js"; import { RdDItem } from "./item.js"; import { RdDItemArme } from "./item-arme.js"; - +import { RdDItemCompetence } from "./item-competence.js"; + /* -------------------------------------------- */ export class RdDActorSheet extends ActorSheet { /** @override */ - static get defaultOptions() { + static get defaultOptions() { RdDUtility.initAfficheContenu(); - return mergeObject(super.defaultOptions, { - classes: ["rdd", "sheet", "actor"], - template: "systems/foundryvtt-reve-de-dragon/templates/actor-sheet.html", + return mergeObject(super.defaultOptions, { + classes: ["rdd", "sheet", "actor"], + template: "systems/foundryvtt-reve-de-dragon/templates/actor-sheet.html", width: 640, //height: 720, - tabs: [{navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "carac"}], - dragDrop: [{dragSelector: ".item-list .item", dropSelector: null}], + tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "carac" }], + dragDrop: [{ dragSelector: ".item-list .item", dropSelector: null }], editCaracComp: false, - montrerCompetencesNiveauBase: false, + showCompNiveauBase: false, montrerArchetype: false }); } @@ -32,79 +33,67 @@ export class RdDActorSheet extends ActorSheet { let data = super.getData(); if ( data.actor.type == 'creature' || data.actor.type == 'humanoide') return data; // Shortcut - data.data.editCaracComp = this.options.editCaracComp; - data.data.montrerCompetencesNiveauBase = this.options.montrerCompetencesNiveauBase; + data.data.editCaracComp = this.options.editCaracComp; + data.data.showCompNiveauBase = this.options.showCompNiveauBase; data.data.montrerArchetype = this.options.montrerArchetype; - - let compCategorieNiveau = RdDUtility.getLevelCategory(); // recup catégorie + data.itemsByType = RdDItem.buildItemsClassification(data.items); // Competence per category - data.competenceByCategory = {}; let competenceXPTotal = 0; - if (data.itemsByType.competence) { - for (const item of data.itemsByType.competence) { - this.actor.checkCompetenceXP( item.name ); // Petite vérification experience - //console.log("Push...", item, item.data.categorie); - let list = data.competenceByCategory[item.data.categorie]; - if (!list) { - list = []; - data.competenceByCategory[item.data.categorie] = list; - } - if (!RdDUtility.isTronc( item.name ) ) // Ignorer les compétences 'troncs' à ce stade - competenceXPTotal += RdDUtility.computeCompetenceXPCost(item); - item.data.afficherCompetence = true; - if ( data.data.montrerCompetencesNiveauBase && (Number(item.data.niveau) == Number(compCategorieNiveau[item.data.categorie]) ) ) { - item.data.afficherCompetence = false; - } - list.push(item); - } - } - this.competenceByCategory = duplicate(data.competenceByCategory); // Sauvegarde locale - competenceXPTotal += RdDUtility.computeCompetenceTroncXP(data.itemsByType.competence); + data.competenceByCategory = RdDItem.classify( + data.itemsByType.competence, + item => item.data.categorie, + item => { + this.actor.checkCompetenceXP(item.name); // Petite vérification experience + item.data.showCompetence = !data.data.showCompNiveauBase || (Number(item.data.niveau) != Number(RdDUtility.getLevelCategory(item.data.categorie))); + // Ignorer les compétences 'troncs' à ce stade + competenceXPTotal += RdDItemCompetence.isTronc(item.name) ? 0 : RdDItemCompetence.computeCompetenceXPCost(item); + return item; + }); + competenceXPTotal += RdDItemCompetence.computeCompetenceTroncXP(data.itemsByType.competence); data.data.competenceXPTotal = competenceXPTotal; - //console.log("XP competence : ", competenceXPTotal); // Compute current carac sum let sum = 0; - for (let caracName in data.data.carac) { - let carac = data.data.carac[caracName]; - if (!carac.derivee) { - sum += parseInt(carac.value); - } + for (let caracName in data.data.carac) { + let currentCarac = data.data.carac[caracName]; + if (!currentCarac.derivee) { + sum += parseInt(currentCarac.value); + } } data.data.caracSum = sum; // Force empty arme, at least for Esquive - if (data.itemsByType.arme == undefined ) data.itemsByType.arme = []; - for (const arme of data.itemsByType.arme) { + if (data.itemsByType.arme == undefined) data.itemsByType.arme = []; + for (const arme of data.itemsByType.arme) { arme.data.niveau = 0; // Per default, TODO to be fixed - for ( const melee of data.competenceByCategory.melee ) { - if (melee.name == arme.data.competence ) + for (const melee of data.competenceByCategory.melee) { + if (melee.name == arme.data.competence) arme.data.niveau = melee.data.niveau } - for ( const tir of data.competenceByCategory.tir ) { - if (tir.name == arme.data.competence ) + for (const tir of data.competenceByCategory.tir) { + if (tir.name == arme.data.competence) arme.data.niveau = tir.data.niveau } - for ( const lancer of data.competenceByCategory.lancer ) { - if (lancer.name == arme.data.competence ) + for (const lancer of data.competenceByCategory.lancer) { + if (lancer.name == arme.data.competence) arme.data.niveau = lancer.data.niveau } } // To avoid armour and so on... - data.data.combat = duplicate( RdDUtility.checkNull(data.itemsByType['arme'])); - data.data.combat = RdDUtility._finalizeArmeList( data.data.combat, data.itemsByType.competence, data.data.carac ); + data.data.combat = duplicate(RdDUtility.checkNull(data.itemsByType['arme'])); + data.data.combat = RdDUtility._finalizeArmeList(data.data.combat, data.itemsByType.competence, data.data.carac); - if (data.competenceByCategory && data.competenceByCategory.melee) { + if (data.competenceByCategory && data.competenceByCategory.melee) { //Specific case for Esquive and Corps à Corps - for ( const melee of data.competenceByCategory.melee ) { + for (const melee of data.competenceByCategory.melee) { if (melee.name == "Esquive") - data.data.combat.push( { name: "Esquive", data: { niveau: melee.data.niveau, description: "", force: 6, initiative: "", competence: "Esquive", dommages: 0} } ); + data.data.combat.push({ name: "Esquive", data: { niveau: melee.data.niveau, description: "", force: 6, initiative: "", competence: "Esquive", dommages: 0 } }); if (melee.name == "Corps à corps") { let cc_init = RdDUtility.calculInitiative(melee.data.niveau, data.data.carac['melee'].value); - data.data.combat.push( RdDItemArme.mainsNues({ niveau: melee.data.niveau, initiative: cc_init }) ); + data.data.combat.push(RdDItemArme.mainsNues({ niveau: melee.data.niveau, initiative: cc_init })); } } } @@ -113,7 +102,7 @@ export class RdDActorSheet extends ActorSheet { data.data.carac.taille.isTaille = true; // To avoid button link; data.data.compteurs.chance.isChance = true; data.data.blessures.resume = this.actor.computeResumeBlessure(data.data.blessures); - + // Mise à jour de l'encombrement total this.actor.computeEncombrementTotalEtMalusArmure(); // Common data @@ -122,23 +111,22 @@ export class RdDActorSheet extends ActorSheet { data.data.isGM = game.user.isGM; data.ajustementsConditions = CONFIG.RDD.ajustementsConditions; data.difficultesLibres = CONFIG.RDD.difficultesLibres; - + // low is normal, this the base used to compute the grid. data.data.fatigue = { - malus: RdDUtility.calculMalusFatigue(data.data.sante.fatigue.value, data.data.sante.endurance.max), - html: "" + RdDUtility.makeHTMLfatigueMatrix( data.data.sante.fatigue.value, data.data.sante.endurance.max ).html() + "
" - } - - RdDUtility.filterItemsPerTypeForSheet(data ); - data.data.sortReserve = data.data.reve.reserve.list; + malus: RdDUtility.calculMalusFatigue(data.data.sante.fatigue.value, data.data.sante.endurance.max), + html: "" + RdDUtility.makeHTMLfatigueMatrix(data.data.sante.fatigue.value, data.data.sante.endurance.max).html() + "
" + } + + RdDUtility.filterItemsPerTypeForSheet(data); + data.data.sortReserve = data.data.reve.reserve.list; data.data.caseSpeciales = data.itemsByType['casetmr']; - RdDUtility.buildArbreDeConteneur( this, data ); + RdDUtility.buildArbreDeConteneur(this, data); data.data.surEncombrementMessage = (data.data.compteurs.surenc.value < 0) ? "Sur-Encombrement!" : ""; return data; } - /* -------------------------------------------- */ async _onDrop(event) { let toSuper = await RdDUtility.processItemDropEvent(this, event); @@ -189,43 +177,43 @@ export class RdDActorSheet extends ActorSheet { } /* -------------------------------------------- */ - async createEmptyTache( ) { - await this.actor.createOwnedItem( { name: 'Nouvelle tache', type: 'tache'}, { renderSheet: true } ); + async createEmptyTache() { + await this.actor.createOwnedItem({ name: 'Nouvelle tache', type: 'tache' }, { renderSheet: true }); } /* -------------------------------------------- */ - async creerObjet( ) { + async creerObjet() { let itemType = $("#creer-equipement").val(); - await this.actor.createOwnedItem( { name: 'Nouveau '+itemType, type: itemType}, { renderSheet: true } ); + await this.actor.createOwnedItem({ name: 'Nouveau ' + itemType, type: itemType }, { renderSheet: true }); } /* -------------------------------------------- */ - async selectObjetType( ) { + async selectObjetType() { let itemType = ["objet", "arme", "armure", "conteneur", "herbe", "ingredient", "livre", "potion", "munition", "monnaie"]; let options = 'Selectionnez le type d\'équipement'; - let d = new Dialog( { - title: "Créer un équipement", - content: options, - buttons: { - one: { + let d = new Dialog({ + title: "Créer un équipement", + content: options, + buttons: { + one: { icon: '', label: "Créer l'objet", callback: () => this.creerObjet() - } } - }); + } + }); d.render(true); } - + /* -------------------------------------------- */ /** @override */ - activateListeners(html) { + activateListeners(html) { super.activateListeners(html); - + HtmlUtility._showControlWhen($(".gm-only"), game.user.isGM); // Everything below here is only needed if the sheet is editable @@ -237,11 +225,11 @@ export class RdDActorSheet extends ActorSheet { const item = this.actor.getOwnedItem(li.data("item-id")); item.sheet.render(true); }); - + // Delete Inventory Item html.find('.item-delete').click(ev => { const li = $(ev.currentTarget).parents(".item"); - this.confirmerSuppression( li ); + this.confirmerSuppression(li); }); html.find('#encaisser-direct').click(ev => { @@ -262,28 +250,28 @@ export class RdDActorSheet extends ActorSheet { html.find('#nettoyer-conteneurs').click(ev => { this.actor.nettoyerConteneurs(); }); - + // Blessure control html.find('.blessure-control').click(ev => { - const li = $(ev.currentTarget).parents(".item"); - let btype = li.data("blessure-type"); - let index = li.data('blessure-index'); + const li = $(ev.currentTarget).parents(".item"); + let btype = li.data("blessure-type"); + let index = li.data('blessure-index'); let active = $(ev.currentTarget).data('blessure-active'); //console.log(btype, index, active); - this.actor.manageBlessureFromSheet(btype, index, active).then( this.render(true) ); + this.actor.manageBlessureFromSheet(btype, index, active).then(this.render(true)); }); // Blessure data html.find('.blessures-soins').change(ev => { - const li = $(ev.currentTarget).parents(".item"); - let btype = li.data('blessure-type'); - let index = li.data('blessure-index'); - let psoins = li.find('input[name=premiers_soins]').val(); + const li = $(ev.currentTarget).parents(".item"); + let btype = li.data('blessure-type'); + let index = li.data('blessure-index'); + let psoins = li.find('input[name=premiers_soins]').val(); let pcomplets = li.find('input[name=soins_complets]').val(); - let jours = li.find('input[name=jours]').val(); - let loc = li.find('input[name=localisation]').val(); + let jours = li.find('input[name=jours]').val(); + let loc = li.find('input[name=localisation]').val(); //console.log(btype, index, psoins, pcomplets, jours, loc); - this.actor.setDataBlessureFromSheet(btype, index, psoins, pcomplets, jours, loc).then( this.render(true) ); + this.actor.setDataBlessureFromSheet(btype, index, psoins, pcomplets, jours, loc).then(this.render(true)); }); // Equip Inventory Item @@ -296,11 +284,11 @@ export class RdDActorSheet extends ActorSheet { // Roll Carac html.find('.carac-label a').click((event) => { let caracName = event.currentTarget.attributes.name.value; - this.actor.rollCarac( caracName.toLowerCase() ); + this.actor.rollCarac(caracName.toLowerCase()); }); html.find('#chance-actuelle').click((event) => { - this.actor.rollCarac( 'chance-actuelle' ); + this.actor.rollCarac('chance-actuelle'); }); html.find('#chance-appel').click((event) => { @@ -310,26 +298,26 @@ export class RdDActorSheet extends ActorSheet { html.find('#jet-astrologie').click((event) => { this.actor.astrologieNombresAstraux(); }); - + // Roll Skill html.find('.competence-label a').click((event) => { let compName = event.currentTarget.text; - this.actor.rollCompetence( compName); + this.actor.rollCompetence(compName); }); html.find('.tache-label a').click((event) => { - const li = $(event.currentTarget).parents(".item"); - let tacheId = li.data('item-id'); - this.actor.rollTache( tacheId ); + const li = $(event.currentTarget).parents(".item"); + let tacheId = li.data('item-id'); + this.actor.rollTache(tacheId); }); html.find('.meditation-label a').click((event) => { - const li = $(event.currentTarget).parents(".item"); - let meditationId = li.data('item-id'); - this.actor.rollMeditation( meditationId ); + const li = $(event.currentTarget).parents(".item"); + let meditationId = li.data('item-id'); + this.actor.rollMeditation(meditationId); }); - + // Points de reve actuel html.find('.ptreve-actuel a').click((event) => { - this.actor.rollCarac( 'reve-actuel' ); + this.actor.rollCarac('reve-actuel'); }); // Roll Weapon1 @@ -340,28 +328,28 @@ export class RdDActorSheet extends ActorSheet { }); // Initiative pour l'arme html.find('.arme-initiative a').click((event) => { - let combatant = game.combat.data.combatants.find(c => c.actor.data._id == this.actor.data._id ); - if ( combatant ) { + let combatant = game.combat.data.combatants.find(c => c.actor.data._id == this.actor.data._id); + if (combatant) { let armeName = event.currentTarget.attributes['data-arme-name'].value; - let arme = this.armesList.find( a => a.name == armeName); - RdDUtility.rollInitiativeCompetence( combatant._id, arme); + let arme = this.armesList.find(a => a.name == armeName); + RdDUtility.rollInitiativeCompetence(combatant._id, arme); } else { ui.notifications.info("Impossible de lancer l'initiative sans être dans un combat."); } }); // Display TMR, visuualisation html.find('#visu-tmr').click((event) => { - this.actor.displayTMR( "visu"); + this.actor.displayTMR("visu"); }); // Display TMR, normal html.find('#monte-tmr').click((event) => { - this.actor.displayTMR( "normal" ); + this.actor.displayTMR("normal"); }); - + // Display TMR, fast html.find('#monte-tmr-rapide').click((event) => { - this.actor.displayTMR( "rapide" ); + this.actor.displayTMR("rapide"); }); html.find('#dormir-une-heure').click((event) => { @@ -393,38 +381,38 @@ export class RdDActorSheet extends ActorSheet { // Display info about queue html.find('.conteneur-name a').click((event) => { let myID = event.currentTarget.attributes['data-item-id'].value; - RdDUtility.toggleAfficheContenu( myID ); + RdDUtility.toggleAfficheContenu(myID); this.render(true); }); - + if (this.options.editCaracComp) { // On carac change html.find('.carac-value').change((event) => { let caracName = event.currentTarget.name.replace(".value", "").replace("data.carac.", ""); //console.log("Value changed :", event, caracName); - this.actor.updateCarac( caracName, parseInt(event.target.value) ); - } ); + this.actor.updateCarac(caracName, parseInt(event.target.value)); + }); html.find('.carac-xp').change((event) => { let caracName = event.currentTarget.name.replace(".xp", "").replace("data.carac.", ""); //console.log("Value changed :", event, caracName); - this.actor.updateCaracXP( caracName, parseInt(event.target.value) ); - } ); + this.actor.updateCaracXP(caracName, parseInt(event.target.value)); + }); // On competence change html.find('.competence-value').change((event) => { let compName = event.currentTarget.attributes.compname.value; //console.log("Competence changed :", compName); - this.actor.updateCompetence( compName, parseInt(event.target.value) ); - } ); + this.actor.updateCompetence(compName, parseInt(event.target.value)); + }); // On competence xp change html.find('.competence-xp').change((event) => { let compName = event.currentTarget.attributes.compname.value; - this.actor.updateCompetenceXP( compName, parseInt(event.target.value) ); - } ); + this.actor.updateCompetenceXP(compName, parseInt(event.target.value)); + }); // On competence archetype change html.find('.competence-archetype').change((event) => { let compName = event.currentTarget.attributes.compname.value; - this.actor.updateCompetenceArchetype( compName, parseInt(event.target.value) ); - } ); + this.actor.updateCompetenceArchetype(compName, parseInt(event.target.value)); + }); } // Gestion du bouton lock/unlock @@ -433,41 +421,41 @@ export class RdDActorSheet extends ActorSheet { this.render(true); }); html.find('#show-hide-competences').click((event) => { - this.options.montrerCompetencesNiveauBase = !this.options.montrerCompetencesNiveauBase; + this.options.showCompNiveauBase = !this.options.showCompNiveauBase; this.render(true); }); html.find('#show-hide-archetype').click((event) => { this.options.montrerArchetype = !this.options.montrerArchetype; this.render(true); }); - + // On pts de reve change html.find('.pointsreve-value').change((event) => { let reveValue = event.currentTarget.value; - let reve = duplicate( this.actor.data.data.reve.reve ); + let reve = duplicate(this.actor.data.data.reve.reve); reve.value = reveValue; - this.actor.update( { "data.reve.reve": reve } ); - } ); - + this.actor.update({ "data.reve.reve": reve }); + }); + // On seuil de reve change html.find('.seuil-reve-value').change((event) => { console.log("seuil-reve-value", event.currentTarget) this.actor.setPointsDeSeuil(event.currentTarget.value); - } ); + }); html.find('#attribut-protection-edit').change((event) => { - this.actor.updateProtectionValue( event.currentTarget.attributes.name.value, parseInt(event.target.value) ); - } ); + this.actor.updateProtectionValue(event.currentTarget.attributes.name.value, parseInt(event.target.value)); + }); // On stress change html.find('.compteur-edit').change((event) => { let fieldName = event.currentTarget.attributes.name.value; - this.actor.updateCompteurValue( fieldName, parseInt(event.target.value) ); - } ); + this.actor.updateCompteurValue(fieldName, parseInt(event.target.value)); + }); html.find('#ethylisme').change((event) => { - this.actor.setEthylisme(parseInt(event.target.value) ); - } ); + this.actor.setEthylisme(parseInt(event.target.value)); + }); html.find('#stress-test').click((event) => { this.actor.stressTest(); this.render(true); @@ -496,15 +484,15 @@ export class RdDActorSheet extends ActorSheet { html.find('.monnaie-plus').click((event) => { const li = $(event.currentTarget).parents(".item"); - this.actor.monnaieIncDec( li.data("item-id"), 1 ); + this.actor.monnaieIncDec(li.data("item-id"), 1); this.render(true); }); html.find('.monnaie-moins').click((event) => { const li = $(event.currentTarget).parents(".item"); - this.actor.monnaieIncDec( li.data("item-id"), -1 ); + this.actor.monnaieIncDec(li.data("item-id"), -1); this.render(true); }); - + html.find('#vie-plus').click((event) => { this.actor.santeIncDec("vie", 1); this.render(true); @@ -538,12 +526,12 @@ export class RdDActorSheet extends ActorSheet { this.render(true); }); } - + /* -------------------------------------------- */ /** @override */ - setPosition(options={}) { + setPosition(options = {}) { const position = super.setPosition(options); const sheetBody = this.element.find(".sheet-body"); const bodyHeight = position.height - 192; diff --git a/module/actor.js b/module/actor.js index 80c1e369..3d084731 100644 --- a/module/actor.js +++ b/module/actor.js @@ -46,13 +46,13 @@ export class RdDActor extends Actor { } // If the created actor has items (only applicable to duplicated actors) bypass the new actor creation logic if (data.items) { + let actor = super.create(data, options); if (data.type == "personnage") { - await RdDActor.checkMonnaiePresence( data.items ); + await actor.checkMonnaiePresence( data.items ); } - return super.create(data, options); + return actor; } - data.items = []; let compendiumName = ""; if (data.type == "personnage") { compendiumName = "foundryvtt-reve-de-dragon.competences"; @@ -61,16 +61,7 @@ export class RdDActor extends Actor { } else if (data.type == "entite") { compendiumName = "foundryvtt-reve-de-dragon.competences-entites"; } - let competences = []; - const pack = game.packs.get(compendiumName); - await pack.getIndex().then(index => competences = index); - for (let comp of competences) - { - let compItem = undefined; - await pack.getEntity(comp._id).then(skill => compItem = skill); - data.items.push(compItem); - } - + data.items = RdDUtility.loadCompendium(compendiumName); // Ajout monnaie if (data.type == "personnage" ) { await RdDActor.ajouterMonnaie( data.items ); @@ -207,12 +198,12 @@ export class RdDActor extends Actor { return this.data.data.compteurs?.surenc?.value ?? 0; } /* -------------------------------------------- */ - getCompetenceList() { + loadCompendiumNames() { return this.data.items.filter( (item) => item.type == 'competence'); } /* -------------------------------------------- */ getCompetence(compName) { - return RdDUtility.findCompetence(this.data.items, compName); + return RdDItemCompetence.findCompetence(this.data.items, compName); } /* -------------------------------------------- */ getTache( id ) { @@ -1428,9 +1419,9 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ async checkCompetenceXP( compName ) { - let competence = RdDUtility.findCompetence( this.data.items, compName); + let competence = RdDItemCompetence.findCompetence( this.data.items, compName); if ( competence && competence.data.xp > 0) { - let xpNeeded = RdDUtility.getCompetenceNextXp( competence.data.niveau ); + let xpNeeded = RdDItemCompetence.getCompetenceNextXp( competence.data.niveau ); if ( competence.data.xp >= xpNeeded ) { competence.data.xp -= xpNeeded; competence.data.niveau += 1; @@ -1952,7 +1943,7 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ async ajouteNombreAstral( data ) { // Gestion expérience (si existante) - data.competence = RdDUtility.findCompetence( this.data.items, "astrologie"); + data.competence = RdDItemCompetence.findCompetence( this.data.items, "astrologie"); data.selectedCarac = this.data.data.carac["vue"]; this._appliquerAjoutExperience( data ); diff --git a/module/item-competence.js b/module/item-competence.js index 21f5dc73..5d8be8a4 100644 --- a/module/item-competence.js +++ b/module/item-competence.js @@ -1,17 +1,37 @@ + +const competenceTroncs = [["Esquive", "Dague", "Corps à corps"], +["Epée à 1 main", "Epée à 2 mains", "Hache à 1 main", "Hache à 2 mains", "Lance", "Masse à 1 main", "Masse à 2 mains"]]; + +const competence_xp_par_niveau = [5, 5, 5, 10, 10, 10, 10, 15, 15, 15, 15, 20, 20, 20, 20, 30, 30, 40, 40, 60, 60, 100, 100, 100, 100, 100, 100, 100, 100, 100]; + export class RdDItemCompetence extends Item { /* -------------------------------------------- */ - static isCompetenceMelee(name) { - return name.toLowerCase().match(/(epée|épée|hache|fleau|fléau|masse|lance|hast|dague|bouclier)/); + static isCompetenceArme(competence) { + switch (competence.data.categorie) { + case 'melee': + return competence.name.toLowerCase() != 'esquive'; + case 'tir': + case 'lancer': + return true; + } + return false; } + + /* -------------------------------------------- */ static isArmeUneMain(competence) { - return competence && competence.name.toLowerCase().includes("1 main"); + return competence?.name.toLowerCase().includes("1 main"); + } + static isArme2Main(competence) { + return competence?.name.toLowerCase().includes("2 main"); } + /* -------------------------------------------- */ static isMalusEncombrementTotal(competence) { - return competence && competence.name.toLowerCase().match(/(natation|acrobatie)/); + return competence?.name.toLowerCase().match(/(natation|acrobatie)/); } + /* -------------------------------------------- */ static setRollDataCreature(rollData) { rollData.carac = { "carac_creature": { label: rollData.competence.name, value: rollData.competence.data.carac_value } }; rollData.competence = duplicate(rollData.competence); @@ -19,4 +39,65 @@ export class RdDItemCompetence extends Item { rollData.competence.data.categorie = "creature"; rollData.selectedCarac = rollData.carac.carac_creature } + /* -------------------------------------------- */ + static isTronc(compName) { + for (let troncList of competenceTroncs) { + for (let troncName of troncList) { + if (troncName == compName) + return troncList; + } + } + return false; + } + /* -------------------------------------------- */ + static computeCompetenceXPCost(competence) { + let minLevel = competence.data.base; + if (minLevel == competence.data.niveau) return 0; + if (competence.data.niveau < -10) return 0; + + let xp = 0; + for (let i = minLevel + 1; i <= competence.data.niveau; i++) { + xp += competence_xp_par_niveau[i + 10]; + //console.log(i, i+10, competence_xp_par_niveau[i+10]); + } + if (competence.data.categorie == 'draconic') { + xp += competence.data.xp_sort; + } + return xp; + } + + /* -------------------------------------------- */ + static computeCompetenceTroncXP(competences) { + let xp = 0; + for (let troncList of competenceTroncs) { + let minNiveau = 0; + for (let troncName of troncList) { + let comp = RdDItemCompetence.findCompetence(competences, troncName); + if (comp) { + minNiveau = Math.min(comp.data.niveau, minNiveau); + } + } + minNiveau = Math.max(minNiveau, 0); // Clamp à 0, pour le tronc commun + let minNiveauXP = competence_xp_par_niveau[minNiveau + 10]; + xp += minNiveauXP; + for (let troncName of troncList) { + let comp = RdDItemCompetence.findCompetence(competences, troncName); + if (comp) { + xp += competence_xp_par_niveau[comp.data.niveau + 10] - minNiveauXP; + } + } + } + return xp; + } + /* -------------------------------------------- */ + static findCompetence(list, name) { + name = name.toLowerCase(); + return list.find(item => item.name.toLowerCase() == name && (item.type == "competence" || item.type == "competencecreature")) + } + + /* -------------------------------------------- */ + static getCompetenceNextXp(niveau) { + return competence_xp_par_niveau[niveau + 10]; + } + } \ No newline at end of file diff --git a/module/item-sheet.js b/module/item-sheet.js index 124c00a6..837bfdb9 100644 --- a/module/item-sheet.js +++ b/module/item-sheet.js @@ -2,6 +2,7 @@ import { RdDItemSort } from "./item-sort.js"; import { RdDUtility } from "./rdd-utility.js"; import { RdDItem } from "./item-rdd.js"; import { RdDAlchimie } from "./rdd-alchimie.js"; +import { RdDItemCompetence } from "./item-competence.js"; /** * Extend the basic ItemSheet with some very simple modifications @@ -47,10 +48,13 @@ export class RdDItemSheet extends ItemSheet { /* -------------------------------------------- */ async getData() { let data = super.getData(); - + data.categorieCompetences = RdDUtility.getCategorieCompetences(); if ( data.item.type == 'tache' || data.item.type == 'livre' || data.item.type == 'meditation') { data.caracList = duplicate(game.system.model.Actor.personnage.carac); - data.competenceList = await RdDUtility.getCompetenceList( 'foundryvtt-reve-de-dragon.competences' ); + data.competences = await RdDUtility.loadCompendiumNames( 'foundryvtt-reve-de-dragon.competences' ); + } + if (data.item.type == 'arme') { + data.competences = await RdDUtility.loadCompendium( 'foundryvtt-reve-de-dragon.competences', it => RdDItemCompetence.isCompetenceArme(it)); } if ( data.item.type == 'recettealchimique' ) { RdDAlchimie.processManipulation(data.item, this.actor && this.actor._id ); @@ -101,8 +105,7 @@ export class RdDItemSheet extends ItemSheet { async _onClickSelectCategorie(event) { event.preventDefault(); - const category = event.currentTarget.value; - let level = CONFIG.RDD.level_category[category]; + let level = RdDUtility.getLevelCategory(event.currentTarget.value); this.object.data.data.base = level; $("#base").val( level ); } diff --git a/module/item.js b/module/item.js index bdd2768f..46ad7721 100644 --- a/module/item.js +++ b/module/item.js @@ -3,16 +3,26 @@ export class RdDItem { /* -------------------------------------------- */ - static buildItemsClassification( items ) { - let itemsByType = {}; + static buildItemsClassification(items) { + return RdDItem.classify(items, it => it.type) + } + + static classify(items, classifier = it => it.type, transform = it => it) { + let itemsBy = {}; + RdDItem.classifyInto(itemsBy, items, classifier, transform); + return itemsBy; + } + + static classifyInto(itemsBy, items, classifier = it => it.type, transform = it => it) { for (const item of items) { - let list = itemsByType[item.type]; + const classification = classifier(item); + let list = itemsBy[classification]; if (!list) { list = []; - itemsByType[item.type] = list; + itemsBy[classification] = list; } - list.push(item); + list.push(transform(item)); } - return itemsByType; } + } \ No newline at end of file diff --git a/module/rdd-astrologie-joueur.js b/module/rdd-astrologie-joueur.js index c231f0b7..ab612adb 100644 --- a/module/rdd-astrologie-joueur.js +++ b/module/rdd-astrologie-joueur.js @@ -1,3 +1,4 @@ +import { RdDItemCompetence } from "./item-competence.js"; import { Misc } from "./misc.js"; import { RdDCalendrier } from "./rdd-calendrier.js"; import { RdDUtility } from "./rdd-utility.js"; @@ -15,7 +16,7 @@ export class RdDAstrologieJoueur extends Dialog { dates: game.system.rdd.calendrier.getJoursSuivants( 10 ), etat: actor.getEtatGeneral(), ajustementsConditions: CONFIG.RDD.ajustementsConditions, - astrologie: RdDUtility.findCompetence( actor.data.items, 'Astrologie') + astrologie: RdDItemCompetence.findCompetence( actor.data.items, 'Astrologie') } const html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-astrologie-joueur.html', data); let options = { classes: ["rdddialog"], width: 600, height: 500, 'z-index': 99999 }; diff --git a/module/rdd-main.js b/module/rdd-main.js index 95237c2d..8e0faad3 100644 --- a/module/rdd-main.js +++ b/module/rdd-main.js @@ -22,6 +22,7 @@ import { RdDTokenHud } from "./rdd-token-hud.js"; import { RdDCommands } from "./rdd-commands.js"; import { RdDCombat } from "./rdd-combat.js"; import { ChatUtility } from "./chat-utility.js"; +import { RdDItemCompetence } from "./item-competence.js"; /* -------------------------------------------- */ /* Foundry VTT Initialization */ @@ -65,7 +66,7 @@ const _patch_initiative = () => { } } let compName = ( armeCombat == undefined ) ? "Corps à corps" : armeCombat.data.competence; - competence = RdDUtility.findCompetence( c.actor.data.items, compName ); + competence = RdDItemCompetence.findCompetence( c.actor.data.items, compName ); rollFormula = RdDUtility.calculInitiative(competence.data.niveau, c.actor.data.data.carac[competence.data.defaut_carac].value); } } @@ -190,7 +191,6 @@ Hooks.once("init", async function() { CONFIG.Actor.entityClass = RdDActor; CONFIG.RDD = { resolutionTable : RdDResolutionTable.resolutionTable, - level_category : RdDUtility.getLevelCategory(), carac_array : RdDUtility.getCaracArray(), ajustementsConditions : RdDUtility.getAjustementsConditions(), difficultesLibres : RdDUtility.getDifficultesLibres() diff --git a/module/rdd-utility.js b/module/rdd-utility.js index 5706bef7..e10e776e 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -6,46 +6,26 @@ import { RdDCombat } from "./rdd-combat.js"; import { RdDRollResolutionTable } from "./rdd-roll-resolution-table.js"; import { RdDItemCompetenceCreature } from "./item-competencecreature.js"; import { RdDItemArme } from "./item-arme.js"; +import { RdDItemCompetence } from "./item-competence.js"; /* -------------------------------------------- */ -const level_category = { - "generale": "-4", - "particuliere": "-8", - "specialisee": "-11", - "connaissance": "-11", - "draconic": "-11", - "melee": "-6", - "tir": "-8", - "lancer": "-8" -} -/* -------------------------------------------- */ -const label_category = { - "generale": "Générales", - "particuliere": "Particulières", - "specialisee": "Spécialisées", - "connaissance": "Connaissances", - "draconic": "Draconics", - "melee": "Mêlée", - "tir": "Tir", - "lancer": "Lancer" -} -/* -------------------------------------------- */ -const competenceTroncs = [ ["Esquive", "Dague", "Corps à corps"], - ["Epée à 1 main", "Epée à 2 mains", "Hache à 1 main", "Hache à 2 mains", "Lance", "Masse à 1 main", "Masse à 2 mains"] ]; -const competence_xp = { - "-11" : [ 5, 10, 15, 25, 35, 45, 55, 70, 85, 100, 115, 135, 155, 175 ], - "-8" : [ 10, 20, 30, 40, 55, 70, 85, 100, 120, 140,160], - "-6" : [ 10, 20, 35, 50, 65, 80, 100, 120, 140], - "-4" : [ 15, 30, 45, 60, 80, 100, 120] +const categorieCompetences = { + "generale": { level: "-4", label: "Générales" }, + "particuliere": { level: "-8", label: "Particulières" }, + "specialisee": { level: "-11", label: "Spécialisées" }, + "connaissance": { level: "-11", label: "Connaissances" }, + "draconic": { level: "-11", label: "Draconics" }, + "melee": { level: "-6", label: "Mêlée" }, + "tir": { level: "-8", label: "Tir" }, + "lancer": { level: "-8", label: "Lancer" } } /* -------------------------------------------- */ // This table starts at 0 -> niveau -10 -const competence_xp_par_niveau = [ 5, 5, 5, 10, 10, 10, 10, 15, 15, 15, 15, 20, 20, 20, 20, 30, 30, 40, 40, 60, 60, 100, 100, 100, 100, 100, 100, 100, 100, 100]; -const carac_array = [ "taille", "apparence", "constitution", "force", "agilite", "dexterite", "vue", "ouie", "odoratgout", "volonte", "intellect", "empathie", "reve", "chance", "melee", "tir", "lancer", "derobee"]; -const difficultesLibres = [0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]; -const ajustementsConditions = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10]; -const ajustementsEncaissement = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10, +11, +12, +13, +14, +15, +16, +17, +18, +19, +20, +21, +22, +23, +24, +25]; +const carac_array = ["taille", "apparence", "constitution", "force", "agilite", "dexterite", "vue", "ouie", "odoratgout", "volonte", "intellect", "empathie", "reve", "chance", "melee", "tir", "lancer", "derobee"]; +const difficultesLibres = [0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]; +const ajustementsConditions = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10]; +const ajustementsEncaissement = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10, +11, +12, +13, +14, +15, +16, +17, +18, +19, +20, +21, +22, +23, +24, +25]; const carac_xp_par_valeur = [6, 6, 7, 7, 8, 8, 9, 9, 10, 20, 30, 40, 50, 60, 70]; const XP_CARAC_OFFSET = 7; @@ -54,12 +34,12 @@ function _buildAllSegmentsFatigue(max) { const cycle = [5, 2, 4, 1, 3, 0]; let fatigue = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]; for (let i = 0; i <= max; i++) { - const ligneFatigue= duplicate(fatigue[i]); + const ligneFatigue = duplicate(fatigue[i]); const caseIncrementee = cycle[i % 6]; ligneFatigue[caseIncrementee]++; ligneFatigue[caseIncrementee + 6]++; ligneFatigue.fatigueMax = 2 * (i + 1); - fatigue[i + 1] = ligneFatigue ; + fatigue[i + 1] = ligneFatigue; } return fatigue; @@ -68,10 +48,9 @@ function _buildAllSegmentsFatigue(max) { /* -------------------------------------------- */ function _cumulSegmentsFatigue(matrix) { let cumulMatrix = []; - for (let line of matrix) - { + for (let line of matrix) { let cumul = duplicate(line); - + for (let i = 1; i < 12; i++) { cumul[i] += cumul[i - 1]; } @@ -84,33 +63,37 @@ function _cumulSegmentsFatigue(matrix) { const fatigueMatrix = _buildAllSegmentsFatigue(60); const cumulFatigueMatrix = _cumulSegmentsFatigue(fatigueMatrix); -const fatigueMalus = [ 0, 0, 0, -1, -1, -1, -2, -3, -4, -5, -6, -7 ]; // Provides the malus for each segment of fatigue -const fatigueLineSize = [ 3, 6, 7, 8, 9, 10, 11, 12]; -const fatigueLineMalus = [ 0, -1, -2, -3, -4, -5, -6, -7 ]; -const fatigueMarche = { "aise": { "4":1, "6":2, "8":3, "10":4, "12":6 }, - "malaise": { "4":2, "6":3, "8":4, "10":6 }, - "difficile": { "4":3, "6":4, "8":6 }, - "tresdifficile": { "4":4, "6":6 } } +const fatigueMalus = [0, 0, 0, -1, -1, -1, -2, -3, -4, -5, -6, -7]; // Provides the malus for each segment of fatigue +const fatigueLineSize = [3, 6, 7, 8, 9, 10, 11, 12]; +const fatigueLineMalus = [0, -1, -2, -3, -4, -5, -6, -7]; +const fatigueMarche = { + "aise": { "4": 1, "6": 2, "8": 3, "10": 4, "12": 6 }, + "malaise": { "4": 2, "6": 3, "8": 4, "10": 6 }, + "difficile": { "4": 3, "6": 4, "8": 6 }, + "tresdifficile": { "4": 4, "6": 6 } +} /* -------------------------------------------- */ - /* Static tables for commands /table */ -const table2func = { "rdd": { descr: "rdd: Ouvre la table de résolution", func: RdDRollResolutionTable.open }, - "queues": { descr: "queues: Tire une queue de Dragon", func: RdDRollTables.getQueue}, - "ombre": { descr: "ombre: Tire une Ombre de Dragon", func: RdDRollTables.getOmbre }, - "tetehr": { descr: "tetehr: Tire une Tête de Dragon pour Hauts Revants", fund: RdDRollTables.getTeteHR}, - "tete" : { descr: "tete: Tire une Tête de Dragon", func: RdDRollTables.getTete}, - "souffle": { descr: "souffle: Tire un Souffle de Dragon", func: RdDRollTables.getSouffle}, - "tarot" : { descr: "tarot: Tire une carte de Tarot Dracnique", func: RdDRollTables.getTarot} }; +/* Static tables for commands /table */ +const table2func = { + "rdd": { descr: "rdd: Ouvre la table de résolution", func: RdDRollResolutionTable.open }, + "queues": { descr: "queues: Tire une queue de Dragon", func: RdDRollTables.getQueue }, + "ombre": { descr: "ombre: Tire une Ombre de Dragon", func: RdDRollTables.getOmbre }, + "tetehr": { descr: "tetehr: Tire une Tête de Dragon pour Hauts Revants", fund: RdDRollTables.getTeteHR }, + "tete": { descr: "tete: Tire une Tête de Dragon", func: RdDRollTables.getTete }, + "souffle": { descr: "souffle: Tire un Souffle de Dragon", func: RdDRollTables.getSouffle }, + "tarot": { descr: "tarot: Tire une carte de Tarot Dracnique", func: RdDRollTables.getTarot } +}; /* -------------------------------------------- */ const definitionsBlessures = [ { type: "legere", facteur: 2 }, - { type: "grave", facteur : 4 }, - { type: "critique", facteur : 6 } + { type: "grave", facteur: 4 }, + { type: "critique", facteur: 6 } ] /* -------------------------------------------- */ -const nomEthylisme = [ "Emeché", "Gris", "Pinté", "Pas frais", "Ivre", "Bu", "Complètement fait", "Ivre mort"]; +const nomEthylisme = ["Emeché", "Gris", "Pinté", "Pas frais", "Ivre", "Bu", "Complètement fait", "Ivre mort"]; /* -------------------------------------------- */ const definitionsEncaissement = { @@ -138,9 +121,9 @@ const definitionsEncaissement = { }; /* -------------------------------------------- */ -export class RdDUtility { +export class RdDUtility { /* -------------------------------------------- */ - static async preloadHandlebarsTemplates( ) { + static async preloadHandlebarsTemplates() { const templatePaths = [ //Character Sheets 'systems/foundryvtt-reve-de-dragon/templates/actor-sheet.html', @@ -168,14 +151,14 @@ export class RdDUtility { 'systems/foundryvtt-reve-de-dragon/templates/item-ombre-sheet.html', 'systems/foundryvtt-reve-de-dragon/templates/item-monnaie-sheet.html', 'systems/foundryvtt-reve-de-dragon/templates/item-meditation-sheet.html', - 'systems/foundryvtt-reve-de-dragon/templates/competence-categorie.html', 'systems/foundryvtt-reve-de-dragon/templates/competence-carac-defaut.html', 'systems/foundryvtt-reve-de-dragon/templates/competence-base.html', 'systems/foundryvtt-reve-de-dragon/templates/enum-aspect-tarot.html', - 'systems/foundryvtt-reve-de-dragon/templates/enum-categorie.html', - 'systems/foundryvtt-reve-de-dragon/templates/enum-categorie_parade.html', + 'systems/foundryvtt-reve-de-dragon/templates/enum-categorie-competence.html', + 'systems/foundryvtt-reve-de-dragon/templates/enum-categorie-ingredient.html', + 'systems/foundryvtt-reve-de-dragon/templates/enum-categorie-parade.html', + 'systems/foundryvtt-reve-de-dragon/templates/enum-competence.html', 'systems/foundryvtt-reve-de-dragon/templates/enum-rarete.html', - 'systems/foundryvtt-reve-de-dragon/templates/arme-competence.html', 'systems/foundryvtt-reve-de-dragon/templates/sort-draconic.html', 'systems/foundryvtt-reve-de-dragon/templates/sort-tmr.html', 'systems/foundryvtt-reve-de-dragon/templates/niveau-ethylisme.html', @@ -225,7 +208,7 @@ export class RdDUtility { return loadTemplates(templatePaths); } - /* -------------------------------------------- */ + /* -------------------------------------------- */ static checkNull(items) { if (items && items.length) { return items; @@ -234,46 +217,46 @@ export class RdDUtility { } /* -------------------------------------------- */ - static getNomEthylisme( niveauEthylisme ) { + static getNomEthylisme(niveauEthylisme) { let index = -niveauEthylisme; - return index <0 ? 'Aucun' : nomEthylisme[index]; + return index < 0 ? 'Aucun' : nomEthylisme[index]; } /* -------------------------------------------- */ - static initAfficheContenu( actorId ) { // persistent handling of conteneur show/hide - if ( !this.afficheContenu ) + static initAfficheContenu(actorId) { // persistent handling of conteneur show/hide + if (!this.afficheContenu) this.afficheContenu = {}; } /* -------------------------------------------- */ - static toggleAfficheContenu( conteneurId) { + static toggleAfficheContenu(conteneurId) { this.afficheContenu[conteneurId] = !this.afficheContenu[conteneurId]; } /* -------------------------------------------- */ - static getAfficheContenu( conteneurId) { + static getAfficheContenu(conteneurId) { return this.afficheContenu[conteneurId]; } /* -------------------------------------------- */ - static filterItemsPerTypeForSheet( data ) { - data.data.materiel = this.checkNull(data.itemsByType['objet']); - data.data.conteneurs = this.checkNull(data.itemsByType['conteneur']); - data.data.armes = this.checkNull(data.itemsByType['arme']); - data.data.armures = this.checkNull(data.itemsByType['armure']); - data.data.livres = this.checkNull(data.itemsByType['livre']); - data.data.potions = this.checkNull(data.itemsByType['potion']); + static filterItemsPerTypeForSheet(data) { + data.data.materiel = this.checkNull(data.itemsByType['objet']); + data.data.conteneurs = this.checkNull(data.itemsByType['conteneur']); + data.data.armes = this.checkNull(data.itemsByType['arme']); + data.data.armures = this.checkNull(data.itemsByType['armure']); + data.data.livres = this.checkNull(data.itemsByType['livre']); + data.data.potions = this.checkNull(data.itemsByType['potion']); data.data.ingredients = this.checkNull(data.itemsByType['ingredient']); - data.data.munitions = this.checkNull(data.itemsByType['munition']); - data.data.herbes = this.checkNull(data.itemsByType['herbe']); - data.data.sorts = this.checkNull(data.itemsByType['sort']); - data.data.queues = this.checkNull(data.itemsByType['queue']); - data.data.souffles = this.checkNull(data.itemsByType['souffle']); - data.data.ombres = this.checkNull(data.itemsByType['ombre']); - data.data.tetes = this.checkNull(data.itemsByType['tete']); - data.data.taches = this.checkNull(data.itemsByType['tache']); - data.data.monnaie = this.checkNull(data.itemsByType['monnaie']); + data.data.munitions = this.checkNull(data.itemsByType['munition']); + data.data.herbes = this.checkNull(data.itemsByType['herbe']); + data.data.sorts = this.checkNull(data.itemsByType['sort']); + data.data.queues = this.checkNull(data.itemsByType['queue']); + data.data.souffles = this.checkNull(data.itemsByType['souffle']); + data.data.ombres = this.checkNull(data.itemsByType['ombre']); + data.data.tetes = this.checkNull(data.itemsByType['tete']); + data.data.taches = this.checkNull(data.itemsByType['tache']); + data.data.monnaie = this.checkNull(data.itemsByType['monnaie']); data.data.meditations = this.checkNull(data.itemsByType['meditation']); data.data.recettesAlchimiques = this.checkNull(data.itemsByType['recettealchimique']); - data.data.objets = data.data.conteneurs.concat(data.data.materiel).concat(data.data.armes).concat(data.data.armures).concat(data.data.munitions).concat(data.data.livres).concat(data.data.potions).concat(data.data.herbes).concat(data.data.ingredients); + data.data.objets = data.data.conteneurs.concat(data.data.materiel).concat(data.data.armes).concat(data.data.armures).concat(data.data.munitions).concat(data.data.livres).concat(data.data.potions).concat(data.data.herbes).concat(data.data.ingredients); } /* -------------------------------------------- */ @@ -309,19 +292,19 @@ export class RdDUtility { //conteneur.data.encTotal = ; Deja calculé if (conteneur.data.contenu) { for (let id of conteneur.data.contenu) { - let objet = data.data.objets.find( objet => (id == objet._id) ); + let objet = data.data.objets.find(objet => (id == objet._id)); if (objet) { if (!objet.data.encombrement) objet.data.encombrement = 0; // Auto-fix objet.estContenu = true; // Permet de filtrer ce qifui est porté dans le template actorSheet.objetVersConteneur[id] = conteneur._id; - conteneur.data.encTotal += Number(objet.data.encombrement) * Number(((objet.data.quantite)?objet.data.quantite:1)); - conteneur.subItems.push( objet ); + conteneur.data.encTotal += Number(objet.data.encombrement) * Number(((objet.data.quantite) ? objet.data.quantite : 1)); + conteneur.subItems.push(objet); } } } } // Construit la liste des conteneurs de niveau 1 (c'est à dire non contenu eux-même dans un conteneur) - let newConteneurs = data.data.conteneurs.filter(function(conteneur, index, arr) { return !conteneur.estContenu } ); + let newConteneurs = data.data.conteneurs.filter(function (conteneur, index, arr) { return !conteneur.estContenu }); data.data.conteneurs = newConteneurs; //console.log(newConteneurs); } @@ -330,20 +313,20 @@ export class RdDUtility { /** Construit la structure récursive des conteneurs, avec imbrication potentielle * */ - static buildConteneur( objet, niveau ) { + static buildConteneur(objet, niveau) { if (!niveau) niveau = 1; objet.niveau = niveau; //console.log("OBJ:", objet); - let str = Handlebars.partials['systems/foundryvtt-reve-de-dragon/templates/actor-inventaire-conteneur.html']( { item: objet} ); + let str = Handlebars.partials['systems/foundryvtt-reve-de-dragon/templates/actor-inventaire-conteneur.html']({ item: objet }); if (objet.type == 'conteneur') { //console.log("ITEM DISPLAYED", this.getAfficheContenu(objet._id) ); - if ( this.getAfficheContenu(objet._id) ) { - str = str + "