Grabbed dndbeyond's source code
``` ~/go/bin/sourcemapper -output ddb -jsurl https://media.dndbeyond.com/character-app/static/js/main.90aa78c5.js ```
This commit is contained in:
@@ -0,0 +1,452 @@
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getDefinitionAvatarUrl(background) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = background.definition) === null || _a === void 0 ? void 0 : _a.avatarUrl) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getAvatarUrl(background) {
|
||||
return getDefinitionAvatarUrl(background);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getDefinitionBonds(background) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = background.definition) === null || _a === void 0 ? void 0 : _a.bonds) !== null && _b !== void 0 ? _b : [];
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getBonds(background) {
|
||||
return getDefinitionBonds(background);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getDefinitionContractsDescription(background) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = background.definition) === null || _a === void 0 ? void 0 : _a.contractsDescription) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getContractsDescription(background) {
|
||||
return getDefinitionContractsDescription(background);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getDefinitionDescription(background) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = background.definition) === null || _a === void 0 ? void 0 : _a.description) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getDescription(background) {
|
||||
return getDefinitionDescription(background);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getEntityTypeId(background) {
|
||||
return getDefinitionEntityTypeId(background);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getDefinitionEntityTypeId(background) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = background.definition) === null || _a === void 0 ? void 0 : _a.entityTypeId) !== null && _b !== void 0 ? _b : -1;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getDefinitionEquipmentDescription(background) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = background.definition) === null || _a === void 0 ? void 0 : _a.equipmentDescription) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getEquipmentDescription(background) {
|
||||
return getDefinitionEquipmentDescription(background);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getDefinitionFeatureDescription(background) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = background.definition) === null || _a === void 0 ? void 0 : _a.featureDescription) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getFeatureDescription(background) {
|
||||
return getDefinitionFeatureDescription(background);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getDefinitionFeatureName(background) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = background.definition) === null || _a === void 0 ? void 0 : _a.featureName) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getFeatureName(background) {
|
||||
return getDefinitionFeatureName(background);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getDefinitionFlaws(background) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = background.definition) === null || _a === void 0 ? void 0 : _a.flaws) !== null && _b !== void 0 ? _b : [];
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getFlaws(background) {
|
||||
return getDefinitionFlaws(background);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getId(background) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = background.definition) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : -1;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getDefinitionIdeals(background) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = background.definition) === null || _a === void 0 ? void 0 : _a.ideals) !== null && _b !== void 0 ? _b : [];
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getIdeals(background) {
|
||||
return getDefinitionIdeals(background);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getDefinitionLanguagesDescription(background) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = background.definition) === null || _a === void 0 ? void 0 : _a.languagesDescription) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getLanguagesDescription(background) {
|
||||
return getDefinitionLanguagesDescription(background);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getDefinitionLargeAvatarUrl(background) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = background.definition) === null || _a === void 0 ? void 0 : _a.largeAvatarUrl) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getLargeAvatarUrl(background) {
|
||||
return getDefinitionLargeAvatarUrl(background);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getName(background) {
|
||||
return getDefinitionName(background);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getDefinitionName(background) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = background.definition) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : '';
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getDefinitionOrganization(background) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = background.definition) === null || _a === void 0 ? void 0 : _a.organization) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getOrganization(background) {
|
||||
return getDefinitionOrganization(background);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getDefinitionPersonalityTraits(background) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = background.definition) === null || _a === void 0 ? void 0 : _a.personalityTraits) !== null && _b !== void 0 ? _b : [];
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getPersonalityTraits(background) {
|
||||
return getDefinitionPersonalityTraits(background);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getDefinitionShortDescription(background) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = background.definition) === null || _a === void 0 ? void 0 : _a.shortDescription) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getShortDescription(background) {
|
||||
return getDefinitionShortDescription(background);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getDefinitionSkillProficienciesDescription(background) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = background.definition) === null || _a === void 0 ? void 0 : _a.skillProficienciesDescription) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getSkillProficienciesDescription(background) {
|
||||
return getDefinitionSkillProficienciesDescription(background);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getDefinitionSnippet(background) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = background.definition) === null || _a === void 0 ? void 0 : _a.snippet) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getSnippet(background) {
|
||||
return getDefinitionSnippet(background);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getDefinitionSpellsPostDescription(background) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = background.definition) === null || _a === void 0 ? void 0 : _a.spellsPostDescription) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getSpellsPostDescription(background) {
|
||||
return getDefinitionSpellsPostDescription(background);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getDefinitionSpellsPreDescription(background) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = background.definition) === null || _a === void 0 ? void 0 : _a.spellsPreDescription) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getSpellsPreDescription(background) {
|
||||
return getDefinitionSpellsPreDescription(background);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getDefinitionSuggestedCharacteristicsDescription(background) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = background.definition) === null || _a === void 0 ? void 0 : _a.suggestedCharacteristicsDescription) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getSuggestedCharacteristicsDescription(background) {
|
||||
return getDefinitionSuggestedCharacteristicsDescription(background);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getDefinitionSuggestedLanguages(background) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = background.definition) === null || _a === void 0 ? void 0 : _a.suggestedLanguages) !== null && _b !== void 0 ? _b : [];
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getSuggestedLanguages(background) {
|
||||
return getDefinitionSuggestedLanguages(background);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getDefinitionSuggestedProficiencies(background) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = background.definition) === null || _a === void 0 ? void 0 : _a.suggestedProficiencies) !== null && _b !== void 0 ? _b : [];
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getSuggestedProficiencies(background) {
|
||||
return getDefinitionSuggestedProficiencies(background);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getDefinitionToolProficienciesDescription(background) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = background.definition) === null || _a === void 0 ? void 0 : _a.toolProficienciesDescription) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getToolProficienciesDescription(background) {
|
||||
return getDefinitionToolProficienciesDescription(background);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getDefinitionSources(background) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = background.definition) === null || _a === void 0 ? void 0 : _a.sources) !== null && _b !== void 0 ? _b : [];
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getSources(background) {
|
||||
return getDefinitionSources(background);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getDefinitionIsHomebrew(background) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = background.definition) === null || _a === void 0 ? void 0 : _a.isHomebrew) !== null && _b !== void 0 ? _b : false;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function isHomebrew(background) {
|
||||
return getDefinitionIsHomebrew(background);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getDefinitionSpellListIds(background) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = background.definition) === null || _a === void 0 ? void 0 : _a.spellListIds) !== null && _b !== void 0 ? _b : [];
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getSpellListIds(background) {
|
||||
return getDefinitionSpellListIds(background);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getCustomBackground(background) {
|
||||
return background.customBackground;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getDefinitionId(background) {
|
||||
return background.definitionId;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getHasCustomBackground(background) {
|
||||
return background.hasCustomBackground;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getChoices(background) {
|
||||
return background.choices;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function getModifiers(background) {
|
||||
return background.modifiers;
|
||||
}
|
||||
export function getFeatListContracts(contract) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = contract === null || contract === void 0 ? void 0 : contract.definition) === null || _a === void 0 ? void 0 : _a.grantedFeats) !== null && _b !== void 0 ? _b : [];
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
export var BackgroundModifierTypeEnum;
|
||||
(function (BackgroundModifierTypeEnum) {
|
||||
BackgroundModifierTypeEnum[BackgroundModifierTypeEnum["TWO_TOOLS"] = 1] = "TWO_TOOLS";
|
||||
BackgroundModifierTypeEnum[BackgroundModifierTypeEnum["TWO_LANGUAGES"] = 2] = "TWO_LANGUAGES";
|
||||
BackgroundModifierTypeEnum[BackgroundModifierTypeEnum["ONE_TOOL_ONE_LANGUAGE"] = 3] = "ONE_TOOL_ONE_LANGUAGE";
|
||||
})(BackgroundModifierTypeEnum || (BackgroundModifierTypeEnum = {}));
|
||||
@@ -0,0 +1,8 @@
|
||||
import { getEntityTypeId, getId } from './accessors';
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function deriveUniqueKey(background) {
|
||||
return [getId(background), getEntityTypeId(background)].join('-');
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
import { ChoiceGenerators } from '../Choice';
|
||||
import { DataOriginDataInfoKeyEnum, DataOriginTypeEnum } from '../DataOrigin';
|
||||
import { FeatList } from '../FeatList';
|
||||
import { ModifierGenerators } from '../Modifier';
|
||||
import { getCustomBackground, getEntityTypeId, getHasCustomBackground, getId, getModifiers, getSpellListIds, } from './accessors';
|
||||
import { deriveUniqueKey } from './derivers';
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
* @param modifierLookup
|
||||
* @param choiceLookup
|
||||
* @param choiceComponents
|
||||
* @param baseFeats
|
||||
*/
|
||||
export function generateBackground(background, modifierLookup, choiceLookup, choiceComponents, baseFeats) {
|
||||
var _a, _b;
|
||||
if (!background || (background && !getHasCustomBackground(background) && background.definition === null)) {
|
||||
return null;
|
||||
}
|
||||
let backgroundInfo;
|
||||
if (getHasCustomBackground(background) && background.customBackground) {
|
||||
const { featuresBackground, characteristicsBackground, name, description, id, entityTypeId } = background.customBackground;
|
||||
let featureName = '';
|
||||
let featureDescription = '';
|
||||
if (featuresBackground) {
|
||||
featureName = featuresBackground.featureName ? featuresBackground.featureName : '';
|
||||
featureDescription = featuresBackground.featureDescription ? featuresBackground.featureDescription : '';
|
||||
}
|
||||
let bonds = [];
|
||||
let flaws = [];
|
||||
let ideals = [];
|
||||
let personalityTraits = [];
|
||||
if (characteristicsBackground) {
|
||||
bonds = characteristicsBackground.bonds === null ? [] : characteristicsBackground.bonds;
|
||||
flaws = characteristicsBackground.flaws === null ? [] : characteristicsBackground.flaws;
|
||||
ideals = characteristicsBackground.ideals === null ? [] : characteristicsBackground.ideals;
|
||||
personalityTraits =
|
||||
characteristicsBackground.personalityTraits === null ? [] : characteristicsBackground.personalityTraits;
|
||||
}
|
||||
backgroundInfo = {
|
||||
hasCustomBackground: getHasCustomBackground(background),
|
||||
customBackground: getCustomBackground(background),
|
||||
definitionId: id,
|
||||
definition: {
|
||||
avatarUrl: '',
|
||||
largeAvatarUrl: '',
|
||||
organization: null,
|
||||
snippet: '',
|
||||
contractsDescription: null,
|
||||
equipmentDescription: '',
|
||||
languagesDescription: '',
|
||||
skillProficienciesDescription: '',
|
||||
spellsPreDescription: null,
|
||||
spellsPostDescription: null,
|
||||
toolProficienciesDescription: '',
|
||||
suggestedCharacteristicsDescription: '',
|
||||
suggestedLanguages: [],
|
||||
suggestedProficiencies: [],
|
||||
id,
|
||||
entityTypeId,
|
||||
name,
|
||||
description,
|
||||
shortDescription: description,
|
||||
featureName,
|
||||
featureDescription,
|
||||
bonds,
|
||||
flaws,
|
||||
ideals,
|
||||
personalityTraits,
|
||||
isHomebrew: false,
|
||||
sources: [],
|
||||
spellListIds: [],
|
||||
grantedFeats: [],
|
||||
},
|
||||
};
|
||||
}
|
||||
else {
|
||||
backgroundInfo = background;
|
||||
}
|
||||
const backgroundId = getId(backgroundInfo);
|
||||
const backgroundTypeId = getEntityTypeId(backgroundInfo);
|
||||
const choices = ChoiceGenerators.generateBaseChoices(backgroundId, backgroundTypeId, choiceLookup, DataOriginTypeEnum.BACKGROUND, backgroundInfo);
|
||||
const modifiers = ModifierGenerators.generateModifiers(backgroundId, backgroundTypeId, modifierLookup, DataOriginTypeEnum.BACKGROUND, backgroundInfo);
|
||||
const featLists = ((_b = (_a = backgroundInfo.definition) === null || _a === void 0 ? void 0 : _a.grantedFeats) === null || _b === void 0 ? void 0 : _b.map((featListContract) => new FeatList(featListContract, choiceComponents.definitionKeyNameMap, baseFeats))) || [];
|
||||
return Object.assign(Object.assign({}, backgroundInfo), { choices,
|
||||
modifiers,
|
||||
featLists });
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function generateBackgroundModifiers(background) {
|
||||
return background ? getModifiers(background) : [];
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function generateRefBackgroundData(background) {
|
||||
let data = {};
|
||||
if (background !== null) {
|
||||
data[deriveUniqueKey(background)] = {
|
||||
[DataOriginDataInfoKeyEnum.PRIMARY]: background,
|
||||
[DataOriginDataInfoKeyEnum.PARENT]: null,
|
||||
};
|
||||
}
|
||||
return data;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param background
|
||||
*/
|
||||
export function generateGlobalSpellListIds(background) {
|
||||
return background ? getSpellListIds(background) : [];
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import * as BackgroundAccessors from './accessors';
|
||||
import * as BackgroundConstants from './constants';
|
||||
import * as BackgroundDerivers from './derivers';
|
||||
import * as BackgroundGenerators from './generators';
|
||||
import * as BackgroundTypings from './typings';
|
||||
export * from './typings';
|
||||
export * from './constants';
|
||||
export { BackgroundAccessors, BackgroundDerivers, BackgroundGenerators };
|
||||
export default Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, BackgroundAccessors), BackgroundConstants), BackgroundDerivers), BackgroundGenerators), BackgroundTypings);
|
||||
Reference in New Issue
Block a user