@optolith/entity-descriptions 0.13.2 → 0.15.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.
Files changed (74) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/lib/creator.d.ts +4 -11
  3. package/lib/creator.js +58 -2
  4. package/lib/entities/activatable.d.ts +5 -2
  5. package/lib/entities/activatable.js +29 -15
  6. package/lib/entities/alternativeRule.d.ts +1 -1
  7. package/lib/entities/attribute.d.ts +1 -3
  8. package/lib/entities/combatTechnique.d.ts +2 -2
  9. package/lib/entities/condition.d.ts +2 -6
  10. package/lib/entities/culture.d.ts +2 -1
  11. package/lib/entities/culture.js +3 -3
  12. package/lib/entities/curriculum.d.ts +1 -1
  13. package/lib/entities/curriculum.js +1 -1
  14. package/lib/entities/derivedCharacteristic.d.ts +1 -1
  15. package/lib/entities/disease.d.ts +1 -1
  16. package/lib/entities/elixir.d.ts +1 -1
  17. package/lib/entities/elixir.js +1 -1
  18. package/lib/entities/equipment.d.ts +4 -6
  19. package/lib/entities/equipment.js +517 -213
  20. package/lib/entities/equipmentPackage.d.ts +1 -1
  21. package/lib/entities/experienceLevel.d.ts +1 -3
  22. package/lib/entities/focusRule.d.ts +1 -1
  23. package/lib/entities/influence.d.ts +1 -1
  24. package/lib/entities/liturgicalChant.d.ts +3 -3
  25. package/lib/entities/optionalRule.d.ts +1 -3
  26. package/lib/entities/partial/adventurePointsValue.js +8 -7
  27. package/lib/entities/partial/dice.js +2 -2
  28. package/lib/entities/partial/enhancements.js +2 -2
  29. package/lib/entities/partial/herbary.js +1 -1
  30. package/lib/entities/partial/prerequisites/single/personalityTrait.js +1 -1
  31. package/lib/entities/partial/prerequisites/single/ratedSum.js +1 -1
  32. package/lib/entities/partial/profession/options/combatTechniquesForAdventurePoints.d.ts +16 -0
  33. package/lib/entities/partial/profession/options/combatTechniquesForAdventurePoints.js +43 -0
  34. package/lib/entities/partial/profession/options/numberOfSpellworksTotalingAdventurePoints.d.ts +16 -0
  35. package/lib/entities/partial/profession/options/numberOfSpellworksTotalingAdventurePoints.js +39 -0
  36. package/lib/entities/partial/profession/packages.d.ts +67 -0
  37. package/lib/entities/partial/profession/packages.js +84 -0
  38. package/lib/entities/partial/profession/variants.d.ts +21 -0
  39. package/lib/entities/partial/profession/variants.js +31 -0
  40. package/lib/entities/partial/rated/activatable/cost.js +11 -9
  41. package/lib/entities/partial/rated/activatable/effect.js +2 -2
  42. package/lib/entities/partial/reader.d.ts +25 -1
  43. package/lib/entities/partial/reader.js +20 -0
  44. package/lib/entities/partial/units/energy.js +2 -1
  45. package/lib/entities/partial/units/length.js +6 -3
  46. package/lib/entities/partial/units/simple.d.ts +55 -0
  47. package/lib/entities/partial/units/simple.js +56 -0
  48. package/lib/entities/partial/units/timeSpan.js +11 -7
  49. package/lib/entities/partial/unknown.d.ts +4 -0
  50. package/lib/entities/partial/unknown.js +4 -0
  51. package/lib/entities/personalityTrait.d.ts +1 -1
  52. package/lib/entities/poison.d.ts +1 -1
  53. package/lib/entities/poison.js +1 -1
  54. package/lib/entities/profession.d.ts +2 -1
  55. package/lib/entities/profession.js +44 -62
  56. package/lib/entities/race.d.ts +2 -2
  57. package/lib/entities/sexPractice.d.ts +1 -3
  58. package/lib/entities/skill.d.ts +1 -1
  59. package/lib/entities/spell.d.ts +17 -16
  60. package/lib/entities/state.d.ts +1 -3
  61. package/lib/entities/tradeSecret.d.ts +4 -0
  62. package/lib/entities/tradeSecret.js +77 -0
  63. package/lib/env.d.ts +9 -2
  64. package/lib/helpers/locale.d.ts +4 -0
  65. package/lib/index.d.ts +320 -293
  66. package/lib/index.js +9 -1
  67. package/lib/references/index.d.ts +2 -3
  68. package/lib/references/index.js +11 -16
  69. package/lib/references/page.d.ts +4 -2
  70. package/lib/references/page.js +6 -4
  71. package/lib/references/pageRange.d.ts +3 -3
  72. package/lib/references/pageRange.js +6 -4
  73. package/lib/tsconfig.tsbuildinfo +1 -1
  74. package/package.json +2 -2
