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,653 @@
|
||||
import { TypeScriptUtils } from '../../utils';
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getAccessType(vehicle) {
|
||||
return vehicle.accessType;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getId(vehicle) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = vehicle.definition) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : '';
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getMappingId(vehicle) {
|
||||
return vehicle.id;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getCharacterId(vehicle) {
|
||||
return vehicle.characterId;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getDefinitionKey(vehicle) {
|
||||
return vehicle.definitionKey;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getDefinitionDefinitionKey(vehicle) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = vehicle.definition) === null || _a === void 0 ? void 0 : _a.definitionKey) !== null && _b !== void 0 ? _b : '';
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getDefinitionId(vehicle) {
|
||||
return vehicle.definitionId;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getUniqueKey(vehicle) {
|
||||
return vehicle.uniqueKey;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getAvatarUrl(vehicle) {
|
||||
return getDefinitionAvatarUrl(vehicle);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getDefinitionAvatarUrl(vehicle) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = vehicle.definition) === null || _a === void 0 ? void 0 : _a.avatarUrl) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getName(vehicle) {
|
||||
return vehicle.name ? vehicle.name : getDefinitionName(vehicle);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getDefinitionName(vehicle) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = vehicle.definition) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
export function getSlug(vehicle) {
|
||||
return getDefinitionSlug(vehicle);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getDefinitionSlug(vehicle) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = vehicle.definition) === null || _a === void 0 ? void 0 : _a.slug) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getDefinitionStats(vehicle) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = vehicle.definition) === null || _a === void 0 ? void 0 : _a.stats) !== null && _b !== void 0 ? _b : [];
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getActionsText(vehicle) {
|
||||
return getDefinitionActionsText(vehicle);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getDefinitionActionsText(vehicle) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = vehicle.definition) === null || _a === void 0 ? void 0 : _a.actionsText) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getDefinitionActions(vehicle) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = vehicle.definition) === null || _a === void 0 ? void 0 : _a.actions) !== null && _b !== void 0 ? _b : [];
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getActions(vehicle) {
|
||||
return vehicle.actions;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getActionSummaries(vehicle) {
|
||||
return getDefinitionComponentActionSummaries(vehicle);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getDefinitionComponentActionSummaries(vehicle) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = vehicle.definition) === null || _a === void 0 ? void 0 : _a.componentActionSummaries) !== null && _b !== void 0 ? _b : [];
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getAllActions(vehicle) {
|
||||
return vehicle.allActions;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getCargoCapacity(vehicle) {
|
||||
return getDefinitionCargoCapacity(vehicle);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getDefinitionCargoCapacity(vehicle) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = vehicle.definition) === null || _a === void 0 ? void 0 : _a.cargoCapacity) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getCargoCapacityDescription(vehicle) {
|
||||
return getDefinitionCargoCapacityDescription(vehicle);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getDefinitionCargoCapacityDescription(vehicle) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = vehicle.definition) === null || _a === void 0 ? void 0 : _a.cargoCapacityDescription) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getEnabledConditions(vehicle) {
|
||||
return getDefinitionEnabledConditions(vehicle);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getDefinitionEnabledConditions(vehicle) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = vehicle.definition) === null || _a === void 0 ? void 0 : _a.enabledConditions) !== null && _b !== void 0 ? _b : [];
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getActiveConditionLookup(vehicle) {
|
||||
return vehicle.activeConditionLookup;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getActiveConditions(vehicle) {
|
||||
return vehicle.activeConditions;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getConditions(vehicle) {
|
||||
return vehicle.conditions;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getRemainingFuel(vehicle) {
|
||||
return vehicle.remainingFuel;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getDefinitionFuelData(vehicle) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = vehicle.definition) === null || _a === void 0 ? void 0 : _a.fuelData) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getFuelData(vehicle) {
|
||||
return vehicle.fuelData;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getPrimaryComponent(vehicle) {
|
||||
return vehicle.primaryComponent;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getComponents(vehicle) {
|
||||
return vehicle.components;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getActionStations(vehicle) {
|
||||
return vehicle.actionStations;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getDefinitionComponents(vehicle) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = vehicle.definition) === null || _a === void 0 ? void 0 : _a.components) !== null && _b !== void 0 ? _b : [];
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getConditionImmunities(vehicle) {
|
||||
return getDefinitionConditionImmunities(vehicle);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getDefinitionConditionImmunities(vehicle) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = vehicle.definition) === null || _a === void 0 ? void 0 : _a.conditionImmunities) !== null && _b !== void 0 ? _b : [];
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getCreatureCapacityDescriptions(vehicle) {
|
||||
return vehicle.creatureCapacityDescriptions;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getCreatureCapacity(vehicle) {
|
||||
return getDefinitionCreatureCapacity(vehicle);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getDefinitionCreatureCapacity(vehicle) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = vehicle.definition) === null || _a === void 0 ? void 0 : _a.creatureCapacity) !== null && _b !== void 0 ? _b : [];
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getDamageImmunities(vehicle) {
|
||||
return getDefinitionDamageImmunities(vehicle);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getDefinitionDamageImmunities(vehicle) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = vehicle.definition) === null || _a === void 0 ? void 0 : _a.damageImmunities) !== null && _b !== void 0 ? _b : [];
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getLength(vehicle) {
|
||||
return getDefinitionLength(vehicle);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getDefinitionLength(vehicle) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = vehicle.definition) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getWidth(vehicle) {
|
||||
return getDefinitionWidth(vehicle);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getDefinitionWidth(vehicle) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = vehicle.definition) === null || _a === void 0 ? void 0 : _a.width) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getLevels(vehicle) {
|
||||
return getDefinitionLevels(vehicle);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getDefinitionLevels(vehicle) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = vehicle.definition) === null || _a === void 0 ? void 0 : _a.levels) !== null && _b !== void 0 ? _b : [];
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getStats(vehicle) {
|
||||
return vehicle.stats;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getTravelPace(vehicle) {
|
||||
return getDefinitionTravelPace(vehicle);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getDefinitionTravelPace(vehicle) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = vehicle.definition) === null || _a === void 0 ? void 0 : _a.travelPace) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getTravelPaceEffectiveHours(vehicle) {
|
||||
return getDefinitionTravelPaceEffectiveHours(vehicle);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getDefinitionTravelPaceEffectiveHours(vehicle) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = vehicle.definition) === null || _a === void 0 ? void 0 : _a.travelPaceEffectiveHours) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getLargeAvatarUrl(vehicle) {
|
||||
return getDefinitionLargeAvatarUrl(vehicle);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getDefinitionLargeAvatarUrl(vehicle) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = vehicle.definition) === null || _a === void 0 ? void 0 : _a.largeAvatarUrl) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getType(vehicle) {
|
||||
return getDefinitionType(vehicle);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getDefinitionType(vehicle) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = vehicle.definition) === null || _a === void 0 ? void 0 : _a.type) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getUrl(vehicle) {
|
||||
return getDefinitionUrl(vehicle);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getDefinitionUrl(vehicle) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = vehicle.definition) === null || _a === void 0 ? void 0 : _a.url) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getWeight(vehicle) {
|
||||
return getDefinitionWeight(vehicle);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getDefinitionWeight(vehicle) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = vehicle.definition) === null || _a === void 0 ? void 0 : _a.weight) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getConfigurations(vehicle) {
|
||||
return getDefinitionConfigurations(vehicle);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getDefinitionConfigurations(vehicle) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = vehicle.definition) === null || _a === void 0 ? void 0 : _a.configurations) !== null && _b !== void 0 ? _b : [];
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getConfigurationLookup(vehicle) {
|
||||
return vehicle.configurationLookup;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getConfigurationValueLookup(vehicle) {
|
||||
return vehicle.configurationValueLookup;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getStatLookup(vehicle) {
|
||||
return vehicle.statLookup;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getFeatures(vehicle) {
|
||||
return vehicle.features;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getDefinitionFeatures(vehicle) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = vehicle.definition) === null || _a === void 0 ? void 0 : _a.features) !== null && _b !== void 0 ? _b : [];
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getDamageImmunityInfos(vehicle) {
|
||||
return vehicle.damageImmunityInfos;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getConditionImmunityInfos(vehicle) {
|
||||
return vehicle.conditionImmunityInfos;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getSizeId(vehicle) {
|
||||
return vehicle.sizeId;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getDefinitionSizeId(vehicle) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = vehicle.definition) === null || _a === void 0 ? void 0 : _a.sizeId) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getSizeInfo(vehicle) {
|
||||
return vehicle.sizeInfo;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getNotes(vehicle) {
|
||||
return vehicle.notes;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getDefinitionDescription(vehicle) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = vehicle.definition) === null || _a === void 0 ? void 0 : _a.description) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getDescription(vehicle) {
|
||||
return vehicle.description;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getObjectTypeInfo(vehicle) {
|
||||
return vehicle.objectTypeInfo;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getMovementKeys(vehicle) {
|
||||
return vehicle.movementKeys;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getMovementNames(vehicle) {
|
||||
return vehicle.movementNames;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getTypeName(vehicle) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = getObjectTypeInfo(vehicle)) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getSearchTags(vehicle) {
|
||||
return [getDefinitionName(vehicle), getTypeName(vehicle)].filter(TypeScriptUtils.isNotNullOrUndefined);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getAllComponentsData(vehicle) {
|
||||
return [...getComponents(vehicle), ...getActionStations(vehicle)];
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getDefinitionSources(vehicle) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = vehicle.definition) === null || _a === void 0 ? void 0 : _a.sources) !== null && _b !== void 0 ? _b : [];
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getSources(vehicle) {
|
||||
return getDefinitionSources(vehicle);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getDefinitionIsHomebrew(vehicle) {
|
||||
var _a, _b;
|
||||
return (_b = (_a = vehicle.definition) === null || _a === void 0 ? void 0 : _a.isHomebrew) !== null && _b !== void 0 ? _b : false;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function isHomebrew(vehicle) {
|
||||
return getDefinitionIsHomebrew(vehicle);
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
export var VehicleConfigurationKeyEnum;
|
||||
(function (VehicleConfigurationKeyEnum) {
|
||||
VehicleConfigurationKeyEnum["ENABLE_TRAVEL_PACE"] = "ETP";
|
||||
VehicleConfigurationKeyEnum["ENABLE_COMPONENTS"] = "EC";
|
||||
VehicleConfigurationKeyEnum["ENABLE_ACTION_STATIONS"] = "EAS";
|
||||
VehicleConfigurationKeyEnum["ENABLE_LEVELS"] = "EL";
|
||||
VehicleConfigurationKeyEnum["ENABLE_COMPONENT_HIT_POINTS"] = "ECHP";
|
||||
VehicleConfigurationKeyEnum["ENABLE_COMPONENT_ARMOR_CLASS"] = "ECAC";
|
||||
VehicleConfigurationKeyEnum["ENABLE_COMPONENT_SPEEDS"] = "ECS";
|
||||
VehicleConfigurationKeyEnum["ENABLE_COMPONENT_MISHAP_THRESHOLD"] = "ECMT";
|
||||
VehicleConfigurationKeyEnum["ENABLE_COMPONENT_DAMAGE_THRESHOLD"] = "ECDT";
|
||||
VehicleConfigurationKeyEnum["ENABLE_COMPONENT_ARMOR_CLASS_MOTIONLESS"] = "ECACM";
|
||||
VehicleConfigurationKeyEnum["ENABLE_COMPONENT_CREW_REQUIREMENTS"] = "ECCR";
|
||||
VehicleConfigurationKeyEnum["ENABLE_COMPONENT_COVER"] = "ECC";
|
||||
VehicleConfigurationKeyEnum["ENABLE_COMPONENT_REMOVAL"] = "ECR";
|
||||
VehicleConfigurationKeyEnum["ENABLE_FEATURES"] = "EF";
|
||||
VehicleConfigurationKeyEnum["ENABLE_CONDITIONS_TRACKING"] = "ECT";
|
||||
VehicleConfigurationKeyEnum["ENABLE_FUEL_TRACKING"] = "EFT";
|
||||
VehicleConfigurationKeyEnum["PRIMARY_COMPONENT_MANAGE_TYPE"] = "PCMT";
|
||||
VehicleConfigurationKeyEnum["SIZE_TYPE"] = "ST";
|
||||
VehicleConfigurationKeyEnum["DISPLAY_TYPE"] = "DT";
|
||||
})(VehicleConfigurationKeyEnum || (VehicleConfigurationKeyEnum = {}));
|
||||
export var VehicleConfigurationDisplayTypeEnum;
|
||||
(function (VehicleConfigurationDisplayTypeEnum) {
|
||||
VehicleConfigurationDisplayTypeEnum["SHIP"] = "ship";
|
||||
VehicleConfigurationDisplayTypeEnum["INFERNAL_WAR_MACHINE"] = "infernal-war-machine";
|
||||
VehicleConfigurationDisplayTypeEnum["SPELLJAMMER"] = "spelljammer";
|
||||
})(VehicleConfigurationDisplayTypeEnum || (VehicleConfigurationDisplayTypeEnum = {}));
|
||||
export var VehicleConfigurationPrimaryComponentManageTypeEnum;
|
||||
(function (VehicleConfigurationPrimaryComponentManageTypeEnum) {
|
||||
VehicleConfigurationPrimaryComponentManageTypeEnum["COMPONENT"] = "component";
|
||||
VehicleConfigurationPrimaryComponentManageTypeEnum["VEHICLE"] = "vehicle";
|
||||
VehicleConfigurationPrimaryComponentManageTypeEnum["ALL"] = "all";
|
||||
})(VehicleConfigurationPrimaryComponentManageTypeEnum || (VehicleConfigurationPrimaryComponentManageTypeEnum = {}));
|
||||
export var VehicleConfigurationSizeTypeEnum;
|
||||
(function (VehicleConfigurationSizeTypeEnum) {
|
||||
VehicleConfigurationSizeTypeEnum["WEIGHT"] = "weight";
|
||||
VehicleConfigurationSizeTypeEnum["DIMENSION"] = "dimension";
|
||||
})(VehicleConfigurationSizeTypeEnum || (VehicleConfigurationSizeTypeEnum = {}));
|
||||
export var VehicleComponentGroupTypeEnum;
|
||||
(function (VehicleComponentGroupTypeEnum) {
|
||||
VehicleComponentGroupTypeEnum["ACTION_STATION"] = "action-station";
|
||||
VehicleComponentGroupTypeEnum["COMPONENT"] = "component";
|
||||
})(VehicleComponentGroupTypeEnum || (VehicleComponentGroupTypeEnum = {}));
|
||||
@@ -0,0 +1,302 @@
|
||||
import { sortBy } from 'lodash';
|
||||
import { TypeScriptUtils } from '../../utils';
|
||||
import { AbilityUtils } from '../Ability';
|
||||
import { AccessTypeEnum } from '../Access';
|
||||
import { ProficiencyLevelEnum } from '../Core';
|
||||
import { DefinitionUtils } from '../Definition';
|
||||
import { DefinitionPoolUtils } from '../DefinitionPool';
|
||||
import { HelperUtils } from '../Helper';
|
||||
import { RuleDataAccessors, RuleDataUtils } from '../RuleData';
|
||||
import { VehicleComponentAccessors } from '../VehicleComponent';
|
||||
import { getAllComponentsData, getConditionImmunities, getCreatureCapacity, getDamageImmunities, getDefinitionActions, getDefinitionKey, getDefinitionStats, getDescription, getLength, getType, getWeight, getWidth, } from './accessors';
|
||||
import { VehicleComponentGroupTypeEnum, VehicleConfigurationDisplayTypeEnum, VehicleConfigurationKeyEnum, VehicleConfigurationSizeTypeEnum, } from './constants';
|
||||
import { generateVehicleAction } from './generators';
|
||||
import { getConfigurationValue } from './utils';
|
||||
/**
|
||||
*
|
||||
* @param vehicleDefinition
|
||||
* @param ruleData
|
||||
*/
|
||||
export function deriveStats(vehicleDefinition, ruleData) {
|
||||
if (vehicleDefinition.stats === null) {
|
||||
return [];
|
||||
}
|
||||
return vehicleDefinition.stats.map((stat) => {
|
||||
const score = stat.value;
|
||||
return {
|
||||
id: stat.id,
|
||||
score,
|
||||
statKey: stat.name,
|
||||
modifier: score === null ? null : AbilityUtils.getStatScoreModifier(score, ruleData),
|
||||
};
|
||||
});
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
* @param ruleData
|
||||
*/
|
||||
export function deriveAbilities(vehicle, ruleData) {
|
||||
const stats = getDefinitionStats(vehicle);
|
||||
return stats.map((stat) => {
|
||||
const score = stat.value;
|
||||
const name = stat.name ? stat.name : '';
|
||||
const statScoreModifier = score === null ? null : AbilityUtils.getStatScoreModifier(score, ruleData);
|
||||
return {
|
||||
label: name,
|
||||
id: stat.id,
|
||||
entityTypeId: -1,
|
||||
name,
|
||||
statKey: name,
|
||||
totalScore: score,
|
||||
score,
|
||||
maxStatScore: RuleDataAccessors.getMaxStatScore(ruleData),
|
||||
isMaxed: !!score && score >= RuleDataAccessors.getMaxStatScore(ruleData),
|
||||
modifier: statScoreModifier,
|
||||
baseScore: score,
|
||||
racialBonus: 0,
|
||||
classBonuses: 0,
|
||||
miscBonus: 0,
|
||||
setScore: 0,
|
||||
stackingBonus: 0,
|
||||
otherBonus: 0,
|
||||
overrideScore: null,
|
||||
proficiency: false,
|
||||
proficiencyLevel: ProficiencyLevelEnum.NONE,
|
||||
isSaveProficiencyModified: false,
|
||||
isSaveModifierModified: false,
|
||||
save: statScoreModifier ? statScoreModifier : 0,
|
||||
saveBonuses: 0,
|
||||
isSaveOverridden: false,
|
||||
allStatBonusSuppliers: [],
|
||||
statSetScoreSuppliers: [],
|
||||
statMaxBonusSuppliers: [],
|
||||
stackingBonusSuppliers: [],
|
||||
};
|
||||
});
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
* @param ruleData
|
||||
*/
|
||||
export function deriveCreatureCapacityDescriptions(vehicle, ruleData) {
|
||||
const creatureCapacityInfos = getCreatureCapacity(vehicle);
|
||||
const descriptions = creatureCapacityInfos.map((capacity) => {
|
||||
var _a;
|
||||
let sizeName = '';
|
||||
if (capacity.sizeId !== null) {
|
||||
const sizeInfo = RuleDataUtils.getCreatureSizeInfo(capacity.sizeId, ruleData);
|
||||
if (sizeInfo && sizeInfo.name) {
|
||||
sizeName = sizeInfo.name;
|
||||
}
|
||||
}
|
||||
const isSpelljammer = getConfigurationValue(VehicleConfigurationKeyEnum.DISPLAY_TYPE, vehicle) ===
|
||||
VehicleConfigurationDisplayTypeEnum.SPELLJAMMER;
|
||||
const needsParens = isSpelljammer && capacity.type !== null;
|
||||
return `${capacity.capacity} ${sizeName} ${needsParens ? '(' : ''}${(_a = capacity.type) !== null && _a !== void 0 ? _a : ''}${needsParens ? ')' : ''}`.trim();
|
||||
});
|
||||
return descriptions;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param abilityLookup
|
||||
*/
|
||||
export function deriveModifierData(abilityLookup) {
|
||||
return {
|
||||
proficiencyBonus: 0,
|
||||
abilityLookup,
|
||||
attunedItemCount: 0,
|
||||
};
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
* @param ruleData
|
||||
*/
|
||||
export function deriveDamageImmunities(vehicle, ruleData) {
|
||||
return getDamageImmunities(vehicle)
|
||||
.map((damageImmunityId) => RuleDataUtils.getDamageType(damageImmunityId, ruleData))
|
||||
.filter(TypeScriptUtils.isNotNullOrUndefined);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
* @param ruleData
|
||||
*/
|
||||
export function deriveConditionImmunities(vehicle, ruleData) {
|
||||
return getConditionImmunities(vehicle)
|
||||
.map((conditionId) => RuleDataUtils.getCondition(conditionId, ruleData))
|
||||
.filter(TypeScriptUtils.isNotNullOrUndefined);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
* @param ruleData
|
||||
*/
|
||||
export function deriveSizeId(vehicle, ruleData) {
|
||||
const sizeType = getConfigurationValue(VehicleConfigurationKeyEnum.SIZE_TYPE, vehicle);
|
||||
let ranges = [];
|
||||
let value = null;
|
||||
switch (sizeType) {
|
||||
case VehicleConfigurationSizeTypeEnum.WEIGHT:
|
||||
ranges = sortBy(RuleDataAccessors.getVehicleWeightRanges(ruleData), (range) => range.minSize);
|
||||
value = getWeight(vehicle);
|
||||
break;
|
||||
case VehicleConfigurationSizeTypeEnum.DIMENSION:
|
||||
ranges = sortBy(RuleDataAccessors.getVehicleDimensionRanges(ruleData), (range) => range.minSize);
|
||||
const dimensions = [];
|
||||
const width = getWidth(vehicle);
|
||||
if (width !== null) {
|
||||
dimensions.push(width);
|
||||
}
|
||||
const length = getLength(vehicle);
|
||||
if (length !== null) {
|
||||
dimensions.push(length);
|
||||
}
|
||||
value = dimensions.length > 0 ? Math.max(...dimensions) : null;
|
||||
break;
|
||||
default:
|
||||
// not implemented
|
||||
}
|
||||
let sizeId = null;
|
||||
if (value !== null && ranges.length > 0) {
|
||||
const compareValue = value;
|
||||
ranges.forEach((range) => {
|
||||
if (compareValue >= range.minSize) {
|
||||
sizeId = range.sizeId;
|
||||
}
|
||||
});
|
||||
}
|
||||
return sizeId;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
* @param ruleData
|
||||
*/
|
||||
export function deriveSizeInfo(vehicle, ruleData) {
|
||||
const sizeId = deriveSizeId(vehicle, ruleData);
|
||||
if (sizeId === null) {
|
||||
return null;
|
||||
}
|
||||
return RuleDataUtils.getCreatureSizeInfo(sizeId, ruleData);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function deriveNotes(vehicle) {
|
||||
const description = getDescription(vehicle);
|
||||
if (!description) {
|
||||
return description;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
* @param ruleData
|
||||
*/
|
||||
export function deriveObjectTypeInfo(vehicle, ruleData) {
|
||||
const type = getType(vehicle);
|
||||
if (type === null) {
|
||||
return null;
|
||||
}
|
||||
return RuleDataUtils.getObjectTypeInfo(type, ruleData);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function deriveMovementKeys(vehicle) {
|
||||
const movementKeys = [];
|
||||
getAllComponentsData(vehicle).forEach((component) => {
|
||||
VehicleComponentAccessors.getSpeedInfos(component).forEach((speed) => {
|
||||
if (speed.type && !movementKeys.includes(speed.type)) {
|
||||
movementKeys.push(speed.type);
|
||||
}
|
||||
});
|
||||
});
|
||||
return movementKeys;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
* @param ruleData
|
||||
*/
|
||||
export function deriveMovementNames(vehicle, ruleData) {
|
||||
return deriveMovementKeys(vehicle)
|
||||
.map((typeKey) => RuleDataUtils.getVehicleMovementName(typeKey, ruleData))
|
||||
.filter(TypeScriptUtils.isNotNullOrUndefined);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function deriveDefinitionId(vehicle) {
|
||||
const definitionKey = getDefinitionKey(vehicle);
|
||||
if (!definitionKey) {
|
||||
return null;
|
||||
}
|
||||
return DefinitionUtils.getDefinitionKeyId(definitionKey);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
* @param definitionPool
|
||||
*/
|
||||
export function deriveAccessType(vehicle, definitionPool) {
|
||||
let accessType = AccessTypeEnum.NO_ACCESS;
|
||||
const definitionKey = getDefinitionKey(vehicle);
|
||||
if (definitionKey !== null) {
|
||||
accessType = DefinitionPoolUtils.getDefinitionAccessType(definitionKey, definitionPool);
|
||||
}
|
||||
return accessType;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param configurationLookup
|
||||
* @param configurationKey
|
||||
* @param defaultValue
|
||||
*/
|
||||
export function deriveConfigurationValueLookupValue(configurationLookup, configurationKey, defaultValue) {
|
||||
const configurationInfo = HelperUtils.lookupDataOrFallback(configurationLookup, configurationKey);
|
||||
if (configurationInfo !== null) {
|
||||
return configurationInfo.value;
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param components
|
||||
*/
|
||||
export function deriveComponentListsByGroupType(components) {
|
||||
const componentTypes = [];
|
||||
const actionStationsTypes = [];
|
||||
components.forEach((component) => {
|
||||
const groupType = VehicleComponentAccessors.getGroupType(component);
|
||||
switch (groupType) {
|
||||
case VehicleComponentGroupTypeEnum.COMPONENT:
|
||||
componentTypes.push(component);
|
||||
break;
|
||||
case VehicleComponentGroupTypeEnum.ACTION_STATION:
|
||||
actionStationsTypes.push(component);
|
||||
break;
|
||||
default:
|
||||
// not implemented
|
||||
}
|
||||
});
|
||||
return {
|
||||
components: componentTypes,
|
||||
actionStations: actionStationsTypes,
|
||||
};
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
* @param ruleData
|
||||
*/
|
||||
export function deriveActions(vehicle, ruleData) {
|
||||
return getDefinitionActions(vehicle).map((actionContract) => generateVehicleAction(vehicle, actionContract, ruleData));
|
||||
}
|
||||
@@ -0,0 +1,232 @@
|
||||
import { keyBy } from 'lodash';
|
||||
import { TypeScriptUtils } from '../../utils';
|
||||
import { ActionGenerators } from '../Action';
|
||||
import { ConditionAccessors } from '../Condition';
|
||||
import { ConditionLevelGenerators } from '../ConditionLevel';
|
||||
import { DataOriginDataInfoKeyEnum, DataOriginGenerators, DataOriginTypeEnum, } from '../DataOrigin';
|
||||
import { DefinitionPoolUtils } from '../DefinitionPool';
|
||||
import { RuleDataUtils } from '../RuleData';
|
||||
import { VehicleComponentAccessors, VehicleComponentGenerators } from '../VehicleComponent';
|
||||
import { getActions, getAllComponentsData, getConditions, getDefinitionFeatures, getDefinitionFuelData, getDefinitionKey, getFeatures, getMappingId, getRemainingFuel, getUniqueKey, } from './accessors';
|
||||
import { VehicleConfigurationDisplayTypeEnum, VehicleConfigurationKeyEnum, VehicleConfigurationPrimaryComponentManageTypeEnum, VehicleConfigurationSizeTypeEnum, } from './constants';
|
||||
import { deriveAbilities, deriveAccessType, deriveActions, deriveComponentListsByGroupType, deriveConditionImmunities, deriveConfigurationValueLookupValue, deriveCreatureCapacityDescriptions, deriveDamageImmunities, deriveDefinitionId, deriveModifierData, deriveMovementKeys, deriveMovementNames, deriveNotes, deriveObjectTypeInfo, deriveSizeId, deriveSizeInfo, deriveStats, } from './derivers';
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function generateUniqueKey(vehicle) {
|
||||
return `${getMappingId(vehicle)}-${getDefinitionKey(vehicle)}`;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
* @param action
|
||||
* @param ruleData
|
||||
*/
|
||||
export function generateVehicleAction(vehicle, action, ruleData) {
|
||||
const baseAction = ActionGenerators.generateBaseAction(action, {});
|
||||
const dataOriginBaseAction = Object.assign(Object.assign({}, baseAction), { dataOrigin: DataOriginGenerators.generateDataOrigin(DataOriginTypeEnum.VEHICLE, vehicle) });
|
||||
const abilities = deriveAbilities(vehicle, ruleData);
|
||||
const abilityLookup = keyBy(abilities, 'id');
|
||||
const modifierData = deriveModifierData(abilityLookup);
|
||||
const proficiencyBonus = 0;
|
||||
const modifiers = [];
|
||||
const valueLookup = {};
|
||||
const martialArtsLevelScale = null;
|
||||
return ActionGenerators.generateAction(dataOriginBaseAction, proficiencyBonus, abilityLookup, modifiers, valueLookup, martialArtsLevelScale, ruleData, modifierData);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param conditionMapping
|
||||
* @param ruleData
|
||||
*/
|
||||
export function generateVehicleCondition(conditionMapping, ruleData) {
|
||||
const baseCondition = RuleDataUtils.getConditionInfo(conditionMapping.conditionId, ruleData);
|
||||
if (baseCondition === null) {
|
||||
return null;
|
||||
}
|
||||
const decoratedCondition = {
|
||||
definition: baseCondition.definition,
|
||||
};
|
||||
let levels = [];
|
||||
if (baseCondition.definition !== null) {
|
||||
const foundLevels = ConditionAccessors.getDefinitionLevels(decoratedCondition).map((level) => {
|
||||
let decoratedLevel = null;
|
||||
if (level) {
|
||||
decoratedLevel = ConditionLevelGenerators.generateConditionLevel(level, decoratedCondition, {});
|
||||
}
|
||||
return decoratedLevel;
|
||||
});
|
||||
levels = foundLevels.filter(TypeScriptUtils.isNotNullOrUndefined);
|
||||
}
|
||||
return Object.assign(Object.assign({}, decoratedCondition), { level: conditionMapping.level, levels, modifiers: [] });
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicleDefinition
|
||||
*/
|
||||
export function generateConfigurationLookup(vehicleDefinition) {
|
||||
const lookup = {};
|
||||
if (vehicleDefinition.configurations === null) {
|
||||
return lookup;
|
||||
}
|
||||
vehicleDefinition.configurations.forEach((configInfo) => {
|
||||
if (configInfo.key !== null) {
|
||||
lookup[configInfo.key] = configInfo;
|
||||
}
|
||||
});
|
||||
return lookup;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicleDefinition
|
||||
*/
|
||||
export function generateConfigurationValueLookup(vehicleDefinition) {
|
||||
const configurationLookup = generateConfigurationLookup(vehicleDefinition);
|
||||
return {
|
||||
[VehicleConfigurationKeyEnum.DISPLAY_TYPE]: deriveConfigurationValueLookupValue(configurationLookup, VehicleConfigurationKeyEnum.DISPLAY_TYPE, VehicleConfigurationDisplayTypeEnum.SHIP),
|
||||
[VehicleConfigurationKeyEnum.SIZE_TYPE]: deriveConfigurationValueLookupValue(configurationLookup, VehicleConfigurationKeyEnum.SIZE_TYPE, VehicleConfigurationSizeTypeEnum.DIMENSION),
|
||||
[VehicleConfigurationKeyEnum.PRIMARY_COMPONENT_MANAGE_TYPE]: deriveConfigurationValueLookupValue(configurationLookup, VehicleConfigurationKeyEnum.PRIMARY_COMPONENT_MANAGE_TYPE, VehicleConfigurationPrimaryComponentManageTypeEnum.COMPONENT),
|
||||
[VehicleConfigurationKeyEnum.ENABLE_TRAVEL_PACE]: deriveConfigurationValueLookupValue(configurationLookup, VehicleConfigurationKeyEnum.ENABLE_TRAVEL_PACE, true),
|
||||
[VehicleConfigurationKeyEnum.ENABLE_COMPONENTS]: deriveConfigurationValueLookupValue(configurationLookup, VehicleConfigurationKeyEnum.ENABLE_COMPONENTS, true),
|
||||
[VehicleConfigurationKeyEnum.ENABLE_ACTION_STATIONS]: deriveConfigurationValueLookupValue(configurationLookup, VehicleConfigurationKeyEnum.ENABLE_ACTION_STATIONS, false),
|
||||
[VehicleConfigurationKeyEnum.ENABLE_LEVELS]: deriveConfigurationValueLookupValue(configurationLookup, VehicleConfigurationKeyEnum.ENABLE_LEVELS, true),
|
||||
[VehicleConfigurationKeyEnum.ENABLE_COMPONENT_HIT_POINTS]: deriveConfigurationValueLookupValue(configurationLookup, VehicleConfigurationKeyEnum.ENABLE_COMPONENT_HIT_POINTS, true),
|
||||
[VehicleConfigurationKeyEnum.ENABLE_COMPONENT_ARMOR_CLASS]: deriveConfigurationValueLookupValue(configurationLookup, VehicleConfigurationKeyEnum.ENABLE_COMPONENT_ARMOR_CLASS, true),
|
||||
[VehicleConfigurationKeyEnum.ENABLE_COMPONENT_SPEEDS]: deriveConfigurationValueLookupValue(configurationLookup, VehicleConfigurationKeyEnum.ENABLE_COMPONENT_SPEEDS, true),
|
||||
[VehicleConfigurationKeyEnum.ENABLE_COMPONENT_MISHAP_THRESHOLD]: deriveConfigurationValueLookupValue(configurationLookup, VehicleConfigurationKeyEnum.ENABLE_COMPONENT_MISHAP_THRESHOLD, false),
|
||||
[VehicleConfigurationKeyEnum.ENABLE_COMPONENT_DAMAGE_THRESHOLD]: deriveConfigurationValueLookupValue(configurationLookup, VehicleConfigurationKeyEnum.ENABLE_COMPONENT_DAMAGE_THRESHOLD, true),
|
||||
[VehicleConfigurationKeyEnum.ENABLE_COMPONENT_ARMOR_CLASS_MOTIONLESS]: deriveConfigurationValueLookupValue(configurationLookup, VehicleConfigurationKeyEnum.ENABLE_COMPONENT_ARMOR_CLASS_MOTIONLESS, false),
|
||||
[VehicleConfigurationKeyEnum.ENABLE_COMPONENT_CREW_REQUIREMENTS]: deriveConfigurationValueLookupValue(configurationLookup, VehicleConfigurationKeyEnum.ENABLE_COMPONENT_CREW_REQUIREMENTS, false),
|
||||
[VehicleConfigurationKeyEnum.ENABLE_COMPONENT_COVER]: deriveConfigurationValueLookupValue(configurationLookup, VehicleConfigurationKeyEnum.ENABLE_COMPONENT_COVER, false),
|
||||
[VehicleConfigurationKeyEnum.ENABLE_COMPONENT_REMOVAL]: deriveConfigurationValueLookupValue(configurationLookup, VehicleConfigurationKeyEnum.ENABLE_COMPONENT_REMOVAL, true),
|
||||
[VehicleConfigurationKeyEnum.ENABLE_FEATURES]: deriveConfigurationValueLookupValue(configurationLookup, VehicleConfigurationKeyEnum.ENABLE_FEATURES, false),
|
||||
[VehicleConfigurationKeyEnum.ENABLE_CONDITIONS_TRACKING]: deriveConfigurationValueLookupValue(configurationLookup, VehicleConfigurationKeyEnum.ENABLE_CONDITIONS_TRACKING, false),
|
||||
[VehicleConfigurationKeyEnum.ENABLE_FUEL_TRACKING]: deriveConfigurationValueLookupValue(configurationLookup, VehicleConfigurationKeyEnum.ENABLE_FUEL_TRACKING, false),
|
||||
};
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
* @param ruleData
|
||||
*/
|
||||
export function generateFeatures(vehicle, ruleData) {
|
||||
const features = getDefinitionFeatures(vehicle);
|
||||
return features.map((feature) => {
|
||||
let actions = null;
|
||||
if (feature.actions !== null) {
|
||||
actions = feature.actions.map((action) => generateVehicleAction(vehicle, action, ruleData));
|
||||
}
|
||||
return Object.assign(Object.assign({}, feature), { actions });
|
||||
});
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicleMapping
|
||||
* @param ruleData
|
||||
*/
|
||||
export function generateActiveConditions(vehicleMapping, ruleData) {
|
||||
const conditions = getConditions(vehicleMapping);
|
||||
if (conditions === null) {
|
||||
return [];
|
||||
}
|
||||
return conditions
|
||||
.map((conditionInfo) => generateVehicleCondition(conditionInfo, ruleData))
|
||||
.filter(TypeScriptUtils.isNotNullOrUndefined);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function generateFuelData(vehicle) {
|
||||
const remainingFuel = getRemainingFuel(vehicle);
|
||||
const fuelData = getDefinitionFuelData(vehicle);
|
||||
if (fuelData === null) {
|
||||
return null;
|
||||
}
|
||||
return Object.assign(Object.assign({}, fuelData), { remainingFuel });
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function generateAggregatedActions(vehicle) {
|
||||
const allActions = [...getActions(vehicle)];
|
||||
const features = getFeatures(vehicle);
|
||||
if (features) {
|
||||
features.forEach((feature) => {
|
||||
if (feature.actions !== null) {
|
||||
feature.actions.forEach((action) => {
|
||||
allActions.push(action);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
getAllComponentsData(vehicle).forEach((component) => {
|
||||
VehicleComponentAccessors.getActions(component).forEach((action) => {
|
||||
allActions.push(action);
|
||||
});
|
||||
});
|
||||
return allActions;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicles
|
||||
* @param vehicleComponentLookup
|
||||
* @param definitionPool
|
||||
* @param ruleData
|
||||
*/
|
||||
export function generateVehicles(vehicles, vehicleComponentLookup, definitionPool, ruleData) {
|
||||
return vehicles
|
||||
.map((vehicle) => generateVehicle(vehicle, vehicleComponentLookup, definitionPool, ruleData))
|
||||
.filter(TypeScriptUtils.isNotNullOrUndefined);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicleMapping
|
||||
* @param vehicleComponentLookup
|
||||
* @param definitionPool
|
||||
* @param ruleData
|
||||
*/
|
||||
export function generateVehicle(vehicleMapping, vehicleComponentLookup, definitionPool, ruleData) {
|
||||
const definitionKey = getDefinitionKey(vehicleMapping);
|
||||
if (definitionKey === null) {
|
||||
return null;
|
||||
}
|
||||
const definition = DefinitionPoolUtils.getVehicleDefinition(definitionKey, definitionPool);
|
||||
if (definition === null) {
|
||||
return null;
|
||||
}
|
||||
const stats = deriveStats(definition, ruleData);
|
||||
const activeConditions = generateActiveConditions(vehicleMapping, ruleData);
|
||||
const baseVehicle = Object.assign(Object.assign({}, vehicleMapping), { definition, definitionId: deriveDefinitionId(vehicleMapping), accessType: deriveAccessType(vehicleMapping, definitionPool), stats, statLookup: keyBy(stats, 'id'), configurationLookup: generateConfigurationLookup(definition), configurationValueLookup: generateConfigurationValueLookup(definition), activeConditions, activeConditionLookup: keyBy(activeConditions, (condition) => ConditionAccessors.getId(condition)) });
|
||||
const generatedComponents = VehicleComponentGenerators.generateVehicleComponents(vehicleMapping, baseVehicle, vehicleComponentLookup, ruleData);
|
||||
const primaryComponent = generatedComponents.find((component) => VehicleComponentAccessors.getIsPrimary(component));
|
||||
if (!primaryComponent) {
|
||||
return null;
|
||||
}
|
||||
const groupedComponents = deriveComponentListsByGroupType(generatedComponents);
|
||||
const componentizedVehicle = Object.assign(Object.assign(Object.assign({}, baseVehicle), groupedComponents), { primaryComponent, uniqueKey: generateUniqueKey(baseVehicle), damageImmunityInfos: deriveDamageImmunities(baseVehicle, ruleData), conditionImmunityInfos: deriveConditionImmunities(baseVehicle, ruleData), creatureCapacityDescriptions: deriveCreatureCapacityDescriptions(baseVehicle, ruleData), sizeId: deriveSizeId(baseVehicle, ruleData), sizeInfo: deriveSizeInfo(baseVehicle, ruleData), notes: deriveNotes(baseVehicle), objectTypeInfo: deriveObjectTypeInfo(baseVehicle, ruleData), actions: deriveActions(baseVehicle, ruleData), features: generateFeatures(baseVehicle, ruleData), fuelData: generateFuelData(baseVehicle) });
|
||||
return Object.assign(Object.assign({}, componentizedVehicle), { movementKeys: deriveMovementKeys(componentizedVehicle), movementNames: deriveMovementNames(componentizedVehicle, ruleData), allActions: generateAggregatedActions(componentizedVehicle) });
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicles
|
||||
*/
|
||||
export function generateRefVehicleData(vehicles) {
|
||||
let data = {};
|
||||
vehicles.forEach((vehicle) => {
|
||||
data[getUniqueKey(vehicle)] = {
|
||||
[DataOriginDataInfoKeyEnum.PRIMARY]: vehicle,
|
||||
[DataOriginDataInfoKeyEnum.PARENT]: null,
|
||||
};
|
||||
});
|
||||
return data;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicles
|
||||
*/
|
||||
export function generateVehicleLookup(vehicles) {
|
||||
return keyBy(vehicles, (vehicle) => getMappingId(vehicle));
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import * as VehicleAccessors from './accessors';
|
||||
import * as VehicleConstants from './constants';
|
||||
import * as VehicleDerivers from './derivers';
|
||||
import * as VehicleGenerators from './generators';
|
||||
import * as VehicleNotes from './notes';
|
||||
import * as VehicleSimulators from './simulators';
|
||||
import * as VehicleTypings from './typings';
|
||||
import * as VehicleUtils from './utils';
|
||||
export * from './constants';
|
||||
export * from './typings';
|
||||
export { VehicleAccessors, VehicleDerivers, VehicleGenerators, VehicleNotes, VehicleSimulators, VehicleUtils };
|
||||
export default Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, VehicleAccessors), VehicleConstants), VehicleDerivers), VehicleGenerators), VehicleNotes), VehicleSimulators), VehicleTypings), VehicleUtils);
|
||||
@@ -0,0 +1,109 @@
|
||||
import { ConditionAccessors } from '../Condition';
|
||||
import { DisplayIntentionEnum, NoteGenerators } from '../Note';
|
||||
import { RuleDataUtils } from '../RuleData';
|
||||
import { VehicleComponentAccessors } from '../VehicleComponent';
|
||||
import { getActiveConditions, getAllComponentsData, getCreatureCapacity, getDescription, getPrimaryComponent, } from './accessors';
|
||||
import { VehicleConfigurationKeyEnum } from './constants';
|
||||
import { getConfigurationValue } from './utils';
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getConditionsNotesComponents(vehicle) {
|
||||
return NoteGenerators.createGroup(getActiveConditions(vehicle).map((condition) => {
|
||||
const name = ConditionAccessors.getName(condition);
|
||||
const level = ConditionAccessors.getActiveLevel(condition);
|
||||
let note = name;
|
||||
if (level !== null) {
|
||||
note = `${name} (Level ${level})`;
|
||||
}
|
||||
return NoteGenerators.createPlainText(note, DisplayIntentionEnum.NEGATIVE);
|
||||
}), ', ');
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getUserDescriptionNoteComponents(vehicle) {
|
||||
const description = getDescription(vehicle);
|
||||
if (!description) {
|
||||
return null;
|
||||
}
|
||||
return NoteGenerators.createPlainText(description);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
* @param ruleData
|
||||
*/
|
||||
export function getCreatureCapacityNoteComponents(vehicle, ruleData) {
|
||||
const creatureCapacityInfos = getCreatureCapacity(vehicle);
|
||||
const creatureCapacityDescriptions = creatureCapacityInfos.map((capacity) => {
|
||||
var _a;
|
||||
let sizeName = '';
|
||||
if (capacity.sizeId !== null) {
|
||||
const sizeInfo = RuleDataUtils.getCreatureSizeInfo(capacity.sizeId, ruleData);
|
||||
if (sizeInfo && sizeInfo.name) {
|
||||
sizeName = sizeInfo.name;
|
||||
}
|
||||
}
|
||||
return `${capacity.capacity} ${sizeName} ${(_a = capacity.type) !== null && _a !== void 0 ? _a : 'crew'}`.trim();
|
||||
});
|
||||
if (creatureCapacityDescriptions.length === 0) {
|
||||
return null;
|
||||
}
|
||||
return NoteGenerators.createGroup(creatureCapacityDescriptions.map((capacityInfo) => NoteGenerators.createPlainText(capacityInfo)), ', ');
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getDamageTakenNotesComponents(vehicle) {
|
||||
const primaryComponent = getPrimaryComponent(vehicle);
|
||||
if (primaryComponent === null) {
|
||||
return null;
|
||||
}
|
||||
let damageNote = null;
|
||||
const primaryComponentHitPointInfo = VehicleComponentAccessors.getHitPointInfo(primaryComponent);
|
||||
if (primaryComponentHitPointInfo !== null && primaryComponentHitPointInfo.remainingHp === 0) {
|
||||
damageNote = 'Wrecked';
|
||||
}
|
||||
else if (getConfigurationValue(VehicleConfigurationKeyEnum.ENABLE_COMPONENT_HIT_POINTS, vehicle)) {
|
||||
let count = 0;
|
||||
getAllComponentsData(vehicle).forEach((component) => {
|
||||
const hitPointInfo = VehicleComponentAccessors.getHitPointInfo(component);
|
||||
if (hitPointInfo !== null && hitPointInfo.remainingHp < hitPointInfo.totalHp) {
|
||||
count += 1;
|
||||
}
|
||||
});
|
||||
if (count > 0) {
|
||||
damageNote = `Damaged Components: ${count}`;
|
||||
}
|
||||
}
|
||||
return damageNote !== null ? NoteGenerators.createPlainText(damageNote, DisplayIntentionEnum.NEGATIVE) : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param vehicle
|
||||
* @param ruleData
|
||||
*/
|
||||
export function getNoteComponents(vehicle, ruleData) {
|
||||
const notes = [];
|
||||
const descriptionNotes = getUserDescriptionNoteComponents(vehicle);
|
||||
if (descriptionNotes) {
|
||||
notes.push(descriptionNotes);
|
||||
}
|
||||
const damageTakenNotes = getDamageTakenNotesComponents(vehicle);
|
||||
if (damageTakenNotes) {
|
||||
notes.push(damageTakenNotes);
|
||||
}
|
||||
const conditionsNotes = getConditionsNotesComponents(vehicle);
|
||||
if (conditionsNotes) {
|
||||
notes.push(conditionsNotes);
|
||||
}
|
||||
const creatureCapacityNotes = getCreatureCapacityNoteComponents(vehicle, ruleData);
|
||||
if (creatureCapacityNotes) {
|
||||
notes.push(creatureCapacityNotes);
|
||||
}
|
||||
return notes;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import { keyBy } from 'lodash';
|
||||
import { VehicleComponentAccessors, VehicleComponentSimulators } from '../VehicleComponent';
|
||||
import { deriveAccessType, deriveActions, deriveComponentListsByGroupType, deriveConditionImmunities, deriveCreatureCapacityDescriptions, deriveDamageImmunities, deriveDefinitionId, deriveMovementKeys, deriveMovementNames, deriveNotes, deriveObjectTypeInfo, deriveSizeId, deriveSizeInfo, deriveStats, } from './derivers';
|
||||
import { generateAggregatedActions, generateConfigurationLookup, generateConfigurationValueLookup, generateFeatures, generateUniqueKey, } from './generators';
|
||||
/**
|
||||
*
|
||||
* @param vehicleDefinition
|
||||
* @param definitionPool
|
||||
* @param ruleData
|
||||
*/
|
||||
export function simulateVehicle(vehicleDefinition, definitionPool, ruleData) {
|
||||
const { definitionKey, name } = vehicleDefinition;
|
||||
if (definitionKey === null) {
|
||||
return null;
|
||||
}
|
||||
const simulatedMapping = {
|
||||
characterId: -1,
|
||||
definitionKey,
|
||||
id: -1,
|
||||
name,
|
||||
description: null,
|
||||
conditions: [],
|
||||
remainingFuel: 0,
|
||||
};
|
||||
const stats = deriveStats(vehicleDefinition, ruleData);
|
||||
const baseVehicle = Object.assign(Object.assign({}, simulatedMapping), { stats, statLookup: keyBy(stats, 'id'), definition: vehicleDefinition, activeConditions: [], activeConditionLookup: {}, configurationLookup: generateConfigurationLookup(vehicleDefinition), configurationValueLookup: generateConfigurationValueLookup(vehicleDefinition), definitionId: deriveDefinitionId(simulatedMapping), accessType: deriveAccessType(simulatedMapping, definitionPool) });
|
||||
const simulatedComponents = VehicleComponentSimulators.simulateVehicleComponents(baseVehicle, ruleData);
|
||||
const primaryComponent = simulatedComponents.find((component) => VehicleComponentAccessors.getIsPrimary(component));
|
||||
if (!primaryComponent) {
|
||||
return null;
|
||||
}
|
||||
const groupedComponents = deriveComponentListsByGroupType(simulatedComponents);
|
||||
const componentizedVehicle = Object.assign(Object.assign(Object.assign({}, baseVehicle), groupedComponents), { primaryComponent, uniqueKey: generateUniqueKey(baseVehicle), damageImmunityInfos: deriveDamageImmunities(baseVehicle, ruleData), conditionImmunityInfos: deriveConditionImmunities(baseVehicle, ruleData), creatureCapacityDescriptions: deriveCreatureCapacityDescriptions(baseVehicle, ruleData), sizeId: deriveSizeId(baseVehicle, ruleData), sizeInfo: deriveSizeInfo(baseVehicle, ruleData), notes: deriveNotes(baseVehicle), objectTypeInfo: deriveObjectTypeInfo(baseVehicle, ruleData), actions: deriveActions(baseVehicle, ruleData), features: generateFeatures(baseVehicle, ruleData), fuelData: null });
|
||||
return Object.assign(Object.assign({}, componentizedVehicle), { movementKeys: deriveMovementKeys(componentizedVehicle), movementNames: deriveMovementNames(componentizedVehicle, ruleData), allActions: generateAggregatedActions(componentizedVehicle) });
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { HelperUtils } from '../Helper';
|
||||
import { getConfigurationValueLookup } from './accessors';
|
||||
/**
|
||||
*
|
||||
* @param key
|
||||
* @param configurationLookup
|
||||
*/
|
||||
export function getConfigurationInfo(key, configurationLookup) {
|
||||
return HelperUtils.lookupDataOrFallback(configurationLookup, key);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param key
|
||||
* @param vehicle
|
||||
*/
|
||||
export function getConfigurationValue(key, vehicle) {
|
||||
return getConfigurationValueLookup(vehicle)[key];
|
||||
}
|
||||
Reference in New Issue
Block a user