New source found from dndbeyond.com
This commit is contained in:
@@ -121,3 +121,6 @@ export function getTagConstraints(choice) {
|
||||
var _a;
|
||||
return (_a = choice.tagConstraints) !== null && _a !== void 0 ? _a : [];
|
||||
}
|
||||
export function getItemDefinitionKey(choice) {
|
||||
return choice.itemDefinitionKey;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { orderBy } from 'lodash';
|
||||
import { TypeScriptUtils } from "../../utils";
|
||||
import { ChoiceAccessors } from '.';
|
||||
import { ClassAccessors } from '../Class';
|
||||
import { AbilityStatEnum, BuilderChoiceSubtypeEnum, BuilderChoiceTypeEnum, } from '../Core';
|
||||
import { DataOriginTypeEnum } from '../DataOrigin';
|
||||
@@ -12,7 +11,7 @@ import { PrerequisiteValidators } from '../Prerequisite';
|
||||
import { RuleDataAccessors } from '../RuleData';
|
||||
import { SourceUtils } from '../Source';
|
||||
import { SpellUtils } from '../Spell';
|
||||
import { getDefaultSubtypes, getOptions, getOptionValue, isOptional } from './accessors';
|
||||
import { getDefaultSubtypes, getItemDefinitionKey, getOptions, getOptionValue, getTagConstraints, getType, isOptional, } from './accessors';
|
||||
export function isOnlyDefaultSelected(choice) {
|
||||
const defaultSubtypes = getDefaultSubtypes(choice);
|
||||
if (defaultSubtypes.length !== 1) {
|
||||
@@ -71,15 +70,17 @@ export function getSortedChoiceOptionsForFeatsInfo(featId, choice, ruleData, ent
|
||||
//used in FeatureChoice for all choices
|
||||
// extracted from FeatureChoice.tsx
|
||||
// TODO needs to be broken down into smaller utils and simplified
|
||||
export function getSortedChoiceOptionsForFeaturesInfo(choice, fetchedFeats, featLookup, charClass, fetchedSubclasses, characterPreferences, prerequisiteData, ruleData, entityRestrictionData) {
|
||||
var _a, _b;
|
||||
export function getSortedChoiceOptionsForFeaturesInfo(choice, fetchedFeats, featLookup, charClass, fetchedSubclasses, itemShoppe, characterPreferences, prerequisiteData, ruleData, entityRestrictionData) {
|
||||
var _a, _b, _c, _d;
|
||||
let description;
|
||||
let introDescription;
|
||||
let availableOptions;
|
||||
let featSubChoices;
|
||||
const optionValue = ChoiceAccessors.getOptionValue(choice);
|
||||
const options = ChoiceAccessors.getOptions(choice);
|
||||
const type = ChoiceAccessors.getType(choice);
|
||||
const tagConstraints = ChoiceAccessors.getTagConstraints(choice);
|
||||
const optionValue = getOptionValue(choice);
|
||||
const options = getOptions(choice);
|
||||
const type = getType(choice);
|
||||
const tagConstraints = getTagConstraints(choice);
|
||||
const itemDefinitionKey = getItemDefinitionKey(choice);
|
||||
switch (type) {
|
||||
case BuilderChoiceTypeEnum.FEAT_CHOICE_OPTION:
|
||||
const availableFeats = getAvailableFeatChoices(optionValue, fetchedFeats, featLookup);
|
||||
@@ -153,12 +154,12 @@ export function getSortedChoiceOptionsForFeaturesInfo(choice, fetchedFeats, feat
|
||||
.filter(TypeScriptUtils.isNotNullOrUndefined)
|
||||
: [];
|
||||
sources.forEach((source) => {
|
||||
var _a, _b;
|
||||
var _a;
|
||||
if ((_a = source.sourceCategory) === null || _a === void 0 ? void 0 : _a.isToggleable) {
|
||||
description += source.sourceCategory.description ? source.sourceCategory.description : '';
|
||||
}
|
||||
description += (_b = chosenSubclass.description) !== null && _b !== void 0 ? _b : '';
|
||||
});
|
||||
description += (_b = chosenSubclass.description) !== null && _b !== void 0 ? _b : '';
|
||||
}
|
||||
break;
|
||||
case BuilderChoiceTypeEnum.ENTITY_SPELL_OPTION:
|
||||
@@ -168,17 +169,39 @@ export function getSortedChoiceOptionsForFeaturesInfo(choice, fetchedFeats, feat
|
||||
// If there is a chosen spell, set detailChoiceDesc to its description.
|
||||
const chosenSpell = spellOptions.find((spell) => spell.id === optionValue);
|
||||
if (chosenSpell) {
|
||||
description = (_b = chosenSpell.description) !== null && _b !== void 0 ? _b : '';
|
||||
description = (_c = chosenSpell.description) !== null && _c !== void 0 ? _c : '';
|
||||
}
|
||||
break;
|
||||
default:
|
||||
availableOptions = options.map((option) => (Object.assign(Object.assign({}, option), { value: option.id })));
|
||||
// If every option in the array has a null sourceId, ignore sorting by sourceId.
|
||||
// If any option has a non-null sourceId, sort by sourceId.
|
||||
const shouldSortBySourceId = options.some((option) => option.hasOwnProperty('sourceId') && option.sourceId !== null);
|
||||
if (shouldSortBySourceId) {
|
||||
const optionsToGroup = SourceUtils.getSimpleSourcedDefinitionContracts(options);
|
||||
availableOptions = SourceUtils.getGroupedOptionsBySourceCategory(optionsToGroup, ruleData, optionValue, entityRestrictionData);
|
||||
const chosenOption = optionsToGroup.find((option) => option.id === optionValue);
|
||||
if (chosenOption) {
|
||||
description = (_d = chosenOption.description) !== null && _d !== void 0 ? _d : '';
|
||||
}
|
||||
}
|
||||
else {
|
||||
availableOptions = options.map((option) => (Object.assign(Object.assign({}, option), { value: option.id })));
|
||||
}
|
||||
}
|
||||
if (itemDefinitionKey !== null && optionValue !== null) {
|
||||
const item = itemShoppe === null || itemShoppe === void 0 ? void 0 : itemShoppe.getInventoryItems().items.find((item) => item.getDefinitionKey() === itemDefinitionKey);
|
||||
//If there is a chosen item mapping and it exists in the item shoppe, set the choice description to the item's description. and return the intro text to display as well.
|
||||
if (item) {
|
||||
description = item.getDescription() || '';
|
||||
introDescription = item.getIntroText();
|
||||
}
|
||||
}
|
||||
return {
|
||||
choice,
|
||||
options: availableOptions,
|
||||
featSubChoices,
|
||||
description,
|
||||
introDescription,
|
||||
};
|
||||
}
|
||||
// filter Choice options based on modifiers and default subtypes that identify when a user has made a choice from another source. We filter those options out or we append the source data origin name next to the option label
|
||||
|
||||
Reference in New Issue
Block a user