Skip to content

Commit

Permalink
Add support for multiple candidate statistics in action object data (f…
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolaj-a authored Dec 30, 2023
1 parent 7886e5c commit 14fac77
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/module/actor/actions/single-check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ interface SingleCheckActionVariantData extends BaseActionVariantData {
modifiers?: RawModifier[];
notes?: SingleCheckActionRollNoteData[];
rollOptions?: string[];
statistic?: string;
statistic?: string | string[];
}

interface SingleCheckActionData extends BaseActionData<SingleCheckActionVariantData> {
difficultyClass?: CheckDC | DCSlug;
modifiers?: RawModifier[];
notes?: SingleCheckActionRollNoteData[];
rollOptions?: string[];
statistic: string;
statistic: string | string[];
}

interface SingleCheckActionUseOptions extends ActionUseOptions {
Expand All @@ -54,7 +54,7 @@ class SingleCheckActionVariant extends BaseActionVariant {
readonly #modifiers?: RawModifier[];
readonly #notes?: RollNoteSource[];
readonly #rollOptions?: string[];
readonly #statistic?: string;
readonly #statistic?: string | string[];

constructor(action: SingleCheckAction, data?: SingleCheckActionVariantData) {
super(action, data);
Expand Down Expand Up @@ -84,7 +84,7 @@ class SingleCheckActionVariant extends BaseActionVariant {
return this.#rollOptions ?? this.#action.rollOptions;
}

get statistic(): string {
get statistic(): string | string[] {
return this.#statistic ?? this.#action.statistic;
}

Expand All @@ -100,7 +100,7 @@ class SingleCheckActionVariant extends BaseActionVariant {
.map(toRollNoteSource)
.map((note) => new RollNotePF2e(note));
const rollOptions = this.rollOptions.concat(options.rollOptions ?? []);
const slug = options.statistic?.trim() || this.statistic;
const slug = options.statistic?.trim() || Array.isArray(this.statistic) ? this.statistic[0] : this.statistic;
const title = this.name
? `${game.i18n.localize(this.#action.name)} - ${game.i18n.localize(this.name)}`
: game.i18n.localize(this.#action.name);
Expand Down Expand Up @@ -143,7 +143,7 @@ class SingleCheckAction extends BaseAction<SingleCheckActionVariantData, SingleC
readonly modifiers: RawModifier[];
readonly notes: RollNoteSource[];
readonly rollOptions: string[];
readonly statistic: string;
readonly statistic: string | string[];

constructor(data: SingleCheckActionData) {
super(data);
Expand Down
2 changes: 1 addition & 1 deletion src/module/system/action-macros/basic/escape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class EscapeAction extends SingleCheckAction {
rollOptions: ["action:escape"],
section: "basic",
slug: "escape",
statistic: "unarmed",
statistic: ["unarmed", "acrobatics", "athletics"],
traits: ["attack"],
});
}
Expand Down

0 comments on commit 14fac77

Please sign in to comment.