coh-content-db 2.0.0-rc.4 → 2.0.0-rc.6

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 (64) hide show
  1. package/README.md +31 -7
  2. package/dist/coh-content-db.d.ts +353 -185
  3. package/dist/coh-content-db.js +460 -300
  4. package/dist/coh-content-db.js.map +1 -1
  5. package/dist/coh-content-db.mjs +448 -294
  6. package/dist/coh-content-db.mjs.map +1 -1
  7. package/package.json +1 -4
  8. package/src/main/api/alternate-data.ts +2 -2
  9. package/src/main/api/badge-data.ts +21 -19
  10. package/src/main/api/badge-requirement-data.ts +82 -0
  11. package/src/main/api/badge-requirement-type.ts +11 -0
  12. package/src/main/api/change.ts +5 -2
  13. package/src/main/api/contact-data.ts +46 -0
  14. package/src/main/api/content-bundle.ts +12 -7
  15. package/src/main/api/markdown-string.ts +4 -0
  16. package/src/main/api/zone-data.ts +20 -0
  17. package/src/main/changelog.ts +7 -2
  18. package/src/main/db/alignments.ts +17 -0
  19. package/src/main/db/alternates.ts +8 -14
  20. package/src/main/db/badge-index.ts +93 -0
  21. package/src/main/db/badge-requirement.ts +102 -0
  22. package/src/main/db/badge-search-options.ts +51 -0
  23. package/src/main/db/badge.ts +55 -48
  24. package/src/main/db/bundle-metadata.ts +5 -6
  25. package/src/main/db/coh-content-database.ts +65 -40
  26. package/src/main/db/contact.ts +59 -0
  27. package/src/main/db/paged.ts +7 -0
  28. package/src/main/db/zone.ts +28 -0
  29. package/src/main/index.ts +15 -11
  30. package/src/main/util.ts +68 -7
  31. package/src/test/api/alignments.test.ts +40 -0
  32. package/src/test/api/badge-data.fixture.ts +9 -7
  33. package/src/test/api/badge-requirement-data.fixture.ts +17 -0
  34. package/src/test/api/badge-requirement-type.test.ts +31 -0
  35. package/src/test/api/contact-data.fixture.ts +13 -0
  36. package/src/test/api/content-bundle.fixture.ts +2 -2
  37. package/src/test/api/content-bundle.test.ts +1 -1
  38. package/src/test/api/zone-data.fixture.ts +8 -0
  39. package/src/test/db/alternates.test.ts +16 -74
  40. package/src/test/db/badge-index.test.ts +520 -0
  41. package/src/test/db/badge-requirement.test.ts +180 -0
  42. package/src/test/db/badge.test.ts +190 -15
  43. package/src/test/db/coh-content-database.test.ts +125 -18
  44. package/src/test/db/contact.test.ts +96 -0
  45. package/src/test/db/zone.test.ts +36 -0
  46. package/src/test/index.test.ts +6 -2
  47. package/src/test/util.test.ts +91 -18
  48. package/src/main/api/badge-partial-data.ts +0 -65
  49. package/src/main/api/badge-partial-type.ts +0 -8
  50. package/src/main/api/game-map-data.ts +0 -26
  51. package/src/main/api/vidiot-map-data.ts +0 -18
  52. package/src/main/api/vidiot-map-point-of-interest-data.ts +0 -30
  53. package/src/main/db/badge-partial.ts +0 -35
  54. package/src/main/db/badge-search-document.ts +0 -16
  55. package/src/main/db/game-map.ts +0 -33
  56. package/src/main/db/vidiot-map-point-of-interest.ts +0 -40
  57. package/src/main/db/vidiot-map.ts +0 -25
  58. package/src/test/api/badge-partial-data.fixture.ts +0 -17
  59. package/src/test/api/badge-partial-type.test.ts +0 -31
  60. package/src/test/api/game-map-data.fixture.ts +0 -10
  61. package/src/test/api/vidiot-map-point-of-interest.fixture.ts +0 -10
  62. package/src/test/api/vidiot-map.fixture.ts +0 -9
  63. package/src/test/db/badge-search-document.test.ts +0 -35
  64. package/src/test/db/coh-content-database-search.test.ts +0 -119
@@ -1,13 +1,17 @@
1
1
  'use strict';
2
2
 
3
- var MiniSearch = require('minisearch');
4
-
5
3
  const ALIGNMENT = ["H", "V", "P"];
6
4
 
