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,5 @@
|
||||
export var DefinitionPoolTypeInfoKeyEnum;
|
||||
(function (DefinitionPoolTypeInfoKeyEnum) {
|
||||
DefinitionPoolTypeInfoKeyEnum["DEFINITION_LOOKUP"] = "definitionLookup";
|
||||
DefinitionPoolTypeInfoKeyEnum["ACCESS_TYPE_LOOKUP"] = "accessTypeLookup";
|
||||
})(DefinitionPoolTypeInfoKeyEnum || (DefinitionPoolTypeInfoKeyEnum = {}));
|
||||
@@ -0,0 +1,16 @@
|
||||
import { keyBy } from 'lodash';
|
||||
import { DefinitionAccessors, DefinitionUtils } from '../Definition';
|
||||
/**
|
||||
*
|
||||
* @param definition
|
||||
*/
|
||||
export function generatePoolDefinitionType(definition) {
|
||||
return DefinitionUtils.getDefinitionKeyType(DefinitionAccessors.getDefinitionKey(definition));
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param definitions
|
||||
*/
|
||||
export function generatePoolDefinitionItems(definitions) {
|
||||
return keyBy(definitions, (definition) => DefinitionUtils.getDefinitionKeyId(DefinitionAccessors.getDefinitionKey(definition)));
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import * as DefinitionPoolConstants from './constants';
|
||||
import * as DefinitionPoolGenerators from './generators';
|
||||
import * as DefinitionPoolSimulators from './simulators';
|
||||
import * as DefinitionPoolTypings from './typings';
|
||||
import * as DefinitionPoolUtils from './utils';
|
||||
export * from './typings';
|
||||
export * from './constants';
|
||||
export { DefinitionPoolGenerators, DefinitionPoolSimulators, DefinitionPoolUtils };
|
||||
export default Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, DefinitionPoolConstants), DefinitionPoolGenerators), DefinitionPoolSimulators), DefinitionPoolTypings), DefinitionPoolUtils);
|
||||
@@ -0,0 +1,14 @@
|
||||
import { DefinitionUtils } from '../Definition';
|
||||
/**
|
||||
*
|
||||
* @param definitions
|
||||
* @param accessType
|
||||
*/
|
||||
export function simulateAccessTypeLookup(definitions, accessType) {
|
||||
return definitions.reduce((acc, definition) => {
|
||||
if (definition.definitionKey) {
|
||||
acc[DefinitionUtils.getDefinitionKeyId(definition.definitionKey)] = accessType;
|
||||
}
|
||||
return acc;
|
||||
}, {});
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
import { values } from 'lodash';
|
||||
import { AccessTypeEnum, AccessUtils } from '../Access';
|
||||
import { DefinitionAccessors, DefinitionTypeEnum, DefinitionUtils } from '../Definition';
|
||||
import { DefinitionPoolTypeInfoKeyEnum } from './constants';
|
||||
/**
|
||||
*
|
||||
* @param type
|
||||
* @param id
|
||||
* @param definitionPool
|
||||
*/
|
||||
export function canAccessDefinition(type, id, definitionPool) {
|
||||
const accessTypeLookup = getTypedDefinitionAccessTypeLookup(type, definitionPool);
|
||||
if (accessTypeLookup && accessTypeLookup[id] && AccessUtils.isAccessible(accessTypeLookup[id])) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param type
|
||||
* @param definitionPool
|
||||
* @param includeNonAccessibleDefinition
|
||||
*/
|
||||
export function getTypedDefinitionList(type, definitionPool, includeNonAccessibleDefinition = false) {
|
||||
const lookup = getTypedDefinitionLookup(type, definitionPool);
|
||||
if (lookup) {
|
||||
const definitions = values(lookup); // lodash values is giving typing conflicts
|
||||
return definitions.filter((definition) => includeNonAccessibleDefinition ||
|
||||
(!includeNonAccessibleDefinition &&
|
||||
canAccessDefinition(DefinitionUtils.getDefinitionKeyType(DefinitionAccessors.getDefinitionKey(definition)), DefinitionUtils.getDefinitionKeyId(DefinitionAccessors.getDefinitionKey(definition)), definitionPool)));
|
||||
}
|
||||
return [];
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param type
|
||||
* @param definitionPool
|
||||
*/
|
||||
export function getTypedDefinitionLookup(type, definitionPool) {
|
||||
if (definitionPool[type]) {
|
||||
return definitionPool[type][DefinitionPoolTypeInfoKeyEnum.DEFINITION_LOOKUP];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param type
|
||||
* @param definitionPool
|
||||
*/
|
||||
export function getTypedDefinitionAccessTypeLookup(type, definitionPool) {
|
||||
if (definitionPool[type]) {
|
||||
return definitionPool[type][DefinitionPoolTypeInfoKeyEnum.ACCESS_TYPE_LOOKUP];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param definitionKey
|
||||
* @param definitionPool
|
||||
*/
|
||||
export function getDefinitionAccessType(definitionKey, definitionPool) {
|
||||
const type = DefinitionUtils.getDefinitionKeyType(definitionKey);
|
||||
const typedDefinitionAccessLookup = getTypedDefinitionAccessTypeLookup(type, definitionPool);
|
||||
const id = DefinitionUtils.getDefinitionKeyId(definitionKey);
|
||||
if (typedDefinitionAccessLookup && typedDefinitionAccessLookup[id]) {
|
||||
return typedDefinitionAccessLookup[id];
|
||||
}
|
||||
return AccessTypeEnum.NO_ACCESS;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param definitionKey
|
||||
* @param definitionPool
|
||||
*/
|
||||
export function getInfusionDefinition(definitionKey, definitionPool) {
|
||||
const type = DefinitionTypeEnum.INFUSION;
|
||||
const id = DefinitionUtils.getDefinitionKeyId(definitionKey);
|
||||
const typedDefinitionLookup = getTypedDefinitionLookup(type, definitionPool);
|
||||
if (typedDefinitionLookup && typedDefinitionLookup[id]) {
|
||||
return typedDefinitionLookup[id];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param definitionKey
|
||||
* @param definitionPool
|
||||
*/
|
||||
export function getVehicleDefinition(definitionKey, definitionPool) {
|
||||
const type = DefinitionTypeEnum.VEHICLE;
|
||||
const id = DefinitionUtils.getDefinitionKeyId(definitionKey);
|
||||
const typedDefinitionLookup = getTypedDefinitionLookup(type, definitionPool);
|
||||
if (typedDefinitionLookup && typedDefinitionLookup[id]) {
|
||||
return typedDefinitionLookup[id];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param definitionPool
|
||||
*/
|
||||
export function getVehicleDefinitionList(definitionPool) {
|
||||
return getTypedDefinitionList(DefinitionTypeEnum.VEHICLE, definitionPool);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param definitionKey
|
||||
* @param definitionPool
|
||||
*/
|
||||
export function getClassFeatureDefinition(definitionKey, definitionPool) {
|
||||
const type = DefinitionTypeEnum.CLASS_FEATURE;
|
||||
const id = DefinitionUtils.getDefinitionKeyId(definitionKey);
|
||||
const typedDefinitionLookup = getTypedDefinitionLookup(type, definitionPool);
|
||||
if (typedDefinitionLookup && typedDefinitionLookup[id]) {
|
||||
return typedDefinitionLookup[id];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param definitionKey
|
||||
* @param definitionPool
|
||||
*/
|
||||
export function getRacialTraitDefinition(definitionKey, definitionPool) {
|
||||
const type = DefinitionTypeEnum.RACIAL_TRAIT;
|
||||
const id = DefinitionUtils.getDefinitionKeyId(definitionKey);
|
||||
const typedDefinitionLookup = getTypedDefinitionLookup(type, definitionPool);
|
||||
if (typedDefinitionLookup && typedDefinitionLookup[id]) {
|
||||
return typedDefinitionLookup[id];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
Reference in New Issue
Block a user