diff --git a/changelog.md b/changelog.md index 178fa015..eb6307e0 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,9 @@ --- # v10.7 - L'os de Semolosse +## v10.7.14 - l'expérience de Semolosse +- Affichage des personnages accordés sur les fiches des entités + ## v10.7.13 - l'armure de Semolosse - Fix: en cas d'armure variable, la détérioration diminue le dé d'armure diff --git a/module/actor-entite-sheet.js b/module/actor-entite-sheet.js index d7a96ce0..50f505bf 100644 --- a/module/actor-entite-sheet.js +++ b/module/actor-entite-sheet.js @@ -1,4 +1,6 @@ import { RdDActorSheet } from "./actor-sheet.js"; +import { RdDSheetUtility } from "./rdd-sheet-utility.js"; +import { RdDUtility } from "./rdd-utility.js"; export class RdDActorEntiteSheet extends RdDActorSheet { @@ -13,6 +15,12 @@ export class RdDActorEntiteSheet extends RdDActorSheet { dragDrop: [{ dragSelector: ".item-list .item", dropSelector: undefined }] }); } + async getData() { + let formData = await super.getData(); + formData.resonances = this.actor.system.sante.resonnance.actors.map(actorId => game.actors.get(actorId)) + .map(actor => { return { id: actor.id, name: actor.name, img: actor.img } }) + return formData + } /* -------------------------------------------- */ /** @override */ @@ -35,6 +43,23 @@ export class RdDActorEntiteSheet extends RdDActorSheet { let compName = event.currentTarget.attributes.compname.value; this.actor.updateCreatureCompetence(compName, "dommages", parseInt(event.target.value)); }); + this.html.find('.resonance-delete').click(async event => { + const li = RdDSheetUtility.getEventElement(event); + const actorId = li.data("actor-id"); + if (actorId) { + const actorResonance = game.actors.get(actorId); + RdDUtility.confirmerSuppressionSubacteur(this, actorResonance, li, () => { + console.log('Delete : ', actorId); + this.removeSubacteur(actorId); + RdDUtility.slideOnDelete(this, li); + }); + } + }); + } + + async removeSubacteur(actorId) { + let newResonances = this.actor.system.sante.resonnance.actors.filter(id => id != actorId); + await this.actor.update({ 'system.sante.resonnance.actors': newResonances }, { renderSheet: false }); } } diff --git a/module/actor-sheet.js b/module/actor-sheet.js index d19ef734..bc71937c 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -129,7 +129,11 @@ export class RdDActorSheet extends RdDBaseActorSheet { const actorId = li.data("actor-id"); if (actorId) { const subActor = game.actors.get(actorId); - RdDUtility.confirmerSuppressionSubacteur(this, subActor, li); + RdDUtility.confirmerSuppressionSubacteur(this, subActor, li, () => { + console.log('Delete : ', subActor.id); + this.actor.removeSubacteur(subActor.id); + RdDUtility.slideOnDelete(this, li); + }); } }); this.html.find('.experiencelog-delete').click(async event => { diff --git a/module/rdd-utility.js b/module/rdd-utility.js index 50e47113..2cf5d7c3 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -136,6 +136,7 @@ export class RdDUtility { 'systems/foundryvtt-reve-de-dragon/templates/actor/blessure.hbs', 'systems/foundryvtt-reve-de-dragon/templates/actor/maladies-poisons.html', 'systems/foundryvtt-reve-de-dragon/templates/actor/possessions.html', + 'systems/foundryvtt-reve-de-dragon/templates/actor/resonances.hbs', 'systems/foundryvtt-reve-de-dragon/templates/actor/taches.html', 'systems/foundryvtt-reve-de-dragon/templates/actor/taches.html', 'systems/foundryvtt-reve-de-dragon/templates/actor/oeuvres.html', @@ -859,17 +860,13 @@ export class RdDUtility { } /* -------------------------------------------- */ - static confirmerSuppressionSubacteur(sheet, subActor, htmlToDelete) { + static confirmerSuppressionSubacteur(sheet, subActor, htmlToDelete, onSuppression = ()=>{}) { RdDConfirm.confirmer({ settingConfirmer: "confirmation-supprimer-lien-acteur", content: `
Etes vous certain de vouloir supprimer le lien vers ${subActor.name} ?
`, title: 'Confirmer la suppression', buttonLabel: 'Supprimer le lien', - onAction: () => { - console.log('Delete : ', subActor.id); - sheet.actor.removeSubacteur(subActor.id); - RdDUtility.slideOnDelete(sheet, htmlToDelete); - } + onAction: onSuppression }) } diff --git a/templates/actor-entite-sheet.html b/templates/actor-entite-sheet.html index 5706efde..fe6c1018 100644 --- a/templates/actor-entite-sheet.html +++ b/templates/actor-entite-sheet.html @@ -41,6 +41,9 @@ {{>"systems/foundryvtt-reve-de-dragon/templates/actor/comp-creature.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/actor/comp-possession.html"}} +