Small cleanup
This commit is contained in:
parent
624059ef02
commit
38a3437267
1 changed files with 7 additions and 7 deletions
|
@ -15,7 +15,7 @@ export class DS4Actor extends Actor<DS4ActorData, DS4Item> {
|
||||||
if (!this.data.name) this.data.name = "New " + this.entity;
|
if (!this.data.name) this.data.name = "New " + this.entity;
|
||||||
this.prepareBaseData();
|
this.prepareBaseData();
|
||||||
this.prepareEmbeddedEntities();
|
this.prepareEmbeddedEntities();
|
||||||
this.applyActiveEffectsToNonDerivedData();
|
this.applyActiveEffectsToBaseData();
|
||||||
this.prepareDerivedData();
|
this.prepareDerivedData();
|
||||||
this.applyActiveEffectsToDerivedData();
|
this.applyActiveEffectsToDerivedData();
|
||||||
this.prepareFinalDerivedData();
|
this.prepareFinalDerivedData();
|
||||||
|
@ -24,6 +24,7 @@ export class DS4Actor extends Actor<DS4ActorData, DS4Item> {
|
||||||
/** @override */
|
/** @override */
|
||||||
prepareBaseData(): void {
|
prepareBaseData(): void {
|
||||||
const data = this.data;
|
const data = this.data;
|
||||||
|
|
||||||
const attributes = data.data.attributes;
|
const attributes = data.data.attributes;
|
||||||
Object.values(attributes).forEach(
|
Object.values(attributes).forEach(
|
||||||
(attribute: ModifiableData<number>) => (attribute.total = attribute.base + attribute.mod),
|
(attribute: ModifiableData<number>) => (attribute.total = attribute.base + attribute.mod),
|
||||||
|
@ -33,7 +34,7 @@ export class DS4Actor extends Actor<DS4ActorData, DS4Item> {
|
||||||
Object.values(traits).forEach((trait: ModifiableData<number>) => (trait.total = trait.base + trait.mod));
|
Object.values(traits).forEach((trait: ModifiableData<number>) => (trait.total = trait.base + trait.mod));
|
||||||
}
|
}
|
||||||
|
|
||||||
applyActiveEffectsToNonDerivedData(): void {
|
applyActiveEffectsToBaseData(): void {
|
||||||
this.applyActiveEffectsFiltered(
|
this.applyActiveEffectsFiltered(
|
||||||
(change) =>
|
(change) =>
|
||||||
!this.derivedDataProperties.includes(change.key) && !this.finalDerivedProperties.includes(change.key),
|
!this.derivedDataProperties.includes(change.key) && !this.finalDerivedProperties.includes(change.key),
|
||||||
|
@ -90,8 +91,7 @@ export class DS4Actor extends Actor<DS4ActorData, DS4Item> {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected _getOriginatingItemOfActiveEffect(effect: ActiveEffect<DS4Actor>): DS4Item | undefined {
|
protected _getOriginatingItemOfActiveEffect(effect: ActiveEffect<DS4Actor>): DS4Item | undefined {
|
||||||
const item = this.items.find((item) => item.uuid === effect.data.origin);
|
return this.items.find((item) => item.uuid === effect.data.origin) ?? undefined;
|
||||||
return item ?? undefined;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -119,8 +119,8 @@ export class DS4Actor extends Actor<DS4ActorData, DS4Item> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The list of properties that are completely derived (i.e. {@link ActiveEffect}s cannot be applied to them), given in dot
|
* The list of properties that are completely derived (i.e. {@link ActiveEffect}s cannot be applied to them),
|
||||||
* notation.
|
* given in dot notation.
|
||||||
*/
|
*/
|
||||||
get finalDerivedProperties(): string[] {
|
get finalDerivedProperties(): string[] {
|
||||||
return ["data.combatValues.hitPoints.max"];
|
return ["data.combatValues.hitPoints.max"];
|
||||||
|
@ -165,9 +165,9 @@ export class DS4Actor extends Actor<DS4ActorData, DS4Item> {
|
||||||
protected _prepareCombatValues(): void {
|
protected _prepareCombatValues(): void {
|
||||||
const data = this.data.data;
|
const data = this.data.data;
|
||||||
const armorValueOfEquippedItems = this._calculateArmorValueOfEquippedItems();
|
const armorValueOfEquippedItems = this._calculateArmorValueOfEquippedItems();
|
||||||
|
|
||||||
data.combatValues.hitPoints.base =
|
data.combatValues.hitPoints.base =
|
||||||
(data.attributes.body.total ?? 0) + (data.traits.constitution.total ?? 0) + 10;
|
(data.attributes.body.total ?? 0) + (data.traits.constitution.total ?? 0) + 10;
|
||||||
|
|
||||||
data.combatValues.defense.base =
|
data.combatValues.defense.base =
|
||||||
(data.attributes.body.total ?? 0) + (data.traits.constitution.total ?? 0) + armorValueOfEquippedItems;
|
(data.attributes.body.total ?? 0) + (data.traits.constitution.total ?? 0) + armorValueOfEquippedItems;
|
||||||
data.combatValues.initiative.base = (data.attributes.mobility.total ?? 0) + (data.traits.agility.total ?? 0);
|
data.combatValues.initiative.base = (data.attributes.mobility.total ?? 0) + (data.traits.agility.total ?? 0);
|
||||||
|
|
Loading…
Reference in a new issue