@optolith/entity-descriptions 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/lib/entities/combatTechnique.d.ts +4 -4
- package/lib/entities/combatTechnique.js +7 -7
- package/lib/entities/experienceLevel.d.ts +1 -1
- package/lib/entities/experienceLevel.js +3 -3
- package/lib/entities/focusRule.d.ts +8 -0
- package/lib/entities/focusRule.js +18 -0
- package/lib/entities/liturgicalChant.d.ts +6 -6
- package/lib/entities/liturgicalChant.js +27 -56
- package/lib/entities/optionalRule.d.ts +5 -0
- package/lib/entities/optionalRule.js +16 -0
- package/lib/entities/partial/rated/activatable/castingTime.d.ts +3 -15
- package/lib/entities/partial/rated/activatable/castingTime.js +19 -34
- package/lib/entities/partial/rated/activatable/checkResultBased.d.ts +1 -1
- package/lib/entities/partial/rated/activatable/checkResultBased.js +2 -2
- package/lib/entities/partial/rated/activatable/cost.d.ts +3 -19
- package/lib/entities/partial/rated/activatable/cost.js +82 -99
- package/lib/entities/partial/rated/activatable/duration.d.ts +5 -24
- package/lib/entities/partial/rated/activatable/duration.js +40 -57
- package/lib/entities/partial/rated/activatable/effect.d.ts +3 -3
- package/lib/entities/partial/rated/activatable/effect.js +7 -7
- package/lib/entities/partial/rated/activatable/index.d.ts +5 -33
- package/lib/entities/partial/rated/activatable/index.js +23 -41
- package/lib/entities/partial/rated/activatable/isMinimumMaximum.d.ts +20 -0
- package/lib/entities/partial/rated/activatable/isMinimumMaximum.js +19 -0
- package/lib/entities/partial/rated/activatable/nonModifiableSuffix.d.ts +16 -0
- package/lib/entities/partial/rated/activatable/nonModifiableSuffix.js +55 -0
- package/lib/entities/partial/rated/activatable/parensIf.d.ts +1 -1
- package/lib/entities/partial/rated/activatable/parensIf.js +3 -1
- package/lib/entities/partial/rated/activatable/range.d.ts +4 -20
- package/lib/entities/partial/rated/activatable/range.js +59 -100
- package/lib/entities/partial/rated/activatable/speed.d.ts +1 -1
- package/lib/entities/partial/rated/activatable/speed.js +1 -1
- package/lib/entities/partial/rated/activatable/targetCategory.d.ts +3 -7
- package/lib/entities/partial/rated/activatable/targetCategory.js +30 -26
- package/lib/entities/partial/rated/improvementCost.d.ts +2 -2
- package/lib/entities/partial/rated/skillCheck.d.ts +2 -2
- package/lib/entities/partial/responsiveText.d.ts +7 -4
- package/lib/entities/partial/responsiveText.js +8 -2
- package/lib/entities/partial/units/energy.d.ts +12 -0
- package/lib/entities/partial/units/energy.js +30 -0
- package/lib/entities/partial/units/length.d.ts +8 -0
- package/lib/entities/partial/units/length.js +12 -0
- package/lib/entities/partial/units/timeSpan.d.ts +8 -0
- package/lib/entities/partial/units/timeSpan.js +22 -0
- package/lib/entities/skill.d.ts +2 -2
- package/lib/entities/skill.js +3 -3
- package/lib/entities/spell.d.ts +6 -6
- package/lib/entities/spell.js +27 -56
- package/lib/helpers/locale.d.ts +8 -0
- package/lib/helpers/locale.js +1 -0
- package/lib/index.d.ts +45 -1
- package/lib/index.js +22 -1
- package/lib/references/index.d.ts +4 -0
- package/lib/references/index.js +46 -0
- package/lib/references/occurrence.d.ts +4 -0
- package/lib/references/occurrence.js +3 -0
- package/lib/references/page.d.ts +23 -0
- package/lib/references/page.js +61 -0
- package/lib/references/pageRange.d.ts +30 -0
- package/lib/references/pageRange.js +58 -0
- package/package.json +7 -3
- package/lib/entities/partial/rated/activatable/isMaximum.d.ts +0 -6
- package/lib/entities/partial/rated/activatable/isMaximum.js +0 -10
- package/lib/entities/partial/rated/activatable/modifiableParameter.d.ts +0 -8
- package/lib/entities/partial/rated/activatable/modifiableParameter.js +0 -9
- package/lib/entities/partial/rated/activatable/nonModifiable.d.ts +0 -9
- package/lib/entities/partial/rated/activatable/nonModifiable.js +0 -75
- package/lib/entities/partial/rated/activatable/units.d.ts +0 -13
- package/lib/entities/partial/rated/activatable/units.js +0 -53
- package/lib/libraryEntry.d.ts +0 -52
- package/lib/libraryEntry.js +0 -17
|
@@ -1,59 +1,41 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { getFastCastingTimeTranslation, getSlowCastingTimeTranslation, } from "./castingTime.js";
|
|
2
|
+
import { getOneTimeCostTranslation, getSustainedCostTranslation, } from "./cost.js";
|
|
3
|
+
import { getDurationForOneTimeTranslation, getDurationForSustainedTranslation, } from "./duration.js";
|
|
4
4
|
import { getTextForActivatableSkillRange } from "./range.js";
|
|
5
5
|
import { Speed } from "./speed.js";
|
|
6
6
|
/**
|
|
7
7
|
* Get the texts for all fast one-time performance parameters.
|
|
8
8
|
*/
|
|
9
|
-
export const
|
|
10
|
-
castingTime:
|
|
11
|
-
cost:
|
|
12
|
-
range: getTextForActivatableSkillRange(
|
|
13
|
-
|
|
14
|
-
...env,
|
|
15
|
-
}),
|
|
16
|
-
duration: getTextForDurationForOneTime(deps, value.duration, env),
|
|
9
|
+
export const getFastOneTimePerformanceParametersTranslations = (getSkillModificationLevelById, locale, entity, responsiveTextSize, value) => ({
|
|
10
|
+
castingTime: getFastCastingTimeTranslation(getSkillModificationLevelById, locale, entity, responsiveTextSize, value.casting_time),
|
|
11
|
+
cost: getOneTimeCostTranslation(getSkillModificationLevelById, locale, Speed.Fast, entity, responsiveTextSize, value.cost),
|
|
12
|
+
range: getTextForActivatableSkillRange(getSkillModificationLevelById, locale, Speed.Fast, responsiveTextSize, entity, value.range),
|
|
13
|
+
duration: getDurationForOneTimeTranslation(locale, responsiveTextSize, value.duration),
|
|
17
14
|
});
|
|
18
15
|
/**
|
|
19
16
|
* Get the texts for all fast sustained performance parameters.
|
|
20
17
|
*/
|
|
21
|
-
export const
|
|
22
|
-
castingTime:
|
|
23
|
-
cost:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}),
|
|
27
|
-
range: getTextForActivatableSkillRange(deps, value.range, {
|
|
28
|
-
speed: Speed.Fast,
|
|
29
|
-
...env,
|
|
30
|
-
}),
|
|
31
|
-
duration: getTextForDurationForSustained(deps, value.duration, env),
|
|
18
|
+
export const getFastSustainedPerformanceParametersTranslations = (getSkillModificationLevelById, locale, entity, responsiveTextSize, value) => ({
|
|
19
|
+
castingTime: getFastCastingTimeTranslation(getSkillModificationLevelById, locale, entity, responsiveTextSize, value.casting_time),
|
|
20
|
+
cost: getSustainedCostTranslation(getSkillModificationLevelById, locale, Speed.Fast, entity, responsiveTextSize, value.cost),
|
|
21
|
+
range: getTextForActivatableSkillRange(getSkillModificationLevelById, locale, Speed.Fast, responsiveTextSize, entity, value.range),
|
|
22
|
+
duration: getDurationForSustainedTranslation(locale, responsiveTextSize, value.duration),
|
|
32
23
|
});
|
|
33
24
|
/**
|
|
34
25
|
* Get the texts for all slow one-time performance parameters.
|
|
35
26
|
*/
|
|
36
|
-
export const
|
|
37
|
-
castingTime:
|
|
38
|
-
cost:
|
|
39
|
-
range: getTextForActivatableSkillRange(
|
|
40
|
-
|
|
41
|
-
...env,
|
|
42
|
-
}),
|
|
43
|
-
duration: getTextForDurationForOneTime(deps, value.duration, env),
|
|
27
|
+
export const getSlowOneTimePerformanceParametersTranslations = (getSkillModificationLevelById, locale, entity, responsiveTextSize, value) => ({
|
|
28
|
+
castingTime: getSlowCastingTimeTranslation(getSkillModificationLevelById, locale, entity, responsiveTextSize, value.casting_time),
|
|
29
|
+
cost: getOneTimeCostTranslation(getSkillModificationLevelById, locale, Speed.Slow, entity, responsiveTextSize, value.cost),
|
|
30
|
+
range: getTextForActivatableSkillRange(getSkillModificationLevelById, locale, Speed.Slow, responsiveTextSize, entity, value.range),
|
|
31
|
+
duration: getDurationForOneTimeTranslation(locale, responsiveTextSize, value.duration),
|
|
44
32
|
});
|
|
45
33
|
/**
|
|
46
34
|
* Get the texts for all slow sustained performance parameters.
|
|
47
35
|
*/
|
|
48
|
-
export const
|
|
49
|
-
castingTime:
|
|
50
|
-
cost:
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}),
|
|
54
|
-
range: getTextForActivatableSkillRange(deps, value.range, {
|
|
55
|
-
speed: Speed.Slow,
|
|
56
|
-
...env,
|
|
57
|
-
}),
|
|
58
|
-
duration: getTextForDurationForSustained(deps, value.duration, env),
|
|
36
|
+
export const getSlowSustainedPerformanceParametersTranslations = (getSkillModificationLevelById, locale, entity, responsiveTextSize, value) => ({
|
|
37
|
+
castingTime: getSlowCastingTimeTranslation(getSkillModificationLevelById, locale, entity, responsiveTextSize, value.casting_time),
|
|
38
|
+
cost: getSustainedCostTranslation(getSkillModificationLevelById, locale, Speed.Slow, entity, responsiveTextSize, value.cost),
|
|
39
|
+
range: getTextForActivatableSkillRange(getSkillModificationLevelById, locale, Speed.Slow, responsiveTextSize, entity, value.range),
|
|
40
|
+
duration: getDurationForSustainedTranslation(locale, responsiveTextSize, value.duration),
|
|
59
41
|
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { LocaleEnvironment } from "../../../../helpers/locale.js";
|
|
2
|
+
import { ResponsiveTextSize } from "../../responsiveText.js";
|
|
3
|
+
/**
|
|
4
|
+
* Wraps the text in a translation that indicates it’s a minimum value.
|
|
5
|
+
*/
|
|
6
|
+
export declare const wrapAsMinimum: (locale: LocaleEnvironment, responsiveTextSize: ResponsiveTextSize, text: string) => string;
|
|
7
|
+
/**
|
|
8
|
+
* Wraps the text in a translation that indicates it’s a minimum value if the
|
|
9
|
+
* `is_minimum` property says it’s a minimum value.
|
|
10
|
+
*/
|
|
11
|
+
export declare const wrapIfMinimum: (locale: LocaleEnvironment, responsiveTextSize: ResponsiveTextSize, is_minimum: boolean | undefined, text: string) => string;
|
|
12
|
+
/**
|
|
13
|
+
* Wraps the text in a translation that indicates it’s a maximum value.
|
|
14
|
+
*/
|
|
15
|
+
export declare const wrapAsMaximum: (locale: LocaleEnvironment, responsiveTextSize: ResponsiveTextSize, text: string) => string;
|
|
16
|
+
/**
|
|
17
|
+
* Wraps the text in a translation that indicates it’s a maximum value if the
|
|
18
|
+
* `is_maximum` property says it’s a maximum value.
|
|
19
|
+
*/
|
|
20
|
+
export declare const wrapIfMaximum: (locale: LocaleEnvironment, responsiveTextSize: ResponsiveTextSize, is_maximum: boolean | undefined, text: string) => string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { responsive } from "../../responsiveText.js";
|
|
2
|
+
/**
|
|
3
|
+
* Wraps the text in a translation that indicates it’s a minimum value.
|
|
4
|
+
*/
|
|
5
|
+
export const wrapAsMinimum = (locale, responsiveTextSize, text) => responsive(responsiveTextSize, () => locale.translate("at least {0}", text), () => locale.translate("min. {0}", text));
|
|
6
|
+
/**
|
|
7
|
+
* Wraps the text in a translation that indicates it’s a minimum value if the
|
|
8
|
+
* `is_minimum` property says it’s a minimum value.
|
|
9
|
+
*/
|
|
10
|
+
export const wrapIfMinimum = (locale, responsiveTextSize, is_minimum, text) => is_minimum === true ? wrapAsMinimum(locale, responsiveTextSize, text) : "";
|
|
11
|
+
/**
|
|
12
|
+
* Wraps the text in a translation that indicates it’s a maximum value.
|
|
13
|
+
*/
|
|
14
|
+
export const wrapAsMaximum = (locale, responsiveTextSize, text) => responsive(responsiveTextSize, () => locale.translate("no more than {0}", text), () => locale.translate("max. {0}", text));
|
|
15
|
+
/**
|
|
16
|
+
* Wraps the text in a translation that indicates it’s a maximum value if the
|
|
17
|
+
* `is_maximum` property says it’s a maximum value.
|
|
18
|
+
*/
|
|
19
|
+
export const wrapIfMaximum = (locale, responsiveTextSize, is_maximum, text) => is_maximum === true ? wrapAsMaximum(locale, responsiveTextSize, text) : "";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { LocaleEnvironment } from "../../../../helpers/locale.js";
|
|
2
|
+
import { ResponsiveTextSize } from "../../responsiveText.js";
|
|
3
|
+
import { Entity } from "./entity.js";
|
|
4
|
+
/**
|
|
5
|
+
* A parameter that is designed to be modifiable.
|
|
6
|
+
*/
|
|
7
|
+
export declare enum ModifiableParameter {
|
|
8
|
+
CastingTime = 0,
|
|
9
|
+
Cost = 1,
|
|
10
|
+
Range = 2
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Returns the suffix for the text of a non-modifiable parameter that indicates
|
|
14
|
+
* that the parameter cannot be modified.
|
|
15
|
+
*/
|
|
16
|
+
export declare const getNonModifiableSuffixTranslation: (locale: LocaleEnvironment, entity: Entity, param: ModifiableParameter, responsiveTextSize: ResponsiveTextSize) => string;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { mapNullable } from "@optolith/helpers/nullable";
|
|
2
|
+
import { assertExhaustive } from "@optolith/helpers/typeSafety";
|
|
3
|
+
import { responsive } from "../../responsiveText.js";
|
|
4
|
+
import { Entity } from "./entity.js";
|
|
5
|
+
/**
|
|
6
|
+
* A parameter that is designed to be modifiable.
|
|
7
|
+
*/
|
|
8
|
+
export var ModifiableParameter;
|
|
9
|
+
(function (ModifiableParameter) {
|
|
10
|
+
ModifiableParameter[ModifiableParameter["CastingTime"] = 0] = "CastingTime";
|
|
11
|
+
ModifiableParameter[ModifiableParameter["Cost"] = 1] = "Cost";
|
|
12
|
+
ModifiableParameter[ModifiableParameter["Range"] = 2] = "Range";
|
|
13
|
+
})(ModifiableParameter || (ModifiableParameter = {}));
|
|
14
|
+
const translationKeyForNonModifiableSuffix = {
|
|
15
|
+
[Entity.Spell]: {
|
|
16
|
+
[ModifiableParameter.CastingTime]: " (you cannot use a modification on this spell’s casting time)",
|
|
17
|
+
[ModifiableParameter.Cost]: " (you cannot use a modification on this spell’s cost)",
|
|
18
|
+
[ModifiableParameter.Range]: " (you cannot use a modification on this spell’s range)",
|
|
19
|
+
},
|
|
20
|
+
[Entity.Ritual]: {
|
|
21
|
+
[ModifiableParameter.CastingTime]: " (you cannot use a modification on this ritual’s ritual time)",
|
|
22
|
+
[ModifiableParameter.Cost]: " (you cannot use a modification on this ritual’s cost)",
|
|
23
|
+
[ModifiableParameter.Range]: " (you cannot use a modification on this ritual’s range)",
|
|
24
|
+
},
|
|
25
|
+
[Entity.LiturgicalChant]: {
|
|
26
|
+
[ModifiableParameter.CastingTime]: " (you cannot use a modification on this chant’s liturgical time)",
|
|
27
|
+
[ModifiableParameter.Cost]: " (you cannot use a modification on this chant’s cost)",
|
|
28
|
+
[ModifiableParameter.Range]: " (you cannot use a modification on this chant’s range)",
|
|
29
|
+
},
|
|
30
|
+
[Entity.Ceremony]: {
|
|
31
|
+
[ModifiableParameter.CastingTime]: " (you cannot use a modification on this ceremony’s ceremonial time)",
|
|
32
|
+
[ModifiableParameter.Cost]: " (you cannot use a modification on this ceremony’s cost)",
|
|
33
|
+
[ModifiableParameter.Range]: " (you cannot use a modification on this ceremony’s range)",
|
|
34
|
+
},
|
|
35
|
+
[Entity.Cantrip]: undefined,
|
|
36
|
+
[Entity.Blessing]: undefined,
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Returns the suffix for the text of a non-modifiable parameter that indicates
|
|
40
|
+
* that the parameter cannot be modified.
|
|
41
|
+
*/
|
|
42
|
+
export const getNonModifiableSuffixTranslation = (locale, entity, param, responsiveTextSize) => responsive(responsiveTextSize, () => mapNullable(translationKeyForNonModifiableSuffix[entity]?.[param], (key) => locale.translate(key)) ?? "", () => {
|
|
43
|
+
switch (entity) {
|
|
44
|
+
case Entity.Spell:
|
|
45
|
+
case Entity.Ritual:
|
|
46
|
+
case Entity.LiturgicalChant:
|
|
47
|
+
case Entity.Ceremony:
|
|
48
|
+
return locale.translate(" (cannot modify)");
|
|
49
|
+
case Entity.Cantrip:
|
|
50
|
+
case Entity.Blessing:
|
|
51
|
+
return "";
|
|
52
|
+
default:
|
|
53
|
+
return assertExhaustive(entity);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
@@ -7,4 +7,4 @@ export declare const parensIf: (text: string | undefined) => string;
|
|
|
7
7
|
* Appends a string in parentheses with a leading space if it is not empty or
|
|
8
8
|
* `undefined`.
|
|
9
9
|
*/
|
|
10
|
-
export declare const
|
|
10
|
+
export declare const appendInParensIfNotEmpty: (textToAppend: string | undefined, text: string) => string;
|
|
@@ -7,4 +7,6 @@ export const parensIf = (text) => text === undefined || text === "" ? "" : ` (${
|
|
|
7
7
|
* Appends a string in parentheses with a leading space if it is not empty or
|
|
8
8
|
* `undefined`.
|
|
9
9
|
*/
|
|
10
|
-
export const
|
|
10
|
+
export const appendInParensIfNotEmpty = (textToAppend, text) => textToAppend === undefined || textToAppend === ""
|
|
11
|
+
? text
|
|
12
|
+
: `${text} (${textToAppend})`;
|
|
@@ -2,35 +2,19 @@ import { Range } from "optolith-database-schema/types/_ActivatableSkillRange";
|
|
|
2
2
|
import { BlessingRange } from "optolith-database-schema/types/Blessing";
|
|
3
3
|
import { CantripRange } from "optolith-database-schema/types/Cantrip";
|
|
4
4
|
import { GetById } from "../../../../helpers/getTypes.js";
|
|
5
|
-
import {
|
|
5
|
+
import { LocaleEnvironment } from "../../../../helpers/locale.js";
|
|
6
6
|
import { ResponsiveTextSize } from "../../responsiveText.js";
|
|
7
7
|
import { Entity } from "./entity.js";
|
|
8
8
|
import { Speed } from "./speed.js";
|
|
9
9
|
/**
|
|
10
10
|
* Returns the text for the range of an activatable skill.
|
|
11
11
|
*/
|
|
12
|
-
export declare const getTextForActivatableSkillRange: (
|
|
13
|
-
getSkillModificationLevelById: GetById.Static.SkillModificationLevel;
|
|
14
|
-
translate: Translate;
|
|
15
|
-
translateMap: TranslateMap;
|
|
16
|
-
}, value: Range, env: {
|
|
17
|
-
speed: Speed;
|
|
18
|
-
responsiveText: ResponsiveTextSize;
|
|
19
|
-
entity: Entity;
|
|
20
|
-
}) => string;
|
|
12
|
+
export declare const getTextForActivatableSkillRange: (getSkillModificationLevelById: GetById.Static.SkillModificationLevel, locale: LocaleEnvironment, speed: Speed, responsiveTextSize: ResponsiveTextSize, entity: Entity, value: Range) => string;
|
|
21
13
|
/**
|
|
22
14
|
* Returns the text for the range of a cantrip.
|
|
23
15
|
*/
|
|
24
|
-
export declare const getTextForCantripRange: (
|
|
25
|
-
translate: Translate;
|
|
26
|
-
}, value: CantripRange, env: {
|
|
27
|
-
responsiveText: ResponsiveTextSize;
|
|
28
|
-
}) => string;
|
|
16
|
+
export declare const getTextForCantripRange: (locale: LocaleEnvironment, responsiveTextSize: ResponsiveTextSize, value: CantripRange) => string;
|
|
29
17
|
/**
|
|
30
18
|
* Returns the text for the range of a blessing.
|
|
31
19
|
*/
|
|
32
|
-
export declare const getTextForBlessingRange: (
|
|
33
|
-
translate: Translate;
|
|
34
|
-
}, value: BlessingRange, env: {
|
|
35
|
-
responsiveText: ResponsiveTextSize;
|
|
36
|
-
}) => string;
|
|
20
|
+
export declare const getTextForBlessingRange: (locale: LocaleEnvironment, responsiveTextSize: ResponsiveTextSize, value: BlessingRange) => string;
|
|
@@ -1,122 +1,81 @@
|
|
|
1
|
+
import { mapNullable } from "@optolith/helpers/nullable";
|
|
1
2
|
import { assertExhaustive } from "@optolith/helpers/typeSafety";
|
|
2
|
-
import {
|
|
3
|
+
import { appendNoteIfRequested, replaceTextIfRequested, } from "../../responsiveText.js";
|
|
4
|
+
import { formatLength } from "../../units/length.js";
|
|
3
5
|
import { MISSING_VALUE } from "../../unknown.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
case "Miles":
|
|
14
|
-
return responsive(responsiveText, () => translate("{0} miles", value), () => translate("{0} mi.", value));
|
|
15
|
-
default:
|
|
16
|
-
return assertExhaustive(unit);
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* Returns the text for the range of an activatable skill.
|
|
21
|
-
*/
|
|
22
|
-
export const getTextForActivatableSkillRange = (deps, value, env) => {
|
|
23
|
-
const translation = deps.translateMap(value.translations);
|
|
24
|
-
if (value.translations !== undefined && translation === undefined) {
|
|
25
|
-
return MISSING_VALUE;
|
|
6
|
+
import { getCheckResultBasedValueTranslation } from "./checkResultBased.js";
|
|
7
|
+
import { Entity } from "./entity.js";
|
|
8
|
+
import { wrapIfMaximum } from "./isMinimumMaximum.js";
|
|
9
|
+
import { getNonModifiableSuffixTranslation, ModifiableParameter, } from "./nonModifiableSuffix.js";
|
|
10
|
+
import { getModifiableBySpeed } from "./speed.js";
|
|
11
|
+
const getModifiableRangeTranslation = (getSkillModificationLevelById, locale, speed, responsiveTextSize, value) => mapNullable(getSkillModificationLevelById(value.initial_modification_level), (modificationLevel) => {
|
|
12
|
+
const range = getModifiableBySpeed((config) => config.range, (config) => config.range, speed, modificationLevel);
|
|
13
|
+
if (range === 1) {
|
|
14
|
+
return locale.translate("Touch");
|
|
26
15
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
})();
|
|
44
|
-
if (range === 1) {
|
|
45
|
-
return deps.translate("Touch");
|
|
46
|
-
}
|
|
47
|
-
return toRangeUnit("Steps", range, deps.translate, env.responsiveText);
|
|
48
|
-
}
|
|
49
|
-
case "Sight":
|
|
50
|
-
return deps.translate("Sight");
|
|
51
|
-
case "Self":
|
|
52
|
-
return deps.translate("Self");
|
|
53
|
-
case "Global":
|
|
54
|
-
return deps.translate("Global");
|
|
55
|
-
case "Touch":
|
|
56
|
-
return (deps.translate("Touch") +
|
|
57
|
-
getTextForNonModifiableSuffix(deps.translate, env.entity, ModifiableParameter.Range, env.responsiveText));
|
|
58
|
-
case "Fixed": {
|
|
59
|
-
return (toRangeUnit(value.value.fixed.unit, value.value.fixed.value, deps.translate, env.responsiveText) +
|
|
60
|
-
getTextForNonModifiableSuffix(deps.translate, env.entity, ModifiableParameter.Range, env.responsiveText));
|
|
61
|
-
}
|
|
62
|
-
case "CheckResultBased": {
|
|
63
|
-
const isMaximum = getTextForIsMaximum(value.value.check_result_based.is_maximum, deps.translate, env.responsiveText);
|
|
64
|
-
const isRadius = value.value.check_result_based.is_radius === true
|
|
65
|
-
? ` ${deps.translate("Radius")}`
|
|
66
|
-
: "";
|
|
67
|
-
return (isMaximum +
|
|
68
|
-
toRangeUnit(value.value.check_result_based.unit, getTextForCheckResultBased(value.value.check_result_based, deps.translate), deps.translate, env.responsiveText) +
|
|
69
|
-
isRadius +
|
|
70
|
-
getTextForNonModifiableSuffix(deps.translate, env.entity, ModifiableParameter.Range, env.responsiveText));
|
|
71
|
-
}
|
|
72
|
-
default:
|
|
73
|
-
return assertExhaustive(value.value);
|
|
74
|
-
}
|
|
75
|
-
})();
|
|
76
|
-
const withReplacement = translation?.replacement !== undefined
|
|
77
|
-
? getResponsiveText(translation.replacement, env.responsiveText).replace("$1", rangeValue)
|
|
78
|
-
: rangeValue;
|
|
79
|
-
const withNote = (() => {
|
|
80
|
-
if (translation?.note === undefined) {
|
|
81
|
-
return withReplacement;
|
|
82
|
-
}
|
|
83
|
-
const note = getResponsiveTextOptional(translation.note, env.responsiveText);
|
|
84
|
-
if (note === undefined) {
|
|
85
|
-
return withReplacement;
|
|
86
|
-
}
|
|
87
|
-
return `${withReplacement} (${note})`;
|
|
88
|
-
})();
|
|
89
|
-
return withNote;
|
|
16
|
+
return formatLength(locale, responsiveTextSize, "Steps", range);
|
|
17
|
+
}) ?? MISSING_VALUE;
|
|
18
|
+
const getSightTranslation = (locale) => locale.translate("Sight");
|
|
19
|
+
const getSelfTranslation = (locale) => locale.translate("Self");
|
|
20
|
+
const getGlobalTranslation = (locale) => locale.translate("Global");
|
|
21
|
+
const getTouchTranslation = (locale, entity, responsiveTextSize) => locale.translate("Touch") +
|
|
22
|
+
getNonModifiableSuffixTranslation(locale, entity, ModifiableParameter.Range, responsiveTextSize);
|
|
23
|
+
const getFixedRangeTranslation = (locale, entity, responsiveTextSize, value) => formatLength(locale, responsiveTextSize, value.unit, value.value) +
|
|
24
|
+
getNonModifiableSuffixTranslation(locale, entity, ModifiableParameter.Range, responsiveTextSize);
|
|
25
|
+
const wrapIfRadius = (locale, is_radius, text) => (is_radius === true ? `${text} ${locale.translate("Radius")}` : text);
|
|
26
|
+
const getCheckResultBasedRangeTranslation = (locale, entity, responsiveTextSize, value) => {
|
|
27
|
+
const range = formatLength(locale, responsiveTextSize, value.unit, getCheckResultBasedValueTranslation(locale.translate, value));
|
|
28
|
+
const rangeWrappedIfRadius = wrapIfRadius(locale, value.is_radius, range);
|
|
29
|
+
const rangeWrappedIfRadiusAndIfMaximum = wrapIfMaximum(locale, responsiveTextSize, value.is_maximum, rangeWrappedIfRadius);
|
|
30
|
+
return (rangeWrappedIfRadiusAndIfMaximum +
|
|
31
|
+
getNonModifiableSuffixTranslation(locale, entity, ModifiableParameter.Range, responsiveTextSize));
|
|
90
32
|
};
|
|
91
|
-
|
|
92
|
-
* Returns the text for the range of a cantrip.
|
|
93
|
-
*/
|
|
94
|
-
export const getTextForCantripRange = (deps, value, env) => {
|
|
33
|
+
const getRangeValueTranslation = (getSkillModificationLevelById, locale, speed, responsiveTextSize, entity, value) => {
|
|
95
34
|
switch (value.tag) {
|
|
35
|
+
case "Modifiable":
|
|
36
|
+
return getModifiableRangeTranslation(getSkillModificationLevelById, locale, speed, responsiveTextSize, value.modifiable);
|
|
37
|
+
case "Sight":
|
|
38
|
+
return getSightTranslation(locale);
|
|
96
39
|
case "Self":
|
|
97
|
-
return
|
|
40
|
+
return getSelfTranslation(locale);
|
|
41
|
+
case "Global":
|
|
42
|
+
return getGlobalTranslation(locale);
|
|
98
43
|
case "Touch":
|
|
99
|
-
return
|
|
44
|
+
return getTouchTranslation(locale, entity, responsiveTextSize);
|
|
100
45
|
case "Fixed": {
|
|
101
|
-
return
|
|
46
|
+
return getFixedRangeTranslation(locale, entity, responsiveTextSize, value.fixed);
|
|
102
47
|
}
|
|
48
|
+
case "CheckResultBased":
|
|
49
|
+
return getCheckResultBasedRangeTranslation(locale, entity, responsiveTextSize, value.check_result_based);
|
|
103
50
|
default:
|
|
104
51
|
return assertExhaustive(value);
|
|
105
52
|
}
|
|
106
53
|
};
|
|
107
54
|
/**
|
|
108
|
-
* Returns the text for the range of
|
|
55
|
+
* Returns the text for the range of an activatable skill.
|
|
109
56
|
*/
|
|
110
|
-
export const
|
|
57
|
+
export const getTextForActivatableSkillRange = (getSkillModificationLevelById, locale, speed, responsiveTextSize, entity, value) => {
|
|
58
|
+
const rangeValue = getRangeValueTranslation(getSkillModificationLevelById, locale, speed, responsiveTextSize, entity, value.value);
|
|
59
|
+
const withReplacement = replaceTextIfRequested("replacement", value.translations, locale.translateMap, responsiveTextSize, rangeValue);
|
|
60
|
+
return appendNoteIfRequested("note", value.translations, locale.translateMap, responsiveTextSize, withReplacement);
|
|
61
|
+
};
|
|
62
|
+
const getTextForTinyAcitvatableRange = (locale, responsiveTextSize, entity, value) => {
|
|
111
63
|
switch (value.tag) {
|
|
112
64
|
case "Self":
|
|
113
|
-
return
|
|
65
|
+
return getSelfTranslation(locale);
|
|
114
66
|
case "Touch":
|
|
115
|
-
return
|
|
116
|
-
case "Fixed":
|
|
117
|
-
return
|
|
118
|
-
}
|
|
67
|
+
return getTouchTranslation(locale, entity, responsiveTextSize);
|
|
68
|
+
case "Fixed":
|
|
69
|
+
return getFixedRangeTranslation(locale, entity, responsiveTextSize, value.fixed);
|
|
119
70
|
default:
|
|
120
71
|
return assertExhaustive(value);
|
|
121
72
|
}
|
|
122
73
|
};
|
|
74
|
+
/**
|
|
75
|
+
* Returns the text for the range of a cantrip.
|
|
76
|
+
*/
|
|
77
|
+
export const getTextForCantripRange = (locale, responsiveTextSize, value) => getTextForTinyAcitvatableRange(locale, responsiveTextSize, Entity.Cantrip, value);
|
|
78
|
+
/**
|
|
79
|
+
* Returns the text for the range of a blessing.
|
|
80
|
+
*/
|
|
81
|
+
export const getTextForBlessingRange = (locale, responsiveTextSize, value) => getTextForTinyAcitvatableRange(locale, responsiveTextSize, Entity.Blessing, value);
|
|
@@ -9,4 +9,4 @@ export declare enum Speed {
|
|
|
9
9
|
/**
|
|
10
10
|
* Returns a common value for a skill modification level depending on the speed.
|
|
11
11
|
*/
|
|
12
|
-
export declare const getModifiableBySpeed: <T>(
|
|
12
|
+
export declare const getModifiableBySpeed: <T>(fast: (config: FastSkillModificationLevelConfig) => T, slow: (config: SlowSkillModificationLevelConfig) => T, speed: Speed, level: SkillModificationLevel) => T;
|
|
@@ -10,7 +10,7 @@ export var Speed;
|
|
|
10
10
|
/**
|
|
11
11
|
* Returns a common value for a skill modification level depending on the speed.
|
|
12
12
|
*/
|
|
13
|
-
export const getModifiableBySpeed = (
|
|
13
|
+
export const getModifiableBySpeed = (fast, slow, speed, level) => {
|
|
14
14
|
switch (speed) {
|
|
15
15
|
case Speed.Fast:
|
|
16
16
|
return fast(level.fast);
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import { TargetCategory } from "optolith-database-schema/types/_ActivatableSkillTargetCategory";
|
|
2
2
|
import { GetById } from "../../../../helpers/getTypes.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { LocaleEnvironment } from "../../../../helpers/locale.js";
|
|
4
|
+
import { EntityDescriptionSection } from "../../../../index.js";
|
|
5
5
|
/**
|
|
6
6
|
* Get the text for the target category.
|
|
7
7
|
*/
|
|
8
|
-
export declare const
|
|
9
|
-
translate: Translate;
|
|
10
|
-
translateMap: TranslateMap;
|
|
11
|
-
getTargetCategoryById: GetById.Static.TargetCategory;
|
|
12
|
-
}, values: TargetCategory) => LibraryEntryContent;
|
|
8
|
+
export declare const getTargetCategoryTranslation: (getTargetCategoryById: GetById.Static.TargetCategory, locale: LocaleEnvironment, values: TargetCategory) => EntityDescriptionSection;
|
|
@@ -1,36 +1,40 @@
|
|
|
1
1
|
import { mapNullable } from "@optolith/helpers/nullable";
|
|
2
2
|
import { assertExhaustive } from "@optolith/helpers/typeSafety";
|
|
3
3
|
import { MISSING_VALUE } from "../../unknown.js";
|
|
4
|
-
import {
|
|
4
|
+
import { appendInParensIfNotEmpty } from "./parensIf.js";
|
|
5
|
+
const getSelfTranslation = (locale) => locale.translate("Self");
|
|
6
|
+
const getZoneTranslation = (locale) => locale.translate("Zone");
|
|
7
|
+
const getLiturgicalChantsAndCeremoniesTranslation = (locale) => locale.translate("Liturgical Chants and Ceremonies");
|
|
8
|
+
const getCantripsTranslation = (locale) => locale.translate("Cantrips");
|
|
9
|
+
const getPredefinedTranslation = (getTargetCategoryById, locale, value) => {
|
|
10
|
+
const numericId = value.id.target_category;
|
|
11
|
+
const specificTargetCategory = getTargetCategoryById(numericId);
|
|
12
|
+
return (mapNullable(locale.translateMap(specificTargetCategory?.translations), (translation) => translation.name) ?? MISSING_VALUE);
|
|
13
|
+
};
|
|
14
|
+
const getTargetCategoryTranslationByType = (getTargetCategoryById, locale, id) => {
|
|
15
|
+
switch (id.tag) {
|
|
16
|
+
case "Self":
|
|
17
|
+
return getSelfTranslation(locale);
|
|
18
|
+
case "Zone":
|
|
19
|
+
return getZoneTranslation(locale);
|
|
20
|
+
case "LiturgicalChantsAndCeremonies":
|
|
21
|
+
return getLiturgicalChantsAndCeremoniesTranslation(locale);
|
|
22
|
+
case "Cantrips":
|
|
23
|
+
return getCantripsTranslation(locale);
|
|
24
|
+
case "Predefined":
|
|
25
|
+
return getPredefinedTranslation(getTargetCategoryById, locale, id.predefined);
|
|
26
|
+
default:
|
|
27
|
+
return assertExhaustive(id);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
5
30
|
/**
|
|
6
31
|
* Get the text for the target category.
|
|
7
32
|
*/
|
|
8
|
-
export const
|
|
9
|
-
label:
|
|
33
|
+
export const getTargetCategoryTranslation = (getTargetCategoryById, locale, values) => ({
|
|
34
|
+
label: locale.translate("Target Category"),
|
|
10
35
|
value: values.length === 0
|
|
11
|
-
?
|
|
36
|
+
? locale.translate("all")
|
|
12
37
|
: values
|
|
13
|
-
.map(({ id, translations }) =>
|
|
14
|
-
const mainName = (() => {
|
|
15
|
-
switch (id.tag) {
|
|
16
|
-
case "Self":
|
|
17
|
-
return deps.translate("Self");
|
|
18
|
-
case "Zone":
|
|
19
|
-
return deps.translate("Zone");
|
|
20
|
-
case "LiturgicalChantsAndCeremonies":
|
|
21
|
-
return deps.translate("Liturgical Chants and Ceremonies");
|
|
22
|
-
case "Cantrips":
|
|
23
|
-
return deps.translate("Cantrips");
|
|
24
|
-
case "Predefined": {
|
|
25
|
-
const numericId = id.predefined.id.target_category;
|
|
26
|
-
const specificTargetCategory = deps.getTargetCategoryById(numericId);
|
|
27
|
-
return (mapNullable(deps.translateMap(specificTargetCategory?.translations), (translation) => translation.name) ?? MISSING_VALUE);
|
|
28
|
-
}
|
|
29
|
-
default:
|
|
30
|
-
return assertExhaustive(id);
|
|
31
|
-
}
|
|
32
|
-
})();
|
|
33
|
-
return appendInParens(mainName, deps.translateMap(translations)?.note);
|
|
34
|
-
})
|
|
38
|
+
.map(({ id, translations }) => appendInParensIfNotEmpty(locale.translateMap(translations)?.note, getTargetCategoryTranslationByType(getTargetCategoryById, locale, id)))
|
|
35
39
|
.join(", "),
|
|
36
40
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ImprovementCost as RawImprovementCost } from "optolith-database-schema/types/_ImprovementCost";
|
|
2
2
|
import { Translate } from "../../../helpers/translate.js";
|
|
3
|
-
import {
|
|
3
|
+
import { EntityDescriptionSection } from "../../../index.js";
|
|
4
4
|
/**
|
|
5
5
|
* Returns the improvement cost as an inline library property.
|
|
6
6
|
*/
|
|
7
|
-
export declare const createImprovementCost: (translate: Translate, improvementCost: RawImprovementCost) =>
|
|
7
|
+
export declare const createImprovementCost: (translate: Translate, improvementCost: RawImprovementCost) => EntityDescriptionSection;
|
|
@@ -2,7 +2,7 @@ import { SkillCheck, SkillCheckPenalty } from "optolith-database-schema/types/_S
|
|
|
2
2
|
import { DerivedCharacteristic } from "optolith-database-schema/types/DerivedCharacteristic";
|
|
3
3
|
import { GetById } from "../../../helpers/getTypes.js";
|
|
4
4
|
import { Translate, TranslateMap } from "../../../helpers/translate.js";
|
|
5
|
-
import {
|
|
5
|
+
import { EntityDescriptionSection } from "../../../index.js";
|
|
6
6
|
import { ResponsiveTextSize } from "../responsiveText.js";
|
|
7
7
|
/**
|
|
8
8
|
* Returns the skill check as an inline library property.
|
|
@@ -16,4 +16,4 @@ export declare const getTextForCheck: (deps: {
|
|
|
16
16
|
responsiveText: ResponsiveTextSize;
|
|
17
17
|
getSpirit: () => DerivedCharacteristic | undefined;
|
|
18
18
|
getToughness: () => DerivedCharacteristic | undefined;
|
|
19
|
-
}) =>
|
|
19
|
+
}) => EntityDescriptionSection;
|
|
@@ -24,8 +24,11 @@ export declare const getResponsiveText: (value: ResponsiveText | undefined, size
|
|
|
24
24
|
export declare const getResponsiveTextOptional: (value: ResponsiveTextOptional | undefined, size: ResponsiveTextSize) => string | undefined;
|
|
25
25
|
/**
|
|
26
26
|
* Replaces a text with a given value if a replacement is requested, otherwise
|
|
27
|
-
* just return the .
|
|
27
|
+
* just return the given value.
|
|
28
28
|
*/
|
|
29
|
-
export declare const replaceTextIfRequested: (translation: LocaleMap<{
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
export declare const replaceTextIfRequested: <Key extends string>(key: Key, translation: LocaleMap<{ [K in Key]?: ResponsiveTextReplace; }> | undefined, translateMap: TranslateMap, responsiveText: ResponsiveTextSize, valueToReplace: string) => string;
|
|
30
|
+
/**
|
|
31
|
+
* Appends a note to a given value if a note is requested, otherwise just return
|
|
32
|
+
* the given value.
|
|
33
|
+
*/
|
|
34
|
+
export declare const appendNoteIfRequested: <Key extends string>(key: Key, translation: LocaleMap<{ [K in Key]?: ResponsiveTextOptional; }> | undefined, translateMap: TranslateMap, responsiveText: ResponsiveTextSize, valueToAppendTo: string) => string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { mapNullable } from "@optolith/helpers/nullable";
|
|
2
2
|
import { assertExhaustive } from "@optolith/helpers/typeSafety";
|
|
3
|
+
import { appendInParensIfNotEmpty } from "./rated/activatable/parensIf.js";
|
|
3
4
|
import { MISSING_VALUE } from "./unknown.js";
|
|
4
5
|
/**
|
|
5
6
|
* Whether the entry is displayed in a normal or compressed setting. Normal/full
|
|
@@ -44,6 +45,11 @@ export const getResponsiveTextOptional = (value, size) => {
|
|
|
44
45
|
};
|
|
45
46
|
/**
|
|
46
47
|
* Replaces a text with a given value if a replacement is requested, otherwise
|
|
47
|
-
* just return the .
|
|
48
|
+
* just return the given value.
|
|
48
49
|
*/
|
|
49
|
-
export const replaceTextIfRequested = (
|
|
50
|
+
export const replaceTextIfRequested = (key, translation, translateMap, responsiveText, valueToReplace) => mapNullable(translateMap(translation)?.[key], (replacement) => getResponsiveText(replacement, responsiveText).replace("$1", valueToReplace)) ?? valueToReplace;
|
|
51
|
+
/**
|
|
52
|
+
* Appends a note to a given value if a note is requested, otherwise just return
|
|
53
|
+
* the given value.
|
|
54
|
+
*/
|
|
55
|
+
export const appendNoteIfRequested = (key, translation, translateMap, responsiveText, valueToAppendTo) => mapNullable(translateMap(translation)?.[key], (note) => appendInParensIfNotEmpty(getResponsiveTextOptional(note, responsiveText), valueToAppendTo)) ?? valueToAppendTo;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { LocaleEnvironment } from "../../../helpers/locale.js";
|
|
2
|
+
import { Entity } from "../rated/activatable/entity.js";
|
|
3
|
+
type EnergyUnit = "ArcaneEnergy" | "KarmaPoints";
|
|
4
|
+
/**
|
|
5
|
+
* Returns the text for an energy unit.
|
|
6
|
+
*/
|
|
7
|
+
export declare const formatEnergy: (locale: LocaleEnvironment, unit: EnergyUnit, value: number | string) => string;
|
|
8
|
+
/**
|
|
9
|
+
* Returns the text for an energy unit that is based on the entity type.
|
|
10
|
+
*/
|
|
11
|
+
export declare const formatEnergyByEntity: (locale: LocaleEnvironment, entity: Entity, value: number | string) => string;
|
|
12
|
+
export {};
|