Improve code slightly in a couple of places
This commit is contained in:
parent
5b26dbb00a
commit
d443b339d8
4 changed files with 29 additions and 30 deletions
|
@ -2,6 +2,7 @@ import { ModifiableDataBaseTotal } from "../common/common-data";
|
|||
import { DS4 } from "../config";
|
||||
import { DS4Item } from "../item/item";
|
||||
import { ItemType } from "../item/item-data";
|
||||
import { DS4ArmorPreparedData, DS4ShieldPreparedData } from "../item/item-prepared-data";
|
||||
import { createCheckRoll } from "../rolls/check-factory";
|
||||
import { DS4ActorData, isAttribute, isTrait } from "./actor-data";
|
||||
import { Check, DS4ActorPreparedData } from "./actor-prepared-data";
|
||||
|
@ -208,13 +209,13 @@ export class DS4Actor extends Actor<DS4ActorData, DS4Item, DS4ActorPreparedData>
|
|||
*/
|
||||
protected _calculateArmorValueOfEquippedItems(): number {
|
||||
return this.items
|
||||
.map((item) => {
|
||||
if (item.data.type === "armor" || item.data.type === "shield") {
|
||||
return item.data.data.equipped ? item.data.data.armorValue : 0;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
})
|
||||
.map((item) => item.data)
|
||||
.filter(
|
||||
(data): data is DS4ArmorPreparedData | DS4ShieldPreparedData =>
|
||||
data.type === "armor" || data.type === "shield",
|
||||
)
|
||||
.filter((data) => data.data.equipped)
|
||||
.map((data) => data.data.armorValue)
|
||||
.reduce((a, b) => a + b, 0);
|
||||
}
|
||||
|
||||
|
@ -340,7 +341,9 @@ export class DS4Actor extends Actor<DS4ActorData, DS4Item, DS4ActorPreparedData>
|
|||
throw new Error(
|
||||
game.i18n.format("DS4.ErrorUnexpectedAttribute", {
|
||||
actualAttribute: selectedAttribute,
|
||||
expectedTypes: "'body', 'agility', 'mind'",
|
||||
expectedTypes: Object.keys(DS4.i18n.attributes)
|
||||
.map((attribute) => `'${attribute}'`)
|
||||
.join(", "),
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
@ -349,7 +352,9 @@ export class DS4Actor extends Actor<DS4ActorData, DS4Item, DS4ActorPreparedData>
|
|||
throw new Error(
|
||||
game.i18n.format("DS4.ErrorUnexpectedTrait", {
|
||||
actualTrait: selectedTrait,
|
||||
expectedTypes: "'strength', 'constitution', 'agility', 'dexterity', 'intellect', 'aura'",
|
||||
expectedTypes: Object.keys(DS4.i18n.traits)
|
||||
.map((attribute) => `'${attribute}'`)
|
||||
.join(", "),
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue