New source found from dndbeyond.com
This commit is contained in:
@@ -14,6 +14,7 @@ export var SnippetMathOperatorEnum;
|
||||
})(SnippetMathOperatorEnum || (SnippetMathOperatorEnum = {}));
|
||||
export var SnippetTagValueTypeEnum;
|
||||
(function (SnippetTagValueTypeEnum) {
|
||||
SnippetTagValueTypeEnum["SPEED"] = "speed";
|
||||
SnippetTagValueTypeEnum["SAVE_DC"] = "savedc";
|
||||
SnippetTagValueTypeEnum["SPELL_ATTACK"] = "spellattack";
|
||||
SnippetTagValueTypeEnum["SCALE_VALUE"] = "scalevalue";
|
||||
@@ -51,6 +52,14 @@ export var SnippetAbilityKeyEnum;
|
||||
SnippetAbilityKeyEnum["WISDOM"] = "wis";
|
||||
SnippetAbilityKeyEnum["CHARISMA"] = "cha";
|
||||
})(SnippetAbilityKeyEnum || (SnippetAbilityKeyEnum = {}));
|
||||
export var SnippetSpeedMovementKeyEnum;
|
||||
(function (SnippetSpeedMovementKeyEnum) {
|
||||
SnippetSpeedMovementKeyEnum["WALK"] = "walk";
|
||||
SnippetSpeedMovementKeyEnum["FLY"] = "fly";
|
||||
SnippetSpeedMovementKeyEnum["BURROW"] = "burrow";
|
||||
SnippetSpeedMovementKeyEnum["SWIM"] = "swim";
|
||||
SnippetSpeedMovementKeyEnum["CLIMB"] = "climb";
|
||||
})(SnippetSpeedMovementKeyEnum || (SnippetSpeedMovementKeyEnum = {}));
|
||||
export var SnippetContentChunkTypeEnum;
|
||||
(function (SnippetContentChunkTypeEnum) {
|
||||
SnippetContentChunkTypeEnum["TEXT"] = "TEXT";
|
||||
|
||||
@@ -5,15 +5,17 @@
|
||||
* @param abilityLookup
|
||||
* @param xpInfo
|
||||
* @param hitPointInfo
|
||||
* @param speedInfo
|
||||
* @param ruleData
|
||||
*/
|
||||
export function generateSnippetData(proficiencyBonus, abilityKeyLookup, abilityLookup, xpInfo, hitPointInfo, ruleData) {
|
||||
export function generateSnippetData(proficiencyBonus, abilityKeyLookup, abilityLookup, xpInfo, hitPointInfo, speedInfo, ruleData) {
|
||||
return {
|
||||
proficiencyBonus,
|
||||
abilityKeyLookup,
|
||||
abilityLookup,
|
||||
xpInfo,
|
||||
hitPointInfo,
|
||||
speedInfo,
|
||||
ruleData,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { isFinite, toNumber } from 'lodash';
|
||||
import { TypeScriptUtils } from '../../utils';
|
||||
import { AbilityAccessors } from '../Ability';
|
||||
import { CharacterDerivers } from '../Character';
|
||||
import { SpeedMovementKeyEnum } from '../Core';
|
||||
import { DiceRenderers } from '../Dice';
|
||||
import { FormatUtils } from '../Format';
|
||||
import { LimitedUseDerivers } from '../LimitedUse';
|
||||
@@ -90,6 +91,7 @@ export function isSnippetPostProcessTypeEnum(key) {
|
||||
*/
|
||||
export function isSnippetTagValueTypeEnum(key) {
|
||||
switch (key) {
|
||||
case SnippetTagValueTypeEnum.SPEED:
|
||||
case SnippetTagValueTypeEnum.SCALE_VALUE:
|
||||
case SnippetTagValueTypeEnum.LIMITED_USE:
|
||||
case SnippetTagValueTypeEnum.CLASS_LEVEL:
|
||||
@@ -107,6 +109,23 @@ export function isSnippetTagValueTypeEnum(key) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param type
|
||||
*/
|
||||
export function isSnippetSpeedMovementKeyEnum(key) {
|
||||
switch (key) {
|
||||
case SpeedMovementKeyEnum.WALK:
|
||||
case SpeedMovementKeyEnum.FLY:
|
||||
case SpeedMovementKeyEnum.BURROW:
|
||||
case SpeedMovementKeyEnum.SWIM:
|
||||
case SpeedMovementKeyEnum.CLIMB:
|
||||
return true;
|
||||
default:
|
||||
// not implemented
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param type
|
||||
@@ -207,6 +226,7 @@ export function throwInvalidSnippetCharacters(str) {
|
||||
keywordMatches === null || keywordMatches === void 0 ? void 0 : keywordMatches.forEach((keyword) => {
|
||||
if (isSnippetTagValueTypeEnum(keyword) ||
|
||||
isSnippetAbilityKeyEnum(keyword) ||
|
||||
isSnippetSpeedMovementKeyEnum(keyword) ||
|
||||
isSnippetValueModifierTypeEnum(keyword) ||
|
||||
isSnippetPostProcessTypeEnum(keyword)) {
|
||||
return;
|
||||
@@ -323,9 +343,21 @@ export function deriveStringTagValue(tagValue, contextData) {
|
||||
* @param proficiencyBonus
|
||||
*/
|
||||
export function deriveNumericTagValue(tagValue, contextData, snippetData, proficiencyBonus) {
|
||||
var _a;
|
||||
const { type, params } = tagValue;
|
||||
let value = 0;
|
||||
switch (type) {
|
||||
case SnippetTagValueTypeEnum.SPEED: {
|
||||
const movementType = (_a = params[0]) !== null && _a !== void 0 ? _a : SpeedMovementKeyEnum.WALK;
|
||||
if (!isSnippetSpeedMovementKeyEnum(movementType)) {
|
||||
throw new Error(`Invalid speed type: ${movementType}`);
|
||||
}
|
||||
const speed = snippetData.speedInfo[movementType];
|
||||
if (speed === null) {
|
||||
throw new Error(`No speed data available for ${movementType}`);
|
||||
}
|
||||
return speed;
|
||||
}
|
||||
case SnippetTagValueTypeEnum.SAVE_DC:
|
||||
if (params.length < 1) {
|
||||
throw new Error('Save DC missing ability key');
|
||||
|
||||
Reference in New Issue
Block a user