Simplify checking if something is a valid attribute / trait / combatValue key
This commit is contained in:
parent
24725c15f9
commit
549669e9e2
5 changed files with 39 additions and 58 deletions
|
@ -3,7 +3,7 @@ import { DS4 } from "../config";
|
|||
import { DS4Item } from "../item/item";
|
||||
import { ItemType } from "../item/item-data";
|
||||
import { createCheckRoll } from "../rolls/check-factory";
|
||||
import { DS4ActorData } from "./actor-data";
|
||||
import { DS4ActorData, isAttribute, isTrait } from "./actor-data";
|
||||
import { Check, DS4ActorPreparedData } from "./actor-prepared-data";
|
||||
|
||||
/**
|
||||
|
@ -336,7 +336,7 @@ export class DS4Actor extends Actor<DS4ActorData, DS4Item, DS4ActorPreparedData>
|
|||
label: game.i18n.localize("DS4.GenericOkButton"),
|
||||
callback: (html) => {
|
||||
const selectedAttribute = html.find(`#${attributeIdentifier}`).val();
|
||||
if (selectedAttribute !== "body" && selectedAttribute !== "mobility" && selectedAttribute !== "mind") {
|
||||
if (!isAttribute(selectedAttribute)) {
|
||||
throw new Error(
|
||||
game.i18n.format("DS4.ErrorUnexpectedAttribute", {
|
||||
actualAttribute: selectedAttribute,
|
||||
|
@ -345,17 +345,10 @@ export class DS4Actor extends Actor<DS4ActorData, DS4Item, DS4ActorPreparedData>
|
|||
);
|
||||
}
|
||||
const selectedTrait = html.find(`#${traitIdentifier}`).val();
|
||||
if (
|
||||
selectedTrait !== "strength" &&
|
||||
selectedTrait !== "constitution" &&
|
||||
selectedTrait !== "agility" &&
|
||||
selectedTrait !== "dexterity" &&
|
||||
selectedTrait !== "intellect" &&
|
||||
selectedTrait !== "aura"
|
||||
) {
|
||||
if (!isTrait(selectedTrait)) {
|
||||
throw new Error(
|
||||
game.i18n.format("DS4.ErrorUnexpectedTrait", {
|
||||
actualAttribute: selectedAttribute,
|
||||
actualTrait: selectedTrait,
|
||||
expectedTypes: "'strength', 'constitution', 'agility', 'dexterity', 'intellect', 'aura'",
|
||||
}),
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue