@optolith/database-schema 0.77.0 → 0.78.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 (48) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/gen/types.d.ts +299 -3
  3. package/lib/cache/activatableSelectOptions.d.ts +2 -2
  4. package/lib/cache/activatableSelectOptions.js +2 -58
  5. package/lib/main.js +2 -0
  6. package/lib/types/Attribute.js +1 -3
  7. package/lib/types/Culture.d.ts +1 -0
  8. package/lib/types/Culture.js +5 -1
  9. package/lib/types/DerivedCharacteristic.js +1 -3
  10. package/lib/types/Locale.d.ts +10 -0
  11. package/lib/types/Locale.js +11 -0
  12. package/lib/types/Profession.d.ts +178 -154
  13. package/lib/types/Profession.js +40 -1
  14. package/lib/types/Race.d.ts +1 -0
  15. package/lib/types/Race.js +10 -0
  16. package/lib/types/SkillGroup.js +1 -3
  17. package/lib/types/SocialStatus.js +1 -0
  18. package/lib/types/Talisman.js +1 -1
  19. package/lib/types/_ActivatableSelectOptions.d.ts +10 -0
  20. package/lib/types/_ActivatableSelectOptions.js +40 -0
  21. package/lib/types/_Identifier.d.ts +2 -0
  22. package/lib/types/_Identifier.js +4 -0
  23. package/lib/types/equipment/item/BandageOrRemedy.js +1 -1
  24. package/lib/types/equipment/item/CeremonialItem.js +1 -1
  25. package/lib/types/equipment/item/Clothes.js +1 -1
  26. package/lib/types/equipment/item/Container.js +1 -1
  27. package/lib/types/equipment/item/EquipmentCategory.d.ts +121 -0
  28. package/lib/types/equipment/item/EquipmentCategory.js +131 -0
  29. package/lib/types/equipment/item/EquipmentOfBlessedOnes.js +1 -1
  30. package/lib/types/equipment/item/IlluminationLightSource.js +1 -1
  31. package/lib/types/equipment/item/IlluminationRefillOrSupply.js +1 -1
  32. package/lib/types/equipment/item/Item.d.ts +287 -0
  33. package/lib/types/equipment/item/Item.js +167 -0
  34. package/lib/types/equipment/item/Liebesspielzeug.js +1 -1
  35. package/lib/types/equipment/item/LuxuryGood.js +1 -1
  36. package/lib/types/equipment/item/MagicalArtifact.js +1 -1
  37. package/lib/types/equipment/item/MusicalInstrument.js +1 -1
  38. package/lib/types/equipment/item/TravelGearOrTool.js +1 -1
  39. package/lib/types/equipment/item/Weapon.js +1 -1
  40. package/lib/types/equipment/item/WeaponAccessory.js +1 -1
  41. package/lib/types/equipment/item/_Item.js +1 -1
  42. package/lib/types/equipment/item/_Weapon.d.ts +2 -2
  43. package/lib/types/equipment/item/_Weapon.js +7 -4
  44. package/lib/types/equipment/item/sub/Reach.js +1 -3
  45. package/lib/types/index.d.ts +2 -0
  46. package/lib/types/index.js +2 -0
  47. package/lib/types/prerequisites/single/ActivatablePrerequisite.js +2 -0
  48. package/package.json +9 -9
@@ -1,4 +1,6 @@
1
1
  import * as DB from "tsondb/schema/dsl";
2
+ import { Case, type GetAllChildInstanceContainersForParent, type GetInstanceById } from "tsondb/schema/gen";
3
+ import type { ActivatableIdentifier, ProfessionSpecialAbilityOption, RequirableSelectOptionIdentifier } from "../../gen/types.js";
2
4
  export declare const select_options: DB.MemberDecl<DB.IncludeIdentifier<[], DB.TypeAlias<"SelectOptions", DB.Object<{
3
5
  derived: DB.MemberDecl<DB.IncludeIdentifier<[], DB.Enum<"SelectOptionCategory", {
4
6
  Blessings: DB.EnumCase<null>;
@@ -1223,3 +1225,11 @@ export declare const explicit_select_options: DB.MemberDecl<DB.ChildEntities<DB.
1223
1225
  }>, []>>>, []>>, false>;
1224
1226
  }>, true>;
