@optolith/entity-descriptions 0.3.1 → 0.3.2
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 +7 -0
- package/lib/entities/culture.js +2 -2
- package/lib/entities/equipment.d.ts +1 -1
- package/lib/entities/equipment.js +54 -62
- package/lib/entities/equipmentPackage.js +9 -10
- package/lib/entities/influence.d.ts +6 -2
- package/lib/entities/influence.js +24 -16
- package/lib/entities/liturgicalChant.d.ts +6 -3
- package/lib/entities/liturgicalChant.js +15 -13
- package/lib/entities/partial/enhancements.d.ts +7 -0
- package/lib/entities/partial/enhancements.js +26 -0
- package/lib/entities/partial/prerequisites/index.d.ts +3 -3
- package/lib/entities/partial/prerequisites/index.js +1 -1
- package/lib/entities/partial/prerequisites/prerequisiteGroups.d.ts +3 -3
- package/lib/entities/partial/prerequisites/prerequisiteGroups.js +10 -1
- package/lib/entities/partial/prerequisites/single/enhancement.d.ts +1 -1
- package/lib/entities/partial/prerequisites/single/profession.d.ts +8 -0
- package/lib/entities/partial/prerequisites/single/profession.js +19 -0
- package/lib/entities/partial/rated/improvementCost.d.ts +0 -8
- package/lib/entities/partial/rated/improvementCost.js +0 -54
- package/lib/entities/poison.js +33 -21
- package/lib/entities/spell.d.ts +5 -2
- package/lib/entities/spell.js +9 -2
- package/lib/index.d.ts +41 -35
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -8
|
@@ -170,7 +170,7 @@ export const printLiturgyPrerequisites = (locale, value) => printPlainPrerequisi
|
|
|
170
170
|
/**
|
|
171
171
|
* Print influence prerequisites as a string.
|
|
172
172
|
*/
|
|
173
|
-
export const printInfluencePrerequisites = (getInstanceById, locale, value) => printPlainPrerequisites(prerequisite => printInfluencePrerequisiteGroup(getInstanceById, locale, prerequisite), locale, value);
|
|
173
|
+
export const printInfluencePrerequisites = (getInstanceById, getResolvedSelectOptionById, getChildInstancesForInstanceId, locale, value) => printPlainPrerequisites(prerequisite => printInfluencePrerequisiteGroup(getInstanceById, getResolvedSelectOptionById, getChildInstancesForInstanceId, locale, prerequisite), locale, value);
|
|
174
174
|
/**
|
|
175
175
|
* Print language prerequisites as a string.
|
|
176
176
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AdvantageDisadvantagePrerequisiteGroup, AnimistPowerPrerequisiteGroup, ArcaneTraditionPrerequisiteGroup, DerivedCharacteristicPrerequisiteGroup, EnhancementPrerequisiteGroup, GeneralPrerequisiteGroup, GeodeRitualPrerequisiteGroup, InfluencePrerequisiteGroup, LanguagePrerequisiteGroup, LiturgyPrerequisiteGroup, PersonalityTraitPrerequisiteGroup, PreconditionGroup, ProfessionPrerequisiteGroup, PublicationPrerequisiteGroup, SpellworkPrerequisiteGroup, type ActivatableIdentifier, type RatedIdentifier } from "optolith-database-schema/gen";
|
|
2
|
-
import type { GetInstanceById } from "../../../helpers/getTypes.js";
|
|
2
|
+
import type { GetAllChildInstancesForParent, GetInstanceById } from "../../../helpers/getTypes.js";
|
|
3
3
|
import { LocaleEnvironment } from "../../../helpers/locale.js";
|
|
4
4
|
import { PrerequisitePart } from "./part.js";
|
|
5
5
|
import { GetResolvedSelectOptionById } from "./single/activatable.js";
|
|
@@ -42,7 +42,7 @@ export declare const printLiturgyPrerequisiteGroup: (locale: LocaleEnvironment,
|
|
|
42
42
|
/**
|
|
43
43
|
* Print the translation of an influence prerequisite group.
|
|
44
44
|
*/
|
|
45
|
-
export declare const printInfluencePrerequisiteGroup: (getInstanceById: GetInstanceById<"Influence">, locale: LocaleEnvironment, prerequisite: InfluencePrerequisiteGroup) => PrerequisitePart | undefined;
|
|
45
|
+
export declare const printInfluencePrerequisiteGroup: (getInstanceById: GetInstanceById<"Influence" | "Race" | ActivatableIdentifier["kind"] | "Aspect">, getResolvedSelectOptionById: GetResolvedSelectOptionById, getChildInstancesForInstanceId: GetAllChildInstancesForParent<"ProfessionVersion">, locale: LocaleEnvironment, prerequisite: InfluencePrerequisiteGroup) => PrerequisitePart | undefined;
|
|
46
46
|
/**
|
|
47
47
|
* Print the translation of a language prerequisite group.
|
|
48
48
|
*/
|
|
@@ -58,7 +58,7 @@ export declare const printGeodeRitualPrerequisiteGroup: (getInstanceById: GetIns
|
|
|
58
58
|
/**
|
|
59
59
|
* Print the translation of an enhancement prerequisite group.
|
|
60
60
|
*/
|
|
61
|
-
export declare const printEnhancementPrerequisiteGroup: (getInstanceById: GetInstanceById<RatedIdentifier["kind"] | "Enhancement">, locale: LocaleEnvironment, prerequisite: EnhancementPrerequisiteGroup) => PrerequisitePart | undefined;
|
|
61
|
+
export declare const printEnhancementPrerequisiteGroup: (getInstanceById: GetInstanceById<RatedIdentifier["kind"] | "Enhancement">, locale: Pick<LocaleEnvironment, "translate" | "translateMap">, prerequisite: EnhancementPrerequisiteGroup) => PrerequisitePart | undefined;
|
|
62
62
|
/**
|
|
63
63
|
* Print the translation of a precondition group.
|
|
64
64
|
*/
|
|
@@ -11,6 +11,7 @@ import { printNoOtherAncestorBloodAdvantagePrerequisite } from "./single/noOther
|
|
|
11
11
|
import { printPactPrerequisite } from "./single/pact.js";
|
|
12
12
|
import { printPersonalityTraitPrerequisite } from "./single/personalityTrait.js";
|
|
13
13
|
import { printPrimaryAttributePrerequisite } from "./single/primaryAttribute.js";
|
|
14
|
+
import { printProfessionPrerequisite } from "./single/profession.js";
|
|
14
15
|
import { printPublicationPrerequisite } from "./single/publication.js";
|
|
15
16
|
import { printRacePrerequisite } from "./single/race.js";
|
|
16
17
|
import { printRatedPrerequisite } from "./single/rated.js";
|
|
@@ -196,10 +197,16 @@ printRulePrerequisite(locale, prerequisite.Rule);
|
|
|
196
197
|
/**
|
|
197
198
|
* Print the translation of an influence prerequisite group.
|
|
198
199
|
*/
|
|
199
|
-
export const printInfluencePrerequisiteGroup = (getInstanceById, locale, prerequisite) => {
|
|
200
|
+
export const printInfluencePrerequisiteGroup = (getInstanceById, getResolvedSelectOptionById, getChildInstancesForInstanceId, locale, prerequisite) => {
|
|
200
201
|
switch (prerequisite.kind) {
|
|
201
202
|
case "Influence":
|
|
202
203
|
return printInfluencePrerequisite(getInstanceById, locale, prerequisite.Influence);
|
|
204
|
+
case "Race":
|
|
205
|
+
return printRacePrerequisite(getInstanceById, locale, prerequisite.Race);
|
|
206
|
+
case "Profession":
|
|
207
|
+
return printProfessionPrerequisite(getChildInstancesForInstanceId, locale, prerequisite.Profession);
|
|
208
|
+
case "Activatable":
|
|
209
|
+
return printActivatablePrerequisite(getInstanceById, getResolvedSelectOptionById, locale, prerequisite.Activatable, false);
|
|
203
210
|
case "Text":
|
|
204
211
|
return printTextPrerequisite(locale, prerequisite.Text);
|
|
205
212
|
default:
|
|
@@ -261,6 +268,8 @@ export const printPreconditionGroup = (getInstanceById, locale, prerequisite) =>
|
|
|
261
268
|
switch (prerequisite.kind) {
|
|
262
269
|
case "Publication":
|
|
263
270
|
return printPublicationPrerequisite(getInstanceById, locale, prerequisite.Publication);
|
|
271
|
+
case "Rule":
|
|
272
|
+
return printRulePrerequisite(locale, prerequisite.Rule);
|
|
264
273
|
case "SexualCharacteristic":
|
|
265
274
|
return printSexualCharacteristicPrerequisite(locale, prerequisite.SexualCharacteristic);
|
|
266
275
|
default:
|
|
@@ -5,4 +5,4 @@ import { PrerequisitePart } from "../part.js";
|
|
|
5
5
|
/**
|
|
6
6
|
* Get the translation of an external enhancement prerequisite.
|
|
7
7
|
*/
|
|
8
|
-
export declare const printEnhancementPrerequisite: (getInstanceById: GetInstanceById<"Spell" | "Ritual" | "LiturgicalChant" | "Ceremony" | "Enhancement">, locale: LocaleEnvironment, prerequisite: EnhancementPrerequisite) => PrerequisitePart | undefined;
|
|
8
|
+
export declare const printEnhancementPrerequisite: (getInstanceById: GetInstanceById<"Spell" | "Ritual" | "LiturgicalChant" | "Ceremony" | "Enhancement">, locale: Pick<LocaleEnvironment, "translate" | "translateMap">, prerequisite: EnhancementPrerequisite) => PrerequisitePart | undefined;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type ProfessionPrerequisite } from "optolith-database-schema/gen";
|
|
2
|
+
import { type GetAllChildInstancesForParent } from "../../../../helpers/getTypes.js";
|
|
3
|
+
import { LocaleEnvironment } from "../../../../helpers/locale.js";
|
|
4
|
+
import { PrerequisitePart } from "../part.js";
|
|
5
|
+
/**
|
|
6
|
+
* Get the translation of a profession prerequisite.
|
|
7
|
+
*/
|
|
8
|
+
export declare const printProfessionPrerequisite: (getChildInstancesForInstanceId: GetAllChildInstancesForParent<"ProfessionVersion">, locale: Pick<LocaleEnvironment, "translateMap">, prerequisite: ProfessionPrerequisite) => PrerequisitePart | undefined;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { getProfessionName } from "../../professions.js";
|
|
2
|
+
import { printDisplayOption } from "../displayOption.js";
|
|
3
|
+
/**
|
|
4
|
+
* Get the translation of a profession prerequisite.
|
|
5
|
+
*/
|
|
6
|
+
export const printProfessionPrerequisite = (getChildInstancesForInstanceId, locale, prerequisite) => {
|
|
7
|
+
if (prerequisite.displayOption !== undefined) {
|
|
8
|
+
return printDisplayOption(locale.translateMap, prerequisite.displayOption);
|
|
9
|
+
}
|
|
10
|
+
const professionName = getProfessionName(locale.translateMap, getChildInstancesForInstanceId, prerequisite.id);
|
|
11
|
+
if (professionName === undefined) {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
value: professionName,
|
|
16
|
+
sentenceType: undefined,
|
|
17
|
+
isMeta: false,
|
|
18
|
+
};
|
|
19
|
+
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type RangeBounds } from "@elyukai/utils/range";
|
|
2
1
|
import type { ImprovementCost } from "optolith-database-schema/gen";
|
|
3
2
|
import { type RawDefinitionListEntityDescriptionSectionItem } from "../../../index.js";
|
|
4
3
|
import { type StdReader } from "../reader.js";
|
|
@@ -10,10 +9,3 @@ export declare const renderImprovementCostValue: (improvementCost: ImprovementCo
|
|
|
10
9
|
* Returns the improvement cost as an inline library property.
|
|
11
10
|
*/
|
|
12
11
|
export declare const renderImprovementCost: (improvementCost: ImprovementCost) => StdReader<RawDefinitionListEntityDescriptionSectionItem, "t">;
|
|
13
|
-
/**
|
|
14
|
-
* Calculates the adventure points for an improvement cost.
|
|
15
|
-
* @throws {RangeError} if the rating range is invalid (max < min).
|
|
16
|
-
*/
|
|
17
|
-
export declare const calculateAdventurePointsFromImprovementCost: (improvementCost: ImprovementCost | ImprovementCost["kind"] | {
|
|
18
|
-
kind: "E";
|
|
19
|
-
} | "E", rating?: number | RangeBounds) => number;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { rangeSize } from "@elyukai/utils/range";
|
|
2
|
-
import { assertExhaustive } from "@elyukai/utils/typeSafety";
|
|
3
1
|
import { translateR } from "../reader.js";
|
|
4
2
|
/**
|
|
5
3
|
* Renders an improvement cost value as a string.
|
|
@@ -12,55 +10,3 @@ export const renderImprovementCost = (improvementCost) => translateR("Improvemen
|
|
|
12
10
|
label,
|
|
13
11
|
value: renderImprovementCostValue(improvementCost),
|
|
14
12
|
}));
|
|
15
|
-
/**
|
|
16
|
-
* Calculates the adventure points for an improvement cost.
|
|
17
|
-
* @throws {RangeError} if the rating range is invalid (max < min).
|
|
18
|
-
*/
|
|
19
|
-
export const calculateAdventurePointsFromImprovementCost = (improvementCost, rating = 1) => {
|
|
20
|
-
const normalized = typeof improvementCost === "string" ? improvementCost : improvementCost.kind;
|
|
21
|
-
const base = (() => {
|
|
22
|
-
switch (normalized) {
|
|
23
|
-
case "A":
|
|
24
|
-
return 1;
|
|
25
|
-
case "B":
|
|
26
|
-
return 2;
|
|
27
|
-
case "C":
|
|
28
|
-
return 3;
|
|
29
|
-
case "D":
|
|
30
|
-
return 4;
|
|
31
|
-
case "E":
|
|
32
|
-
return 15;
|
|
33
|
-
default:
|
|
34
|
-
return assertExhaustive(normalized);
|
|
35
|
-
}
|
|
36
|
-
})();
|
|
37
|
-
const lastRatingOfSameValue = (() => {
|
|
38
|
-
switch (normalized) {
|
|
39
|
-
case "A":
|
|
40
|
-
case "B":
|
|
41
|
-
case "C":
|
|
42
|
-
case "D":
|
|
43
|
-
return 12;
|
|
44
|
-
case "E":
|
|
45
|
-
return 14;
|
|
46
|
-
default:
|
|
47
|
-
return assertExhaustive(normalized);
|
|
48
|
-
}
|
|
49
|
-
})();
|
|
50
|
-
if (typeof rating === "number") {
|
|
51
|
-
return (base *
|
|
52
|
-
(rating < lastRatingOfSameValue ? 1 : rating - lastRatingOfSameValue + 1));
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
const [min, max] = rating;
|
|
56
|
-
if (max < min) {
|
|
57
|
-
throw new RangeError(`Invalid rating range: ${min} - ${max}`);
|
|
58
|
-
}
|
|
59
|
-
const size = rangeSize(rating);
|
|
60
|
-
const constantRangeSize = Math.min(size, lastRatingOfSameValue - min + 1);
|
|
61
|
-
const variableRangeSize = size - constantRangeSize;
|
|
62
|
-
const constantCost = base * constantRangeSize;
|
|
63
|
-
const variableCost = base * (((variableRangeSize + 1) * (variableRangeSize + 2)) / 2 - 1);
|
|
64
|
-
return constantCost + variableCost;
|
|
65
|
-
}
|
|
66
|
-
};
|
package/lib/entities/poison.js
CHANGED
|
@@ -28,18 +28,14 @@ const renderApplicationType = (translate, localeJoin, localeCompare, application
|
|
|
28
28
|
}
|
|
29
29
|
})
|
|
30
30
|
.toSorted(localeCompare)
|
|
31
|
-
.map((type, index, arr) => index === arr.length - 1 && type.at(-1) === "-"
|
|
32
|
-
? type.slice(0, -1)
|
|
33
|
-
: type), "conjunction"),
|
|
31
|
+
.map((type, index, arr) => index === arr.length - 1 && type.at(-1) === "-" ? type.slice(0, -1) : type), "conjunction"),
|
|
34
32
|
});
|
|
35
33
|
const renderLevel = (translate, translateMap, level) => {
|
|
36
34
|
switch (level.kind) {
|
|
37
35
|
case "QualityLevel":
|
|
38
36
|
return translate("QL");
|
|
39
37
|
case "Constant":
|
|
40
|
-
return typeof level.Constant === "number"
|
|
41
|
-
? level.Constant
|
|
42
|
-
: level.Constant.value;
|
|
38
|
+
return typeof level.Constant === "number" ? level.Constant : level.Constant.value;
|
|
43
39
|
case "BySubtype":
|
|
44
40
|
return level.BySubtype.map(subtype => `${subtype.value} (${translateMap(subtype.translations)?.name ?? MISSING_VALUE})`).join(", ");
|
|
45
41
|
default:
|
|
@@ -84,9 +80,7 @@ const renderIntoxicantValues = (translate, translateMap, getInstanceById, intoxi
|
|
|
84
80
|
ingestion: translation?.ingestion ?? MISSING_VALUE,
|
|
85
81
|
sideEffect: translation?.side_effect,
|
|
86
82
|
overdose: translation?.overdose ?? MISSING_VALUE,
|
|
87
|
-
legality: intoxicant.legality.is_legal
|
|
88
|
-
? translate("legal")
|
|
89
|
-
: translate("illegal"),
|
|
83
|
+
legality: intoxicant.legality.is_legal ? translate("legal") : translate("illegal"),
|
|
90
84
|
special: translation?.special,
|
|
91
85
|
addiction: intoxicant?.addiction === undefined
|
|
92
86
|
? undefined
|
|
@@ -104,13 +98,20 @@ const renderSourceTypeBasedValues = (translate, translateMap, getInstanceById, s
|
|
|
104
98
|
const translation = translateMap(sourceType.AlchemicalPoison.translations);
|
|
105
99
|
return {
|
|
106
100
|
level: translate("QL"),
|
|
107
|
-
sourceType:
|
|
101
|
+
sourceType: [
|
|
102
|
+
sourceType.AlchemicalPoison.isDemonic === true ? translate("demonic poison") : undefined,
|
|
103
|
+
translate("alchemical poison"),
|
|
104
|
+
]
|
|
105
|
+
.filter(isNotNullish)
|
|
106
|
+
.join(", "),
|
|
108
107
|
...(sourceType.AlchemicalPoison.intoxicant === undefined
|
|
109
108
|
? undefined
|
|
110
109
|
: renderIntoxicantValues(translate, translateMap, getInstanceById, sourceType.AlchemicalPoison.intoxicant)),
|
|
111
110
|
typicalIngredients: translation?.typical_ingredients.join(", "),
|
|
112
111
|
priceOfIngedientsPerLevel: translate("{$cost} per level", {
|
|
113
|
-
cost: translate(".input {$value :number} {{{$value} silverthalers}}", {
|
|
112
|
+
cost: translate(".input {$value :number} {{{$value} silverthalers}}", {
|
|
113
|
+
value: sourceType.AlchemicalPoison.cost_per_ingredient_level,
|
|
114
|
+
}),
|
|
114
115
|
}),
|
|
115
116
|
laboratory: renderLaboratoryLevel(translate, sourceType.AlchemicalPoison.laboratory),
|
|
116
117
|
brewingDifficulty: sign(sourceType.AlchemicalPoison.brewing_difficulty),
|
|
@@ -121,6 +122,11 @@ const renderSourceTypeBasedValues = (translate, translateMap, getInstanceById, s
|
|
|
121
122
|
})),
|
|
122
123
|
};
|
|
123
124
|
}
|
|
125
|
+
case "AlchemicalPactGiftPoison":
|
|
126
|
+
return {
|
|
127
|
+
level: translate("QL"),
|
|
128
|
+
sourceType: translate("alchemical poison"),
|
|
129
|
+
};
|
|
124
130
|
case "MineralPoison":
|
|
125
131
|
return {
|
|
126
132
|
level: sourceType.MineralPoison.level,
|
|
@@ -155,8 +161,7 @@ const renderStart = (translate, translateMap, start) => {
|
|
|
155
161
|
case "DiceBased":
|
|
156
162
|
return formatTimeSpan(translate, ResponsiveTextSize.Full, start.DiceBased.unit, renderDiceAndFlat(translate, start.DiceBased.dice, start.DiceBased.flat));
|
|
157
163
|
case "Indefinite":
|
|
158
|
-
return
|
|
159
|
-
MISSING_VALUE);
|
|
164
|
+
return translateMap(start.Indefinite.translations)?.description ?? MISSING_VALUE;
|
|
160
165
|
default:
|
|
161
166
|
return assertExhaustive(start);
|
|
162
167
|
}
|
|
@@ -176,13 +181,14 @@ const renderDuration = (translate, translateMap, duration) => {
|
|
|
176
181
|
return value.Constant.toString();
|
|
177
182
|
case "Dice":
|
|
178
183
|
return renderDice(translate, value.Dice);
|
|
184
|
+
case "CircleOfDamnation":
|
|
185
|
+
return translate("CoD");
|
|
179
186
|
default:
|
|
180
187
|
return assertExhaustive(value);
|
|
181
188
|
}
|
|
182
189
|
});
|
|
183
190
|
case "Indefinite":
|
|
184
|
-
return
|
|
185
|
-
UNHANDLED_VALUE);
|
|
191
|
+
return translateMap(duration.Indefinite.translations)?.description ?? UNHANDLED_VALUE;
|
|
186
192
|
default:
|
|
187
193
|
return assertExhaustive(duration);
|
|
188
194
|
}
|
|
@@ -197,8 +203,14 @@ const renderCost = (translate, translateMap, cost) => {
|
|
|
197
203
|
return translate(".input {$value :number} {{{$value} silverthalers}}", {
|
|
198
204
|
value: cost.Constant,
|
|
199
205
|
});
|
|
206
|
+
case "DependingOnPurchaseOrSale":
|
|
207
|
+
return `${translate(".input {$value :number} {{{$value} silverthalers}}", {
|
|
208
|
+
value: cost.DependingOnPurchaseOrSale.purchase,
|
|
209
|
+
})} (${translate("purchase")}) / ${translate(".input {$value :number} {{{$value} silverthalers}}", {
|
|
210
|
+
value: cost.DependingOnPurchaseOrSale.sale,
|
|
211
|
+
})} (${translate("sale")})`;
|
|
200
212
|
case "Indefinite":
|
|
201
|
-
return
|
|
213
|
+
return translateMap(cost.Indefinite.translations)?.description ?? MISSING_VALUE;
|
|
202
214
|
default:
|
|
203
215
|
return assertExhaustive(cost);
|
|
204
216
|
}
|
|
@@ -218,7 +230,7 @@ const renderValueCost = (translate, translateMap, cost, value) => value === unde
|
|
|
218
230
|
* Get a JSON representation of the rules text for a poison.
|
|
219
231
|
*/
|
|
220
232
|
export const getPoisonEntityDescription = createEntityDescriptionCreator(({ getInstanceById, getResolvedSelectOptionById, idMap }, locale, { content: entry }) => {
|
|
221
|
-
const { translate, translateMap, join: localeJoin, compare: localeCompare
|
|
233
|
+
const { translate, translateMap, join: localeJoin, compare: localeCompare } = locale;
|
|
222
234
|
const translation = translateMap(entry.translations);
|
|
223
235
|
if (translation === undefined) {
|
|
224
236
|
return undefined;
|
|
@@ -254,9 +266,7 @@ export const getPoisonEntityDescription = createEntityDescriptionCreator(({ getI
|
|
|
254
266
|
{
|
|
255
267
|
label: translate("Effect"),
|
|
256
268
|
value: translation.effect.default +
|
|
257
|
-
(translation.effect.reduced === undefined
|
|
258
|
-
? ""
|
|
259
|
-
: ` / ${translation.effect.reduced}`),
|
|
269
|
+
(translation.effect.reduced === undefined ? "" : ` / ${translation.effect.reduced}`),
|
|
260
270
|
},
|
|
261
271
|
sideEffect === undefined
|
|
262
272
|
? undefined
|
|
@@ -287,7 +297,9 @@ export const getPoisonEntityDescription = createEntityDescriptionCreator(({ getI
|
|
|
287
297
|
label: translate("Legality"),
|
|
288
298
|
value: legality,
|
|
289
299
|
},
|
|
290
|
-
|
|
300
|
+
entry.cost === undefined
|
|
301
|
+
? undefined
|
|
302
|
+
: renderValueCost(translate, translateMap, entry.cost, entry.value),
|
|
291
303
|
special === undefined
|
|
292
304
|
? undefined
|
|
293
305
|
: {
|
package/lib/entities/spell.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type RatedIdentifier } from "optolith-database-schema/gen";
|
|
1
2
|
import type { GetAllChildInstancesForParent, GetInstanceById } from "../helpers/getTypes.js";
|
|
2
3
|
import { type IdMap } from "../index.js";
|
|
3
4
|
/**
|
|
@@ -10,14 +11,16 @@ export declare const getCantripEntityDescription: import("../creator.js").Entity
|
|
|
10
11
|
* Get a JSON representation of the rules text for a skill.
|
|
11
12
|
*/
|
|
12
13
|
export declare const getSpellEntityDescription: import("../creator.js").EntityDescriptionCreator<"Spell", {
|
|
13
|
-
getInstanceById: GetInstanceById<"Publication" | "Attribute" | "SkillModificationLevel" | "TargetCategory" | "Property" | "MagicalTradition" | "DerivedCharacteristic">;
|
|
14
|
+
getInstanceById: GetInstanceById<"Publication" | "Attribute" | "SkillModificationLevel" | "TargetCategory" | "Property" | "MagicalTradition" | "DerivedCharacteristic" | RatedIdentifier["kind"] | "Enhancement">;
|
|
15
|
+
getChildInstancesForInstanceId: GetAllChildInstancesForParent<"Enhancement">;
|
|
14
16
|
idMap: IdMap;
|
|
15
17
|
}, import("../index.js").EntityDescription>;
|
|
16
18
|
/**
|
|
17
19
|
* Get a JSON representation of the rules text for a ritual.
|
|
18
20
|
*/
|
|
19
21
|
export declare const getRitualEntityDescription: import("../creator.js").EntityDescriptionCreator<"Ritual", {
|
|
20
|
-
getInstanceById: GetInstanceById<"Publication" | "Attribute" | "SkillModificationLevel" | "TargetCategory" | "Property" | "MagicalTradition" | "DerivedCharacteristic">;
|
|
22
|
+
getInstanceById: GetInstanceById<"Publication" | "Attribute" | "SkillModificationLevel" | "TargetCategory" | "Property" | "MagicalTradition" | "DerivedCharacteristic" | RatedIdentifier["kind"] | "Enhancement">;
|
|
23
|
+
getChildInstancesForInstanceId: GetAllChildInstancesForParent<"Enhancement">;
|
|
21
24
|
idMap: IdMap;
|
|
22
25
|
}, import("../index.js").EntityDescription>;
|
|
23
26
|
/**
|
package/lib/entities/spell.js
CHANGED
|
@@ -10,6 +10,7 @@ import { assertExhaustive } from "@optolith/helpers/typeSafety";
|
|
|
10
10
|
import { Case } from "tsondb/schema/gen";
|
|
11
11
|
import { createEntityDescriptionCreator } from "../creator.js";
|
|
12
12
|
import { renderAnimalTypesSection } from "./partial/animalTypes.js";
|
|
13
|
+
import { renderEnhancements } from "./partial/enhancements.js";
|
|
13
14
|
import { printAnimistPowerPrerequisites, printGeodeRitualPrerequisites, } from "./partial/prerequisites/index.js";
|
|
14
15
|
import { renderCastingTime, renderFastSkillNonModifiableCastingTime, renderSlowSkillNonModifiableCastingTime, } from "./partial/rated/activatable/castingTime.js";
|
|
15
16
|
import { renderMagicalActionCost, renderModifiableOneTimeCost, renderNonModifiableOneTimeCost, } from "./partial/rated/activatable/cost.js";
|
|
@@ -151,7 +152,7 @@ export const getCantripEntityDescription = createEntityDescriptionCreator(({ get
|
|
|
151
152
|
/**
|
|
152
153
|
* Get a JSON representation of the rules text for a skill.
|
|
153
154
|
*/
|
|
154
|
-
export const getSpellEntityDescription = createEntityDescriptionCreator(({ getInstanceById, idMap }, locale, { content: entry }) => {
|
|
155
|
+
export const getSpellEntityDescription = createEntityDescriptionCreator(({ getInstanceById, getChildInstancesForInstanceId, idMap }, locale, { content: entry, entity, id }) => {
|
|
155
156
|
const { translate, translateMap, compare: localeCompare } = locale;
|
|
156
157
|
const translation = translateMap(entry.translations);
|
|
157
158
|
if (translation === undefined) {
|
|
@@ -161,7 +162,9 @@ export const getSpellEntityDescription = createEntityDescriptionCreator(({ getIn
|
|
|
161
162
|
translate,
|
|
162
163
|
translateMap,
|
|
163
164
|
getInstanceById,
|
|
165
|
+
getChildInstancesForInstanceId,
|
|
164
166
|
localeJoin: locale.join,
|
|
167
|
+
localeCompare: locale.compare,
|
|
165
168
|
energyUnit: "ArcaneEnergy",
|
|
166
169
|
responsiveTextSize: ResponsiveTextSize.Full,
|
|
167
170
|
nonModifiableSuffix: (param) => {
|
|
@@ -197,6 +200,7 @@ export const getSpellEntityDescription = createEntityDescriptionCreator(({ getIn
|
|
|
197
200
|
renderImprovementCost(entry.improvement_cost).run(env),
|
|
198
201
|
],
|
|
199
202
|
},
|
|
203
|
+
renderEnhancements(Case(entity, id), entry.improvement_cost).run(env),
|
|
200
204
|
],
|
|
201
205
|
errata: translation.errata,
|
|
202
206
|
references: entry.src,
|
|
@@ -205,7 +209,7 @@ export const getSpellEntityDescription = createEntityDescriptionCreator(({ getIn
|
|
|
205
209
|
/**
|
|
206
210
|
* Get a JSON representation of the rules text for a ritual.
|
|
207
211
|
*/
|
|
208
|
-
export const getRitualEntityDescription = createEntityDescriptionCreator(({ getInstanceById, idMap }, locale, { content: entry }) => {
|
|
212
|
+
export const getRitualEntityDescription = createEntityDescriptionCreator(({ getInstanceById, getChildInstancesForInstanceId, idMap }, locale, { content: entry, entity, id }) => {
|
|
209
213
|
const { translate, translateMap, compare: localeCompare } = locale;
|
|
210
214
|
const translation = translateMap(entry.translations);
|
|
211
215
|
if (translation === undefined) {
|
|
@@ -215,7 +219,9 @@ export const getRitualEntityDescription = createEntityDescriptionCreator(({ getI
|
|
|
215
219
|
translate,
|
|
216
220
|
translateMap,
|
|
217
221
|
getInstanceById,
|
|
222
|
+
getChildInstancesForInstanceId,
|
|
218
223
|
localeJoin: locale.join,
|
|
224
|
+
localeCompare: locale.compare,
|
|
219
225
|
energyUnit: "ArcaneEnergy",
|
|
220
226
|
responsiveTextSize: ResponsiveTextSize.Full,
|
|
221
227
|
nonModifiableSuffix: (param) => {
|
|
@@ -251,6 +257,7 @@ export const getRitualEntityDescription = createEntityDescriptionCreator(({ getI
|
|
|
251
257
|
renderImprovementCost(entry.improvement_cost).run(env),
|
|
252
258
|
],
|
|
253
259
|
},
|
|
260
|
+
renderEnhancements(Case(entity, id), entry.improvement_cost).run(env),
|
|
254
261
|
],
|
|
255
262
|
errata: translation.errata,
|
|
256
263
|
references: entry.src,
|