Simplify getting the source name of effects
This commit is contained in:
parent
e39d245aff
commit
4d2a7d1686
6 changed files with 17 additions and 17 deletions
|
@ -125,7 +125,7 @@
|
|||
"DS4.EffectEnabled": "Aktiv",
|
||||
"DS4.EffectEnabledAbbr": "A",
|
||||
"DS4.EffectLabel": "Bezeichnung",
|
||||
"DS4.EffectSource": "Quelle",
|
||||
"DS4.EffectSourceName": "Quelle",
|
||||
"DS4.ActorName": "Name",
|
||||
"DS4.ActorImageAltText": "Bild des Aktors",
|
||||
"DS4.ActorTypeCharacter": "Charakter",
|
||||
|
|
|
@ -125,7 +125,7 @@
|
|||
"DS4.EffectEnabled": "Enabled",
|
||||
"DS4.EffectEnabledAbbr": "E",
|
||||
"DS4.EffectLabel": "Label",
|
||||
"DS4.EffectSource": "Source",
|
||||
"DS4.EffectSourceName": "Source",
|
||||
"DS4.ActorName": "Name",
|
||||
"DS4.ActorImageAltText": "Image of the Actor",
|
||||
"DS4.ActorTypeCharacter": "Character",
|
||||
|
|
|
@ -21,4 +21,11 @@ export class DS4ActiveEffect extends ActiveEffect {
|
|||
}
|
||||
return super.apply(actor, change);
|
||||
}
|
||||
|
||||
/**
|
||||
* A public wrapper for {@link ActiveEffect#_getSourceName}.
|
||||
*/
|
||||
async getSourceName(): Promise<string> {
|
||||
return this._getSourceName();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ import { getCanvas, getGame } from "../../helpers";
|
|||
import { DS4Item } from "../../item/item";
|
||||
import { DS4Settings, getDS4Settings } from "../../settings";
|
||||
import notifications from "../../ui/notifications";
|
||||
import { DS4Actor } from "../actor";
|
||||
import { isCheck } from "../actor-data-properties";
|
||||
|
||||
/**
|
||||
|
@ -61,16 +60,10 @@ export class DS4ActorSheet extends ActorSheet<ActorSheet.Options, DS4ActorSheetD
|
|||
}),
|
||||
);
|
||||
|
||||
const enrichedEffectPromises = this.actor.effects.toObject().map(async (effect) => {
|
||||
const originatingDocument = effect.origin !== undefined ? await fromUuid(effect.origin) : undefined;
|
||||
const source =
|
||||
(originatingDocument instanceof DS4Actor || originatingDocument instanceof DS4Item
|
||||
? originatingDocument.name
|
||||
: null) ?? undefined;
|
||||
|
||||
const enrichedEffectPromises = this.actor.effects.map(async (effect) => {
|
||||
return {
|
||||
...effect,
|
||||
source,
|
||||
...effect.toObject(),
|
||||
sourceName: await effect.getSourceName(),
|
||||
};
|
||||
});
|
||||
const enrichedEffects = await Promise.all(enrichedEffectPromises);
|
||||
|
@ -335,5 +328,5 @@ interface DS4ActorSheetData extends ActorSheet.Data<ActorSheet.Options> {
|
|||
type ActiveEffectDataSource = foundry.data.ActiveEffectData["_source"];
|
||||
|
||||
interface EnrichedActiveEffectDataSource extends ActiveEffectDataSource {
|
||||
source?: string;
|
||||
sourceName: string;
|
||||
}
|
||||
|
|
|
@ -22,8 +22,8 @@ SPDX-License-Identifier: MIT
|
|||
{{!-- label --}}
|
||||
<div title="{{effectData.label}}">{{effectData.label}}</div>
|
||||
|
||||
{{!-- source --}}
|
||||
<div>{{effectData.source}}</div>
|
||||
{{!-- source name --}}
|
||||
<div>{{effectData.sourceName}}</div>
|
||||
|
||||
{{!-- control buttons --}}
|
||||
{{> systems/ds4/templates/sheets/actor/components/overview-control-buttons.hbs
|
||||
|
|
|
@ -18,8 +18,8 @@ SPDX-License-Identifier: MIT
|
|||
{{!-- label --}}
|
||||
<div>{{localize 'DS4.EffectLabel'}}</div>
|
||||
|
||||
{{!-- origin --}}
|
||||
<div>{{localize 'DS4.EffectSource'}}</div>
|
||||
{{!-- source name --}}
|
||||
<div>{{localize 'DS4.EffectSourceName'}}</div>
|
||||
|
||||
{{!-- control buttons placeholder --}}
|
||||
<div></div>
|
||||
|
|
Loading…
Reference in a new issue