coh-content-db 2.0.0-rc.2 → 2.0.0-rc.21

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 (120) hide show
  1. package/.editorconfig +10 -11
  2. package/.github/workflows/build.yml +4 -2
  3. package/.github/workflows/pull-request.yml +1 -1
  4. package/.github/workflows/release.yml +1 -1
  5. package/CHANGELOG.md +47 -0
  6. package/README.md +77 -32
  7. package/dist/coh-content-db.d.ts +755 -290
  8. package/dist/coh-content-db.js +1028 -358
  9. package/dist/coh-content-db.js.map +1 -1
  10. package/dist/coh-content-db.mjs +998 -349
  11. package/dist/coh-content-db.mjs.map +1 -1
  12. package/eslint.config.mjs +1 -0
  13. package/jest.config.mjs +1 -0
  14. package/package.json +14 -14
  15. package/src/main/api/alignment.ts +18 -2
  16. package/src/main/api/badge-data.ts +29 -51
  17. package/src/main/api/badge-requirement-data.ts +64 -0
  18. package/src/main/api/badge-requirement-type.ts +32 -0
  19. package/src/main/api/badge-type.ts +15 -15
  20. package/src/main/api/bundle-data.ts +47 -0
  21. package/src/main/api/bundle-header-data.ts +44 -0
  22. package/src/main/api/contact-data.ts +49 -0
  23. package/src/main/api/enhancement-category.ts +26 -26
  24. package/src/main/api/level-range-data.ts +4 -0
  25. package/src/main/api/location-data.ts +28 -0
  26. package/src/main/api/markdown-string.ts +4 -0
  27. package/src/main/api/mission-data.ts +57 -0
  28. package/src/main/api/mission-flashback-data.ts +31 -0
  29. package/src/main/api/mission-type.ts +2 -0
  30. package/src/main/api/morality.ts +49 -0
  31. package/src/main/api/set-title-data.ts +4 -0
  32. package/src/main/api/sex.ts +8 -1
  33. package/src/main/api/variant-context.ts +11 -0
  34. package/src/main/api/variant-data.ts +22 -0
  35. package/src/main/api/zone-data.ts +44 -0
  36. package/src/main/api/zone-type.ts +59 -0
  37. package/src/main/db/abstract-index.ts +37 -0
  38. package/src/main/db/alignment-list.ts +54 -0
  39. package/src/main/db/badge-index.ts +83 -0
  40. package/src/main/db/badge-requirement.ts +81 -0
  41. package/src/main/db/badge-search-options.ts +52 -0
  42. package/src/main/db/badge.ts +97 -74
  43. package/src/main/db/bundle-header.ts +52 -0
  44. package/src/main/db/coh-content-database.ts +123 -14
  45. package/src/main/db/contact.ts +63 -0
  46. package/src/main/db/level-range.ts +15 -0
  47. package/src/main/db/location.ts +30 -0
  48. package/src/main/db/mission.ts +108 -0
  49. package/src/main/db/morality-list.ts +99 -0
  50. package/src/main/db/paged.ts +11 -0
  51. package/src/main/db/set-title-ids.ts +10 -0
  52. package/src/main/db/variants.ts +84 -0
  53. package/src/main/db/zone.ts +57 -0
  54. package/src/main/index.ts +33 -18
  55. package/src/main/util/coalesce-to-array.ts +13 -0
  56. package/src/main/util/links.ts +104 -0
  57. package/src/main/util/to-date.ts +9 -0
  58. package/src/test/api/alignment.test.ts +38 -4
  59. package/src/test/api/badge-data.fixture.ts +2 -15
  60. package/src/test/api/badge-data.test.ts +5 -4
  61. package/src/test/api/badge-requirement-data.fixture.ts +7 -0
  62. package/src/test/api/badge-requirement-type.test.ts +31 -0
  63. package/src/test/api/badge-type.test.ts +5 -5
  64. package/src/test/api/bundle-data.fixture.ts +7 -0
  65. package/src/test/api/bundle-header-data.fixture.ts +8 -0
  66. package/src/test/api/contact-data.fixture.ts +7 -0
  67. package/src/test/api/enhancement-category.test.ts +5 -5
  68. package/src/test/api/mission-data.fixture.ts +12 -0
  69. package/src/test/api/morality.test.ts +31 -0
  70. package/src/test/api/sex.test.ts +33 -1
  71. package/src/test/api/zone-data.fixture.ts +9 -0
  72. package/src/test/db/abstract-index.test.ts +55 -0
  73. package/src/test/db/alignment-list.test.ts +200 -0
  74. package/src/test/db/badge-index.test.ts +653 -0
  75. package/src/test/db/badge-requirement.test.ts +145 -0
  76. package/src/test/db/badge.test.ts +416 -14
  77. package/src/test/db/bundle-header.test.ts +89 -0
  78. package/src/test/db/coh-content-database.test.ts +265 -24
  79. package/src/test/db/contact.test.ts +98 -0
  80. package/src/test/db/level-range.test.ts +47 -0
  81. package/src/test/db/location.test.ts +51 -0
  82. package/src/test/db/mission.test.ts +173 -0
  83. package/src/test/db/morality-list.test.ts +457 -0
  84. package/src/test/db/set-title-ids.test.ts +19 -0
  85. package/src/test/db/variants.test.ts +188 -0
  86. package/src/test/db/zone.test.ts +81 -0
  87. package/src/test/integration.test.ts +16 -0
  88. package/src/test/util/coalese-to-array.test.ts +17 -0
  89. package/src/test/util/links.test.ts +149 -0
  90. package/src/test/util/to-date.test.ts +15 -0
  91. package/src/main/api/alternate-data.ts +0 -22
  92. package/src/main/api/badge-partial-data.ts +0 -65
  93. package/src/main/api/badge-partial-type.ts +0 -8
  94. package/src/main/api/change.ts +0 -14
  95. package/src/main/api/game-map-data.ts +0 -26
  96. package/src/main/api/plaque-type.ts +0 -6
  97. package/src/main/api/server-group-data.ts +0 -65
  98. package/src/main/api/vidiot-map-data.ts +0 -18
  99. package/src/main/api/vidiot-map-point-of-interest-data.ts +0 -30
  100. package/src/main/changelog.ts +0 -20
  101. package/src/main/db/alternates.ts +0 -81
  102. package/src/main/db/badge-partial.ts +0 -35
  103. package/src/main/db/game-map.ts +0 -33
  104. package/src/main/db/server-group.ts +0 -112
  105. package/src/main/db/vidiot-map-point-of-interest.ts +0 -40
  106. package/src/main/db/vidiot-map.ts +0 -25
  107. package/src/main/util.ts +0 -17
  108. package/src/test/api/badge-partial-data.fixture.ts +0 -17
  109. package/src/test/api/badge-partial-type.test.ts +0 -31
  110. package/src/test/api/game-map-data.fixture.ts +0 -10
  111. package/src/test/api/plaque-type.test.ts +0 -31
  112. package/src/test/api/server-group-data.fixture.ts +0 -23
  113. package/src/test/api/server-group-data.test.ts +0 -15
  114. package/src/test/api/vidiot-map-point-of-interest.fixture.ts +0 -10
  115. package/src/test/api/vidiot-map.fixture.ts +0 -9
  116. package/src/test/changelog.test.ts +0 -36
  117. package/src/test/db/alternates.test.ts +0 -223
  118. package/src/test/db/server-group.test.ts +0 -124
  119. package/src/test/index.test.ts +0 -10
  120. package/src/test/util.test.ts +0 -39
@@ -1,85 +1,276 @@
1
1
  'use strict';
2
2
 
3
- const ALIGNMENT = ["H", "V", "P"];
3
+ const ALIGNMENT = ["hero", "villain", "praetorian"];
4
+ const ALIGNMENT_ORDER = Object.fromEntries(ALIGNMENT.map((x, index) => [x, index]));
5
+ function compareAlignment(a, b) {
6
+ const orderA = a ? ALIGNMENT_ORDER[a] : -1;
7
+ const orderB = b ? ALIGNMENT_ORDER[b] : -1;
8
+ return orderA - orderB;
9
+ }
4
10
 
