Skip to content

Commit

Permalink
Strip default false value from toggle RollOptions on extract (foundry…
Browse files Browse the repository at this point in the history
  • Loading branch information
simonward committed Apr 28, 2023
1 parent 45565c4 commit 12bd16c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions build/lib/extractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { ActorSourcePF2e } from "@actor/data/index.ts";
import type { NPCAttributesSource, NPCSystemSource } from "@actor/npc/data.ts";
import { isPhysicalData } from "@item/data/helpers.ts";
import { ActionItemSource, ItemSourcePF2e, MeleeSource, SpellSource } from "@item/data/index.ts";
import { RuleElementSource } from "@module/rules/index.ts";
import { isObject, sluggify } from "@util/index.ts";
import fs from "fs";
import { JSDOM } from "jsdom";
Expand Down Expand Up @@ -482,6 +483,20 @@ class PackExtractor {
} else if (source.type === "spellcastingEntry" && this.#lastActor?.type === "npc") {
delete (source.system as { ability?: unknown }).ability;
}

for (const rule of source.system.rules) {
this.#pruneRuleElement(rule);
}
}

#pruneRuleElement(source: RuleElementSource): void {
switch (source.key) {
case "RollOption":
if ("toggleable" in source && source.toggleable && !source.value) {
delete source.value;
}
return;
}
}

#sortDataItems(docSource: PackEntry): ItemSourcePF2e[] {
Expand Down

0 comments on commit 12bd16c

Please sign in to comment.