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)) } } }