5
- const BADGE_PARTIAL_TYPE = [
6
- "PLAQUE",
7
- "BADGE",
8
- "INVENTION",
9
- "INVENTION_PLUS_ONE"
10
- // Some invention badges require you to build x of two different invention levels, 'plus one of either level'.
11
+ const BADGE_REQUIREMENT_TYPE = [
12
+ /**
13
+ * Collect a badge.
14
+ */
15
+ "badge",
16
+ /**
17
+ * Craft an invention.
18
+ */
19
+ "invention",
20
+ /**
21
+ * Some invention badges require you to build x of two different invention levels, 'plus one of either level'.
22
+ */
23
+ "invention-plus-one",
24
+ /**
25
+ * Visit a location.
26
+ */
27
+ "location",
28
+ /**
29
+ * Click on a monument.
30
+ */
31
+ "monument",
32
+ /**
33
+ * Complete a mission.
34
+ */
35
+ "mission",
36
+ /**
37
+ * Complete an arbitrary task.
38
+ */
39
+ "task"
11
40
  ];
12
41
 
13
42
  const BADGE_TYPE = [
14
- "EXPLORATION",
15
- "HISTORY",
16
- "ACCOMPLISHMENT",
17
- "ACHIEVEMENT",
18
- "ACCOLADE",
19
- "GLADIATOR",
20
- "VETERAN",
21
- "PVP",
22
- "INVENTION",
23
- "DEFEAT",
24
- "EVENT",
25
- "OUROBOROS",
26
- "CONSIGNMENT",
27
- "DAY_JOB",
28
- "AE"
43
+ "exploration",
44
+ "history",
45
+ "accomplishment",
46
+ "achievement",
47
+ "accolade",
48
+ "gladiator",
49
+ "veteran",
50
+ "pvp",
51
+ "invention",
52
+ "defeat",
53
+ "event",
54
+ "ouroboros",
55
+ "consignment",
56
+ "day-job",
57
+ "architect-entertainment"
29
58
  ];
30
59
 
31
60
  const ENHANCEMENT_CATEGORY = [
32
- "DEFENSE_DEBUFF",
33
- "TO_HIT_DEBUFF",
34
- "TAUNT",
35
- "CONFUSE",
36
- "HEALING",
37
- "DEFENSE_BUFF",
38
- "RESIST_DAMAGE",
39
- "INTANGIBILITY",
40
- "SLEEP",
41
- "SLOW",
42
- "HOLD",
43
- "STUN",
44
- "IMMOBILIZE",
45
- "FEAR",
46
- "ENDURANCE_MODIFICATION",
47
- "ENDURANCE_REDUCTION",
48
- "RECHARGE_REDUCTION",
49
- "INTERRUPT_DURATION",
50
- "ACCURACY",
51
- "TO_HIT_BUFF",
52
- "DAMAGE",
53
- "KNOCKBACK",
54
- "RUN_SPEED",
55
- "JUMP",
56
- "FLY_SPEED",
57
- "RANGE"
61
+ "defense-debuff",
62
+ "to-hit-debuff",
63
+ "taunt",
64
+ "confuse",
65
+ "healing",
66
+ "defense-buff",
67
+ "resist-damage",
68
+ "intangibility",
69
+ "sleep",
70
+ "slow",
71
+ "hold",
72
+ "stun",
73
+ "immobilize",
74
+ "fear",
75
+ "endurance-modification",
76
+ "endurance-reduction",
77
+ "recharge-reduction",
78
+ "interrupt-duration",
79
+ "accuracy",
80
+ "to-hit-buff",
81
+ "damage",
82
+ "knockback",
83
+ "run-speed",
84
+ "jump",
85
+ "fly-speed",
86
+ "range"
58
87
  ];
59
88
 
60
- const PLAQUE_TYPE = [
61
- "WALL_PLAQUE",
62
- "MONUMENT"
89
+ const MISSION_TYPE = ["story-arc", "mission", "task-force", "strike-force", "trial", "personal-story"];
90
+
91
+ const MORALITY = ["hero", "vigilante", "villain", "rogue", "resistance", "loyalist"];
92
+ const MORALITY_EXTENDED = [
93
+ ...MORALITY,
94
+ /**
95
+ * Any of the Primal Earth moralities - Hero, Vigilante, Villain, Rogue.
96
+ */
97
+ "primal",
98
+ /**
99
+ * Either of the Praetorian Earth moralities - Resistance or Loyalist.
100
+ */
101
+ "praetorian",
102
+ /**
103
+ * The moralities that roll up to the Hero {@link Alignment} - Hero and Vigilante.
104
+ */
105
+ "heroic",
106
+ /**
107
+ * The moralities that roll up to the Villain {@link Alignment} - Villain and Rogue.
108
+ */
109
+ "villainous",
110
+ /**
111
+ * Moralities with access to Paragon City - Hero, Vigilante and Rogue.
112
+ */
113
+ "paragon-city-access",
114
+ /**
115
+ * Moralities with access to the Rogue Isles - Villain, Rogue and Vigilante.
116
+ */
117
+ "rogue-isles-access",
118
+ /**
119
+ * All the moralities.
120
+ */
121
+ "all"
63
122
  ];
123
+ const MoralityMap = {
124
+ hero: "hero",
125
+ vigilante: "hero",
126
+ villain: "villain",
127
+ rogue: "villain",
128
+ loyalist: "praetorian",
129
+ resistance: "praetorian",
130
+ praetorian: "praetorian"
131
+ };
64
132
 
65
133
  const SEX = ["M", "F"];
134
+ const SEX_ORDER = Object.fromEntries(SEX.map((x, index) => [x, index]));
135
+ function compareSex(a, b) {
136
+ const orderA = a ? SEX_ORDER[a] : -1;
137
+ const orderB = b ? SEX_ORDER[b] : -1;
138
+ return orderA - orderB;
139
+ }
66
140
 
67
- var __typeError$4 = (msg) => {
141
+ const ZONE_TYPE = [
142
+ /**
143
+ * The standard zone type, even if not technically occurring in the 'City' proper.
144
+ */
145
+ "city",
146
+ /**
147
+ * An Ouroboros flashback to a zone as it was in a previous era.
148
+ */
149
+ "echo",
150
+ /**
151
+ * Tutorial zon, usually inaccessible after leaving.
152
+ */
153
+ "tutorial",
154
+ /**
155
+ * Trial zones, like the Abandoned Sewers trial.
156
+ */
157
+ "trial",
158
+ /**
159
+ * Hazard zones like the Hollows.
160
+ */
161
+ "hazard",
162
+ /**
163
+ * Mayhem mission zones.
164
+ */
165
+ "mayhem",
166
+ /**
167
+ * Safeguard mission zones.
168
+ */
169
+ "safeguard",
170
+ /**
171
+ * Exists inside a mission not covered by the other types.
172
+ */
173
+ "mission",
174
+ /**
175
+ * Incarnate trial zones.
176
+ */
177
+ "incarnate",
178
+ /**
179
+ * Cooprative zones where Heroes and Villains can team up for PvE content.
180
+ */
181
+ "co-op",
182
+ /**
183
+ * PvP zones like Bloody Bay.
184
+ */
185
+ "pvp",
186
+ /**
187
+ * Located in an arena PvP map.
188
+ */
189
+ "arena",
190
+ /**
191
+ * A building, usually contained within another zone, like the AE buildings.
192
+ */
193
+ "building",
194
+ /**
195
+ * Stuff like the (Phone only) zone.
196
+ */
197
+ "other"
198
+ ];
199
+
200
+ var __defProp$c = Object.defineProperty;
201
+ var __typeError$6 = (msg) => {
68
202
  throw TypeError(msg);
69
203
  };
70
- var __accessCheck$4 = (obj, member, msg) => member.has(obj) || __typeError$4("Cannot " + msg);
71
- var __privateGet$4 = (obj, member, getter) => (__accessCheck$4(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
72
- var __privateAdd$4 = (obj, member, value) => member.has(obj) ? __typeError$4("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
73
- var __privateSet$1 = (obj, member, value, setter) => (__accessCheck$4(obj, member, "write to private field"), member.set(obj, value), value);
74
- var __privateMethod$1 = (obj, member, method) => (__accessCheck$4(obj, member, "access private method"), method);
204
+ var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
205
+ var __publicField$c = (obj, key, value) => __defNormalProp$c(obj, typeof key !== "symbol" ? key + "" : key, value);
206
+ var __accessCheck$6 = (obj, member, msg) => member.has(obj) || __typeError$6("Cannot " + msg);
207
+ var __privateGet$5 = (obj, member, getter) => (__accessCheck$6(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
208
+ var __privateAdd$6 = (obj, member, value) => member.has(obj) ? __typeError$6("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
209
+ var __privateSet$5 = (obj, member, value, setter) => (__accessCheck$6(obj, member, "write to private field"), member.set(obj, value), value);
210
+ var _items$1;
211
+ class AlignmentList {
212
+ constructor(items) {
213
+ __privateAdd$6(this, _items$1);
214
+ __publicField$c(this, "hero");
215
+ __publicField$c(this, "villain");
216
+ __publicField$c(this, "praetorian");
217
+ __publicField$c(this, "primal");
218
+ __publicField$c(this, "all");
219
+ const set = new Set(items ?? [...ALIGNMENT]);
220
+ this.hero = set.has("hero") || set.has("primal") || set.has("all");
221
+ this.villain = set.has("villain") || set.has("primal") || set.has("all");
222
+ this.praetorian = set.has("praetorian") || set.has("all");
223
+ this.primal = this.hero && this.villain;
224
+ this.all = this.hero && this.villain && this.praetorian;
225
+ __privateSet$5(this, _items$1, /* @__PURE__ */ new Set());
226
+ if (this.hero) __privateGet$5(this, _items$1).add("hero");
227
+ if (this.villain) __privateGet$5(this, _items$1).add("villain");
228
+ if (this.praetorian) __privateGet$5(this, _items$1).add("praetorian");
229
+ }
230
+ get items() {
231
+ return [...__privateGet$5(this, _items$1)];
232
+ }
233
+ has(alignment) {
234
+ switch (alignment) {
235
+ case "hero": {
236
+ return this.hero;
237
+ }
238
+ case "villain": {
239
+ return this.villain;
240
+ }
241
+ case "praetorian": {
242
+ return this.praetorian;
243
+ }
244
+ case "primal": {
245
+ return this.primal;
246
+ }
247
+ case "all": {
248
+ return this.all;
249
+ }
250
+ default: {
251
+ return false;
252
+ }
253
+ }
254
+ }
255
+ }
256
+ _items$1 = new WeakMap();
257
+
258
+ var __typeError$5 = (msg) => {
259
+ throw TypeError(msg);
260
+ };
261
+ var __accessCheck$5 = (obj, member, msg) => member.has(obj) || __typeError$5("Cannot " + msg);
262
+ var __privateGet$4 = (obj, member, getter) => (__accessCheck$5(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
263
+ var __privateAdd$5 = (obj, member, value) => member.has(obj) ? __typeError$5("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
264
+ var __privateSet$4 = (obj, member, value, setter) => (__accessCheck$5(obj, member, "write to private field"), member.set(obj, value), value);
265
+ var __privateMethod$2 = (obj, member, method) => (__accessCheck$5(obj, member, "access private method"), method);
75
266
  var _value, _Key_instances, validateKey_fn;
76
267
  const INVALID_KEY_PATTERN = /[^a-z0-9-]/;
77
268
  class Key {
78
269
  constructor(value) {
79
- __privateAdd$4(this, _Key_instances);
80
- __privateAdd$4(this, _value);
81
- __privateMethod$1(this, _Key_instances, validateKey_fn).call(this, value);
82
- __privateSet$1(this, _value, value);
270
+ __privateAdd$5(this, _Key_instances);
271
+ __privateAdd$5(this, _value);
272
+ __privateMethod$2(this, _Key_instances, validateKey_fn).call(this, value);
273
+ __privateSet$4(this, _value, value);
83
274
  }
84
275
  get value() {
85
276
  return __privateGet$4(this, _value);
@@ -91,429 +282,751 @@ validateKey_fn = function(key) {
91
282
  if (INVALID_KEY_PATTERN.test(key)) throw new Error(`Invalid key: [${key}]; Keys can only contain lowercase characters, numbers and dashes.`);
92
283
  };
93
284
 
94
- var __defProp$6 = Object.defineProperty;
95
- var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
96
- var __publicField$6 = (obj, key, value) => __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
285
+ var __defProp$b = Object.defineProperty;
286
+ var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
287
+ var __publicField$b = (obj, key, value) => __defNormalProp$b(obj, typeof key !== "symbol" ? key + "" : key, value);
97
288
  class Archetype {
98
289
  constructor(data) {
99
- __publicField$6(this, "key");
100
- __publicField$6(this, "name");
101
- __publicField$6(this, "description");
290
+ __publicField$b(this, "key");
291
+ __publicField$b(this, "name");
292
+ __publicField$b(this, "description");
102
293
  this.key = new Key(data.key).value;
103
294
  this.name = data.name;
104
295
  this.description = data.description;
105
296
  }
106
297
  }
107
298
 
108
- var __defProp$5 = Object.defineProperty;
109
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
110
- var __publicField$5 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
111
- class BadgePartial {
299
+ function coalesceToArray(value) {
300
+ if (!value) return void 0;
301
+ return Array.isArray(value) ? value : [value];
302
+ }
303
+
304
+ var __defProp$a = Object.defineProperty;
305
+ var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
306
+ var __publicField$a = (obj, key, value) => __defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
307
+ class BadgeRequirement {
112
308
  constructor(data) {
113
- __publicField$5(this, "key");
114
- __publicField$5(this, "type");
115
- __publicField$5(this, "mapKey");
116
- __publicField$5(this, "loc");
117
- __publicField$5(this, "plaqueType");
118
- __publicField$5(this, "inscription");
119
- __publicField$5(this, "vidiotMapKey");
120
- __publicField$5(this, "badgeKey");
121
- __publicField$5(this, "inventionLevel");
122
- __publicField$5(this, "inventionTypes");
123
- __publicField$5(this, "inventionCount");
124
- __publicField$5(this, "notes");
309
+ /**
310
+ * Unique key used to reference this badge requirement.
311
+ *
312
+ * Keys must be unique and can only contain lowercase letters, numbers and hyphens (`-`).
313
+ */
314
+ __publicField$a(this, "key");
315
+ /**
316
+ * The requirement type.
317
+ */
318
+ __publicField$a(this, "type");
319
+ /**
320
+ * If the requirement involves a location, where it is.
321
+ */
322
+ __publicField$a(this, "location");
323
+ /**
324
+ * If the requirement involves a badge, the badge key.
325
+ */
326
+ __publicField$a(this, "badgeKey");
327
+ /**
328
+ * If the requirement involves a mission, the mission key.
329
+ */
330
+ __publicField$a(this, "missionKey");
331
+ /**
332
+ * If the requirement involves a monument, the text that is displayed thereon.
333
+ */
334
+ __publicField$a(this, "monumentText");
335
+ /**
336
+ * If the requirement involves crafting an invention, the Level of the invention required.
337
+ */
338
+ __publicField$a(this, "inventionLevel");
339
+ /**
340
+ * If the requirement involves crafting an invention, the types of enhancements that will qualify.
341
+ */
342
+ __publicField$a(this, "inventionTypes");
343
+ /**
344
+ * Number of times the task needs to be repeated.
345
+ */
346
+ __publicField$a(this, "count");
347
+ /**
348
+ * Additional information about the requirement.
349
+ */
350
+ __publicField$a(this, "notes");
351
+ /**
352
+ * List of external links. Wiki, forums, etc.
353
+ */
354
+ __publicField$a(this, "links");
125
355
  this.key = new Key(data.key).value;
126
356
  this.type = data.type;
127
- this.mapKey = data.mapKey;
128
- this.loc = data.loc;
129
- this.plaqueType = data.plaqueType;
130
- this.inscription = data.inscription;
131
- this.vidiotMapKey = data.vidiotMapKey;
357
+ this.location = coalesceToArray(data.location);
132
358
  this.badgeKey = data.badgeKey;
359
+ this.missionKey = data.missionKey;
360
+ this.monumentText = data.monumentText;
133
361
  this.inventionLevel = data.inventionLevel;
134
362
  this.inventionTypes = data.inventionTypes;
135
- this.inventionCount = data.inventionCount;
363
+ this.count = data.count;
136
364
  this.notes = data.notes;
365
+ this.links = data.links ?? [];
137
366
  }
138
367
  }
139
368
 
140
- var __typeError$3 = (msg) => {
369
+ var __typeError$4 = (msg) => {
141
370
  throw TypeError(msg);
142
371
  };
143
- var __accessCheck$3 = (obj, member, msg) => member.has(obj) || __typeError$3("Cannot " + msg);
144
- var __privateGet$3 = (obj, member, getter) => (__accessCheck$3(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
145
- var __privateAdd$3 = (obj, member, value) => member.has(obj) ? __typeError$3("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
146
- var __privateSet = (obj, member, value, setter) => (__accessCheck$3(obj, member, "write to private field"), member.set(obj, value), value);
147
- var __privateMethod = (obj, member, method) => (__accessCheck$3(obj, member, "access private method"), method);
148
- var _sortedValues, _Alternates_instances, compareAlternates_fn, compareAlignment_fn, compareSex_fn;
149
- const ALIGNMENT_SORT = { H: 2, V: 1, P: 0 };
150
- const SEX_SORT = { M: 1, F: 0 };
151
- class Alternates {
152
- constructor(values) {
153
- __privateAdd$3(this, _Alternates_instances);
154
- __privateAdd$3(this, _sortedValues, []);
155
- __privateSet(this, _sortedValues, values.sort());
156
- __privateGet$3(this, _sortedValues).sort((a, b) => __privateMethod(this, _Alternates_instances, compareAlternates_fn).call(this, a, b));
372
+ var __accessCheck$4 = (obj, member, msg) => member.has(obj) || __typeError$4("Cannot " + msg);
373
+ var __privateGet$3 = (obj, member, getter) => (__accessCheck$4(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
374
+ var __privateAdd$4 = (obj, member, value) => member.has(obj) ? __typeError$4("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
375
+ var __privateSet$3 = (obj, member, value, setter) => (__accessCheck$4(obj, member, "write to private field"), member.set(obj, value), value);
376
+ var __privateMethod$1 = (obj, member, method) => (__accessCheck$4(obj, member, "access private method"), method);
377
+ var _sortedValues, _Variants_instances, compareVariants_fn;
378
+ class Variants {
379
+ /**
380
+ * Create a variant set from either a list of categorized values, or a single value when there are no variants.
381
+ * @param value List of variants, or a single value.
382
+ */
383
+ constructor(value) {
384
+ __privateAdd$4(this, _Variants_instances);
385
+ __privateAdd$4(this, _sortedValues, []);
386
+ if (Array.isArray(value)) {
387
+ __privateSet$3(this, _sortedValues, value.toSorted());
388
+ __privateGet$3(this, _sortedValues).sort((a, b) => __privateMethod$1(this, _Variants_instances, compareVariants_fn).call(this, a, b));
389
+ } else {
390
+ __privateSet$3(this, _sortedValues, [{ value }]);
391
+ }
157
392
  }
158
- getValue(alignment, sex) {
393
+ /**
394
+ * Get a variant by context
395
+ * @param context The context
396
+ */
397
+ getVariant(context) {
398
+ const alignment = context?.morality ? MoralityMap[context.morality] : void 0;
399
+ const sex = context?.sex;
159
400
  for (let index = __privateGet$3(this, _sortedValues).length; index--; ) {
160
401
  const entry = __privateGet$3(this, _sortedValues)[index];
161
- if ((entry.alignment === void 0 || entry.alignment === alignment) && (entry.sex === void 0 || entry.sex === sex)) return entry.value;
402
+ if ((entry.alignment === void 0 || entry.alignment === alignment) && (entry.sex === void 0 || entry.sex === sex)) return entry;
162
403
  }
163
- return void 0;
404
+ return this.default;
405
+ }
406
+ /**
407
+ * Get a value by variant context
408
+ * @param context The context
409
+ */
410
+ getValue(context) {
411
+ return this.getVariant(context)?.value;
164
412
  }
165
413
  /**
166
- * Get the default value for this list of alternates, the value with the highest priority and lowest specificity.
414
+ * Get the default value for this list of variants, the value with the highest priority and lowest specificity.
167
415
  */
168
416
  get default() {
169
- return __privateGet$3(this, _sortedValues)[0]?.value;
417
+ return __privateGet$3(this, _sortedValues)[0];
170
418
  }
171
419
  /**
172
- * Get the list of alternates sorted in canonical order (alignment then sex, low to high specificity).
420
+ * Get the list of variants sorted in canonical order (alignment then sex, low to high specificity).
173
421
  */
174
422
  get canonical() {
175
423
  return __privateGet$3(this, _sortedValues);
176
424
  }
425
+ /**
426
+ * Create a joined string from the variant values in canonical order.
427
+ * @param separator Separator to use. Default is ' / '
428
+ */
429
+ toString(separator) {
430
+ return this.canonical.map((x) => x.value).join(separator);
431
+ }
177
432
  }
178
433
  _sortedValues = new WeakMap();
179
- _Alternates_instances = new WeakSet();
180
- compareAlternates_fn = function(a, b) {
434
+ _Variants_instances = new WeakSet();
435
+ compareVariants_fn = function(a, b) {
181
436
  const aSpecificity = (a.alignment ? 2 : 0) + (a.sex ? 1 : 0);
182
437
  const bSpecificity = (b.alignment ? 2 : 0) + (b.sex ? 1 : 0);
183
438
  if (aSpecificity !== bSpecificity) return aSpecificity - bSpecificity;
184
- const alignmentComparison = __privateMethod(this, _Alternates_instances, compareAlignment_fn).call(this, a.alignment, b.alignment);
439
+ const alignmentComparison = compareAlignment(a.alignment, b.alignment);
185
440
  if (alignmentComparison !== 0) return alignmentComparison;
186
- const sexComparison = __privateMethod(this, _Alternates_instances, compareSex_fn).call(this, a.sex, b.sex);
441
+ const sexComparison = compareSex(a.sex, b.sex);
187
442
  if (sexComparison !== 0) return sexComparison;
188
443
  return String(a.value).localeCompare(String(b.value));
189
444
  };
190
- compareAlignment_fn = function(a, b) {
191
- if (a === b) return 0;
192
- if (a === void 0 && b !== void 0) return -1;
193
- if (b === void 0 && a !== void 0) return 1;
194
- const aSort = a === void 0 ? -1 : ALIGNMENT_SORT[a] ?? -1;
195
- const bSort = b === void 0 ? -1 : ALIGNMENT_SORT[b] ?? -1;
196
- if (aSort !== bSort) return bSort - aSort;
197
- return a?.localeCompare(b ?? "") ?? 0;
198
- };
199
- compareSex_fn = function(a, b) {
200
- if (a === b) return 0;
201
- if (a === void 0 && b !== void 0) return -1;
202
- if (b === void 0 && a !== void 0) return 1;
203
- const aSort = SEX_SORT[a ?? -1] ?? -1;
204
- const bSort = SEX_SORT[b ?? -1] ?? -1;
205
- if (aSort !== bSort) return bSort - aSort;
206
- return a?.localeCompare(b ?? "") ?? 0;
445
+
446
+ var __defProp$9 = Object.defineProperty;
447
+ var __typeError$3 = (msg) => {
448
+ throw TypeError(msg);
207
449
  };
450
+ var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
451
+ var __publicField$9 = (obj, key, value) => __defNormalProp$9(obj, typeof key !== "symbol" ? key + "" : key, value);
452
+ var __accessCheck$3 = (obj, member, msg) => member.has(obj) || __typeError$3("Cannot " + msg);
453
+ var __privateGet$2 = (obj, member, getter) => (__accessCheck$3(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
454
+ var __privateAdd$3 = (obj, member, value) => member.has(obj) ? __typeError$3("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
455
+ var __privateSet$2 = (obj, member, value, setter) => (__accessCheck$3(obj, member, "write to private field"), member.set(obj, value), value);
456
+ var _items;
457
+ class MoralityList {
458
+ constructor(items) {
459
+ __privateAdd$3(this, _items);
460
+ __publicField$9(this, "hero");
461
+ __publicField$9(this, "vigilante");
462
+ __publicField$9(this, "villain");
463
+ __publicField$9(this, "rogue");
464
+ __publicField$9(this, "resistance");
465
+ __publicField$9(this, "loyalist");
466
+ __publicField$9(this, "primal");
467
+ __publicField$9(this, "praetorian");
468
+ __publicField$9(this, "heroic");
469
+ __publicField$9(this, "villainous");
470
+ __publicField$9(this, "paragonCityAccess");
471
+ __publicField$9(this, "rogueIslesAccess");
472
+ __publicField$9(this, "all");
473
+ const set = new Set(items ?? [...MORALITY]);
474
+ this.hero = set.has("hero") || set.has("primal") || set.has("heroic") || set.has("paragon-city-access") || set.has("all");
475
+ this.vigilante = set.has("vigilante") || set.has("primal") || set.has("heroic") || set.has("paragon-city-access") || set.has("rogue-isles-access") || set.has("all");
476
+ this.villain = set.has("villain") || set.has("primal") || set.has("villainous") || set.has("rogue-isles-access") || set.has("all");
477
+ this.rogue = set.has("rogue") || set.has("primal") || set.has("villainous") || set.has("paragon-city-access") || set.has("rogue-isles-access") || set.has("all");
478
+ this.resistance = set.has("resistance") || set.has("praetorian") || set.has("all");
479
+ this.loyalist = set.has("loyalist") || set.has("praetorian") || set.has("all");
480
+ this.primal = this.hero && this.vigilante && this.villain && this.rogue;
481
+ this.praetorian = this.loyalist && this.resistance;
482
+ this.heroic = this.hero && this.vigilante;
483
+ this.villainous = this.villain && this.rogue;
484
+ this.paragonCityAccess = this.heroic && this.rogue;
485
+ this.rogueIslesAccess = this.villainous && this.vigilante;
486
+ this.all = this.primal && this.praetorian;
487
+ __privateSet$2(this, _items, /* @__PURE__ */ new Set());
488
+ if (this.hero) __privateGet$2(this, _items).add("hero");
489
+ if (this.vigilante) __privateGet$2(this, _items).add("vigilante");
490
+ if (this.villain) __privateGet$2(this, _items).add("villain");
491
+ if (this.rogue) __privateGet$2(this, _items).add("rogue");
492
+ if (this.resistance) __privateGet$2(this, _items).add("resistance");
493
+ if (this.loyalist) __privateGet$2(this, _items).add("loyalist");
494
+ }
495
+ get items() {
496
+ return [...__privateGet$2(this, _items)];
497
+ }
498
+ has(morality) {
499
+ switch (morality) {
500
+ case "hero": {
501
+ return this.hero;
502
+ }
503
+ case "vigilante": {
504
+ return this.vigilante;
505
+ }
506
+ case "villain": {
507
+ return this.villain;
508
+ }
509
+ case "rogue": {
510
+ return this.rogue;
511
+ }
512
+ case "resistance": {
513
+ return this.resistance;
514
+ }
515
+ case "loyalist": {
516
+ return this.loyalist;
517
+ }
518
+ case "primal": {
519
+ return this.primal;
520
+ }
521
+ case "praetorian": {
522
+ return this.praetorian;
523
+ }
524
+ case "heroic": {
525
+ return this.hero;
526
+ }
527
+ case "paragon-city-access": {
528
+ return this.paragonCityAccess;
529
+ }
530
+ case "rogue-isles-access": {
531
+ return this.rogueIslesAccess;
532
+ }
533
+ case "villainous": {
534
+ return this.villainous;
535
+ }
536
+ case "all": {
537
+ return this.all;
538
+ }
539
+ default: {
540
+ return false;
541
+ }
542
+ }
543
+ }
544
+ }
545
+ _items = new WeakMap();
208
546
 
209
- var __defProp$4 = Object.defineProperty;
547
+ var __defProp$8 = Object.defineProperty;
548
+ var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
549
+ var __publicField$8 = (obj, key, value) => __defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
550
+ class AbstractIndex {
551
+ /**
552
+ * Create a new index.
553
+ * @param keyField The field of the values that will act as the key.
554
+ * @param values Values to index.
555
+ */
556
+ constructor(keyField, values) {
557
+ __publicField$8(this, "_values", []);
558
+ __publicField$8(this, "_hashTable", {});
559
+ this._values = values ?? [];
560
+ this._hashTable = {};
561
+ for (const value of this.values) {
562
+ const key = value[keyField];
563
+ if (this._hashTable[key] !== void 0) throw new Error(`Duplicate key [${key}]`);
564
+ this._hashTable[key] = value;
565
+ }
566
+ }
567
+ /**
568
+ * Return all indexed values
569
+ */
570
+ get values() {
571
+ return this._values;
572
+ }
573
+ /**
574
+ * Get a value from the index
575
+ * @param key Key string
576
+ */
577
+ get(key) {
578
+ if (!key) return void 0;
579
+ return this._hashTable[key];
580
+ }
581
+ }
582
+
583
+ function toDate(iso) {
584
+ const date = new Date(iso);
585
+ if (!date || Number.isNaN(date.getTime())) throw new Error(`Invalid date format: [${iso}]`);
586
+ return date;
587
+ }
588
+
589
+ var __defProp$7 = Object.defineProperty;
590
+ var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
591
+ var __publicField$7 = (obj, key, value) => __defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
592
+ class SetTitleIds {
593
+ constructor(value) {
594
+ __publicField$7(this, "primal");
595
+ __publicField$7(this, "praetorian");
596
+ [this.primal, this.praetorian] = value;
597
+ }
598
+ }
599
+
600
+ var __defProp$6 = Object.defineProperty;
210
601
  var __typeError$2 = (msg) => {
211
602
  throw TypeError(msg);
212
603
  };
213
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
214
- var __publicField$4 = (obj, key, value) => __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
604
+ var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
605
+ var __publicField$6 = (obj, key, value) => __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
215
606
  var __accessCheck$2 = (obj, member, msg) => member.has(obj) || __typeError$2("Cannot " + msg);
216
- var __privateGet$2 = (obj, member, getter) => (__accessCheck$2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
607
+ var __privateGet$1 = (obj, member, getter) => (__accessCheck$2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
217
608
  var __privateAdd$2 = (obj, member, value) => member.has(obj) ? __typeError$2("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
218
- var _partialsIndex;
609
+ var __privateSet$1 = (obj, member, value, setter) => (__accessCheck$2(obj, member, "write to private field"), member.set(obj, value), value);
610
+ var _requirementsIndex, _zoneKeys;
219
611
  class Badge {
220
- constructor(data) {
221
- __privateAdd$2(this, _partialsIndex, {});
612
+ constructor(badgeData) {
613
+ __privateAdd$2(this, _requirementsIndex);
614
+ __privateAdd$2(this, _zoneKeys, /* @__PURE__ */ new Set());
222
615
  /**
223
616
  * The database key for this badge.
224
617
  */
225
- __publicField$4(this, "key");
618
+ __publicField$6(this, "key");
226
619
  /**
227
620
  * The type of badge.
228
621
  */
229
- __publicField$4(this, "type");
622
+ __publicField$6(this, "type");
230
623
  /**
231
624
  * The name of this badge.
232
625
  *
233
626
  * May vary by character sex or alignment.
234
627
  */
235
- __publicField$4(this, "name");
628
+ __publicField$6(this, "name");
629
+ /**
630
+ * The date that the badge was added to the game.
631
+ */
632
+ __publicField$6(this, "releaseDate");
236
633
  /**
237
- * The character alignments that this badge is available to.
634
+ * The character moralities that this badge is available to.
238
635
  */
239
- __publicField$4(this, "alignment");
636
+ __publicField$6(this, "morality");
240
637
  /**
241
638
  * The badge text as it appears in-game. May vary by character sex or alignment.
242
639
  */
243
- __publicField$4(this, "badgeText");
640
+ __publicField$6(this, "badgeText");
244
641
  /**
245
- * Description of how to acquire the badge.
246
- *
247
- * Supports {@link https://www.markdownguide.org/|Markdown} format.
642
+ * Short description of how to acquire the badge. Detailed instructions will be in the notes field.
248
643
  */
249
- __publicField$4(this, "acquisition");
644
+ __publicField$6(this, "acquisition");
250
645
  /**
251
646
  * Absolute URL to this badge's icon.
252
647
  *
253
648
  * May vary by character sex or alignment.
254
649
  */
255
- __publicField$4(this, "icon");
650
+ __publicField$6(this, "icon");
256
651
  /**
257
652
  * Freeform notes or tips about the badge.
258
- *
259
- * Supports {@link https://www.markdownguide.org/|Markdown} format.
260
653
  */
261
- __publicField$4(this, "notes");
654
+ __publicField$6(this, "notes");
262
655
  /**
263
- * List of external links for this Badge. Wiki, forums, etc.
656
+ * List of external links. Wiki, forums, etc.
264
657
  */
265
- __publicField$4(this, "links");
658
+ __publicField$6(this, "links");
266
659
  /**
267
- * For exploration badges, the key of the {@link GameMap} that this badge is found on.
660
+ * The id used with the in-game `/settitle` command to apply the badge.
661
+ * The first value is the id for primal characters and the (optional) second number is the id for praetorian characters.
268
662
  */
269
- __publicField$4(this, "mapKey");
663
+ __publicField$6(this, "setTitleId");
270
664
  /**
271
- * For exploration badges, the `/loc` coordinates of the badge on the in-game map.
665
+ * A description of the effect the badge will have, such as a buff or granting a temporary power.
272
666
  */
273
- __publicField$4(this, "loc");
667
+ __publicField$6(this, "effect");
274
668
  /**
275
- * For badges that appear on a Vidiot Map, the number or letter the badge appears as.
669
+ * Some badges are not included in the badge total count... such as Flames of Prometheus, which can be removed by redeeming it for a Notice of the Well.
276
670
  */
277
- __publicField$4(this, "vidiotMapKey");
671
+ __publicField$6(this, "ignoreInTotals");
672
+ this.key = new Key(badgeData.key).value;
673
+ this.type = badgeData.type;
674
+ this.name = new Variants(badgeData.name);
675
+ this.releaseDate = toDate(badgeData.releaseDate);
676
+ this.morality = new MoralityList(coalesceToArray(badgeData.morality));
677
+ this.badgeText = new Variants(badgeData.badgeText ?? []);
678
+ this.acquisition = badgeData.acquisition;
679
+ this.icon = new Variants(badgeData.icon ?? []);
680
+ this.notes = badgeData.notes;
681
+ this.links = badgeData.links ?? [];
682
+ this.effect = badgeData.effect;
683
+ this.setTitleId = badgeData.setTitleId ? new SetTitleIds(badgeData.setTitleId) : void 0;
684
+ this.ignoreInTotals = badgeData.ignoreInTotals ?? false;
685
+ __privateSet$1(this, _requirementsIndex, new AbstractIndex("key", badgeData.requirements?.map((x) => new BadgeRequirement(x))));
686
+ for (const requirement of __privateGet$1(this, _requirementsIndex).values) {
687
+ if (requirement.location) for (const location of requirement.location) {
688
+ if (location.zoneKey) __privateGet$1(this, _zoneKeys).add(location.zoneKey);
689
+ }
690
+ }
691
+ }
692
+ /**
693
+ * Represents the requirements for badges with multiple fulfillment steps, such as visiting monuments for history badges, completing missions, or collecting other badges.
694
+ */
695
+ get requirements() {
696
+ return __privateGet$1(this, _requirementsIndex).values;
697
+ }
698
+ getRequirement(key) {
699
+ return __privateGet$1(this, _requirementsIndex).get(key);
700
+ }
701
+ /**
702
+ * Return a list of all the zone keys referenced by this badge.
703
+ */
704
+ get zoneKeys() {
705
+ return [...__privateGet$1(this, _zoneKeys)];
706
+ }
707
+ /**
708
+ * The zone key if this badge relates to a single zone.
709
+ */
710
+ get zoneKey() {
711
+ return __privateGet$1(this, _zoneKeys).size === 1 ? __privateGet$1(this, _zoneKeys).values().next().value : void 0;
712
+ }
713
+ }
714
+ _requirementsIndex = new WeakMap();
715
+ _zoneKeys = new WeakMap();
716
+ function compareByName(a, b, context) {
717
+ const aName = a?.name?.getValue(context);
718
+ const bName = b?.name?.getValue(context);
719
+ if (!aName && !bName) return 0;
720
+ if (!aName) return 1;
721
+ if (!bName) return -1;
722
+ return aName.localeCompare(bName);
723
+ }
724
+ function compareByZoneKey(a, b) {
725
+ const aZone = a?.zoneKey;
726
+ const bZone = b?.zoneKey;
727
+ if (!aZone && !bZone) return 0;
728
+ if (!aZone) return 1;
729
+ if (!bZone) return -1;
730
+ return aZone.localeCompare(bZone);
731
+ }
732
+ function compareByReleaseDate(a, b) {
733
+ const aReleaseDate = a?.releaseDate?.getTime();
734
+ const bReleaseDate = b?.releaseDate?.getTime();
735
+ if (aReleaseDate === bReleaseDate) return 0;
736
+ if (!aReleaseDate) return 1;
737
+ if (!bReleaseDate) return -1;
738
+ return aReleaseDate < bReleaseDate ? -1 : 1;
739
+ }
740
+
741
+ var __typeError$1 = (msg) => {
742
+ throw TypeError(msg);
743
+ };
744
+ var __accessCheck$1 = (obj, member, msg) => member.has(obj) || __typeError$1("Cannot " + msg);
745
+ var __privateAdd$1 = (obj, member, value) => member.has(obj) ? __typeError$1("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
746
+ var __privateMethod = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
747
+ var _BadgeIndex_instances, satisfiesQueryPredicate_fn, satisfiesFilterPredicate_fn, sort_fn;
748
+ class BadgeIndex extends AbstractIndex {
749
+ constructor(values) {
750
+ super("key", values);
751
+ __privateAdd$1(this, _BadgeIndex_instances);
752
+ }
753
+ search(options) {
754
+ const matched = options?.query || options?.filter ? this._values.filter((badge) => __privateMethod(this, _BadgeIndex_instances, satisfiesQueryPredicate_fn).call(this, badge, options?.query) && __privateMethod(this, _BadgeIndex_instances, satisfiesFilterPredicate_fn).call(this, badge, options?.filter)) : this._values;
755
+ const sorted = __privateMethod(this, _BadgeIndex_instances, sort_fn).call(this, matched, options);
756
+ const totalPages = options?.pageSize ? Math.ceil(matched.length / options?.pageSize) : 1;
757
+ const pageNumber = Math.max(1, Math.min(totalPages, options?.page ?? 1));
758
+ const items = options?.pageSize ? sorted.slice((pageNumber - 1) * options.pageSize, pageNumber * options?.pageSize) : sorted;
759
+ return {
760
+ items,
761
+ pageIndex: pageNumber - 1,
762
+ pageNumber,
763
+ pageSize: options?.pageSize,
764
+ matchedItemCount: matched.length,
765
+ totalItemCount: this._values.length,
766
+ totalPageCount: totalPages
767
+ };
768
+ }
769
+ }
770
+ _BadgeIndex_instances = new WeakSet();
771
+ satisfiesQueryPredicate_fn = function(badge, query) {
772
+ const queryString = query?.str?.toLowerCase() ?? "";
773
+ const fields = query?.fields ? new Set(query?.fields) : /* @__PURE__ */ new Set(["name"]);
774
+ if (fields.size === 0) return true;
775
+ return !!(fields.has("name") && badge.name.canonical.some((x) => x.value.toLowerCase().includes(queryString)) || fields.has("badge-text") && badge.badgeText.canonical.some((x) => x.value.toLowerCase().includes(queryString)) || fields.has("acquisition") && badge.acquisition?.toLowerCase().includes(queryString) || fields.has("effect") && badge.effect?.toLowerCase().includes(queryString) || fields.has("notes") && badge.notes?.toLowerCase().includes(queryString) || fields.has("set-title-id") && badge.setTitleId?.primal.toString() === queryString || fields.has("set-title-id") && badge.setTitleId?.praetorian?.toString() === queryString);
776
+ };
777
+ satisfiesFilterPredicate_fn = function(badge, filter) {
778
+ return (!filter?.type || badge.type === filter.type) && (!filter?.zoneKey || badge.zoneKey === filter.zoneKey) && (!filter?.morality || badge.morality.has(filter.morality)) && (!filter?.predicate || filter.predicate(badge));
779
+ };
780
+ sort_fn = function(badges, options) {
781
+ switch (options?.sort) {
782
+ case "name.asc": {
783
+ return badges.toSorted((a, b) => compareByName(a, b, options.variantContext));
784
+ }
785
+ case "name.desc": {
786
+ return badges.toSorted((a, b) => compareByName(b, a, options.variantContext));
787
+ }
788
+ case "zone-key.asc": {
789
+ return badges.toSorted(compareByZoneKey);
790
+ }
791
+ case "zone-key.desc": {
792
+ return badges.toSorted((a, b) => compareByZoneKey(b, a));
793
+ }
794
+ case "release-date.asc": {
795
+ return badges.toSorted(compareByReleaseDate);
796
+ }
797
+ case "release-date.desc": {
798
+ return badges.toSorted((a, b) => compareByReleaseDate(b, a));
799
+ }
800
+ case "canonical.desc": {
801
+ return badges.toReversed();
802
+ }
803
+ default: {
804
+ return [...badges];
805
+ }
806
+ }
807
+ };
808
+
809
+ var __defProp$5 = Object.defineProperty;
810
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
811
+ var __publicField$5 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
812
+ class BundleHeader {
813
+ constructor(data) {
278
814
  /**
279
- * ID used with the in-game `/settitle` command to apply the badge.
815
+ * Name of the fork this bundle contains data for.
280
816
  */
281
- __publicField$4(this, "setTitle");
817
+ __publicField$5(this, "name");
282
818
  /**
283
- * A description of the effect the badge will have, such as a buff or granting a temporary power.
284
- *
285
- * Supports {@link https://www.markdownguide.org/|Markdown} format.
819
+ * Version number for this data package.
286
820
  */
287
- __publicField$4(this, "effect");
821
+ __publicField$5(this, "version");
288
822
  /**
289
- * A list of requirements for badges that have partial fulfilment steps, such as visiting plaques for history badges, or collecting other badges for meta-badges like accolades.
823
+ * The time this bundle was last updated.
290
824
  */
291
- __publicField$4(this, "partials");
825
+ __publicField$5(this, "lastUpdateTime");
292
826
  /**
293
- * Some badges are not included in the badge total count... such as Flames of Prometheus, which can be removed by redeeming it for a Notice of the Well.
827
+ * Description of the fork.
294
828
  */
295
- __publicField$4(this, "ignoreInTotals");
296
- this.key = new Key(data.key).value;
297
- this.type = data.type;
298
- this.name = new Alternates(data.name);
299
- this.alignment = data.alignment;
300
- this.badgeText = new Alternates(data.badgeText ?? []);
301
- this.acquisition = data.acquisition;
302
- this.icon = new Alternates(data.icon ?? []);
303
- this.notes = data.notes;
304
- this.links = data.links;
305
- this.mapKey = data.mapKey;
306
- this.loc = data.loc;
307
- this.effect = data.effect;
308
- this.vidiotMapKey = data.vidiotMapKey;
309
- this.setTitle = data.setTitle;
310
- this.ignoreInTotals = data.ignoreInTotals ?? false;
311
- this.partials = data.partials?.map((data2) => {
312
- if (__privateGet$2(this, _partialsIndex)[data2.key] !== void 0) throw new Error(`Duplicate badge partial key [${data2.key}]`);
313
- const badge = new BadgePartial(data2);
314
- __privateGet$2(this, _partialsIndex)[badge.key] = badge;
315
- return badge;
316
- });
317
- }
318
- getPartial(key) {
319
- const result = __privateGet$2(this, _partialsIndex)[key];
320
- if (result === void 0) throw new Error(`Unknown badge partial key [${key}]`);
321
- return result;
322
- }
323
- }
324
- _partialsIndex = new WeakMap();
829
+ __publicField$5(this, "description");
830
+ /**
831
+ * Url for the repository where the bundle is maintained.
832
+ */
833
+ __publicField$5(this, "repositoryUrl");
834
+ /**
835
+ * Url for the location of the changelog.
836
+ */
837
+ __publicField$5(this, "changelogUrl");
838
+ /**
839
+ * List of external links. Wiki, forums, etc.
840
+ */
841
+ __publicField$5(this, "links");
842
+ if (!data) throw new Error("Missing header data");
843
+ this.name = data.name;
844
+ this.version = data.version;
845
+ this.lastUpdateTime = toDate(data.lastUpdateTime);
846
+ this.description = data?.description;
847
+ this.repositoryUrl = data?.repositoryUrl;
848
+ this.changelogUrl = data?.changelogUrl;
849
+ this.links = data?.links ?? [];
850
+ }
851
+ }
852
+
853
+ var __defProp$4 = Object.defineProperty;
854
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
855
+ var __publicField$4 = (obj, key, value) => __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
856
+ class LevelRange {
857
+ constructor(value) {
858
+ __publicField$4(this, "min");
859
+ __publicField$4(this, "max");
860
+ if (Array.isArray(value)) {
861
+ this.min = value[0];
862
+ this.max = value[1] === void 0 ? void 0 : value[1];
863
+ } else {
864
+ this.min = value;
865
+ }
866
+ }
867
+ }
325
868
 
326
869
  var __defProp$3 = Object.defineProperty;
327
870
  var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
328
871
  var __publicField$3 = (obj, key, value) => __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
329
- class VidiotMapPointOfInterest {
872
+ class Zone {
330
873
  constructor(data) {
331
874
  /**
332
- * The pixel-space position of the PoI on the map graphic.
875
+ * Unique key used to reference this zone.
333
876
  *
334
- * Screen-space, pixels from top-left `[0, 0]`.
877
+ * Keys must be unique and can only contain lowercase letters, numbers and hyphens (`-`).
335
878
  */
336
- __publicField$3(this, "pos");
879
+ __publicField$3(this, "key");
337
880
  /**
338
- * Freeform notes about the PoI.
339
- *
340
- * Supports {@link https://www.markdownguide.org/|Markdown} format.
881
+ * The name of the zone as it appears in-game.
341
882
  */
342
- __publicField$3(this, "notes");
883
+ __publicField$3(this, "name");
884
+ /**
885
+ * The type of zone.
886
+ */
887
+ __publicField$3(this, "type");
888
+ /**
889
+ * The character moralities that this zone is accessible by.
890
+ */
891
+ __publicField$3(this, "morality");
343
892
  /**
344
- * If the POI is a zone transfer, the map it transfers to.
893
+ * The level range this zone is recommended for.
345
894
  */
346
- __publicField$3(this, "mapKey");
895
+ __publicField$3(this, "levelRange");
347
896
  /**
348
- * If the POI is a badge, the badge.
897
+ * Freeform notes or tips about the zone.
349
898
  */
350
- __publicField$3(this, "badgeKey");
899
+ __publicField$3(this, "notes");
351
900
  /**
352
- * If the POI is a partial for a badge, the partial key.
901
+ * List of external links. Wiki, forums, etc.
353
902
  */
354
- __publicField$3(this, "badgePartialKey");
355
- this.pos = data.pos;
903
+ __publicField$3(this, "links");
904
+ this.key = new Key(data.key).value;
905
+ this.name = data.name;
906
+ this.type = data.type;
907
+ this.morality = new MoralityList(coalesceToArray(data.morality));
908
+ this.levelRange = data.levelRange ? new LevelRange(data.levelRange) : void 0;
356
909
  this.notes = data.notes;
357
- this.mapKey = data.mapKey;
358
- this.badgeKey = data.badgeKey;
359
- this.badgePartialKey = data.badgePartialKey;
910
+ this.links = data.links ?? [];
360
911
  }
361
912
  }
362
913
 
363
914
  var __defProp$2 = Object.defineProperty;
364
915
  var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
365
916
  var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
366
- class VidiotMap {
917
+ class Contact {
367
918
  constructor(data) {
368
919
  /**
369
- * URL of the map image.
920
+ * Unique key used to reference this contact.
921
+ *
922
+ * Keys must be unique and can only contain lowercase letters, numbers and hyphens (`-`).
370
923
  */
371
- __publicField$2(this, "imageUrl");
924
+ __publicField$2(this, "key");
372
925
  /**
373
- * Name to display for the Vidiot map.
926
+ * The name of this contact.
374
927
  */
375
928
  __publicField$2(this, "name");
376
929
  /**
377
- * List of Points of Interest labelled on the image.
930
+ * The contact's title.
378
931
  */
379
- __publicField$2(this, "pointsOfInterest");
380
- this.imageUrl = data.imageUrl;
381
- this.name = data.name;
382
- this.pointsOfInterest = data.pointsOfInterest?.map((data2) => new VidiotMapPointOfInterest(data2));
383
- }
384
- }
385
-
386
- var __defProp$1 = Object.defineProperty;
387
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
388
- var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
389
- class GameMap {
390
- constructor(data) {
932
+ __publicField$2(this, "title");
391
933
  /**
392
- * The database key for this map.
934
+ * The character moralities that this contact will interact with.
393
935
  */
394
- __publicField$1(this, "key");
936
+ __publicField$2(this, "morality");
395
937
  /**
396
- * The name of the map as it appears in-game.
938
+ * The location of this contact.
397
939
  */
398
- __publicField$1(this, "name");
940
+ __publicField$2(this, "location");
399
941
  /**
400
- * List of external links for this Map. Wiki, forums, etc.
942
+ * The level range this contact will offer missions for.
401
943
  */
402
- __publicField$1(this, "links");
944
+ __publicField$2(this, "levelRange");
403
945
  /**
404
- * List of Vidiot Map assets for this map.
946
+ * Freeform notes or tips about the contact.
405
947
  */
406
- __publicField$1(this, "vidiotMaps");
948
+ __publicField$2(this, "notes");
949
+ /**
950
+ * List of external links. Wiki, forums, etc.
951
+ */
952
+ __publicField$2(this, "links");
407
953
  this.key = new Key(data.key).value;
408
954
  this.name = data.name;
409
- this.links = data.links;
410
- this.vidiotMaps = data.vidiotMaps?.map((data2) => new VidiotMap(data2));
955
+ this.title = data.title;
956
+ this.morality = new MoralityList(coalesceToArray(data.morality));
957
+ this.location = data.location;
958
+ this.levelRange = data.levelRange ? new LevelRange(data.levelRange) : void 0;
959
+ this.notes = data.notes;
960
+ this.links = data.links ?? [];
411
961
  }
412
962
  }
413
963
 
414
- var __defProp = Object.defineProperty;
415
- var __typeError$1 = (msg) => {
416
- throw TypeError(msg);
417
- };
418
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
419
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
420
- var __accessCheck$1 = (obj, member, msg) => member.has(obj) || __typeError$1("Cannot " + msg);
421
- var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
422
- var __privateAdd$1 = (obj, member, value) => member.has(obj) ? __typeError$1("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
423
- var _archetypeIndex, _mapIndex, _badgeIndex;
424
- class ServerGroup {
964
+ var __defProp$1 = Object.defineProperty;
965
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
966
+ var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
967
+ class Mission {
425
968
  constructor(data) {
426
- __privateAdd$1(this, _archetypeIndex, {});
427
- __privateAdd$1(this, _mapIndex, {});
428
- __privateAdd$1(this, _badgeIndex, {});
429
- /**
430
- * The database key for this server group.
431
- */
432
- __publicField(this, "key");
433
969
  /**
434
- * Name of the server group.
970
+ * Unique key used to reference this mission.
971
+ *
972
+ * Keys must be unique and can only contain lowercase letters, numbers and hyphens (`-`).
435
973
  */
436
- __publicField(this, "name");
974
+ __publicField$1(this, "key");
437
975
  /**
438
- * Description of the server group.
976
+ * The name of the mission as it appears from the contact.
439
977
  *
440
- * Supports {@link https://www.markdownguide.org/|Markdown} format.
978
+ * The name may be different when viewed in Ouroboros as a Flashback.
441
979
  */
442
- __publicField(this, "description");
980
+ __publicField$1(this, "name");
443
981
  /**
444
- * Repository where the db content package is maintained.
982
+ * The type of mission... Story arc, task force, trial, etc.
445
983
  */
446
- __publicField(this, "repository");
984
+ __publicField$1(this, "type");
447
985
  /**
448
- * List of external links for this Server Group. Wiki, forums, etc.
986
+ * The character moralities that may accept the mission.
449
987
  */
450
- __publicField(this, "links");
988
+ __publicField$1(this, "morality");
451
989
  /**
452
- * List of the game server names in this server group.
453
- * Torchbearer, Excelsior, etc.
990
+ * The keys of any contacts that provide this mission.
454
991
  */
455
- __publicField(this, "servers");
992
+ __publicField$1(this, "contactKeys");
456
993
  /**
457
- * List of archetypes available in this server group.
994
+ * The level range this mission is available for.
458
995
  */
459
- __publicField(this, "archetypes");
996
+ __publicField$1(this, "levelRange");
460
997
  /**
461
- * List of game maps supported by this server group.
998
+ * Freeform notes or tips about the mission.
462
999
  */
463
- __publicField(this, "maps");
1000
+ __publicField$1(this, "notes");
464
1001
  /**
465
- * List of badges available on this server group.
1002
+ * List of external links. Wiki, forums, etc.
466
1003
  */
467
- __publicField(this, "badges");
1004
+ __publicField$1(this, "links");
468
1005
  /**
469
- * Change log for this data package.
1006
+ * If the mission is available in Ouroboros as a Flashback.
470
1007
  */
471
- __publicField(this, "changelog");
1008
+ __publicField$1(this, "flashback");
472
1009
  this.key = new Key(data.key).value;
473
1010
  this.name = data.name;
474
- this.description = data.description;
475
- this.repository = data.repository;
476
- this.links = data.links;
477
- this.servers = data.servers ?? [];
478
- this.archetypes = data.archetypes?.map((data2) => {
479
- if (__privateGet$1(this, _archetypeIndex)[data2.key] !== void 0) throw new Error(`Duplicate archetype key [${data2.key}]`);
480
- const archetype = new Archetype(data2);
481
- __privateGet$1(this, _archetypeIndex)[archetype.key] = archetype;
482
- return archetype;
483
- }) ?? [];
484
- this.maps = data.maps?.map((data2) => {
485
- if (__privateGet$1(this, _mapIndex)[data2.key] !== void 0) throw new Error(`Duplicate map key [${data2.key}]`);
486
- const map = new GameMap(data2);
487
- __privateGet$1(this, _mapIndex)[map.key] = map;
488
- return map;
489
- }) ?? [];
490
- this.badges = data.badges?.map((data2) => {
491
- if (__privateGet$1(this, _badgeIndex)[data2.key] !== void 0) throw new Error(`Duplicate badge key [${data2.key}]`);
492
- const badge = new Badge(data2);
493
- __privateGet$1(this, _badgeIndex)[badge.key] = badge;
494
- return badge;
495
- }) ?? [];
496
- this.changelog = data.changelog;
497
- }
498
- getArchetype(key) {
499
- const result = __privateGet$1(this, _archetypeIndex)[key];
500
- if (result === void 0) throw new Error(`Unknown archetype key [${key}]`);
501
- return result;
502
- }
503
- getMap(key) {
504
- const result = __privateGet$1(this, _mapIndex)[key];
505
- if (result === void 0) throw new Error(`Unknown map key [${key}]`);
506
- return result;
507
- }
508
- getBadge(key) {
509
- const result = __privateGet$1(this, _badgeIndex)[key];
510
- if (result === void 0) throw new Error(`Unknown badge key [${key}]`);
511
- return result;
1011
+ this.type = data.type;
1012
+ this.morality = new MoralityList(coalesceToArray(data.morality));
1013
+ this.contactKeys = coalesceToArray(data.contactKeys);
1014
+ this.levelRange = data.levelRange ? new LevelRange(data.levelRange) : void 0;
1015
+ this.notes = data.notes;
1016
+ this.links = data.links ?? [];
1017
+ this.flashback = createFlashback(data);
512
1018
  }
513
1019
  }
514
- _archetypeIndex = new WeakMap();
515
- _mapIndex = new WeakMap();
516
- _badgeIndex = new WeakMap();
1020
+ function createFlashback(data) {
1021
+ if (!data.flashback) return void 0;
1022
+ return {
1023
+ id: data.flashback.id,
1024
+ levelRange: data.flashback.levelRange ? new LevelRange(data.flashback.levelRange) : void 0,
1025
+ name: data.flashback.name ?? data.name,
1026
+ morality: new MoralityList(coalesceToArray(data.flashback.morality ?? data.morality)),
1027
+ notes: data.flashback.notes
1028
+ };
1029
+ }
517
1030
 
518
1031
  var __typeError = (msg) => {
519
1032
  throw TypeError(msg);
@@ -521,67 +1034,224 @@ var __typeError = (msg) => {
521
1034
  var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
522
1035
  var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
523
1036
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
524
- var _serverGroups;
1037
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
1038
+ var _archetypeIndex, _zoneIndex, _contactIndex, _missionIndex, _badgeIndex, _header, _servers;
525
1039
  class CohContentDatabase {
526
- constructor() {
527
- __privateAdd(this, _serverGroups, {});
1040
+ /**
1041
+ * Create a db instance from the given content bundle.
1042
+ * @param bundle The bundle to load.
1043
+ */
1044
+ constructor(bundle) {
1045
+ __privateAdd(this, _archetypeIndex);
1046
+ __privateAdd(this, _zoneIndex);
1047
+ __privateAdd(this, _contactIndex);
1048
+ __privateAdd(this, _missionIndex);
1049
+ __privateAdd(this, _badgeIndex);
1050
+ __privateAdd(this, _header);
1051
+ __privateAdd(this, _servers);
1052
+ __privateSet(this, _header, new BundleHeader(bundle.header));
1053
+ __privateSet(this, _servers, bundle.servers ?? []);
1054
+ __privateSet(this, _archetypeIndex, new AbstractIndex("key", bundle.archetypes?.map((x) => new Archetype(x))));
1055
+ __privateSet(this, _zoneIndex, new AbstractIndex("key", bundle.zones?.map((x) => new Zone(x))));
1056
+ __privateSet(this, _contactIndex, new AbstractIndex("key", bundle.contacts?.map((x) => new Contact(x))));
1057
+ __privateSet(this, _missionIndex, new AbstractIndex("key", bundle.missions?.map((x) => new Mission(x))));
1058
+ __privateSet(this, _badgeIndex, new BadgeIndex(bundle.badges?.map((x) => new Badge(x))));
1059
+ }
1060
+ /**
1061
+ * Header information about the content bundle.
1062
+ */
1063
+ get header() {
1064
+ return __privateGet(this, _header);
1065
+ }
1066
+ /**
1067
+ * List of the game server names.
1068
+ *
1069
+ * Torchbearer, Excelsior, etc.
1070
+ */
1071
+ get servers() {
1072
+ return __privateGet(this, _servers);
1073
+ }
1074
+ /**
1075
+ * List of archetypes.
1076
+ */
1077
+ get archetypes() {
1078
+ return __privateGet(this, _archetypeIndex).values;
1079
+ }
1080
+ /**
1081
+ * Get archetype by key.
1082
+ * @param key The key.
1083
+ */
1084
+ getArchetype(key) {
1085
+ return __privateGet(this, _archetypeIndex).get(key);
1086
+ }
1087
+ /**
1088
+ * List of game zones.
1089
+ */
1090
+ get zones() {
1091
+ return __privateGet(this, _zoneIndex).values;
528
1092
  }
529
1093
  /**
530
- * Load a server group data package into the database.
531
- * @param data The data to load.
1094
+ * Get zone by key.
1095
+ * @param key The key.
532
1096
  */
533
- loadServerGroupData(data) {
534
- __privateGet(this, _serverGroups)[data.key] = new ServerGroup(data);
1097
+ getZone(key) {
1098
+ return __privateGet(this, _zoneIndex).get(key);
535
1099
  }
536
1100
  /**
537
- * Get all the server groups currently loaded in the database.
1101
+ * List of contacts.
538
1102
  */
539
- listServerGroups() {
540
- return Object.values(__privateGet(this, _serverGroups));
1103
+ get contacts() {
1104
+ return __privateGet(this, _contactIndex).values;
541
1105
  }
542
1106
  /**
543
- * get a server group by key.
544
- * @param serverGroupKey The key.
1107
+ * Get contact by key.
1108
+ * @param key The key.
545
1109
  */
546
- getServerGroup(serverGroupKey) {
547
- return __privateGet(this, _serverGroups)[serverGroupKey];
1110
+ getContact(key) {
1111
+ return __privateGet(this, _contactIndex).get(key);
1112
+ }
1113
+ /**
1114
+ * List of missions.
1115
+ */
1116
+ get missions() {
1117
+ return __privateGet(this, _missionIndex).values;
1118
+ }
1119
+ /**
1120
+ * Get mission by key.
1121
+ * @param key The key.
1122
+ */
1123
+ getMission(key) {
1124
+ return __privateGet(this, _missionIndex).get(key);
1125
+ }
1126
+ /**
1127
+ * List of badges.
1128
+ */
1129
+ get badges() {
1130
+ return __privateGet(this, _badgeIndex).values;
1131
+ }
1132
+ /**
1133
+ * Get badge by key.
1134
+ * @param key The key.
1135
+ */
1136
+ getBadge(key) {
1137
+ return __privateGet(this, _badgeIndex).get(key);
1138
+ }
1139
+ /**
1140
+ * Search, sort and filter the badge list.
1141
+ * This is a fairly brute-forced approach and will not be as performant as loading the badge data into a traditional
1142
+ * database engine, but is sufficient for most operations.
1143
+ * @param options {@link BadgeSearchOptions}
1144
+ */
1145
+ searchBadges(options) {
1146
+ return __privateGet(this, _badgeIndex).search(options);
548
1147
  }
549
1148
  }
550
- _serverGroups = new WeakMap();
1149
+ _archetypeIndex = new WeakMap();
1150
+ _zoneIndex = new WeakMap();
1151
+ _contactIndex = new WeakMap();
1152
+ _missionIndex = new WeakMap();
1153
+ _badgeIndex = new WeakMap();
1154
+ _header = new WeakMap();
1155
+ _servers = new WeakMap();
551
1156
 
552
- const CHANGELOG = [
553
- {
554
- version: "2.0.0",
555
- date: /* @__PURE__ */ new Date("2025-03-12"),
556
- description: "* Replaced redundant interfaces with their concrete equivalents.\n* Replaced enums with extensible union types; Server groups with new badge types, enhancement types, etc. can now extend them locally.\n* Removed the `serverGroup` property from entities to simplify the object tree; Server group context will need to be managed separately.\n* Standardized pluralization of some field names (name, icon).\n* Combined `settitle` ids into a single tuple field.\n* Change from GNU to The Unlicense.\n* Removed dependency on lodash. There are now no third-party runtime dependencies.\n* Moved from webpack to rollup for packaging.\n* Add eslint for linting.\n* Add jest for unit tests.\n* Added GitHub Actions for CI.\n"
1157
+ var __defProp = Object.defineProperty;
1158
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1159
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
1160
+ class Location {
1161
+ constructor(data) {
1162
+ /**
1163
+ * Key of the {@link Zone} that the location references.
1164
+ */
1165
+ __publicField(this, "zoneKey");
1166
+ /**
1167
+ * In-game `/loc` coordinates of the location.
1168
+ */
1169
+ __publicField(this, "coords");
1170
+ /**
1171
+ * The type of icon to use if the location appears on a map. (Typically the Vidiot map icon).
1172
+ */
1173
+ __publicField(this, "icon");
1174
+ /**
1175
+ * The text that should appear in the location icon. (Typically a number or symbol from the Vidiot map).
1176
+ */
1177
+ __publicField(this, "iconText");
1178
+ this.zoneKey = data.zoneKey;
1179
+ this.coords = data.coords;
1180
+ this.icon = data.icon;
1181
+ this.iconText = data.iconText;
557
1182
  }
558
- ];
1183
+ }
559
1184
 
560
- function createBadgeReference(target) {
1185
+ function badgeUri(target) {
1186
+ const key = typeof target === "string" ? target : target.key;
1187
+ return `badge://${key}`;
1188
+ }
1189
+ function badgeLink(target) {
1190
+ const key = typeof target === "string" ? target : target.key;
1191
+ return `[${key}](${badgeUri(target)})`;
1192
+ }
1193
+ function contactUri(target) {
1194
+ const key = typeof target === "string" ? target : target.key;
1195
+ return `contact://${key}`;
1196
+ }
1197
+ function contactLink(target) {
1198
+ const key = typeof target === "string" ? target : target.key;
1199
+ return `[${key}](${contactUri(target)})`;
1200
+ }
1201
+ function missionUri(target) {
1202
+ const key = typeof target === "string" ? target : target.key;
1203
+ return `mission://${key}`;
1204
+ }
1205
+ function missionLink(target) {
1206
+ const key = typeof target === "string" ? target : target.key;
1207
+ return `[${key}](${missionUri(target)})`;
1208
+ }
1209
+ function zoneUri(target) {
561
1210
  const key = typeof target === "string" ? target : target.key;
562
- return `[badge:${key}]`;
1211
+ return `zone://${key}`;
563
1212
  }
564
- function createMapReference(target) {
1213
+ function zoneLink(target) {
565
1214
  const key = typeof target === "string" ? target : target.key;
566
- return `[map:${key}]`;
1215
+ return `[${key}](${zoneUri(target)})`;
567
1216
  }
568
1217
 
569
1218
  exports.ALIGNMENT = ALIGNMENT;
1219
+ exports.AlignmentList = AlignmentList;
570
1220
  exports.Archetype = Archetype;
571
- exports.BADGE_PARTIAL_TYPE = BADGE_PARTIAL_TYPE;
1221
+ exports.BADGE_REQUIREMENT_TYPE = BADGE_REQUIREMENT_TYPE;
572
1222
  exports.BADGE_TYPE = BADGE_TYPE;
573
1223
  exports.Badge = Badge;
574
- exports.BadgePartial = BadgePartial;
575
- exports.CHANGELOG = CHANGELOG;
1224
+ exports.BadgeIndex = BadgeIndex;
1225
+ exports.BadgeRequirement = BadgeRequirement;
1226
+ exports.BundleHeader = BundleHeader;
576
1227
  exports.CohContentDatabase = CohContentDatabase;
1228
+ exports.Contact = Contact;
577
1229
  exports.ENHANCEMENT_CATEGORY = ENHANCEMENT_CATEGORY;
578
- exports.GameMap = GameMap;
579
1230
  exports.Key = Key;
580
- exports.PLAQUE_TYPE = PLAQUE_TYPE;
1231
+ exports.LevelRange = LevelRange;
1232
+ exports.Location = Location;
1233
+ exports.MISSION_TYPE = MISSION_TYPE;
1234
+ exports.MORALITY = MORALITY;
1235
+ exports.MORALITY_EXTENDED = MORALITY_EXTENDED;
1236
+ exports.Mission = Mission;
1237
+ exports.MoralityList = MoralityList;
1238
+ exports.MoralityMap = MoralityMap;
581
1239
  exports.SEX = SEX;
582
- exports.ServerGroup = ServerGroup;
583
- exports.VidiotMap = VidiotMap;
584
- exports.VidiotMapPointOfInterest = VidiotMapPointOfInterest;
585
- exports.createBadgeReference = createBadgeReference;
586
- exports.createMapReference = createMapReference;
1240
+ exports.SetTitleIds = SetTitleIds;
1241
+ exports.Variants = Variants;
1242
+ exports.ZONE_TYPE = ZONE_TYPE;
1243
+ exports.Zone = Zone;
1244
+ exports.badgeLink = badgeLink;
1245
+ exports.badgeUri = badgeUri;
1246
+ exports.compareAlignment = compareAlignment;
1247
+ exports.compareByName = compareByName;
1248
+ exports.compareByReleaseDate = compareByReleaseDate;
1249
+ exports.compareByZoneKey = compareByZoneKey;
1250
+ exports.compareSex = compareSex;
1251
+ exports.contactLink = contactLink;
1252
+ exports.contactUri = contactUri;
1253
+ exports.missionLink = missionLink;
1254
+ exports.missionUri = missionUri;
1255
+ exports.zoneLink = zoneLink;
1256
+ exports.zoneUri = zoneUri;
587
1257
  //# sourceMappingURL=coh-content-db.js.map