@@ -1,4 +1,5 @@
1
1
  import { type ActivatableIdentifier, type RatedIdentifier } from "@optolith/database-schema/gen";
2
+ import type { StdEnv } from "../env.js";
2
3
  import type { GetAllChildInstancesForParent, GetInstanceById } from "../helpers/getTypes.js";
3
4
  import { type IdMap } from "../index.js";
4
5
  import type { GetResolvedSelectOptionById } from "./partial/prerequisites/single/activatable.js";
@@ -7,7 +8,7 @@ import type { GetResolvedSelectOptionById } from "./partial/prerequisites/single
7
8
  */
8
9
  export declare const getCantripEntityDescription: import("../creator.js").EntityDescriptionCreator<"Cantrip", {
9
10
  getInstanceById: GetInstanceById<"Publication" | "TargetCategory" | "Property" | "MagicalTradition" | "Curriculum">;
10
- }, import("../index.js").EntityDescription>;
11
+ } & StdEnv<"fd" | "t" | "tm" | "ibi", "Publication">, import("../index.js").EntityDescription<string>>;
11
12
  /**
12
13
  * Get a JSON representation of the rules text for a skill.
13
14
  */
@@ -15,7 +16,7 @@ export declare const getSpellEntityDescription: import("../creator.js").EntityDe
15
16
  getInstanceById: GetInstanceById<"Publication" | "Attribute" | "SkillModificationLevel" | "TargetCategory" | "Property" | "MagicalTradition" | "DerivedCharacteristic" | RatedIdentifier["kind"] | "Enhancement" | "FocusRule">;
16
17
  getChildInstancesForInstanceId: GetAllChildInstancesForParent<"Enhancement">;
17
18
  idMap: IdMap;
18
- }, import("../index.js").EntityDescription>;
19
+ } & StdEnv<"fd" | "t" | "tm" | "ibi", "Publication">, import("../index.js").EntityDescription<string>>;
19
20
  /**
20
21
  * Get a JSON representation of the rules text for a ritual.
21
22
  */
@@ -23,88 +24,88 @@ export declare const getRitualEntityDescription: import("../creator.js").EntityD
23
24
  getInstanceById: GetInstanceById<"Publication" | "Attribute" | "SkillModificationLevel" | "TargetCategory" | "Property" | "MagicalTradition" | "DerivedCharacteristic" | RatedIdentifier["kind"] | "Enhancement" | "FocusRule">;
24
25
  getChildInstancesForInstanceId: GetAllChildInstancesForParent<"Enhancement">;
25
26
  idMap: IdMap;
26
- }, import("../index.js").EntityDescription>;
27
+ } & StdEnv<"fd" | "t" | "tm" | "ibi", "Publication">, import("../index.js").EntityDescription<string>>;
27
28
  /**
28
29
  * Get a JSON representation of the rules text for a curse.
29
30
  */
30
31
  export declare const getCurseEntityDescription: import("../creator.js").EntityDescriptionCreator<"Curse", {
31
32
  getInstanceById: GetInstanceById<"Publication" | "Attribute" | "Property" | "DerivedCharacteristic">;
32
33
  idMap: IdMap;
33
- }, import("../index.js").EntityDescription>;
34
+ } & StdEnv<"fd" | "t" | "tm" | "ibi", "Publication">, import("../index.js").EntityDescription<string>>;
34
35
  /**
35
36
  * Get a JSON representation of the rules text for an Elven magical song.
36
37
  */