1225
1227
  }, "parent">>, true>;
1228
+ /**
1229
+ * Stub for once option rules are formalized in the database schema.
1230
+ */
1231
+ export declare const verifyOptionsForActivatableEntry: (value: {
1232
+ id: ActivatableIdentifier | Case<"Enhancement", string>;
1233
+ level?: number;
1234
+ options?: (RequirableSelectOptionIdentifier | ProfessionSpecialAbilityOption)[];
1235
+ }, getInstanceById: GetInstanceById, getAllChildInstancesForParent: GetAllChildInstanceContainersForParent) => string[];
@@ -1,4 +1,6 @@
1
+ import { isEmpty, isNotEmpty } from "@elyukai/utils/array/nonEmpty";
1
2
  import * as DB from "tsondb/schema/dsl";
3
+ import { Case, fromUniformCase, } from "tsondb/schema/gen";
2
4
  import { NestedTranslationMap } from "./Locale.js";
3
5
  import { SelectOptionCategory } from "./_ActivatableSelectOptionCategory.js";
4
6
  import { NewSkillApplication, SkillUse } from "./_ActivatableSkillApplicationsAndUses.js";
@@ -216,3 +218,41 @@ Note that this is only a full definition of options for simple logic that can be
216
218
  // ]
217
219
  // }
218
220
  // },
221
+ /**
222
+ * Stub for once option rules are formalized in the database schema.
223
+ */
224
+ export const verifyOptionsForActivatableEntry = (value, getInstanceById, getAllChildInstancesForParent) => {
225
+ if (value.id.kind === "Enhancement") {
226
+ return [];
227
+ }
228
+ const referencedInstance = getInstanceById(value.id);
229
+ if (!referencedInstance) {
230
+ return [
231
+ `Referenced instance of entity ${value.id.kind} with id ${fromUniformCase(value.id)} not found.`,
232
+ ];
233
+ }
234
+ const generalSelectOptions = getAllChildInstancesForParent("GeneralSelectOption", value.id);
235
+ const errorMessages = [];
236
+ if (!("levels" in referencedInstance && typeof referencedInstance.levels === "number") &&
237
+ value.level !== undefined) {
238
+ errorMessages.push(`The referenced instance of entity ${value.id.kind} with id ${fromUniformCase(value.id)} does not have levels, but a level was specified in the prerequisite.`);
239
+ }
240
+ if ((("select_options" in referencedInstance &&
241
+ referencedInstance.select_options?.derived !== undefined) ||
242
+ isNotEmpty(generalSelectOptions)) &&
243
+ (value.options === undefined || isEmpty(value.options))) {
244
+ errorMessages.push(`The referenced instance of entity ${value.id.kind} with id ${fromUniformCase(value.id)} has select options, but no options were specified in the prerequisite.`);
245
+ }
246
+ for (const option of value.options ?? []) {
247
+ if (option.kind === "General") {
248
+ const referencedOption = getInstanceById(Case("GeneralSelectOption", option.General));
249
+ if (!referencedOption) {
250
+ errorMessages.push(`Referenced select option of entity GeneralSelectOption with id ${fromUniformCase(option)} not found.`);
251
+ }
252
+ if (referencedOption?.parent !== value.id) {
253
+ errorMessages.push(`Referenced select option of entity GeneralSelectOption with id ${fromUniformCase(option)} does not belong to the instance of entity ${value.id.kind} with id ${fromUniformCase(value.id)}.`);
254
+ }
255
+ }
256
+ }
257
+ return [];
258
+ };
@@ -61,6 +61,7 @@ export declare const ElementIdentifier: () => R;
61
61
  export declare const ElixirIdentifier: () => R;
62
62
  export declare const ElvenMagicalSongIdentifier: () => R;
63
63
  export declare const EnhancementIdentifier: () => R;
64
+ export declare const EquipmentCategoryIdentifier: () => R;
64
65
  export declare const EquipmentOfBlessedOnesIdentifier: () => R;
65
66
  export declare const ExperienceLevelIdentifier: () => R;
66
67
  export declare const EyeColorIdentifier: () => R;
@@ -85,6 +86,7 @@ export declare const IlluminationLightSourceIdentifier: () => R;
85
86
  export declare const IlluminationRefillOrSupplyIdentifier: () => R;
