From 2e689f642aa4da97c297e09f09a04b212c4fe39c Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Sat, 7 Dec 2024 23:51:44 +0100 Subject: [PATCH] =?UTF-8?q?Fix=20s=C3=A9lection=20cible=20parmi=20multiple?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changelog.md | 1 + module/dialog-select.js | 10 +++++----- module/targets.js | 9 +++++++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/changelog.md b/changelog.md index 8cf8a3ce..f1933af2 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,7 @@ ## 12.0.27 - Les vêtements d'Astrobazzarh - Ajout de la liste des armures dans l'onglet caractéristiques - Correction des ajouts de blessures (prise en compte de l'endurance et des contusions) +- Correction du choix d'une cible parmi toutes les cibles pour les combats ## 12.0.26 - Astrobazzarh le Haut-rêvant - bouton pour le don de haut-rêve en un clic diff --git a/module/dialog-select.js b/module/dialog-select.js index cb7ccbc2..0623ca55 100644 --- a/module/dialog-select.js +++ b/module/dialog-select.js @@ -2,11 +2,11 @@ export class DialogSelect extends Dialog { static extractIdNameImg(it) { return { id: it.id, name: it.name, img: it.img } } - static async select(selectData, onSelectChoice) { - const html = await renderTemplate("systems/foundryvtt-reve-de-dragon/templates/dialog-select.html", selectData) + static async select(selectionData, onSelectChoice) { + const html = await renderTemplate("systems/foundryvtt-reve-de-dragon/templates/dialog-select.html", selectionData) const dialogData = { - title: selectData.title ?? selectData.label, + title: selectionData.title ?? selectionData.label, content: html, buttons: {} } @@ -18,7 +18,7 @@ export class DialogSelect extends Dialog { 'max-height': 600, 'z-index': 99999 } - new DialogSelect(dialogData, dialogOptions, selectData, onSelectChoice).render(true) + new DialogSelect(dialogData, dialogOptions, selectionData, onSelectChoice).render(true) } constructor(dialogData, dialogOptions, selectionData, onSelectChoice) { @@ -36,7 +36,7 @@ export class DialogSelect extends Dialog { } choiceSelected(selectedId) { - const selected = this.selectionData.find(it => it.id == selectedId) + const selected = this.selectionData.list.find(it => it.id == selectedId) this.close() if (selected) { this.onSelectChoice(selected) diff --git a/module/targets.js b/module/targets.js index 98f76f2a..073336f5 100644 --- a/module/targets.js +++ b/module/targets.js @@ -11,7 +11,12 @@ export class Targets { } static extractTokenData(target) { - return { id: target?.id, name: target?.document.name, img: target?.document.texture.src ?? target?.actor.img ?? 'icons/svg/mystery-man.svg' }; + return { + id: target?.id, + name: target?.document.name, + img: target?.document.texture.src ?? target?.actor.img ?? 'icons/svg/mystery-man.svg', + target + }; } static buildActorTokenData(tokenId, actor) { return { id: tokenId, name: actor.name, img: actor.img ?? 'icons/svg/mystery-man.svg' }; @@ -35,7 +40,7 @@ export class Targets { label: "Choisir une seule des cibles", list: targets.map(it => Targets.extractTokenData(it)) }; - DialogSelect.select(selectData, onSelectTarget) + DialogSelect.select(selectData, t => onSelectTarget(t.target)) } } }