37
38
  export declare const getElvenMagicalSongEntityDescription: import("../creator.js").EntityDescriptionCreator<"ElvenMagicalSong", {
38
39
  getInstanceById: GetInstanceById<"Publication" | "Attribute" | "Property" | "DerivedCharacteristic" | "Skill">;
39
40
  idMap: IdMap;
40
- }, import("../index.js").EntityDescription>;
41
+ } & StdEnv<"fd" | "t" | "tm" | "ibi", "Publication">, import("../index.js").EntityDescription<string>>;
41
42
  /**
42
43
  * Get a JSON representation of the rules text for a domination ritual.
43
44
  */
44
45
  export declare const getDominationRitualEntityDescription: import("../creator.js").EntityDescriptionCreator<"DominationRitual", {
45
46
  getInstanceById: GetInstanceById<"Publication" | "Attribute" | "Property" | "DerivedCharacteristic" | "SkillModificationLevel">;
46
47
  idMap: IdMap;
47
- }, import("../index.js").EntityDescription>;
48
+ } & StdEnv<"fd" | "t" | "tm" | "ibi", "Publication">, import("../index.js").EntityDescription<string>>;
48
49
  /**
49
50
  * Get a JSON representation of the rules text for a magical dance.
50
51
  */
51
52
  export declare const getMagicalDanceEntityDescription: import("../creator.js").EntityDescriptionCreator<"MagicalDance", {
52
53
  getInstanceById: GetInstanceById<"Publication" | "Attribute" | "Property" | "DerivedCharacteristic" | "ArcaneBardTradition" | "ArcaneDancerTradition">;
53
- }, import("../index.js").EntityDescription>;
54
+ } & StdEnv<"fd" | "t" | "tm" | "ibi", "Publication">, import("../index.js").EntityDescription<string>>;
54
55
  /**
55
56
  * Get a JSON representation of the rules text for a magical melody.
56
57
  */
57
58
  export declare const getMagicalMelodyEntityDescription: import("../creator.js").EntityDescriptionCreator<"MagicalMelody", {
58
59
  getInstanceById: GetInstanceById<"Publication" | "Attribute" | "Property" | "DerivedCharacteristic" | "Skill" | "ArcaneBardTradition" | "ArcaneDancerTradition">;
59
- }, import("../index.js").EntityDescription>;
60
+ } & StdEnv<"fd" | "t" | "tm" | "ibi", "Publication">, import("../index.js").EntityDescription<string>>;
60
61
  /**
61
62
  * Get a JSON representation of the rules text for a familiar’s trick.
62
63
  */
63
64
  export declare const getFamiliarsTrickEntityDescription: import("../creator.js").EntityDescriptionCreator<"FamiliarsTrick", {
64
65
  getInstanceById: GetInstanceById<"Publication" | "Attribute" | "Property" | "DerivedCharacteristic" | "AnimalType">;
65
- }, import("../index.js").EntityDescription>;
66
+ } & StdEnv<"fd" | "t" | "tm" | "ibi", "Publication">, import("../index.js").EntityDescription<string>>;
66
67
  /**
67
68
  * Get a JSON representation of the rules text for a animist power.
68
69
  */
69
70
  export declare const getAnimistPowerEntityDescription: import("../creator.js").EntityDescriptionCreator<"AnimistPower", {
70
71
  getInstanceById: GetInstanceById<"Publication" | "Attribute" | "SkillModificationLevel" | "TargetCategory" | "Property" | "MagicalTradition" | "DerivedCharacteristic" | "AnimistPower" | "Tribe">;
71
72
  idMap: IdMap;
72
- }, import("../index.js").EntityDescription>;
73
+ } & StdEnv<"fd" | "t" | "tm" | "ibi", "Publication">, import("../index.js").EntityDescription<string>>;
73
74
  /**
74
75
  * Get a JSON representation of the rules text for a Goede ritual.
75
76
  */
76
77
  export declare const getGeodeRitualEntityDescription: import("../creator.js").EntityDescriptionCreator<"GeodeRitual", {
77
78
  getInstanceById: GetInstanceById<"Publication" | "Attribute" | "SkillModificationLevel" | "TargetCategory" | "Property" | "MagicalTradition" | "DerivedCharacteristic" | "Influence" | ActivatableIdentifier["kind"] | "Aspect">;
78
79
  getResolvedSelectOptionById: GetResolvedSelectOptionById;
79
- }, import("../index.js").EntityDescription>;
80
+ } & StdEnv<"fd" | "t" | "tm" | "ibi", "Publication">, import("../index.js").EntityDescription<string>>;
80
81
  /**
81
82
  * Get a JSON representation of the rules text for a jester trick.
82
83
  */
83
84
  export declare const getJesterTrickEntityDescription: import("../creator.js").EntityDescriptionCreator<"JesterTrick", {
84
85
  getInstanceById: GetInstanceById<"Publication" | "Attribute" | "SkillModificationLevel" | "TargetCategory" | "Property" | "MagicalTradition" | "DerivedCharacteristic">;
85
86
  idMap: IdMap;
86
- }, import("../index.js").EntityDescription>;
87
+ } & StdEnv<"fd" | "t" | "tm" | "ibi", "Publication">, import("../index.js").EntityDescription<string>>;
87
88
  /**
88
89
  * Get a JSON representation of the rules text for a goblin ritual.
89
90
  */
90
91
  export declare const getGoblinRitualEntityDescription: import("../creator.js").EntityDescriptionCreator<"GoblinRitual", {
91
92
  getInstanceById: GetInstanceById<"Publication" | "Attribute" | "SkillModificationLevel" | "TargetCategory" | "Property" | "MagicalTradition" | "DerivedCharacteristic">;
92
93
  idMap: IdMap;
93
- }, import("../index.js").EntityDescription>;
94
+ } & StdEnv<"fd" | "t" | "tm" | "ibi", "Publication">, import("../index.js").EntityDescription<string>>;
94
95
  /**
95
96
  * Get a JSON representation of the rules text for a Zibilja ritual.
96
97
  */
97
98
  export declare const getZibiljaRitualEntityDescription: import("../creator.js").EntityDescriptionCreator<"ZibiljaRitual", {
98
99
  getInstanceById: GetInstanceById<"Publication" | "Attribute" | "SkillModificationLevel" | "TargetCategory" | "Property" | "MagicalTradition" | "DerivedCharacteristic">;
99
100
  idMap: IdMap;
100
- }, import("../index.js").EntityDescription>;
101
+ } & StdEnv<"fd" | "t" | "tm" | "ibi", "Publication">, import("../index.js").EntityDescription<string>>;
101
102
  /**
102
103
  * Get a JSON representation of the rules text for a Bannzeichen.
103
104
  */
104
105
  export declare const getBannzeichenEntityDescription: import("../creator.js").EntityDescriptionCreator<"Bannzeichen", {
105
106
  getInstanceById: GetInstanceById<"Publication" | "Attribute" | "Property" | "DerivedCharacteristic">;
106
107
  getChildInstancesForInstanceId: GetAllChildInstancesForParent<"BannzeichenOption">;
107
- }, import("../index.js").EntityDescription>;
108
+ } & StdEnv<"fd" | "t" | "tm" | "ibi", "Publication">, import("../index.js").EntityDescription<string>>;
108
109
  /**
109
110
  * Get a JSON representation of the rules text for a magical rune.
110
111
  */
@@ -112,4 +113,4 @@ export declare const getMagicalRuneEntityDescription: import("../creator.js").En
112
113
  getInstanceById: GetInstanceById<"Publication" | "Attribute" | "Property" | "DerivedCharacteristic" | "Skill">;
113
114
  getChildInstancesForInstanceId: GetAllChildInstancesForParent<"MagicalRuneOption">;
114
115
  idMap: IdMap;
115
- }, import("../index.js").EntityDescription>;
116
+ } & StdEnv<"fd" | "t" | "tm" | "ibi", "Publication">, import("../index.js").EntityDescription<string>>;
@@ -1,6 +1,4 @@
1
1
  /**
2
2
  * Get a JSON representation of the rules text for a state.
3
3
  */
4
- export declare const getStateEntityDescription: import("../creator.js").EntityDescriptionCreator<"State", {
5
- getInstanceById: import("../helpers/getTypes.js").GetInstanceById<"Publication">;
6
- }, import("../index.js").EntityDescription>;
4
+ export declare const getStateEntityDescription: import("../creator.js").EntityDescriptionCreator<"State", import("@elyukai/utils/nullable").AnyNonNullish & import("../env.js").StdEnv<"fd" | "t" | "tm" | "ibi", "Publication">, import("../index.js").EntityDescription<string>>;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Get a JSON representation of the rules text for a state.
3
+ */
4
+ export declare const getTradeSecretEntityDescription: import("../creator.js").EntityDescriptionCreator<"TradeSecret", import("@elyukai/utils/nullable").AnyNonNullish & import("../env.js").StdEnv<"fd" | "t" | "tm" | "ibi", "Publication">, import("../index.js").EntityDescription<string>>;
@@ -0,0 +1,77 @@
1
+ import { Reader } from "@elyukai/utils/reader";
2
+ import { assertExhaustive } from "@elyukai/utils/typeSafety";
3
+ import { createEntityDescriptionCreator } from "../creator.js";
4
+ import { renderDefaultValueMapLabel, renderValueMap } from "./partial/map.js";
5
+ import { evaluateMathOperation } from "./partial/mathOperation.js";
6
+ import { printPlainGeneralPrerequisites } from "./partial/prerequisites/index.js";
7
+ import { translateR } from "./partial/reader.js";
8
+ import { formatAdventurePoints, formatArbitraryAdventurePoints } from "./partial/units/simple.js";
9
+ const renderAdventurePointsValue = (value) => {
10
+ switch (value.kind) {
11
+ case "Fixed": {
12
+ return formatAdventurePoints(value.Fixed);
13
+ }
14
+ case "DependingOnActiveInstances":
15
+ switch (value.DependingOnActiveInstances.kind) {
16
+ case "Threshold":
17
+ return formatAdventurePoints(value.DependingOnActiveInstances.Threshold.normal);
18
+ case "Expression": {
19
+ const { expression, customLabels } = value.DependingOnActiveInstances.Expression;
20
+ const values = Array.from({
21
+ length: customLabels === undefined ? 3 : customLabels.options.length,
22
+ }, (_, index) => evaluateMathOperation(expression, exprValue => {
23
+ switch (exprValue.kind) {
24
+ case "Constant":
25
+ return exprValue.Constant;
26
+ case "Active":
27
+ return index;
28
+ default:
29
+ return assertExhaustive(exprValue);
30
+ }
31
+ }));
32
+ if (customLabels !== undefined) {
33
+ return renderValueMap(customLabels,
34
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- customLabels.options is guaranteed to have at least as many entries as values
35
+ (_, index) => Reader.of(values[index]), renderDefaultValueMapLabel, formatArbitraryAdventurePoints);
36
+ }
37
+ const labels = Array.from({ length: 3 }, (_, index) => `${(index + 1).toFixed()}.`).join("/");
38
+ return translateR("{$values}/and so on Adventure Points for the {$labels}/and so on purchase", {
39
+ values: values.join("/"),
40
+ labels,
41
+ });
42
+ }
43
+ default:
44
+ return assertExhaustive(value.DependingOnActiveInstances);
45
+ }
46
+ default:
47
+ return assertExhaustive(value);
48
+ }
49
+ };
50
+ /**
51
+ * Get a JSON representation of the rules text for a state.
52
+ */
53
+ export const getTradeSecretEntityDescription = createEntityDescriptionCreator((_, env, { content: entry }) => {
54
+ const translation = env.translateMap(entry.translations);
55
+ if (translation === undefined) {
56
+ return undefined;
57
+ }
58
+ return {
59
+ type: "tabular",
60
+ title: translation.name,
61
+ className: "trade-secret",
62
+ labels: {
63
+ name: translateR("Name"),
64
+ prerequisites: translateR("Prerequisites"),
65
+ apValue: translateR("AP Value"),
66
+ },
67
+ values: {
68
+ name: Reader.of(translation.name),
69
+ prerequisites: entry.prerequisites === undefined
70
+ ? translateR("none")
71
+ : printPlainGeneralPrerequisites(entry.prerequisites),
72
+ apValue: renderAdventurePointsValue(entry.ap_value),
73
+ },
74
+ errata: translation.errata,
75
+ references: entry.src,
76
+ };
77
+ });
package/lib/env.d.ts CHANGED
@@ -1,14 +1,15 @@
1
1
  import type { AnyNonNullish } from "@elyukai/utils/nullable";