86
87
  export declare const InfluenceIdentifier: () => R;
87
88
  export declare const InstrumentEnchantmentIdentifier: () => R;
89
+ export declare const ItemIdentifier: () => R;
88
90
  export declare const JesterTrickIdentifier: () => R;
89
91
  export declare const JewelryIdentifier: () => R;
90
92
  export declare const KarmaSpecialAbilityIdentifier: () => R;
@@ -30,12 +30,14 @@ import { Clothes } from "./equipment/item/Clothes.js";
30
30
  import { ClothingPackage } from "./equipment/item/ClothingPackage.js";
31
31
  import { Container } from "./equipment/item/Container.js";
32
32
  import { Elixir } from "./equipment/item/Elixir.js";
33
+ import { EquipmentCategory } from "./equipment/item/EquipmentCategory.js";
33
34
  import { EquipmentOfBlessedOnes } from "./equipment/item/EquipmentOfBlessedOnes.js";
34
35
  import { GemOrPreciousStone } from "./equipment/item/GemOrPreciousStone.js";
35
36
  import { HerbalAid } from "./equipment/item/HerbalAid.js";
36
37
  import { HerbalPreservation } from "./equipment/item/HerbalPreservation.js";
37
38
  import { IlluminationLightSource } from "./equipment/item/IlluminationLightSource.js";
38
39
  import { IlluminationRefillOrSupply } from "./equipment/item/IlluminationRefillOrSupply.js";
40
+ import { Item } from "./equipment/item/Item.js";
39
41
  import { Jewelry } from "./equipment/item/Jewelry.js";
40
42
  import { Laboratory } from "./equipment/item/Laboratory.js";
41
43
  import { Liebesspielzeug } from "./equipment/item/Liebesspielzeug.js";
@@ -225,6 +227,7 @@ export const ElementIdentifier = () => R(Element);
225
227
  export const ElixirIdentifier = () => R(Elixir);
226
228
  export const ElvenMagicalSongIdentifier = () => R(ElvenMagicalSong);
227
229
  export const EnhancementIdentifier = () => R(Enhancement);
230
+ export const EquipmentCategoryIdentifier = () => R(EquipmentCategory);
228
231
  export const EquipmentOfBlessedOnesIdentifier = () => R(EquipmentOfBlessedOnes);
229
232
  export const ExperienceLevelIdentifier = () => R(ExperienceLevel);
230
233
  export const EyeColorIdentifier = () => R(EyeColor);
@@ -249,6 +252,7 @@ export const IlluminationLightSourceIdentifier = () => R(IlluminationLightSource
249
252
  export const IlluminationRefillOrSupplyIdentifier = () => R(IlluminationRefillOrSupply);
250
253
  export const InfluenceIdentifier = () => R(Influence);
251
254
  export const InstrumentEnchantmentIdentifier = () => R(InstrumentEnchantment);
255
+ export const ItemIdentifier = () => R(Item);
252
256
  export const JesterTrickIdentifier = () => R(JesterTrick);
253
257
  export const JewelryIdentifier = () => R(Jewelry);
254
258
  export const KarmaSpecialAbilityIdentifier = () => R(KarmaSpecialAbility);
@@ -41,7 +41,7 @@ export const BandageOrRemedy = DB.Entity(import.meta.url, {
41
41
  return checkWeaponCombatTechniqueIntegrity({
42
42
  ...rest,
43
43
  instanceContent: instanceContent.combat_use.Weapon,
44
- }, { secondary: true });
44
+ });
45
45
  }
46
46
  return [];
47
47
  },
@@ -46,7 +46,7 @@ export const CeremonialItem = DB.Entity(import.meta.url, {
46
46
  return checkWeaponCombatTechniqueIntegrity({
47
47
  ...rest,
48
48
  instanceContent: instanceContent.combat_use.Weapon,
49
- }, { secondary: true });
49
+ });
50
50
  }
51
51
  return [];
52
52
  },
@@ -41,7 +41,7 @@ export const Clothes = DB.Entity(import.meta.url, {
41
41
  return checkWeaponCombatTechniqueIntegrity({
42
42
  ...rest,
43
43
  instanceContent: instanceContent.combat_use.Weapon,
44
- }, { secondary: true });
44
+ });
45
45
  }
