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,42 @@
|
||||
import { HelperUtils } from '../Helper';
|
||||
export function getCharacterId(knownInfusion) {
|
||||
return knownInfusion.characterId;
|
||||
}
|
||||
export function getChoiceKey(knownInfusion) {
|
||||
return knownInfusion.choiceKey;
|
||||
}
|
||||
export function getUniqueKey(knownInfusion) {
|
||||
return knownInfusion.uniqueKey;
|
||||
}
|
||||
export function getDefinitionKey(knownInfusion) {
|
||||
return knownInfusion.definitionKey;
|
||||
}
|
||||
export function getMappingId(knownInfusion) {
|
||||
return knownInfusion.id;
|
||||
}
|
||||
/**
|
||||
* TODO remove this once it is a string
|
||||
* @param knownInfusion
|
||||
* @returns {number | null}
|
||||
*/
|
||||
export function getItemId(knownInfusion) {
|
||||
if (knownInfusion.itemId !== null) {
|
||||
return HelperUtils.parseInputInt(knownInfusion.itemId);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
export function getItemName(knownInfusion) {
|
||||
return knownInfusion.itemName;
|
||||
}
|
||||
export function getItemTypeId(knownInfusion) {
|
||||
return knownInfusion.itemTypeId;
|
||||
}
|
||||
export function getLegacyItemTypeId(knownInfusion) {
|
||||
return knownInfusion.legacyItemTypeId;
|
||||
}
|
||||
export function getSimulatedInfusion(knownInfusion) {
|
||||
return knownInfusion.simulatedInfusion;
|
||||
}
|
||||
export function getItemDefinitionKey(knownInfusion) {
|
||||
return knownInfusion.itemDefinitionKey;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { DefinitionHacks } from '../Definition';
|
||||
import { getItemId, getItemTypeId } from './accessors';
|
||||
/**
|
||||
*
|
||||
* @param knownInfusionMapping
|
||||
*/
|
||||
export function deriveItemDefinitionKey(knownInfusionMapping) {
|
||||
const itemTypeId = getItemTypeId(knownInfusionMapping);
|
||||
const itemId = getItemId(knownInfusionMapping);
|
||||
if (!itemTypeId || !itemId) {
|
||||
return null;
|
||||
}
|
||||
return DefinitionHacks.hack__generateDefinitionKey(itemTypeId, itemId);
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
import { TypeScriptUtils } from '../../utils';
|
||||
import { HelperUtils } from '../Helper';
|
||||
import { InfusionAccessors, InfusionSimulators, InfusionTypeEnum } from '../Infusion';
|
||||
import { getUniqueKey, getDefinitionKey, getItemDefinitionKey, getSimulatedInfusion, getChoiceKey } from './accessors';
|
||||
import { deriveItemDefinitionKey } from './derivers';
|
||||
/**
|
||||
*
|
||||
* @param knownInfusions
|
||||
*/
|
||||
export function generateKnownInfusionLookupByChoiceKey(knownInfusions) {
|
||||
return HelperUtils.generateNonNullLookup(knownInfusions, getUniqueKey);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param knownInfusions
|
||||
*/
|
||||
export function generateKnownInfusionLookup(knownInfusions) {
|
||||
return HelperUtils.generateNonNullLookup(knownInfusions, getDefinitionKey);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param knownInfusions
|
||||
*/
|
||||
export function generateKnownReplicatedItems(knownInfusions) {
|
||||
return knownInfusions.reduce((acc, knownInfusion) => {
|
||||
const simulatedInfusion = getSimulatedInfusion(knownInfusion);
|
||||
if (simulatedInfusion !== null && InfusionAccessors.getType(simulatedInfusion) === InfusionTypeEnum.REPLICATE) {
|
||||
const itemDefinitionKey = getItemDefinitionKey(knownInfusion);
|
||||
if (itemDefinitionKey !== null) {
|
||||
acc = [...acc, itemDefinitionKey];
|
||||
}
|
||||
}
|
||||
return acc;
|
||||
}, []);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param knownInfusions
|
||||
* @param definitionPool
|
||||
*/
|
||||
export function generateKnownInfusions(knownInfusions, definitionPool, characterId) {
|
||||
return knownInfusions
|
||||
.map((knownInfusionMapping) => generateKnownInfusion(knownInfusionMapping, definitionPool, characterId))
|
||||
.filter(TypeScriptUtils.isNotNullOrUndefined);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param knownInfusionMapping
|
||||
* @param definitionPool
|
||||
*/
|
||||
export function generateKnownInfusion(knownInfusionMapping, definitionPool, characterId) {
|
||||
const definitionKey = getDefinitionKey(knownInfusionMapping);
|
||||
if (!definitionKey) {
|
||||
return null;
|
||||
}
|
||||
const uniqueKey = `${characterId}-${getChoiceKey(knownInfusionMapping)}`;
|
||||
return Object.assign(Object.assign({}, knownInfusionMapping), { simulatedInfusion: InfusionSimulators.simulateInfusion(definitionKey, definitionPool), itemDefinitionKey: deriveItemDefinitionKey(knownInfusionMapping), uniqueKey });
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import * as KnownInfusionAccessors from './accessors';
|
||||
import * as KnownInfusionDerivers from './derivers';
|
||||
import * as KnownInfusionGenerators from './generators';
|
||||
import * as KnownInfusionTypings from './typings';
|
||||
export * from './typings';
|
||||
export { KnownInfusionAccessors, KnownInfusionDerivers, KnownInfusionGenerators };
|
||||
export default Object.assign(Object.assign(Object.assign(Object.assign({}, KnownInfusionAccessors), KnownInfusionDerivers), KnownInfusionGenerators), KnownInfusionTypings);
|
||||
Reference in New Issue
Block a user