2
2
  import type { Reader } from "@elyukai/utils/reader";
3
- import type { ChildEntityMap, EntityMap } from "@optolith/database-schema/gen";
3
+ import type { ChildEntityMap, EntityMap, LocaleMeasurementAdjustments } from "@optolith/database-schema/gen";
4
4
  import type { GetResolvedSelectOptionById } from "./entities/partial/prerequisites/single/activatable.js";
5
5
  import type { ModifiableParameter } from "./entities/partial/rated/activatable/nonModifiableSuffix.js";
6
6
  import type { Speed } from "./entities/partial/rated/activatable/speed.js";
7
7
  import type { ResponsiveTextSize } from "./entities/partial/responsiveText.js";
8
8
  import { type EnergyUnit } from "./entities/partial/units/energy.js";
9
9
  import type { GetAllChildInstancesForParent, GetAllInstances, GetInstanceById } from "./helpers/getTypes.js";
10
- import type { FormatNumber, LocaleCompare, LocaleJoin } from "./helpers/locale.js";
10
+ import type { FormatDate, FormatNumber, LocaleCompare, LocaleJoin } from "./helpers/locale.js";
11
11
  import type { Format, Translate, TranslateMap, TranslationKeysWithoutParams } from "./helpers/translate.js";
12
+ import type { IdMap } from "./index.js";
12
13
  import type { PublicationOptions } from "./references/publicationOptions.js";
13
14
  /**
14
15
  * The standard set of environment properties for readers in this project.
@@ -16,6 +17,7 @@ import type { PublicationOptions } from "./references/publicationOptions.js";
16
17
  export type EnvMap<E extends keyof EntityMap = never, AE extends keyof EntityMap = never, CE extends keyof ChildEntityMap = never> = {
17
18
  format: Format;
18
19
  formatNumber: FormatNumber;
20
+ formatDate: FormatDate;
19
21
  translate: Translate;
20
22
  translateMap: TranslateMap;
21
23
  localeJoin: LocaleJoin;
@@ -30,6 +32,8 @@ export type EnvMap<E extends keyof EntityMap = never, AE extends keyof EntityMap
30
32
  getResolvedSelectOptionById: GetResolvedSelectOptionById;
31
33
  publicationOptions: PublicationOptions;
32
34
  displayedInProfession: boolean;
35
+ measurementAdjustments: Required<LocaleMeasurementAdjustments>;
36
+ idMap: IdMap;
33
37
  };
34
38
  /**
35
39
  * Shortcuts for selecting keys of the shared environment map type.
@@ -37,6 +41,7 @@ export type EnvMap<E extends keyof EntityMap = never, AE extends keyof EntityMap
37
41
  export type EnvMapAbbr = {
38
42
  f: "format";
39
43
  fn: "formatNumber";
44
+ fd: "formatDate";
40
45
  t: "translate";
41
46
  tm: "translateMap";
42
47
  lj: "localeJoin";
@@ -51,6 +56,8 @@ export type EnvMapAbbr = {
51
56
  rso: "getResolvedSelectOptionById";
52
57
  po: "publicationOptions";
53
58
  dip: "displayedInProfession";
59
+ ma: "measurementAdjustments";
60
+ idm: "idMap";
54
61
  };
55
62
  /**
56
63
  * The standard set of environment properties for readers in this project.
@@ -31,3 +31,7 @@ export type LocaleJoin = (list: string[], type: LocaleJoinType) => string;
31
31
  * A function that formats a number according to the locale’s rules.
32
32
  */
33
33
  export type FormatNumber = (value: number) => string;
34
+ /**
35
+ * A function that formats a date according to the locale’s rules.
36
+ */
37
+ export type FormatDate = (date: Date) => string;