mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-06-09 06:08:10 +02:00
[Bug] Potential Adversary When Removed (#248)
* Fixed so edit/view/delete of potential adversary is handled if the adversary Actor has been removed from the world * Improved lang
This commit is contained in:
parent
ee8a48f73d
commit
ac7fb93635
4 changed files with 28 additions and 7 deletions
|
|
@ -181,13 +181,20 @@ export default class DHEnvironmentSettings extends HandlebarsApplicationMixin(Ap
|
|||
|
||||
static async #viewAdversary(_, button) {
|
||||
const adversary = await foundry.utils.fromUuid(button.dataset.adversary);
|
||||
if (!adversary) {
|
||||
ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.notifications.adversaryMissing'));
|
||||
return;
|
||||
}
|
||||
|
||||
adversary.sheet.render(true);
|
||||
}
|
||||
|
||||
static async #deleteAdversary(event, target) {
|
||||
const adversaryKey = target.dataset.adversary;
|
||||
const path = `system.potentialAdversaries.${target.dataset.potentialAdversary}.adversaries`;
|
||||
const newAdversaries = foundry.utils.getProperty(this.actor, path).filter(x => x.uuid !== adversaryKey);
|
||||
const newAdversaries = foundry.utils
|
||||
.getProperty(this.actor, path)
|
||||
.filter(x => x && (x?.uuid ?? x) !== adversaryKey);
|
||||
await this.actor.update({ [path]: newAdversaries });
|
||||
this.render();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue