// Roster transforms, run between parsing the .ros file and building the roster. // // The point of these is to print *generic* datasheets - every option a unit // could take, the way the official cards read - rather than a record of the one // list you happen to be playing. import { defaultConfig, defaultToggles } from "./config.js"; import { convertChoiceAbilities } from "./convertChoiceAbilities.js"; import { mergeDuplicateUnits } from "./mergeDuplicateUnits.js"; import { removeLeaderAbilities } from "./removeLeaderAbilities.js"; export { defaultConfig, defaultToggles } from "./config.js"; export { convertChoiceAbilities } from "./convertChoiceAbilities.js"; export { mergeDuplicateUnits } from "./mergeDuplicateUnits.js"; export { removeLeaderAbilities } from "./removeLeaderAbilities.js"; /** * Apply the enabled transforms to `doc`, in place. * * Order matters. The merge runs first because it folds duplicate copies of a * unit together, deduplicating their shared ability profiles on the way; doing * it before the splitter means the splitter sees one copy of each ability * instead of several. The strip then removes what neither of the others needs * to look at, leaving the least text for the splitter to walk. * * Returns a report per transform, for the console and the UI. */ export function applyTransforms( doc, toggles = defaultToggles, config = defaultConfig, ) { const report = {}; if (toggles.mergeDuplicateUnits) { report.mergeDuplicateUnits = mergeDuplicateUnits(doc, config); } if (toggles.removeLeaderAbilities) { report.removeLeaderAbilities = removeLeaderAbilities(doc, config); } if (toggles.convertChoiceAbilities) { report.convertChoiceAbilities = convertChoiceAbilities(doc, config); } return report; }