7
- const BADGE_PARTIAL_TYPE = [
5
+ const BADGE_REQUIREMENT_TYPE = [
8
6
  "PLAQUE",
9
7
  "BADGE",
10
8
  "INVENTION",
9
+ "MISSION",
10
+ // Complete a mission
11
+ "ARC",
12
+ // Complete a story arc
13
+ "TASK_FORCE",
14
+ // Complete a task force
11
15
  "INVENTION_PLUS_ONE"
12
16
  // Some invention badges require you to build x of two different invention levels, 'plus one of either level'.
13
17
  ];
@@ -66,115 +70,60 @@ const PLAQUE_TYPE = [
66
70
 
67
71
  const SEX = ["M", "F"];
68
72
 
69
- var __typeError$3 = (msg) => {
70
- throw TypeError(msg);
71
- };
72
- var __accessCheck$3 = (obj, member, msg) => member.has(obj) || __typeError$3("Cannot " + msg);
73
- var __privateGet$3 = (obj, member, getter) => (__accessCheck$3(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
74
- 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);
75
- var __privateSet$2 = (obj, member, value, setter) => (__accessCheck$3(obj, member, "write to private field"), member.set(obj, value), value);
76
- var __privateMethod$1 = (obj, member, method) => (__accessCheck$3(obj, member, "access private method"), method);
77
- var _value, _Key_instances, validateKey_fn;
78
- const INVALID_KEY_PATTERN = /[^a-z0-9-]/;
79
- class Key {
80
- constructor(value) {
81
- __privateAdd$3(this, _Key_instances);
82
- __privateAdd$3(this, _value);
83
- __privateMethod$1(this, _Key_instances, validateKey_fn).call(this, value);
84
- __privateSet$2(this, _value, value);
85
- }
86
- get value() {
87
- return __privateGet$3(this, _value);
88
- }
89
- }
90
- _value = new WeakMap();
91
- _Key_instances = new WeakSet();
92
- validateKey_fn = function(key) {
93
- if (INVALID_KEY_PATTERN.test(key)) throw new Error(`Invalid key: [${key}]; Keys can only contain lowercase characters, numbers and dashes.`);
94
- };
95
-
96
- var __defProp$8 = Object.defineProperty;
97
- var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
98
- var __publicField$8 = (obj, key, value) => __defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
99
- class Archetype {
100
- constructor(data) {
101
- __publicField$8(this, "key");
102
- __publicField$8(this, "name");
103
- __publicField$8(this, "description");
104
- this.key = new Key(data.key).value;
105
- this.name = data.name;
106
- this.description = data.description;
107
- }
108
- }
109
-
110
73
  var __defProp$7 = Object.defineProperty;
111
74
  var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
112
75
  var __publicField$7 = (obj, key, value) => __defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
113
- class BadgePartial {
114
- constructor(data) {
115
- __publicField$7(this, "key");
116
- __publicField$7(this, "type");
117
- __publicField$7(this, "mapKey");
118
- __publicField$7(this, "loc");
119
- __publicField$7(this, "plaqueType");
120
- __publicField$7(this, "inscription");
121
- __publicField$7(this, "vidiotMapKey");
122
- __publicField$7(this, "badgeKey");
123
- __publicField$7(this, "inventionLevel");
124
- __publicField$7(this, "inventionTypes");
125
- __publicField$7(this, "inventionCount");
126
- __publicField$7(this, "notes");
127
- this.key = new Key(data.key).value;
128
- this.type = data.type;
129
- this.mapKey = data.mapKey;
130
- this.loc = data.loc;
131
- this.plaqueType = data.plaqueType;
132
- this.inscription = data.inscription;
133
- this.vidiotMapKey = data.vidiotMapKey;
134
- this.badgeKey = data.badgeKey;
135
- this.inventionLevel = data.inventionLevel;
136
- this.inventionTypes = data.inventionTypes;
137
- this.inventionCount = data.inventionCount;
138
- this.notes = data.notes;
76
+ class Alignments {
77
+ constructor(raw) {
78
+ __publicField$7(this, "items");
79
+ __publicField$7(this, "hero");
80
+ __publicField$7(this, "villain");
81
+ __publicField$7(this, "praetorian");
82
+ __publicField$7(this, "primal");
83
+ this.items = raw;
84
+ this.hero = raw.includes("H");
85
+ this.villain = raw.includes("V");
86
+ this.praetorian = raw.includes("P");
87
+ this.primal = !this.praetorian && (this.hero || this.villain);
139
88
  }
140
89
  }
141
90
 
142
- var __typeError$2 = (msg) => {
91
+ var __typeError$4 = (msg) => {
143
92
  throw TypeError(msg);
144
93
  };
145
- var __accessCheck$2 = (obj, member, msg) => member.has(obj) || __typeError$2("Cannot " + msg);
146
- var __privateGet$2 = (obj, member, getter) => (__accessCheck$2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
147
- 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);
148
- var __privateSet$1 = (obj, member, value, setter) => (__accessCheck$2(obj, member, "write to private field"), member.set(obj, value), value);
149
- var __privateMethod = (obj, member, method) => (__accessCheck$2(obj, member, "access private method"), method);
94
+ var __accessCheck$4 = (obj, member, msg) => member.has(obj) || __typeError$4("Cannot " + msg);
95
+ var __privateGet$4 = (obj, member, getter) => (__accessCheck$4(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
96
+ 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);
97
+ var __privateSet$3 = (obj, member, value, setter) => (__accessCheck$4(obj, member, "write to private field"), member.set(obj, value), value);
98
+ var __privateMethod$2 = (obj, member, method) => (__accessCheck$4(obj, member, "access private method"), method);
150
99
  var _sortedValues, _Alternates_instances, compareAlternates_fn, compareAlignment_fn, compareSex_fn;
151
100
  const ALIGNMENT_SORT = { H: 2, V: 1, P: 0 };
152
101
  const SEX_SORT = { M: 1, F: 0 };
153
102
  class Alternates {
154
103
  constructor(values) {
155
- __privateAdd$2(this, _Alternates_instances);
156
- __privateAdd$2(this, _sortedValues, []);
157
- __privateSet$1(this, _sortedValues, values.sort());
158
- __privateGet$2(this, _sortedValues).sort((a, b) => __privateMethod(this, _Alternates_instances, compareAlternates_fn).call(this, a, b));
104
+ __privateAdd$4(this, _Alternates_instances);
105
+ __privateAdd$4(this, _sortedValues, []);
106
+ __privateSet$3(this, _sortedValues, values.sort());
107
+ __privateGet$4(this, _sortedValues).sort((a, b) => __privateMethod$2(this, _Alternates_instances, compareAlternates_fn).call(this, a, b));
159
108
  }
160
109
  getValue(alignment, sex) {
161
- for (let index = __privateGet$2(this, _sortedValues).length; index--; ) {
162
- const entry = __privateGet$2(this, _sortedValues)[index];
110
+ for (let index = __privateGet$4(this, _sortedValues).length; index--; ) {
111
+ const entry = __privateGet$4(this, _sortedValues)[index];
163
112
  if ((entry.alignment === void 0 || entry.alignment === alignment) && (entry.sex === void 0 || entry.sex === sex)) return entry.value;
164
113
  }
165
- return this.default;
114
+ return this.default?.value;
166
115
  }
167
116
  /**
168
117
  * Get the default value for this list of alternates, the value with the highest priority and lowest specificity.
169
118
  */
170
119
  get default() {
171
- return __privateGet$2(this, _sortedValues)[0]?.value;
120
+ return __privateGet$4(this, _sortedValues)[0];
172
121
  }
173
122
  /**
174
123
  * Get the list of alternates sorted in canonical order (alignment then sex, low to high specificity).
175
124
  */
176
125
  get canonical() {
177
- return __privateGet$2(this, _sortedValues);
126
+ return __privateGet$4(this, _sortedValues);
178
127
  }
179
128
  /**
180
129
  * Create a joined string from the alternate values in canonical order.
@@ -190,9 +139,9 @@ compareAlternates_fn = function(a, b) {
190
139
  const aSpecificity = (a.alignment ? 2 : 0) + (a.sex ? 1 : 0);
191
140
  const bSpecificity = (b.alignment ? 2 : 0) + (b.sex ? 1 : 0);
192
141
  if (aSpecificity !== bSpecificity) return aSpecificity - bSpecificity;
193
- const alignmentComparison = __privateMethod(this, _Alternates_instances, compareAlignment_fn).call(this, a.alignment, b.alignment);
142
+ const alignmentComparison = __privateMethod$2(this, _Alternates_instances, compareAlignment_fn).call(this, a.alignment, b.alignment);
194
143
  if (alignmentComparison !== 0) return alignmentComparison;
195
- const sexComparison = __privateMethod(this, _Alternates_instances, compareSex_fn).call(this, a.sex, b.sex);
144
+ const sexComparison = __privateMethod$2(this, _Alternates_instances, compareSex_fn).call(this, a.sex, b.sex);
196
145
  if (sexComparison !== 0) return sexComparison;
197
146
  return String(a.value).localeCompare(String(b.value));
198
147
  };
@@ -202,8 +151,7 @@ compareAlignment_fn = function(a, b) {
202
151
  if (b === void 0 && a !== void 0) return 1;
203
152
  const aSort = a === void 0 ? -1 : ALIGNMENT_SORT[a] ?? -1;
204
153
  const bSort = b === void 0 ? -1 : ALIGNMENT_SORT[b] ?? -1;
205
- if (aSort !== bSort) return bSort - aSort;
206
- return a?.localeCompare(b ?? "") ?? 0;
154
+ return bSort - aSort;
207
155
  };
208
156
  compareSex_fn = function(a, b) {
209
157
  if (a === b) return 0;
@@ -211,242 +159,353 @@ compareSex_fn = function(a, b) {
211
159
  if (b === void 0 && a !== void 0) return 1;
212
160
  const aSort = SEX_SORT[a ?? -1] ?? -1;
213
161
  const bSort = SEX_SORT[b ?? -1] ?? -1;
214
- if (aSort !== bSort) return bSort - aSort;
215
- return a?.localeCompare(b ?? "") ?? 0;
162
+ return bSort - aSort;
216
163
  };
217
164
 
218
- var __defProp$6 = Object.defineProperty;
219
- var __typeError$1 = (msg) => {
165
+ var __typeError$3 = (msg) => {
220
166
  throw TypeError(msg);
221
167
  };
168
+ var __accessCheck$3 = (obj, member, msg) => member.has(obj) || __typeError$3("Cannot " + msg);
169
+ var __privateGet$3 = (obj, member, getter) => (__accessCheck$3(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
170
+ 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);
171
+ var __privateSet$2 = (obj, member, value, setter) => (__accessCheck$3(obj, member, "write to private field"), member.set(obj, value), value);
172
+ var __privateMethod$1 = (obj, member, method) => (__accessCheck$3(obj, member, "access private method"), method);
173
+ var _value, _Key_instances, validateKey_fn;
174
+ const INVALID_KEY_PATTERN = /[^a-z0-9-]/;
175
+ class Key {
176
+ constructor(value) {
177
+ __privateAdd$3(this, _Key_instances);
178
+ __privateAdd$3(this, _value);
179
+ __privateMethod$1(this, _Key_instances, validateKey_fn).call(this, value);
180
+ __privateSet$2(this, _value, value);
181
+ }
182
+ get value() {
183
+ return __privateGet$3(this, _value);
184
+ }
185
+ }
186
+ _value = new WeakMap();
187
+ _Key_instances = new WeakSet();
188
+ validateKey_fn = function(key) {
189
+ if (INVALID_KEY_PATTERN.test(key)) throw new Error(`Invalid key: [${key}]; Keys can only contain lowercase characters, numbers and dashes.`);
190
+ };
191
+
192
+ var __defProp$6 = Object.defineProperty;
222
193
  var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
223
194
  var __publicField$6 = (obj, key, value) => __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
224
- var __accessCheck$1 = (obj, member, msg) => member.has(obj) || __typeError$1("Cannot " + msg);
225
- var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
226
- 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);
227
- var _partialsIndex;
228
- class Badge {
195
+ class Archetype {
229
196
  constructor(data) {
230
- __privateAdd$1(this, _partialsIndex, {});
231
- /**
232
- * The database key for this badge.
233
- */
234
197
  __publicField$6(this, "key");
198
+ __publicField$6(this, "name");
199
+ __publicField$6(this, "description");
200
+ this.key = new Key(data.key).value;
201
+ this.name = data.name;
202
+ this.description = data.description;
203
+ }
204
+ }
205
+
206
+ var __defProp$5 = Object.defineProperty;
207
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
208
+ var __publicField$5 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
209
+ class BadgeRequirement {
210
+ constructor(data) {
235
211
  /**
236
- * The type of badge.
212
+ * Key.
237
213
  */
238
- __publicField$6(this, "type");
214
+ __publicField$5(this, "key");
239
215
  /**
240
- * The name of this badge.
241
- *
242
- * May vary by character sex or alignment.
216
+ * Type of requirement.
243
217
  */
244
- __publicField$6(this, "name");
218
+ __publicField$5(this, "type");
245
219
  /**
246
- * The character alignments that this badge is available to.
220
+ * Zone the requirement is located in.
247
221
  */
248
- __publicField$6(this, "alignment");
222
+ __publicField$5(this, "zoneKey");
249
223
  /**
250
- * The badge text as it appears in-game. May vary by character sex or alignment.
224
+ * /loc coordinates.
251
225
  */
252
- __publicField$6(this, "badgeText");
226
+ __publicField$5(this, "loc");
253
227
  /**
254
- * Description of how to acquire the badge.
255
- *
256
- * Supports {@link https://www.markdownguide.org/|Markdown} format.
228
+ * Is it a wall plaque or a physical monument?
257
229
  */
258
- __publicField$6(this, "acquisition");
230
+ __publicField$5(this, "plaqueType");
259
231
  /**
260
- * Absolute URL to this badge's icon.
261
- *
262
- * May vary by character sex or alignment.
232
+ * Plaque inscription.
263
233
  */
264
- __publicField$6(this, "icon");
234
+ __publicField$5(this, "plaqueInscription");
265
235
  /**
266
- * Freeform notes or tips about the badge.
267
- *
268
- * Supports {@link https://www.markdownguide.org/|Markdown} format.
236
+ * The number or letter the plaque appears as on Vidiot Maps.
269
237
  */
270
- __publicField$6(this, "notes");
238
+ __publicField$5(this, "vidiotMapKey");
271
239
  /**
272
- * List of external links for this Badge. Wiki, forums, etc.
240
+ * The key of the badge for this requirement.
273
241
  */
274
- __publicField$6(this, "links");
242
+ __publicField$5(this, "badgeKey");
275
243
  /**
276
- * For exploration badges, the key of the {@link GameMap} that this badge is found on.
244
+ * Mission name.
277
245
  */
278
- __publicField$6(this, "mapKey");
246
+ __publicField$5(this, "missionName");
279
247
  /**
280
- * For exploration badges, the `/loc` coordinates of the badge on the in-game map.
248
+ * {@link Contact} key for the story arc.
281
249
  */
282
- __publicField$6(this, "loc");
250
+ __publicField$5(this, "contactKey");
283
251
  /**
284
- * For badges that appear on a Vidiot Map, the number or letter the badge appears as.
252
+ * Level of the invention required.
285
253
  */
286
- __publicField$6(this, "vidiotMapKey");
254
+ __publicField$5(this, "inventionLevel");
287
255
  /**
288
- * ID used with the in-game `/settitle` command to apply the badge.
256
+ * The types of enhancements required to be crafted.
289
257
  */
290
- __publicField$6(this, "setTitle");
258
+ __publicField$5(this, "inventionTypes");
291
259
  /**
292
- * A description of the effect the badge will have, such as a buff or granting a temporary power.
293
- *
294
- * Supports {@link https://www.markdownguide.org/|Markdown} format.
260
+ * Number of invention crafts required.
295
261
  */
296
- __publicField$6(this, "effect");
262
+ __publicField$5(this, "inventionCount");
297
263
  /**
298
- * 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.
264
+ * Any additional notes.
299
265
  */
300
- __publicField$6(this, "partials");
266
+ __publicField$5(this, "notes");
301
267
  /**
302
- * 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.
268
+ * List of external links. Wiki, forums, etc.
303
269
  */
304
- __publicField$6(this, "ignoreInTotals");
270
+ __publicField$5(this, "links");
305
271
  this.key = new Key(data.key).value;
306
272
  this.type = data.type;
307
- this.name = new Alternates(data.name);
308
- this.alignment = data.alignment;
309
- this.badgeText = new Alternates(data.badgeText ?? []);
310
- this.acquisition = data.acquisition;
311
- this.icon = new Alternates(data.icon ?? []);
312
- this.notes = data.notes;
313
- this.links = data.links;
314
- this.mapKey = data.mapKey;
273
+ this.zoneKey = data.zoneKey;
315
274
  this.loc = data.loc;
316
- this.effect = data.effect;
275
+ this.plaqueType = data.plaqueType;
276
+ this.plaqueInscription = data.plaqueInscription;
317
277
  this.vidiotMapKey = data.vidiotMapKey;
318
- this.setTitle = data.setTitle;
319
- this.ignoreInTotals = data.ignoreInTotals ?? false;
320
- this.partials = data.partials?.map((data2) => {
321
- if (__privateGet$1(this, _partialsIndex)[data2.key] !== void 0) throw new Error(`Duplicate badge partial key [${data2.key}]`);
322
- const badge = new BadgePartial(data2);
323
- __privateGet$1(this, _partialsIndex)[badge.key] = badge;
324
- return badge;
325
- });
326
- }
327
- getPartial(key) {
328
- const result = __privateGet$1(this, _partialsIndex)[key];
329
- if (result === void 0) throw new Error(`Unknown badge partial key [${key}]`);
330
- return result;
278
+ this.badgeKey = data.badgeKey;
279
+ this.missionName = data.missionName;
280
+ this.contactKey = data.contactKey;
281
+ this.inventionLevel = data.inventionLevel;
282
+ this.inventionTypes = data.inventionTypes;
283
+ this.inventionCount = data.inventionCount;
284
+ this.notes = data.notes;
285
+ this.links = data.links ?? [];
331
286
  }
332
287
  }
333
- _partialsIndex = new WeakMap();
334
288
 
335
- var __defProp$5 = Object.defineProperty;
336
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
337
- var __publicField$5 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
338
- class VidiotMapPointOfInterest {
339
- constructor(data) {
289
+ var __defProp$4 = Object.defineProperty;
290
+ var __typeError$2 = (msg) => {
291
+ throw TypeError(msg);
292
+ };
293
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
294
+ var __publicField$4 = (obj, key, value) => __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
295
+ var __accessCheck$2 = (obj, member, msg) => member.has(obj) || __typeError$2("Cannot " + msg);
296
+ var __privateGet$2 = (obj, member, getter) => (__accessCheck$2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
297
+ 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);
298
+ var _requirementsIndex;
299
+ class Badge {
300
+ constructor(badgeData) {
301
+ __privateAdd$2(this, _requirementsIndex, {});
340
302
  /**
341
- * The pixel-space position of the PoI on the map graphic.
342
- *
343
- * Screen-space, pixels from top-left `[0, 0]`.
303
+ * The database key for this badge.
344
304
  */
345
- __publicField$5(this, "pos");
305
+ __publicField$4(this, "key");
346
306
  /**
347
- * Freeform notes about the PoI.
307
+ * The type of badge.
308
+ */
309
+ __publicField$4(this, "type");
310
+ /**
311
+ * The name of this badge.
348
312
  *
349
- * Supports {@link https://www.markdownguide.org/|Markdown} format.
313
+ * May vary by character sex or alignment.
350
314
  */
351
- __publicField$5(this, "notes");
315
+ __publicField$4(this, "name");
352
316
  /**
353
- * If the POI is a zone transfer, the map it transfers to.
317
+ * The character alignments that this badge is available to.
354
318
  */
355
- __publicField$5(this, "mapKey");
319
+ __publicField$4(this, "alignment");
356
320
  /**
357
- * If the POI is a badge, the badge.
321
+ * The badge text as it appears in-game. May vary by character sex or alignment.
358
322
  */
359
- __publicField$5(this, "badgeKey");
323
+ __publicField$4(this, "badgeText");
360
324
  /**
361
- * If the POI is a partial for a badge, the partial key.
325
+ * Short description of how to acquire the badge. Detailed instructions will be in the notes field.
362
326
  */
363
- __publicField$5(this, "badgePartialKey");
364
- this.pos = data.pos;
365
- this.notes = data.notes;
366
- this.mapKey = data.mapKey;
367
- this.badgeKey = data.badgeKey;
368
- this.badgePartialKey = data.badgePartialKey;
369
- }
370
- }
371
-
372
- var __defProp$4 = Object.defineProperty;
373
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
374
- var __publicField$4 = (obj, key, value) => __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
375
- class VidiotMap {
376
- constructor(data) {
327
+ __publicField$4(this, "acquisition");
377
328
  /**
378
- * URL of the map image.
329
+ * Absolute URL to this badge's icon.
330
+ *
331
+ * May vary by character sex or alignment.
379
332
  */
380
- __publicField$4(this, "imageUrl");
333
+ __publicField$4(this, "icon");
381
334
  /**
382
- * Name to display for the Vidiot map.
335
+ * Freeform notes or tips about the badge.
383
336
  */
384
- __publicField$4(this, "name");
337
+ __publicField$4(this, "notes");
385
338
  /**
386
- * List of Points of Interest labelled on the image.
339
+ * List of external links. Wiki, forums, etc.
387
340
  */
388
- __publicField$4(this, "pointsOfInterest");
389
- this.imageUrl = data.imageUrl;
390
- this.name = data.name;
391
- this.pointsOfInterest = data.pointsOfInterest?.map((data2) => new VidiotMapPointOfInterest(data2));
392
- }
393
- }
394
-
395
- var __defProp$3 = Object.defineProperty;
396
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
397
- var __publicField$3 = (obj, key, value) => __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
398
- class GameMap {
399
- constructor(data) {
341
+ __publicField$4(this, "links");
400
342
  /**
401
- * The database key for this map.
343
+ * For exploration badges, the key of the {@link Zone} that this badge is found on.
402
344
  */
403
- __publicField$3(this, "key");
345
+ __publicField$4(this, "zoneKey");
404
346
  /**
405
- * The name of the map as it appears in-game.
347
+ * For exploration badges, the `/loc` coordinates of the badge.
406
348
  */
407
- __publicField$3(this, "name");
349
+ __publicField$4(this, "loc");
408
350
  /**
409
- * List of external links for this Map. Wiki, forums, etc.
351
+ * For plaques that appear on a Vidiot Map, the number or letter the badge appears as.
410
352
  */
411
- __publicField$3(this, "links");
353
+ __publicField$4(this, "vidiotMapKey");
412
354
  /**
413
- * List of Vidiot Map assets for this map.
355
+ * ID used with the in-game `/settitle` command to apply the badge.
414
356
  */
415
- __publicField$3(this, "vidiotMaps");
416
- this.key = new Key(data.key).value;
417
- this.name = data.name;
418
- this.links = data.links;
419
- this.vidiotMaps = data.vidiotMaps?.map((data2) => new VidiotMap(data2));
357
+ __publicField$4(this, "setTitle");
358
+ /**
359
+ * A description of the effect the badge will have, such as a buff or granting a temporary power.
360
+ */
361
+ __publicField$4(this, "effect");
362
+ /**
363
+ * Represents the layered requirements for badges with multiple fulfillment steps,
364
+ * such as visiting plaques for history badges or collecting other badges.
365
+ *
366
+ * The outer array represents groups of requirements evaluated with OR logic —
367
+ * fulfilling any group satisfies the badge.
368
+ *
369
+ * Each inner array represents individual requirements evaluated with AND logic —
370
+ * all conditions in the group must be met.
371
+ */
372
+ __publicField$4(this, "requirements");
373
+ /**
374
+ * 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.
375
+ */
376
+ __publicField$4(this, "ignoreInTotals");
377
+ this.key = new Key(badgeData.key).value;
378
+ this.type = badgeData.type;
379
+ this.name = new Alternates(badgeData.name);
380
+ this.alignment = new Alignments(badgeData.alignment);
381
+ this.badgeText = new Alternates(badgeData.badgeText ?? []);
382
+ this.acquisition = badgeData.acquisition;
383
+ this.icon = new Alternates(badgeData.icon ?? []);
384
+ this.notes = badgeData.notes;
385
+ this.links = badgeData.links ?? [];
386
+ this.zoneKey = badgeData.zoneKey;
387
+ this.loc = badgeData.loc;
388
+ this.effect = badgeData.effect;
389
+ this.vidiotMapKey = badgeData.vidiotMapKey;
390
+ this.setTitle = badgeData.setTitle;
391
+ this.ignoreInTotals = badgeData.ignoreInTotals ?? false;
392
+ this.requirements = badgeData.requirements?.map((groups, index) => {
393
+ const existingKeysInGroup = /* @__PURE__ */ new Set();
394
+ return groups.map((requirementData) => {
395
+ if (existingKeysInGroup.has(requirementData.key)) throw new Error(`Duplicate badge requirement key [${badgeData.key}:${requirementData.key}] in group [${index + 1}]`);
396
+ existingKeysInGroup.add(requirementData.key);
397
+ const badge = new BadgeRequirement(requirementData);
398
+ __privateGet$2(this, _requirementsIndex)[badge.key] = badge;
399
+ return badge;
400
+ });
401
+ });
402
+ }
403
+ getRequirement(key) {
404
+ const result = __privateGet$2(this, _requirementsIndex)[key];
405
+ if (result === void 0) throw new Error(`Unknown badge requirement key [${key}]`);
406
+ return result;
420
407
  }
421
408
  }
409
+ _requirementsIndex = new WeakMap();
422
410
 
423
- var __defProp$2 = Object.defineProperty;
424
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
425
- var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
411
+ var __typeError$1 = (msg) => {
412
+ throw TypeError(msg);
413
+ };
414
+ var __accessCheck$1 = (obj, member, msg) => member.has(obj) || __typeError$1("Cannot " + msg);
415
+ var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
416
+ 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);
417
+ var __privateSet$1 = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
418
+ var __privateMethod = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
419
+ var _badges, _badgeIndex$1, _zoneOrder, _BadgeIndex_instances, satisfiesQueryPredicate_fn, satisfiesFilterPredicate_fn, sort_fn;
420
+ class BadgeIndex {
421
+ constructor(badges, zones) {
422
+ __privateAdd$1(this, _BadgeIndex_instances);
423
+ __privateAdd$1(this, _badges, []);
424
+ __privateAdd$1(this, _badgeIndex$1, {});
425
+ __privateAdd$1(this, _zoneOrder, {});
426
+ __privateSet$1(this, _zoneOrder, Object.fromEntries(
427
+ zones?.sort((a, b) => a.name.localeCompare(b.name))?.map((x, index) => [x.key, index]) ?? []
428
+ ));
429
+ __privateSet$1(this, _badges, badges);
430
+ for (const badge of badges) {
431
+ if (__privateGet$1(this, _badgeIndex$1)[badge.key] !== void 0) throw new Error(`Duplicate badge key [${badge.key}]`);
432
+ __privateGet$1(this, _badgeIndex$1)[badge.key] = badge;
433
+ }
434
+ }
435
+ getBadge(key) {
436
+ const result = __privateGet$1(this, _badgeIndex$1)[key];
437
+ if (result === void 0) throw new Error(`Unknown badge key [${key}]`);
438
+ return result;
439
+ }
440
+ badgeExists(key) {
441
+ return !!__privateGet$1(this, _badgeIndex$1)[key];
442
+ }
443
+ searchBadges(options) {
444
+ const filtered = options?.query || options?.filter ? __privateGet$1(this, _badges).filter((badge) => __privateMethod(this, _BadgeIndex_instances, satisfiesQueryPredicate_fn).call(this, badge, options?.query) && __privateMethod(this, _BadgeIndex_instances, satisfiesFilterPredicate_fn).call(this, badge, options?.filter)) : __privateGet$1(this, _badges);
445
+ const totalPages = options?.pageSize ? Math.ceil(filtered.length / options?.pageSize) : 1;
446
+ const page = Math.max(1, Math.min(totalPages, options?.page ?? 1));
447
+ const paged = options?.pageSize ? filtered.slice((page - 1) * options.pageSize, page * options?.pageSize) : filtered;
448
+ const sorted = __privateMethod(this, _BadgeIndex_instances, sort_fn).call(this, paged, options?.sort);
449
+ return {
450
+ items: sorted,
451
+ page,
452
+ pageSize: options?.pageSize,
453
+ totalItems: filtered.length,
454
+ totalPages
455
+ };
456
+ }
457
+ }
458
+ _badges = new WeakMap();
459
+ _badgeIndex$1 = new WeakMap();
460
+ _zoneOrder = new WeakMap();
461
+ _BadgeIndex_instances = new WeakSet();
462
+ satisfiesQueryPredicate_fn = function(badge, query) {
463
+ const queryString = query?.str?.toLowerCase() ?? "";
464
+ return !!((query?.on?.name ?? true) && badge.name.canonical.some((x) => x.value.toLowerCase().includes(queryString)) || query?.on?.badgeText && badge.badgeText.canonical.some((x) => x.value.toLowerCase().includes(queryString)) || query?.on?.acquisition && badge.acquisition?.toLowerCase().includes(queryString) || query?.on?.effect && badge.effect?.toLowerCase().includes(queryString) || query?.on?.notes && badge.notes?.toLowerCase().includes(queryString) || query?.on?.setTitle && (badge.setTitle?.id?.toString().includes(queryString) || badge.setTitle?.praetorianId?.toString().includes(queryString)));
465
+ };
466
+ satisfiesFilterPredicate_fn = function(badge, filter) {
467
+ return (!filter?.type || badge.type === filter.type) && (!filter?.zoneKey || badge.zoneKey === filter.zoneKey) && (!filter?.alignment || badge.alignment.items.includes(filter.alignment));
468
+ };
469
+ sort_fn = function(badges, sort) {
470
+ if (!sort) return badges;
471
+ const ascending = sort.dir !== "DESC";
472
+ if (!sort.by || sort.by === "CANONICAL") return sort.dir === "DESC" ? badges.reverse() : badges;
473
+ if (sort.by === "BADGE_NAME") return ascending ? badges.sort((a, b) => a.name.default?.value.localeCompare(b.name.default?.value ?? "") ?? 0) : badges.sort((a, b) => b.name.default?.value.localeCompare(a.name.default?.value ?? "") ?? 0);
474
+ return badges.sort((a, b) => {
475
+ const aIndex = __privateGet$1(this, _zoneOrder)[a.zoneKey ?? ""];
476
+ const bIndex = __privateGet$1(this, _zoneOrder)[b.zoneKey ?? ""];
477
+ if (aIndex === bIndex) return 0;
478
+ if (aIndex === void 0) return ascending ? 1 : -1;
479
+ if (bIndex === void 0) return ascending ? -1 : 1;
480
+ return ascending ? aIndex - bIndex : bIndex - aIndex;
481
+ });
482
+ };
483
+
484
+ var __defProp$3 = Object.defineProperty;
485
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
486
+ var __publicField$3 = (obj, key, value) => __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
426
487
  class BundleMetadata {
427
488
  constructor(bundle) {
428
489
  /**
429
- * Name of the server group.
490
+ * Name of the content bundle.
430
491
  */
431
- __publicField$2(this, "name");
492
+ __publicField$3(this, "name");
432
493
  /**
433
- * Description of the server group.
434
- *
435
- * Supports {@link https://www.markdownguide.org/|Markdown} format.
494
+ * Description of the fork.
436
495
  */
437
- __publicField$2(this, "description");
496
+ __publicField$3(this, "description");
438
497
  /**
439
498
  * Repository where the db content package is maintained.
440
499
  */
441
- __publicField$2(this, "repository");
500
+ __publicField$3(this, "repository");
442
501
  /**
443
- * List of external links for this Server Group. Wiki, forums, etc.
502
+ * List of external links. Wiki, forums, etc.
444
503
  */
445
- __publicField$2(this, "links");
504
+ __publicField$3(this, "links");
446
505
  /**
447
506
  * Change log for this data package.
448
507
  */
449
- __publicField$2(this, "changelog");
508
+ __publicField$3(this, "changelog");
450
509
  this.name = bundle.name;
451
510
  this.description = bundle.description;
452
511
  this.repository = bundle.repository;
@@ -455,20 +514,78 @@ class BundleMetadata {
455
514
  }
456
515
  }
457
516
 
517
+ var __defProp$2 = Object.defineProperty;
518
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
519
+ var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
520
+ class Zone {
521
+ constructor(data) {
522
+ /**
523
+ * Unique key used to reference this zone.
524
+ *
525
+ * Keys can only contain lowercase letters, numbers and hyphens (`-`).
526
+ */
527
+ __publicField$2(this, "key");
528
+ /**
529
+ * The name of the zone as it appears in-game.
530
+ */
531
+ __publicField$2(this, "name");
532
+ /**
533
+ * List of external links. Wiki, forums, etc.
534
+ */
535
+ __publicField$2(this, "links");
536
+ this.key = new Key(data.key).value;
537
+ this.name = data.name;
538
+ this.links = data.links ?? [];
539
+ }
540
+ }
541
+
458
542
  var __defProp$1 = Object.defineProperty;
459
543
  var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
460
544
  var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
461
- class BadgeSearchDocument {
462
- constructor(badge) {
463
- __publicField$1(this, "id");
545
+ class Contact {
546
+ constructor(contactData) {
547
+ /**
548
+ * Unique key used to reference this contact.
549
+ *
550
+ * Keys can only contain lowercase letters, numbers and hyphens (`-`).
551
+ */
464
552
  __publicField$1(this, "key");
553
+ /**
554
+ * The name of this contact.
555
+ */
465
556
  __publicField$1(this, "name");
466
- __publicField$1(this, "badgeText");
467
- __publicField$1(this, "acquisition");
468
- this.id = this.key = badge.key;
469
- this.name = badge.name.toString(", ");
470
- this.badgeText = badge.badgeText.toString(", ");
471
- this.acquisition = badge.acquisition ?? "";
557
+ /**
558
+ * The contact's title.
559
+ */
560
+ __publicField$1(this, "title");
561
+ /**
562
+ * The zone this character is located in.
563
+ */
564
+ __publicField$1(this, "zoneKey");
565
+ /**
566
+ * The `/loc` coordinates of the contact.
567
+ */
568
+ __publicField$1(this, "loc");
569
+ /**
570
+ * The level range this contact will offer missions for.
571
+ */
572
+ __publicField$1(this, "levelRange");
573
+ /**
574
+ * Freeform notes or tips about the contact.
575
+ */
576
+ __publicField$1(this, "notes");
577
+ /**
578
+ * List of external links. Wiki, forums, etc.
579
+ */
580
+ __publicField$1(this, "links");
581
+ this.key = new Key(contactData.key).value;
582
+ this.name = contactData.name;
583
+ this.title = contactData.title;
584
+ this.zoneKey = contactData.zoneKey;
585
+ this.loc = contactData.loc;
586
+ this.levelRange = contactData.levelRange;
587
+ this.notes = contactData.notes;
588
+ this.links = contactData.links ?? [];
472
589
  }
473
590
  }
474
591
 
@@ -482,7 +599,7 @@ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot
482
599
  var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
483
600
  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);
484
601
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
485
- var _archetypeIndex, _mapIndex, _badgeIndex, _badgeSearch;
602
+ var _archetypeIndex, _zoneIndex, _contactIndex, _badgeIndex;
486
603
  class CohContentDatabase {
487
604
  /**
488
605
  * Initialize the database with a content bundle.
@@ -490,83 +607,99 @@ class CohContentDatabase {
490
607
  */
491
608
  constructor(bundle) {
492
609
  __privateAdd(this, _archetypeIndex, {});
493
- __privateAdd(this, _mapIndex, {});
494
- __privateAdd(this, _badgeIndex, {});
495
- __privateAdd(this, _badgeSearch);
610
+ __privateAdd(this, _zoneIndex, {});
611
+ __privateAdd(this, _contactIndex, {});
612
+ __privateAdd(this, _badgeIndex);
496
613
  /**
497
614
  * Metadata about the content bundle.
498
615
  */
499
616
  __publicField(this, "metadata");
500
617
  /**
501
- * List of the game server names in this server group.
618
+ * List of the game server names.
619
+ *
502
620
  * Torchbearer, Excelsior, etc.
503
621
  */
504
622
  __publicField(this, "servers");
505
623
  /**
506
- * List of archetypes available in this server group.
624
+ * List of archetypes.
507
625
  */
508
626
  __publicField(this, "archetypes");
509
627
  /**
510
- * List of game maps supported by this server group.
628
+ * List of game zones.
629
+ */
630
+ __publicField(this, "zones");
631
+ /**
632
+ * List of contacts.
511
633
  */
512
- __publicField(this, "maps");
634
+ __publicField(this, "contacts");
513
635
  /**
514
- * List of badges available on this server group.
636
+ * List of badges.
515
637
  */
516
638
  __publicField(this, "badges");
517
639
  this.metadata = new BundleMetadata(bundle);
518
640
  this.servers = bundle.servers ?? [];
519
641
  this.archetypes = bundle.archetypes?.map((data) => {
520
- if (__privateGet(this, _archetypeIndex)[data.key] !== void 0) throw new Error(`Duplicate archetype key [${data.key}]`);
642
+ if (__privateGet(this, _archetypeIndex)[data.key] !== void 0) throw new Error(`Duplicate archetype key '${data.key}'`);
521
643
  const archetype = new Archetype(data);
522
644
  __privateGet(this, _archetypeIndex)[archetype.key] = archetype;
523
645
  return archetype;
524
646
  }) ?? [];
525
- this.maps = bundle.maps?.map((data) => {
526
- if (__privateGet(this, _mapIndex)[data.key] !== void 0) throw new Error(`Duplicate map key [${data.key}]`);
527
- const map = new GameMap(data);
528
- __privateGet(this, _mapIndex)[map.key] = map;
529
- return map;
647
+ this.zones = bundle.zones?.map((data) => {
648
+ if (__privateGet(this, _zoneIndex)[data.key] !== void 0) throw new Error(`Duplicate zone key '${data.key}'`);
649
+ const zone = new Zone(data);
650
+ __privateGet(this, _zoneIndex)[zone.key] = zone;
651
+ return zone;
530
652
  }) ?? [];
531
- this.badges = bundle.badges?.map((data) => {
532
- if (__privateGet(this, _badgeIndex)[data.key] !== void 0) throw new Error(`Duplicate badge key [${data.key}]`);
533
- const badge = new Badge(data);
534
- __privateGet(this, _badgeIndex)[badge.key] = badge;
535
- return badge;
653
+ this.contacts = bundle.contacts?.map((data) => {
654
+ if (__privateGet(this, _contactIndex)[data.key] !== void 0) throw new Error(`Duplicate contact key '${data.key}'`);
655
+ const contact = new Contact(data);
656
+ __privateGet(this, _contactIndex)[contact.key] = contact;
657
+ return contact;
536
658
  }) ?? [];
537
- __privateSet(this, _badgeSearch, new MiniSearch({
538
- fields: ["key", "name", "badgeText", "acquisition"],
539
- storeFields: ["key"]
540
- }));
541
- for (const badge of this.badges) {
542
- __privateGet(this, _badgeSearch).add(new BadgeSearchDocument(badge));
543
- }
659
+ this.badges = bundle.badges?.map((data) => new Badge(data)) ?? [];
660
+ __privateSet(this, _badgeIndex, new BadgeIndex(this.badges, this.zones));
544
661
  }
545
662
  getArchetype(key) {
546
663
  const result = __privateGet(this, _archetypeIndex)[key];
547
- if (result === void 0) throw new Error(`Unknown archetype key [${key}]`);
664
+ if (result === void 0) throw new Error(`Unknown archetype key '${key}'`);
548
665
  return result;
549
666
  }
550
- getMap(key) {
551
- const result = __privateGet(this, _mapIndex)[key];
552
- if (result === void 0) throw new Error(`Unknown map key [${key}]`);
667
+ getZone(key) {
668
+ const result = __privateGet(this, _zoneIndex)[key];
669
+ if (result === void 0) throw new Error(`Unknown zone key '${key}'`);
553
670
  return result;
554
671
  }
555
- getBadge(key) {
556
- const result = __privateGet(this, _badgeIndex)[key];
557
- if (result === void 0) throw new Error(`Unknown badge key [${key}]`);
672
+ getContact(key) {
673
+ const result = __privateGet(this, _contactIndex)[key];
674
+ if (result === void 0) throw new Error(`Unknown contact key '${key}'`);
558
675
  return result;
559
676
  }
560
- searchBadges(query) {
561
- if (!query) return this.badges;
562
- const keys = __privateGet(this, _badgeSearch).search(query, { prefix: true, fuzzy: true });
563
- return keys.map((result) => this.getBadge(result["key"]));
677
+ zoneExists(key) {
678
+ return !!__privateGet(this, _zoneIndex)[key];
679
+ }
680
+ contactExists(key) {
681
+ return !!__privateGet(this, _contactIndex)[key];
682
+ }
683
+ getBadge(key) {
684
+ return __privateGet(this, _badgeIndex).getBadge(key);
685
+ }
686
+ badgeExists(key) {
687
+ return __privateGet(this, _badgeIndex).badgeExists(key);
688
+ }
689
+ /**
690
+ * Search, sort and filter the badge list.
691
+ * This is a fairly brute-forced approach and will not be as performant as loading the badge data into a traditional
692
+ * database engine, but is sufficient for most operations.
693
+ * @param options {@link BadgeSearchOptions}
694
+ */
695
+ searchBadges(options) {
696
+ return __privateGet(this, _badgeIndex).searchBadges(options);
564
697
  }
565
698
  }
566
699
  _archetypeIndex = new WeakMap();
567
- _mapIndex = new WeakMap();
700
+ _zoneIndex = new WeakMap();
701
+ _contactIndex = new WeakMap();
568
702
  _badgeIndex = new WeakMap();
569
- _badgeSearch = new WeakMap();
570
703
 
571
704
  const CHANGELOG = [
572
705
  {
@@ -574,14 +707,19 @@ const CHANGELOG = [
574
707
  date: /* @__PURE__ */ new Date("2025-03-12"),
575
708
  description: `* Replaced redundant interfaces with their concrete equivalents.
576
709
  * Server groups are now referred to as 'forks'.
577
- * Replaced enums with extensible union types; Forks with new badge types, enhancement types, etc. can now extend them locally.
710
+ * Replaced enums with union types.
578
711
  * \`IServerGroupData\` is now \`ContentBundle\` and each database instance is now designed to accept only a single server group.
712
+ * \`GameMap\` is now \`Zone\`.
579
713
  * Removed the \`serverGroup\` property from entities to simplify the object tree given that only a single context can exist per db now.
580
714
  * Added a simple indexing and search function for badge names, text and acquisition info.
715
+ * Zone and badge references now follow a standard Markdown link format with a \`badge://\` or \`map://\` protocol.
716
+ * Badge partials are now known as badge requirements and support both AND and OR groups of requirements.
717
+ * Removed the \`VidiotMap\` API as it was never used or fleshed out properly.
718
+ * Added support for story arcs to badge requirements including a link to the contact.
581
719
  * Standardized pluralization of some field names (name, icon).
582
720
  * Combined \`settitle\` ids into a single tuple field.
583
721
  * Change from GNU to The Unlicense.
584
- * Removed dependency on lodash.
722
+ * Removed all third-party dependencies.
585
723
  * Moved from webpack to rollup for packaging.
586
724
  * Add eslint for linting.
587
725
  * Add jest for unit tests.
@@ -590,31 +728,53 @@ const CHANGELOG = [
590
728
  }
591
729
  ];
592
730
 
593
- function createBadgeReference(target) {
731
+ function badgeUri(target) {
732
+ const key = typeof target === "string" ? target : target.key;
733
+ return `badge://${key}`;
734
+ }
735
+ function badgeLink(target) {
736
+ const key = typeof target === "string" ? target : target.key;
737
+ return `[${key}](${badgeUri(target)})`;
738
+ }
739
+ function contactUri(target) {
740
+ const key = typeof target === "string" ? target : target.key;
741
+ return `contact://${key}`;
742
+ }
743
+ function contactLink(target) {
744
+ const key = typeof target === "string" ? target : target.key;
745
+ return `[${key}](${contactUri(target)})`;
746
+ }
747
+ function zoneUri(target) {
594
748
  const key = typeof target === "string" ? target : target.key;
595
- return `[badge:${key}]`;
749
+ return `zone://${key}`;
596
750
  }
597
- function createMapReference(target) {
751
+ function zoneLink(target) {
598
752
  const key = typeof target === "string" ? target : target.key;
599
- return `[map:${key}]`;
753
+ return `[${key}](${zoneUri(target)})`;
600
754
  }
601
755
 
602
756
  exports.ALIGNMENT = ALIGNMENT;
757
+ exports.Alignments = Alignments;
758
+ exports.Alternates = Alternates;
603
759
  exports.Archetype = Archetype;
604
- exports.BADGE_PARTIAL_TYPE = BADGE_PARTIAL_TYPE;
760
+ exports.BADGE_REQUIREMENT_TYPE = BADGE_REQUIREMENT_TYPE;
605
761
  exports.BADGE_TYPE = BADGE_TYPE;
606
762
  exports.Badge = Badge;
607
- exports.BadgePartial = BadgePartial;
763
+ exports.BadgeIndex = BadgeIndex;
764
+ exports.BadgeRequirement = BadgeRequirement;
608
765
  exports.BundleMetadata = BundleMetadata;
609
766
  exports.CHANGELOG = CHANGELOG;
610
767
  exports.CohContentDatabase = CohContentDatabase;
768
+ exports.Contact = Contact;
611
769
  exports.ENHANCEMENT_CATEGORY = ENHANCEMENT_CATEGORY;
612
- exports.GameMap = GameMap;
613
770
  exports.Key = Key;
614
771
  exports.PLAQUE_TYPE = PLAQUE_TYPE;
615
772
  exports.SEX = SEX;
616
- exports.VidiotMap = VidiotMap;
617
- exports.VidiotMapPointOfInterest = VidiotMapPointOfInterest;
618
- exports.createBadgeReference = createBadgeReference;
619
- exports.createMapReference = createMapReference;
773
+ exports.Zone = Zone;
774
+ exports.badgeLink = badgeLink;
775
+ exports.badgeUri = badgeUri;
776
+ exports.contactLink = contactLink;
777
+ exports.contactUri = contactUri;
778
+ exports.zoneLink = zoneLink;
779
+ exports.zoneUri = zoneUri;
620
780
  //# sourceMappingURL=coh-content-db.js.map