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,381 @@
|
||||
import { TypeScriptUtils } from '../../utils';
|
||||
import { VehicleComponentGroupTypeEnum } from '../Vehicle';
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getActions(component) {
|
||||
return component.actions;
|
||||
}
|
||||
/**
|
||||
* @deprecated - this was a generated string of action name and description snippet that we no longer get on the definition
|
||||
* @param component
|
||||
*/
|
||||
export function getDefinitionActionsDescription(component) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = component.definition) === null || _a === void 0 ? void 0 : _a.actionsDescription) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
* @deprecated - this was a generated string of action name and description snippet that we no longer get on the definition
|
||||
* @param component
|
||||
*/
|
||||
export function getActionsDescription(component) {
|
||||
return getDefinitionActionsDescription(component);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getComponentId(component) {
|
||||
return component.componentId;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getCosts(component) {
|
||||
return getDefinitionCosts(component);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getDefinitionCosts(component) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = component.definition) === null || _a === void 0 ? void 0 : _a.costs) !== null && _b !== void 0 ? _b : [];
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getArmorClass(component) {
|
||||
return getDefinitionArmorClass(component);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getDefinitionArmorClass(component) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = component.definition) === null || _a === void 0 ? void 0 : _a.armorClass) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getArmorClassDescription(component) {
|
||||
return getDefinitionArmorClassDescription(component);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getDefinitionArmorClassDescription(component) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = component.definition) === null || _a === void 0 ? void 0 : _a.armorClassDescription) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getArmorClassInfo(component) {
|
||||
return component.armorClassInfo;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getCoverType(component) {
|
||||
return getDefinitionCoverType(component);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getDefinitionCoverType(component) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = component.definition) === null || _a === void 0 ? void 0 : _a.coverType) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getRequiredCrew(component) {
|
||||
return getDefinitionRequiredCrew(component);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getDefinitionRequiredCrew(component) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = component.definition) === null || _a === void 0 ? void 0 : _a.requiredCrew) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getMishapThreshold(component) {
|
||||
return getDefinitionMishapThreshold(component);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getDefinitionMishapThreshold(component) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = component.definition) === null || _a === void 0 ? void 0 : _a.mishapThreshold) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getDamageThreshold(component) {
|
||||
return getDefinitionDamageThreshold(component);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getDefinitionDamageThreshold(component) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = component.definition) === null || _a === void 0 ? void 0 : _a.damageThreshold) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getMappingDescription(component) {
|
||||
return component.description;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getDescription(component) {
|
||||
return component.description;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getDefinitionDescription(component) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = component.definition) === null || _a === void 0 ? void 0 : _a.description) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getDisplayOrder(component) {
|
||||
return component.displayOrder;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getHitPoints(component) {
|
||||
return getDefinitionHitPoints(component);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getDefinitionHitPoints(component) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = component.definition) === null || _a === void 0 ? void 0 : _a.hitPoints) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getIsRemovable(component) {
|
||||
return component.isRemovable;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getLevelId(component) {
|
||||
return component.levelId;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getVehicleLevelId(component) {
|
||||
return component.vehicleLevelId;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getName(component) {
|
||||
var _a;
|
||||
return (_a = component.name) !== null && _a !== void 0 ? _a : getDefinitionName(component);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getDefinitionName(component) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = component.definition) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getSpeedInfos(component) {
|
||||
return component.speedInfos;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getSpeeds(component) {
|
||||
return getDefinitionSpeeds(component);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getDefinitionSpeeds(component) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = component.definition) === null || _a === void 0 ? void 0 : _a.speeds) !== null && _b !== void 0 ? _b : [];
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getTypes(component) {
|
||||
return getDefinitionTypes(component);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getDefinitionTypes(component) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = component.definition) === null || _a === void 0 ? void 0 : _a.types) !== null && _b !== void 0 ? _b : [];
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getId(component) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = component.definition) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getMappingId(component) {
|
||||
return component.id;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getCharacterId(component) {
|
||||
return component.characterId;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getDefinitionDefinitionKey(component) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = component.definition) === null || _a === void 0 ? void 0 : _a.definitionKey) !== null && _b !== void 0 ? _b : '';
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getDefinitionKey(component) {
|
||||
var _a;
|
||||
return (_a = component.definitionKey) !== null && _a !== void 0 ? _a : '';
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getDefinitionActions(component) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = component.definition) === null || _a === void 0 ? void 0 : _a.actions) !== null && _b !== void 0 ? _b : [];
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getIsPrimary(component) {
|
||||
return component.isPrimaryComponent;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getGroupType(component) {
|
||||
if (component.definition && component.definition.groupType !== null) {
|
||||
const groupType = component.definition
|
||||
.groupType;
|
||||
switch (groupType) {
|
||||
case VehicleComponentGroupTypeEnum.COMPONENT:
|
||||
case VehicleComponentGroupTypeEnum.ACTION_STATION:
|
||||
return groupType;
|
||||
default:
|
||||
TypeScriptUtils.testUnreachable(groupType);
|
||||
}
|
||||
}
|
||||
return VehicleComponentGroupTypeEnum.COMPONENT;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getUniqueKey(component) {
|
||||
return component.uniqueKey;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getUniquenessFactor(component) {
|
||||
return component.uniquenessFactor;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getHitPointSpeedAdjustments(component) {
|
||||
return component.hitPointSpeedAdjustments;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getHitPointInfo(component) {
|
||||
return component.hitPointInfo;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getRemovedHitPoints(component) {
|
||||
return component.removedHitPoints;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getVehicleMappingId(component) {
|
||||
return component.vehicleMappingId;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function getTypeNames(component) {
|
||||
return component.typeNames;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
export var ComponentAdjustmentEnum;
|
||||
(function (ComponentAdjustmentEnum) {
|
||||
ComponentAdjustmentEnum["HIT_POINT_SPEED_ADJUSTMENT"] = "speed";
|
||||
})(ComponentAdjustmentEnum || (ComponentAdjustmentEnum = {}));
|
||||
//TODO new for spelljammers
|
||||
export var ComponentCostTypeEnum;
|
||||
(function (ComponentCostTypeEnum) {
|
||||
ComponentCostTypeEnum["COMPONENT"] = "component";
|
||||
ComponentCostTypeEnum["AMMUNITION"] = "ammunition";
|
||||
})(ComponentCostTypeEnum || (ComponentCostTypeEnum = {}));
|
||||
@@ -0,0 +1,111 @@
|
||||
import { TypeScriptUtils } from '../../utils';
|
||||
import { AbilityStatEnum } from '../Core';
|
||||
import { HelperUtils } from '../Helper';
|
||||
import { RuleDataUtils } from '../RuleData';
|
||||
import { VehicleAccessors, VehicleUtils } from '../Vehicle';
|
||||
import { VehicleConfigurationKeyEnum, VehicleGenerators } from '../Vehicle';
|
||||
import { getArmorClass, getArmorClassDescription, getDefinitionActions, getDefinitionSpeeds, getHitPoints, getRemovedHitPoints, getTypes, } from './accessors';
|
||||
import { ComponentAdjustmentEnum } from './constants';
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
* @param vehicle
|
||||
*/
|
||||
export function deriveArmorClassInfo(component, vehicle) {
|
||||
const enableMotionlessArmorClass = VehicleUtils.getConfigurationValue(VehicleConfigurationKeyEnum.ENABLE_COMPONENT_ARMOR_CLASS_MOTIONLESS, vehicle);
|
||||
const armorClass = getArmorClass(component);
|
||||
let movingArmorClass = null;
|
||||
if (enableMotionlessArmorClass && armorClass !== null) {
|
||||
const dexScore = HelperUtils.lookupDataOrFallback(VehicleAccessors.getStatLookup(vehicle), AbilityStatEnum.DEXTERITY);
|
||||
let dexModifier = 0;
|
||||
if (dexScore !== null && dexScore.modifier !== null) {
|
||||
dexModifier = dexScore.modifier;
|
||||
}
|
||||
movingArmorClass = armorClass + dexModifier;
|
||||
}
|
||||
return {
|
||||
base: armorClass,
|
||||
moving: movingArmorClass,
|
||||
description: getArmorClassDescription(component),
|
||||
};
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
* @param ruleData
|
||||
*/
|
||||
export function deriveTypeNames(component, ruleData) {
|
||||
return getTypes(component)
|
||||
.map((type) => {
|
||||
if (type.type === null) {
|
||||
return null;
|
||||
}
|
||||
return RuleDataUtils.getComponentTypeName(type.type, ruleData);
|
||||
})
|
||||
.filter(TypeScriptUtils.isNotNullOrUndefined);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
* @param ruleData
|
||||
*/
|
||||
export function deriveSpeedInfos(component, ruleData) {
|
||||
return getDefinitionSpeeds(component).map((speedInfo) => {
|
||||
if (speedInfo.modes === null) {
|
||||
return speedInfo;
|
||||
}
|
||||
const modes = speedInfo.modes.map((mode) => {
|
||||
const movementInfo = mode.movementId === null ? null : RuleDataUtils.getMovementInfo(mode.movementId, ruleData);
|
||||
return Object.assign(Object.assign({}, mode), { movementInfo });
|
||||
});
|
||||
return Object.assign(Object.assign({}, speedInfo), { modes });
|
||||
});
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function deriveHitPointInfo(component) {
|
||||
const hitPoints = getHitPoints(component);
|
||||
if (hitPoints === null) {
|
||||
return null;
|
||||
}
|
||||
const removedHp = getRemovedHitPoints(component);
|
||||
return {
|
||||
baseHp: hitPoints,
|
||||
bonusHp: null,
|
||||
overrideHp: null,
|
||||
remainingHp: hitPoints - removedHp,
|
||||
removedHp,
|
||||
tempHp: null,
|
||||
totalHp: hitPoints,
|
||||
};
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function deriveHitPointSpeedAdjustments(component) {
|
||||
const adjustments = [];
|
||||
getTypes(component).forEach((type) => {
|
||||
if (type.adjustments) {
|
||||
type.adjustments.forEach((adjustment) => {
|
||||
if (adjustment.type && adjustment.type === ComponentAdjustmentEnum.HIT_POINT_SPEED_ADJUSTMENT) {
|
||||
if (adjustment.values) {
|
||||
adjustments.push(...adjustment.values);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
return adjustments;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
* @param ruleData
|
||||
* @param vehicle
|
||||
*/
|
||||
export function deriveActions(component, ruleData, vehicle) {
|
||||
return getDefinitionActions(component).map((actionContract) => VehicleGenerators.generateVehicleAction(vehicle, actionContract, ruleData));
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
import { groupBy, keyBy } from 'lodash';
|
||||
import { TypeScriptUtils } from '../../utils';
|
||||
import { DefinitionAccessors } from '../Definition';
|
||||
import { HelperUtils } from '../Helper';
|
||||
import { VehicleAccessors } from '../Vehicle';
|
||||
import { getCosts, getDefinitionKey, getMappingId, getName, getTypes, getVehicleMappingId } from './accessors';
|
||||
import { deriveActions, deriveArmorClassInfo, deriveHitPointInfo, deriveHitPointSpeedAdjustments, deriveSpeedInfos, deriveTypeNames, } from './derivers';
|
||||
/**
|
||||
*
|
||||
* @param components
|
||||
*/
|
||||
export function generateVehicleComponentLookup(components) {
|
||||
return groupBy(components, (component) => getVehicleMappingId(component));
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function generateUniqueKey(component) {
|
||||
const types = getTypes(component).map((type) => (type.type ? type.type : ''));
|
||||
const id = getMappingId(component);
|
||||
return `${id}-${types.join('-')}-${getName(component)}`;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
*/
|
||||
export function generateUniquenessFactor(component) {
|
||||
const factors = [];
|
||||
const name = getName(component);
|
||||
if (name) {
|
||||
factors.push(name);
|
||||
}
|
||||
getTypes(component).forEach((type) => {
|
||||
if (type.type) {
|
||||
factors.push(type.type);
|
||||
}
|
||||
});
|
||||
return factors.join('|');
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicleMapping
|
||||
* @param vehicle
|
||||
* @param vehicleComponentLookup
|
||||
* @param ruleData
|
||||
*/
|
||||
export function generateVehicleComponents(vehicleMapping, vehicle, vehicleComponentLookup, ruleData) {
|
||||
const componentDefinitionMappingLookup = keyBy(VehicleAccessors.getDefinitionComponents(vehicle), (componentDefinition) => DefinitionAccessors.getDefinitionKey(componentDefinition));
|
||||
const chracterVehicleComponentMappings = HelperUtils.lookupDataOrFallback(vehicleComponentLookup, VehicleAccessors.getMappingId(vehicleMapping), []);
|
||||
return chracterVehicleComponentMappings
|
||||
.map((componentMapping) => {
|
||||
const componentDefinitionMapping = HelperUtils.lookupDataOrFallback(componentDefinitionMappingLookup, getDefinitionKey(componentMapping), null);
|
||||
return generateVehicleComponent(componentMapping, componentDefinitionMapping, ruleData, vehicle);
|
||||
})
|
||||
.filter(TypeScriptUtils.isNotNullOrUndefined);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param componentMapping
|
||||
* @param componentDefinitionMapping
|
||||
* @param ruleData
|
||||
* @param vehicle
|
||||
*/
|
||||
export function generateVehicleComponent(componentMapping, componentDefinitionMapping, ruleData, vehicle) {
|
||||
if (componentDefinitionMapping === null) {
|
||||
return null;
|
||||
}
|
||||
const baseVehicleComponent = Object.assign(Object.assign({}, componentMapping), componentDefinitionMapping);
|
||||
return Object.assign(Object.assign({}, baseVehicleComponent), { armorClassInfo: deriveArmorClassInfo(baseVehicleComponent, vehicle), costs: getCosts(baseVehicleComponent), uniqueKey: generateUniqueKey(baseVehicleComponent), uniquenessFactor: generateUniquenessFactor(baseVehicleComponent), hitPointSpeedAdjustments: deriveHitPointSpeedAdjustments(baseVehicleComponent), actions: deriveActions(baseVehicleComponent, ruleData, vehicle), hitPointInfo: deriveHitPointInfo(baseVehicleComponent), typeNames: deriveTypeNames(baseVehicleComponent, ruleData), speedInfos: deriveSpeedInfos(baseVehicleComponent, ruleData) });
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import * as VehicleComponentAccessors from './accessors';
|
||||
import * as VehicleComponentConstants from './constants';
|
||||
import * as VehicleComponentDerivers from './derivers';
|
||||
import * as VehicleComponentGenerators from './generators';
|
||||
import * as VehicleComponentSimulators from './simulators';
|
||||
import * as VehicleComponentTypings from './typings';
|
||||
export * from './constants';
|
||||
export * from './typings';
|
||||
export { VehicleComponentAccessors, VehicleComponentDerivers, VehicleComponentGenerators, VehicleComponentSimulators };
|
||||
export default Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, VehicleComponentAccessors), VehicleComponentConstants), VehicleComponentDerivers), VehicleComponentGenerators), VehicleComponentTypings), VehicleComponentSimulators);
|
||||
@@ -0,0 +1,37 @@
|
||||
import { keyBy } from 'lodash';
|
||||
import { TypeScriptUtils } from '../../utils';
|
||||
import { DefinitionAccessors, DefinitionUtils } from '../Definition';
|
||||
import { HelperUtils } from '../Helper';
|
||||
import { VehicleAccessors } from '../Vehicle';
|
||||
import { getCosts, getDefinitionName } from './accessors';
|
||||
import { deriveActions, deriveArmorClassInfo, deriveHitPointInfo, deriveHitPointSpeedAdjustments, deriveSpeedInfos, deriveTypeNames, } from './derivers';
|
||||
import { generateUniqueKey, generateUniquenessFactor } from './generators';
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
* @param ruleData
|
||||
*/
|
||||
export function simulateVehicleComponents(vehicle, ruleData) {
|
||||
const definitionComponents = VehicleAccessors.getDefinitionComponents(vehicle);
|
||||
const componentDefinitionLookup = keyBy(definitionComponents, (componentDefinition) => DefinitionAccessors.getDefinitionKey(componentDefinition));
|
||||
return definitionComponents
|
||||
.map((componentMapping) => {
|
||||
const definitionMapping = HelperUtils.lookupDataOrFallback(componentDefinitionLookup, DefinitionAccessors.getDefinitionKey(componentMapping), null);
|
||||
if (definitionMapping === null) {
|
||||
return null;
|
||||
}
|
||||
return simulateVehicleComponent(definitionMapping, vehicle, ruleData);
|
||||
})
|
||||
.filter(TypeScriptUtils.isNotNullOrUndefined);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param componentDefinitionMapping
|
||||
* @param vehicle
|
||||
* @param ruleData
|
||||
*/
|
||||
export function simulateVehicleComponent(componentDefinitionMapping, vehicle, ruleData) {
|
||||
const definitionKey = DefinitionAccessors.getDefinitionKey(componentDefinitionMapping);
|
||||
const baseVehicleComponent = Object.assign(Object.assign({}, componentDefinitionMapping), { characterId: -1, id: -1, definitionKey, componentId: DefinitionUtils.getDefinitionKeyId(definitionKey), vehicleLevelId: null, vehicleMappingId: VehicleAccessors.getMappingId(vehicle), name: getDefinitionName(componentDefinitionMapping), removedHitPoints: 0 });
|
||||
return Object.assign(Object.assign({}, baseVehicleComponent), { uniqueKey: generateUniqueKey(baseVehicleComponent), costs: getCosts(baseVehicleComponent), armorClassInfo: deriveArmorClassInfo(baseVehicleComponent, vehicle), uniquenessFactor: generateUniquenessFactor(baseVehicleComponent), hitPointSpeedAdjustments: deriveHitPointSpeedAdjustments(baseVehicleComponent), actions: deriveActions(baseVehicleComponent, ruleData, vehicle), hitPointInfo: deriveHitPointInfo(baseVehicleComponent), typeNames: deriveTypeNames(baseVehicleComponent, ruleData), speedInfos: deriveSpeedInfos(baseVehicleComponent, ruleData) });
|
||||
}
|
||||
Reference in New Issue
Block a user