46
46
  return [];
47
47
  },
@@ -41,7 +41,7 @@ export const Container = DB.Entity(import.meta.url, {
41
41
  return checkWeaponCombatTechniqueIntegrity({
42
42
  ...rest,
43
43
  instanceContent: instanceContent.combat_use.Weapon,
44
- }, { secondary: true });
44
+ });
45
45
  }
46
46
  return [];
47
47
  },
@@ -0,0 +1,121 @@
1
+ import type { NonEmptyArray } from "@elyukai/utils/array/nonEmpty";
2
+ import * as DB from "tsondb/schema/dsl";
3
+ import type { Case } from "tsondb/schema/gen";
4
+ import type { DefaultEquipmentCategoryTypeRules, EquipmentCategory as EquipmentCategoryType, ValueRule } from "../../../../gen/types.js";
5
+ declare const ValueRule: DB.Enum<"ValueRule", {
6
+ Required: DB.EnumCase<null>;
7
+ Optional: DB.EnumCase<null>;
8
+ Prohibited: DB.EnumCase<null>;
9
+ }, []>;
10
+ declare const EquipmentCategoryType: DB.Enum<"EquipmentCategoryType", {
11
+ Default: DB.EnumCase<DB.IncludeIdentifier<[], DB.TypeAlias<"DefaultEquipmentCategoryTypeRules", DB.Object<{
12
+ combatValues: DB.MemberDecl<DB.IncludeIdentifier<[], DB.TypeAlias<"AllowedCombatValues", DB.Object<{
13
+ isWeaponAllowed: DB.MemberDecl<DB.Boolean, true>;
14
+ isArmorAllowed: DB.MemberDecl<DB.Boolean, true>;
15
+ }>, []>>, true>;
16
+ restrictedTo: DB.MemberDecl<DB.IncludeIdentifier<[], DB.Enum<"ValueRule", {
17
+ Required: DB.EnumCase<null>;
18
+ Optional: DB.EnumCase<null>;
19
+ Prohibited: DB.EnumCase<null>;
20
+ }, []>>, true>;
21
+ structurePoints: DB.MemberDecl<DB.IncludeIdentifier<[], DB.Enum<"ValueRule", {
22
+ Required: DB.EnumCase<null>;
23
+ Optional: DB.EnumCase<null>;
24
+ Prohibited: DB.EnumCase<null>;
25
+ }, []>>, true>;
26
+ weight: DB.MemberDecl<DB.IncludeIdentifier<[], DB.Enum<"ValueRule", {
27
+ Required: DB.EnumCase<null>;
28
+ Optional: DB.EnumCase<null>;
29
+ Prohibited: DB.EnumCase<null>;
30
+ }, []>>, true>;
31
+ complexity: DB.MemberDecl<DB.IncludeIdentifier<[], DB.Enum<"ValueRule", {
32
+ Required: DB.EnumCase<null>;
33
+ Optional: DB.EnumCase<null>;
34
+ Prohibited: DB.EnumCase<null>;
35
+ }, []>>, true>;
36
+ }>, []>>>;
37
+ Special: DB.EnumCase<DB.IncludeIdentifier<[], DB.Enum<"SpecialEquipmentCategoryEntity", {
38
+ AnimalCare: DB.EnumCase<null>;
39
+ Book: DB.EnumCase<null>;
40
+ Elixir: DB.EnumCase<null>;
41
+ GemOrPreciousStone: DB.EnumCase<null>;
42
+ Newspaper: DB.EnumCase<null>;
43
+ Poison: DB.EnumCase<null>;
44
+ WorkingSupernaturalCreature: DB.EnumCase<null>;
45
+ }, []>>>;
46
+ }, []>;
47
+ declare const DefaultEquipmentCategoryTypeRules: DB.TypeAlias<"DefaultEquipmentCategoryTypeRules", DB.Object<{
48
+ combatValues: DB.MemberDecl<DB.IncludeIdentifier<[], DB.TypeAlias<"AllowedCombatValues", DB.Object<{
49
+ isWeaponAllowed: DB.MemberDecl<DB.Boolean, true>;
50
+ isArmorAllowed: DB.MemberDecl<DB.Boolean, true>;
51
+ }>, []>>, true>;
52
+ restrictedTo: DB.MemberDecl<DB.IncludeIdentifier<[], DB.Enum<"ValueRule", {
53
+ Required: DB.EnumCase<null>;
54
+ Optional: DB.EnumCase<null>;
55
+ Prohibited: DB.EnumCase<null>;
56
+ }, []>>, true>;
57
+ structurePoints: DB.MemberDecl<DB.IncludeIdentifier<[], DB.Enum<"ValueRule", {
58
+ Required: DB.EnumCase<null>;
59
+ Optional: DB.EnumCase<null>;
60
+ Prohibited: DB.EnumCase<null>;
61
+ }, []>>, true>;
62
+ weight: DB.MemberDecl<DB.IncludeIdentifier<[], DB.Enum<"ValueRule", {
63
+ Required: DB.EnumCase<null>;
64
+ Optional: DB.EnumCase<null>;
65
+ Prohibited: DB.EnumCase<null>;
66
+ }, []>>, true>;
67
+ complexity: DB.MemberDecl<DB.IncludeIdentifier<[], DB.Enum<"ValueRule", {
68
+ Required: DB.EnumCase<null>;
69
+ Optional: DB.EnumCase<null>;
70
+ Prohibited: DB.EnumCase<null>;
71
+ }, []>>, true>;
72
+ }>, []>;
73
+ export declare const EquipmentCategory: DB.Entity<"EquipmentCategory", {
74
+ position: DB.MemberDecl<DB.Integer, true>;
75
+ type: DB.MemberDecl<DB.IncludeIdentifier<[], DB.Enum<"EquipmentCategoryType", {
76
+ Default: DB.EnumCase<DB.IncludeIdentifier<[], DB.TypeAlias<"DefaultEquipmentCategoryTypeRules", DB.Object<{
77
+ combatValues: DB.MemberDecl<DB.IncludeIdentifier<[], DB.TypeAlias<"AllowedCombatValues", DB.Object<{
78
+ isWeaponAllowed: DB.MemberDecl<DB.Boolean, true>;
79
+ isArmorAllowed: DB.MemberDecl<DB.Boolean, true>;
80
+ }>, []>>, true>;
81
+ restrictedTo: DB.MemberDecl<DB.IncludeIdentifier<[], DB.Enum<"ValueRule", {
82
+ Required: DB.EnumCase<null>;
83
+ Optional: DB.EnumCase<null>;
84
+ Prohibited: DB.EnumCase<null>;
85
+ }, []>>, true>;
86
+ structurePoints: DB.MemberDecl<DB.IncludeIdentifier<[], DB.Enum<"ValueRule", {
87
+ Required: DB.EnumCase<null>;
88
+ Optional: DB.EnumCase<null>;
89
+ Prohibited: DB.EnumCase<null>;
90
+ }, []>>, true>;
91
+ weight: DB.MemberDecl<DB.IncludeIdentifier<[], DB.Enum<"ValueRule", {
92
+ Required: DB.EnumCase<null>;
93
+ Optional: DB.EnumCase<null>;
94
+ Prohibited: DB.EnumCase<null>;
95
+ }, []>>, true>;
96
+ complexity: DB.MemberDecl<DB.IncludeIdentifier<[], DB.Enum<"ValueRule", {
97
+ Required: DB.EnumCase<null>;
98
+ Optional: DB.EnumCase<null>;
99
+ Prohibited: DB.EnumCase<null>;
100
+ }, []>>, true>;
101
+ }>, []>>>;
102
+ Special: DB.EnumCase<DB.IncludeIdentifier<[], DB.Enum<"SpecialEquipmentCategoryEntity", {
103
+ AnimalCare: DB.EnumCase<null>;
104
+ Book: DB.EnumCase<null>;
105
+ Elixir: DB.EnumCase<null>;
106
+ GemOrPreciousStone: DB.EnumCase<null>;
107
+ Newspaper: DB.EnumCase<null>;
108
+ Poison: DB.EnumCase<null>;
109
+ WorkingSupernaturalCreature: DB.EnumCase<null>;
110
+ }, []>>>;
111
+ }, []>>, true>;
112
+ translations: DB.MemberDecl<DB.NestedEntityMap<"EquipmentCategoryTranslation", {
113
+ name: DB.MemberDecl<DB.String, true>;
114
+ }>, true>;
115
+ }, undefined>;
116
+ export declare const isEquipmentCategoryOfDefaultType: (category: EquipmentCategoryType) => category is Omit<EquipmentCategoryType, "type"> & {
117
+ type: Case<"Default", DefaultEquipmentCategoryTypeRules>;
118
+ };
119
+ export declare const mergeValueRules: (categories: NonEmptyArray<ValueRule>) => ValueRule["kind"];
120
+ export declare const mergeAllValueRules: (categories: NonEmptyArray<DefaultEquipmentCategoryTypeRules>) => DefaultEquipmentCategoryTypeRules;
121
+ export {};
@@ -0,0 +1,131 @@
1
+ import * as DB from "tsondb/schema/dsl";
2
+ import { NestedTranslationMap } from "../../Locale.js";
3
+ const ValueRule = DB.Enum(import.meta.url, {
4
+ name: "ValueRule",
5
+ comment: "Defines if an instance MUST/CAN/MUST NOT define a value for this parameter. If multiple rules apply to the same parameter, the order of precedence is Required > Optional > Prohibited.",
6
+ values: () => ({
7
+ Required: DB.EnumCase({
8
+ comment: "The parameter MUST be present in all instances the rule applies to.",
9
+ type: null,
10
+ }),
11
+ Optional: DB.EnumCase({
12
+ comment: "The parameter CAN be present in any instances the rule applies to.",
13
+ type: null,
14
+ }),
15
+ Prohibited: DB.EnumCase({
16
+ comment: "The parameter MUST NOT be present in any instances the rule applies to.",
17
+ type: null,
18
+ }),
19
+ }),
20
+ });
21
+ const AllowedCombatValues = DB.TypeAlias(import.meta.url, {
22
+ name: "AllowedCombatValues",
23
+ comment: "The combat values that are allowed for this category. If any combat value is allowed and used, advantages, disadvantages and known item specifics are also allowed to be defined for the item.",
24
+ type: () => DB.Object({
25
+ isWeaponAllowed: DB.Required({
26
+ comment: "Is the item allowed to be used as a weapon?",
27
+ type: DB.Boolean(),
28
+ }),
29
+ isArmorAllowed: DB.Required({
30
+ comment: "Is the item allowed to be used as an armor?",
31
+ type: DB.Boolean(),
32
+ }),
33
+ }),
34
+ });
35
+ const EquipmentCategoryType = DB.Enum(import.meta.url, {
36
+ name: "EquipmentCategoryType",
37
+ values: () => ({
38
+ Default: DB.EnumCase({
39
+ comment: "Items that can be expressed using the generic Item entity.",
40
+ type: DB.IncludeIdentifier(DefaultEquipmentCategoryTypeRules),
41
+ }),
42
+ Special: DB.EnumCase({
43
+ comment: "Items whose rules and/or values cannot be expressed using the generic Item entity.",
44
+ type: DB.IncludeIdentifier(SpecialEquipmentCategoryEntity),
45
+ }),
46
+ }),
47
+ });
48
+ const DefaultEquipmentCategoryTypeRules = DB.TypeAlias(import.meta.url, {
49
+ name: "DefaultEquipmentCategoryTypeRules",
50
+ type: () => DB.Object({
51
+ combatValues: DB.Required({
52
+ comment: "The combat values that are allowed for this category. If any combat value is allowed and used, advantages, disadvantages and known item specifics are also allowed to be defined for the item.",
53
+ type: DB.IncludeIdentifier(AllowedCombatValues),
54
+ }),
55
+ restrictedTo: DB.Required({
56
+ comment: "Presence of restrictions to certain groups for items in this category.",
57
+ type: DB.IncludeIdentifier(ValueRule),
58
+ }),
59
+ structurePoints: DB.Required({
60
+ comment: "Presence of structure points to certain groups for items in this category.",
61
+ type: DB.IncludeIdentifier(ValueRule),
62
+ }),
63
+ weight: DB.Required({
64
+ comment: "Presence of weight to certain groups for items in this category.",
65
+ type: DB.IncludeIdentifier(ValueRule),
66
+ }),
67
+ complexity: DB.Required({
68
+ comment: "Presence of complexity to certain groups for items in this category.",
69
+ type: DB.IncludeIdentifier(ValueRule),
70
+ }),
71
+ }),
72
+ });
73
+ const SpecialEquipmentCategoryEntity = DB.Enum(import.meta.url, {
74
+ name: "SpecialEquipmentCategoryEntity",
75
+ values: () => ({
76
+ AnimalCare: DB.EnumCase({ type: null }),
77
+ Book: DB.EnumCase({ type: null }),
78
+ Elixir: DB.EnumCase({ type: null }),
79
+ GemOrPreciousStone: DB.EnumCase({ type: null }),
80
+ Newspaper: DB.EnumCase({ type: null }),
81
+ Poison: DB.EnumCase({ type: null }),
82
+ WorkingSupernaturalCreature: DB.EnumCase({ type: null }),
83
+ }),
84
+ });
85
+ export const EquipmentCategory = DB.Entity(import.meta.url, {
86
+ name: "EquipmentCategory",
87
+ namePlural: "EquipmentCategories",
88
+ type: () => DB.Object({
89
+ position: DB.Required({
90
+ comment: "The position of the category in the list. This has to be a unique value.",
91
+ type: DB.Integer({ minimum: 0 }),
92
+ }),
93
+ type: DB.Required({
94
+ comment: "The type of the equipment category.",
95
+ type: DB.IncludeIdentifier(EquipmentCategoryType),
96
+ }),
97
+ translations: NestedTranslationMap(DB.Required, "EquipmentCategory", DB.Object({
98
+ name: DB.Required({
99
+ comment: "The equipment category’s name.",
100
+ type: DB.String({ minLength: 1 }),
101
+ }),
102
+ })),
103
+ }),
104
+ instanceDisplayName: {},
105
+ sortOrder: { keyPath: "position", isIndex: true },
106
+ uniqueConstraints: [
107
+ {
108
+ keyPath: "position",
109
+ },
110
+ {
111
+ entityMapKeyPath: "translations",
112
+ keyPathInEntityMap: "name",
113
+ },
114
+ ],
115
+ });
116
+ export const isEquipmentCategoryOfDefaultType = (category) => category.type.kind === "Default";
117
+ export const mergeValueRules = (categories) => categories.reduce((acc, elem) => acc === "Required" || elem.kind === "Required"
118
+ ? "Required"
119
+ : acc === "Optional" || elem.kind === "Optional"
120
+ ? "Optional"
121
+ : "Prohibited", "Prohibited");
122
+ export const mergeAllValueRules = (categories) => ({
123
+ combatValues: {
124
+ isWeaponAllowed: categories.some(category => category.combatValues.isWeaponAllowed),
125
+ isArmorAllowed: categories.some(category => category.combatValues.isArmorAllowed),
126
+ },
127
+ restrictedTo: { kind: mergeValueRules(categories.map(category => category.restrictedTo)) },
128
+ structurePoints: { kind: mergeValueRules(categories.map(category => category.structurePoints)) },
129
+ weight: { kind: mergeValueRules(categories.map(category => category.weight)) },
130
+ complexity: { kind: mergeValueRules(categories.map(category => category.complexity)) },
131
+ });
@@ -37,7 +37,7 @@ export const EquipmentOfBlessedOnes = DB.Entity(import.meta.url, {
37
37
  return checkWeaponCombatTechniqueIntegrity({
38
38
  ...rest,
39
39
  instanceContent: instanceContent.combat_use.Weapon,
40
- }, { secondary: true });
40
+ });
41
41
  }
42
42
  return [];
43
43
  },
@@ -45,7 +45,7 @@ export const IlluminationLightSource = DB.Entity(import.meta.url, {
45
45
  return checkWeaponCombatTechniqueIntegrity({
46
46
  ...rest,
47
47
  instanceContent: instanceContent.combat_use.Weapon,
48
- }, { secondary: true });
48
+ });
49
49
  }
50
50
  return [];
51
51
  },
@@ -41,7 +41,7 @@ export const IlluminationRefillOrSupply = DB.Entity(import.meta.url, {
41
41
  return checkWeaponCombatTechniqueIntegrity({
42
42
  ...rest,
43
43
  instanceContent: instanceContent.combat_use.Weapon,
44
- }, { secondary: true });
44
+ });
45
45
  }
46
46
  return [];
47
47
  },