[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:
WBHarry 2025-07-02 23:36:27 +02:00 committed by GitHub
parent ee8a48f73d
commit ac7fb93635
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 28 additions and 7 deletions

View file

@ -12,7 +12,6 @@ export default class DhpEnvironment extends DaggerheartSheet(ActorSheetV2) {
actions: {
addAdversary: this.addAdversary,
deleteProperty: this.deleteProperty,
viewAdversary: this.viewAdversary,
openSettings: this.openSettings,
useItem: this.useItem,
toChat: this.toChat
@ -103,14 +102,24 @@ export default class DhpEnvironment extends DaggerheartSheet(ActorSheetV2) {
this.render();
}
static async viewAdversary(_, button) {
const adversary = await foundry.utils.fromUuid(button.dataset.adversary);
async viewAdversary(_, button) {
const target = button.closest('[data-item-uuid]');
const adversary = await foundry.utils.fromUuid(target.dataset.itemUuid);
if (!adversary) {
ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.notifications.adversaryMissing'));
return;
}
adversary.sheet.render(true);
}
static async useItem(event) {
static async useItem(event, button) {
const action = this.getAction(event);
action.use(event);
if (!action) {
await this.viewAdversary(event, button);
} else {
action.use(event);
}
}
static async toChat(event) {