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

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 (65) hide show
  1. package/README.md +3 -3
  2. package/dist/coh-content-db.d.ts +384 -181
  3. package/dist/coh-content-db.js +604 -348
  4. package/dist/coh-content-db.js.map +1 -1
  5. package/dist/coh-content-db.mjs +592 -347
  6. package/dist/coh-content-db.mjs.map +1 -1
  7. package/eslint.config.mjs +1 -0
  8. package/package.json +1 -1
  9. package/src/main/api/alignment.ts +18 -2
  10. package/src/main/api/badge-data.ts +12 -42
  11. package/src/main/api/badge-requirement-data.ts +17 -35
  12. package/src/main/api/badge-requirement-type.ts +28 -7
  13. package/src/main/api/badge-type.ts +15 -15
  14. package/src/main/api/contact-data.ts +7 -5
  15. package/src/main/api/content-bundle.ts +6 -0
  16. package/src/main/api/enhancement-category.ts +26 -26
  17. package/src/main/api/location-data.ts +28 -0
  18. package/src/main/api/mission-data.ts +83 -0
  19. package/src/main/api/mission-type.ts +2 -0
  20. package/src/main/api/morality.ts +31 -0
  21. package/src/main/api/sex.ts +8 -1
  22. package/src/main/api/zone-data.ts +1 -1
  23. package/src/main/changelog.ts +5 -4
  24. package/src/main/db/alignment-list.ts +54 -0
  25. package/src/main/db/alternates.ts +15 -32
  26. package/src/main/db/badge-index.ts +11 -36
  27. package/src/main/db/badge-requirement.ts +22 -43
  28. package/src/main/db/badge-search-options.ts +4 -4
  29. package/src/main/db/badge.ts +53 -54
  30. package/src/main/db/coh-content-database.ts +28 -24
  31. package/src/main/db/contact.ts +17 -14
  32. package/src/main/db/location.ts +30 -0
  33. package/src/main/db/mission.ts +107 -0
  34. package/src/main/db/morality-list.ts +99 -0
  35. package/src/main/db/zone.ts +1 -1
  36. package/src/main/index.ts +8 -3
  37. package/src/main/util.ts +43 -3
  38. package/src/test/api/alignment.test.ts +38 -4
  39. package/src/test/api/badge-data.fixture.ts +1 -17
  40. package/src/test/api/badge-data.test.ts +3 -3
  41. package/src/test/api/badge-requirement-data.fixture.ts +1 -11
  42. package/src/test/api/badge-requirement-type.test.ts +3 -3
  43. package/src/test/api/badge-type.test.ts +5 -5
  44. package/src/test/api/contact-data.fixture.ts +0 -6
  45. package/src/test/api/content-bundle.fixture.ts +1 -17
  46. package/src/test/api/enhancement-category.test.ts +5 -5
  47. package/src/test/api/mission-data.fixture.ts +12 -0
  48. package/src/test/api/sex.test.ts +33 -1
  49. package/src/test/api/zone-data.fixture.ts +1 -1
  50. package/src/test/db/alignment-list.test.ts +200 -0
  51. package/src/test/db/alternates.test.ts +60 -56
  52. package/src/test/db/badge-index.test.ts +82 -72
  53. package/src/test/db/badge-requirement.test.ts +35 -70
  54. package/src/test/db/badge.test.ts +185 -64
  55. package/src/test/db/coh-content-database.test.ts +58 -69
  56. package/src/test/db/contact.test.ts +25 -24
  57. package/src/test/db/location.test.ts +51 -0
  58. package/src/test/db/mission.test.ts +171 -0
  59. package/src/test/db/morality-list.test.ts +457 -0
  60. package/src/test/db/zone.test.ts +4 -4
  61. package/src/test/util.test.ts +54 -1
  62. package/src/main/api/plaque-type.ts +0 -6
  63. package/src/main/db/alignments.ts +0 -17
  64. package/src/test/api/alignments.test.ts +0 -40
  65. package/src/test/api/plaque-type.test.ts +0 -31
@@ -1,114 +1,188 @@
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
11
  const BADGE_REQUIREMENT_TYPE = [
6
- "PLAQUE",
7
- "BADGE",
8
- "INVENTION",
9
- "MISSION",
10
- // Complete a mission
11
- "ARC",
12
- // Complete a story arc
13
- "TASK_FORCE",
14
- // Complete a task force
15
- "INVENTION_PLUS_ONE"
16
- // Some invention badges require you to build x of two different invention levels, 'plus one of either level'.
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"
17
40
  ];
18
41
 
19
42
  const BADGE_TYPE = [
20
- "EXPLORATION",
21
- "HISTORY",
22
- "ACCOMPLISHMENT",
23
- "ACHIEVEMENT",
24
- "ACCOLADE",
25
- "GLADIATOR",
26
- "VETERAN",
27
- "PVP",
28
- "INVENTION",
29
- "DEFEAT",
30
- "EVENT",
31
- "OUROBOROS",
32
- "CONSIGNMENT",
33
- "DAY_JOB",
34
- "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"
35
58
  ];
36
59
 
37
60
  const ENHANCEMENT_CATEGORY = [
38
- "DEFENSE_DEBUFF",
39
- "TO_HIT_DEBUFF",
40
- "TAUNT",
41
- "CONFUSE",
42
- "HEALING",
43
- "DEFENSE_BUFF",
44
- "RESIST_DAMAGE",
45
- "INTANGIBILITY",
46
- "SLEEP",
47
- "SLOW",
48
- "HOLD",
49
- "STUN",
50
- "IMMOBILIZE",
51
- "FEAR",
52
- "ENDURANCE_MODIFICATION",
53
- "ENDURANCE_REDUCTION",
54
- "RECHARGE_REDUCTION",
55
- "INTERRUPT_DURATION",
56
- "ACCURACY",
57
- "TO_HIT_BUFF",
58
- "DAMAGE",
59
- "KNOCKBACK",
60
- "RUN_SPEED",
61
- "JUMP",
62
- "FLY_SPEED",
63
- "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"
64
87
  ];
65
88
 
66
- const PLAQUE_TYPE = [
67
- "WALL_PLAQUE",
68
- "MONUMENT"
69
- ];
89
+ const MISSION_TYPE = ["story-arc", "mission", "task-force", "strike-force", "trial", "personal-story"];
90
+
91
+ const MORALITY = ["hero", "vigilante", "villain", "rogue", "resistance", "loyalist"];
70
92
 
71
93
  const SEX = ["M", "F"];
94
+ const SEX_ORDER = Object.fromEntries(SEX.map((x, index) => [x, index]));
95
+ function compareSex(a, b) {
96
+ const orderA = a ? SEX_ORDER[a] : -1;
97
+ const orderB = b ? SEX_ORDER[b] : -1;
98
+ return orderA - orderB;
99
+ }
72
100
 
73
- var __defProp$7 = Object.defineProperty;
74
- var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
75
- var __publicField$7 = (obj, key, value) => __defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
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);
101
+ var __defProp$a = Object.defineProperty;
102
+ var __typeError$6 = (msg) => {
103
+ throw TypeError(msg);
104
+ };
105
+ var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
106
+ var __publicField$a = (obj, key, value) => __defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
107
+ var __accessCheck$6 = (obj, member, msg) => member.has(obj) || __typeError$6("Cannot " + msg);
108
+ var __privateGet$6 = (obj, member, getter) => (__accessCheck$6(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
109
+ 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);
110
+ var __privateSet$5 = (obj, member, value, setter) => (__accessCheck$6(obj, member, "write to private field"), member.set(obj, value), value);
111
+ var _items$1;
112
+ class AlignmentList {
113
+ constructor(items) {
114
+ __privateAdd$6(this, _items$1);
115
+ __publicField$a(this, "hero");
116
+ __publicField$a(this, "villain");
117
+ __publicField$a(this, "praetorian");
118
+ __publicField$a(this, "primal");
119
+ __publicField$a(this, "all");
120
+ const set = new Set(items ?? [...ALIGNMENT]);
121
+ this.hero = set.has("hero") || set.has("primal") || set.has("all");
122
+ this.villain = set.has("villain") || set.has("primal") || set.has("all");
123
+ this.praetorian = set.has("praetorian") || set.has("all");
124
+ this.primal = this.hero && this.villain;
125
+ this.all = this.hero && this.villain && this.praetorian;
126
+ __privateSet$5(this, _items$1, /* @__PURE__ */ new Set());
127
+ if (this.hero) __privateGet$6(this, _items$1).add("hero");
128
+ if (this.villain) __privateGet$6(this, _items$1).add("villain");
129
+ if (this.praetorian) __privateGet$6(this, _items$1).add("praetorian");
130
+ }
131
+ get items() {
132
+ return [...__privateGet$6(this, _items$1)];
133
+ }
134
+ has(alignment) {
135
+ switch (alignment) {
136
+ case "hero": {
137
+ return this.hero;
138
+ }
139
+ case "villain": {
140
+ return this.villain;
141
+ }
142
+ case "praetorian": {
143
+ return this.praetorian;
144
+ }
145
+ case "primal": {
146
+ return this.primal;
147
+ }
148
+ case "all": {
149
+ return this.all;
150
+ }
151
+ default: {
152
+ return false;
153
+ }
154
+ }
88
155
  }
89
156
  }
157
+ _items$1 = new WeakMap();
90
158
 
91
- var __typeError$4 = (msg) => {
159
+ var __typeError$5 = (msg) => {
92
160
  throw TypeError(msg);
93
161
  };
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);
99
- var _sortedValues, _Alternates_instances, compareAlternates_fn, compareAlignment_fn, compareSex_fn;
100
- const ALIGNMENT_SORT = { H: 2, V: 1, P: 0 };
101
- const SEX_SORT = { M: 1, F: 0 };
162
+ var __accessCheck$5 = (obj, member, msg) => member.has(obj) || __typeError$5("Cannot " + msg);
163
+ var __privateGet$5 = (obj, member, getter) => (__accessCheck$5(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
164
+ 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);
165
+ var __privateSet$4 = (obj, member, value, setter) => (__accessCheck$5(obj, member, "write to private field"), member.set(obj, value), value);
166
+ var __privateMethod$2 = (obj, member, method) => (__accessCheck$5(obj, member, "access private method"), method);
167
+ var _sortedValues, _Alternates_instances, compareAlternates_fn;
102
168
  class Alternates {
103
- constructor(values) {
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));
169
+ /**
170
+ * Create an alternate set from either a list of categorized values, or a single value when there are no alternates.
171
+ * @param value List of alternates, or a single value.
172
+ */
173
+ constructor(value) {
174
+ __privateAdd$5(this, _Alternates_instances);
175
+ __privateAdd$5(this, _sortedValues, []);
176
+ if (Array.isArray(value)) {
177
+ __privateSet$4(this, _sortedValues, value.sort());
178
+ __privateGet$5(this, _sortedValues).sort((a, b) => __privateMethod$2(this, _Alternates_instances, compareAlternates_fn).call(this, a, b));
179
+ } else {
180
+ __privateSet$4(this, _sortedValues, [{ value }]);
181
+ }
108
182
  }
109
183
  getValue(alignment, sex) {
110
- for (let index = __privateGet$4(this, _sortedValues).length; index--; ) {
111
- const entry = __privateGet$4(this, _sortedValues)[index];
184
+ for (let index = __privateGet$5(this, _sortedValues).length; index--; ) {
185
+ const entry = __privateGet$5(this, _sortedValues)[index];
112
186
  if ((entry.alignment === void 0 || entry.alignment === alignment) && (entry.sex === void 0 || entry.sex === sex)) return entry.value;
113
187
  }
114
188
  return this.default?.value;
@@ -117,13 +191,13 @@ class Alternates {
117
191
  * Get the default value for this list of alternates, the value with the highest priority and lowest specificity.
118
192
  */
119
193
  get default() {
120
- return __privateGet$4(this, _sortedValues)[0];
194
+ return __privateGet$5(this, _sortedValues)[0];
121
195
  }
122
196
  /**
123
197
  * Get the list of alternates sorted in canonical order (alignment then sex, low to high specificity).
124
198
  */
125
199
  get canonical() {
126
- return __privateGet$4(this, _sortedValues);
200
+ return __privateGet$5(this, _sortedValues);
127
201
  }
128
202
  /**
129
203
  * Create a joined string from the alternate values in canonical order.
@@ -139,48 +213,32 @@ compareAlternates_fn = function(a, b) {
139
213
  const aSpecificity = (a.alignment ? 2 : 0) + (a.sex ? 1 : 0);
140
214
  const bSpecificity = (b.alignment ? 2 : 0) + (b.sex ? 1 : 0);
141
215
  if (aSpecificity !== bSpecificity) return aSpecificity - bSpecificity;
142
- const alignmentComparison = __privateMethod$2(this, _Alternates_instances, compareAlignment_fn).call(this, a.alignment, b.alignment);
216
+ const alignmentComparison = compareAlignment(a.alignment, b.alignment);
143
217
  if (alignmentComparison !== 0) return alignmentComparison;
144
- const sexComparison = __privateMethod$2(this, _Alternates_instances, compareSex_fn).call(this, a.sex, b.sex);
218
+ const sexComparison = compareSex(a.sex, b.sex);
145
219
  if (sexComparison !== 0) return sexComparison;
146
220
  return String(a.value).localeCompare(String(b.value));
147
221
  };
148
- compareAlignment_fn = function(a, b) {
149
- if (a === b) return 0;
150
- if (a === void 0 && b !== void 0) return -1;
151
- if (b === void 0 && a !== void 0) return 1;
152
- const aSort = a === void 0 ? -1 : ALIGNMENT_SORT[a] ?? -1;
153
- const bSort = b === void 0 ? -1 : ALIGNMENT_SORT[b] ?? -1;
154
- return bSort - aSort;
155
- };
156
- compareSex_fn = function(a, b) {
157
- if (a === b) return 0;
158
- if (a === void 0 && b !== void 0) return -1;
159
- if (b === void 0 && a !== void 0) return 1;
160
- const aSort = SEX_SORT[a ?? -1] ?? -1;
161
- const bSort = SEX_SORT[b ?? -1] ?? -1;
162
- return bSort - aSort;
163
- };
164
222
 
165
- var __typeError$3 = (msg) => {
223
+ var __typeError$4 = (msg) => {
166
224
  throw TypeError(msg);
167
225
  };
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);
226
+ var __accessCheck$4 = (obj, member, msg) => member.has(obj) || __typeError$4("Cannot " + msg);
227
+ var __privateGet$4 = (obj, member, getter) => (__accessCheck$4(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
228
+ 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);
229
+ var __privateSet$3 = (obj, member, value, setter) => (__accessCheck$4(obj, member, "write to private field"), member.set(obj, value), value);
230
+ var __privateMethod$1 = (obj, member, method) => (__accessCheck$4(obj, member, "access private method"), method);
173
231
  var _value, _Key_instances, validateKey_fn;
174
232
  const INVALID_KEY_PATTERN = /[^a-z0-9-]/;
175
233
  class Key {
176
234
  constructor(value) {
177
- __privateAdd$3(this, _Key_instances);
178
- __privateAdd$3(this, _value);
235
+ __privateAdd$4(this, _Key_instances);
236
+ __privateAdd$4(this, _value);
179
237
  __privateMethod$1(this, _Key_instances, validateKey_fn).call(this, value);
180
- __privateSet$2(this, _value, value);
238
+ __privateSet$3(this, _value, value);
181
239
  }
182
240
  get value() {
183
- return __privateGet$3(this, _value);
241
+ return __privateGet$4(this, _value);
184
242
  }
185
243
  }
186
244
  _value = new WeakMap();
@@ -189,215 +247,314 @@ validateKey_fn = function(key) {
189
247
  if (INVALID_KEY_PATTERN.test(key)) throw new Error(`Invalid key: [${key}]; Keys can only contain lowercase characters, numbers and dashes.`);
190
248
  };
191
249
 
192
- var __defProp$6 = Object.defineProperty;
193
- var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
194
- var __publicField$6 = (obj, key, value) => __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
250
+ var __defProp$9 = Object.defineProperty;
251
+ var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
252
+ var __publicField$9 = (obj, key, value) => __defNormalProp$9(obj, typeof key !== "symbol" ? key + "" : key, value);
195
253
  class Archetype {
196
254
  constructor(data) {
197
- __publicField$6(this, "key");
198
- __publicField$6(this, "name");
199
- __publicField$6(this, "description");
255
+ __publicField$9(this, "key");
256
+ __publicField$9(this, "name");
257
+ __publicField$9(this, "description");
200
258
  this.key = new Key(data.key).value;
201
259
  this.name = data.name;
202
260
  this.description = data.description;
203
261
  }
204
262
  }
205
263
 
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);
264
+ function badgeUri(target) {
265
+ const key = typeof target === "string" ? target : target.key;
266
+ return `badge://${key}`;
267
+ }
268
+ function badgeLink(target) {
269
+ const key = typeof target === "string" ? target : target.key;
270
+ return `[${key}](${badgeUri(target)})`;
271
+ }
272
+ function contactUri(target) {
273
+ const key = typeof target === "string" ? target : target.key;
274
+ return `contact://${key}`;
275
+ }
276
+ function contactLink(target) {
277
+ const key = typeof target === "string" ? target : target.key;
278
+ return `[${key}](${contactUri(target)})`;
279
+ }
280
+ function missionUri(target) {
281
+ const key = typeof target === "string" ? target : target.key;
282
+ return `mission://${key}`;
283
+ }
284
+ function missionLink(target) {
285
+ const key = typeof target === "string" ? target : target.key;
286
+ return `[${key}](${missionUri(target)})`;
287
+ }
288
+ function zoneUri(target) {
289
+ const key = typeof target === "string" ? target : target.key;
290
+ return `zone://${key}`;
291
+ }
292
+ function zoneLink(target) {
293
+ const key = typeof target === "string" ? target : target.key;
294
+ return `[${key}](${zoneUri(target)})`;
295
+ }
296
+ function coalesceToArray(value) {
297
+ if (!value) return void 0;
298
+ return Array.isArray(value) ? value : [value];
299
+ }
300
+
301
+ var __defProp$8 = Object.defineProperty;
302
+ var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
303
+ var __publicField$8 = (obj, key, value) => __defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
209
304
  class BadgeRequirement {
210
305
  constructor(data) {
211
306
  /**
212
- * Key.
213
- */
214
- __publicField$5(this, "key");
215
- /**
216
- * Type of requirement.
217
- */
218
- __publicField$5(this, "type");
219
- /**
220
- * Zone the requirement is located in.
221
- */
222
- __publicField$5(this, "zoneKey");
223
- /**
224
- * /loc coordinates.
225
- */
226
- __publicField$5(this, "loc");
227
- /**
228
- * Is it a wall plaque or a physical monument?
307
+ * Unique key used to reference this badge requirement.
308
+ *
309
+ * Keys must be unique and can only contain lowercase letters, numbers and hyphens (`-`).
229
310
  */
230
- __publicField$5(this, "plaqueType");
311
+ __publicField$8(this, "key");
231
312
  /**
232
- * Plaque inscription.
313
+ * The requirement type.
233
314
  */
234
- __publicField$5(this, "plaqueInscription");
315
+ __publicField$8(this, "type");
235
316
  /**
236
- * The number or letter the plaque appears as on Vidiot Maps.
317
+ * If the requirement involves a location, where it is.
237
318
  */
238
- __publicField$5(this, "vidiotMapKey");
319
+ __publicField$8(this, "location");
239
320
  /**
240
- * The key of the badge for this requirement.
321
+ * If the requirement involves a badge, the badge key.
241
322
  */
242
- __publicField$5(this, "badgeKey");
323
+ __publicField$8(this, "badgeKey");
243
324
  /**
244
- * Mission name.
325
+ * If the requirement involves a mission, the mission key.
245
326
  */
246
- __publicField$5(this, "missionName");
327
+ __publicField$8(this, "missionKey");
247
328
  /**
248
- * {@link Contact} key for the story arc.
329
+ * If the requirement involves a monument, the text that is displayed thereon.
249
330
  */
250
- __publicField$5(this, "contactKey");
331
+ __publicField$8(this, "monumentText");
251
332
  /**
252
- * Level of the invention required.
333
+ * If the requirement involves crafting an invention, the Level of the invention required.
253
334
  */
254
- __publicField$5(this, "inventionLevel");
335
+ __publicField$8(this, "inventionLevel");
255
336
  /**
256
- * The types of enhancements required to be crafted.
337
+ * If the requirement involves crafting an invention, the types of enhancements that will qualify.
257
338
  */
258
- __publicField$5(this, "inventionTypes");
339
+ __publicField$8(this, "inventionTypes");
259
340
  /**
260
- * Number of invention crafts required.
341
+ * Number of times the task needs to be repeated.
261
342
  */
262
- __publicField$5(this, "inventionCount");
343
+ __publicField$8(this, "count");
263
344
  /**
264
- * Any additional notes.
345
+ * Additional information about the requirement.
265
346
  */
266
- __publicField$5(this, "notes");
347
+ __publicField$8(this, "notes");
267
348
  /**
268
349
  * List of external links. Wiki, forums, etc.
269
350
  */
270
- __publicField$5(this, "links");
351
+ __publicField$8(this, "links");
271
352
  this.key = new Key(data.key).value;
272
353
  this.type = data.type;
273
- this.zoneKey = data.zoneKey;
274
- this.loc = data.loc;
275
- this.plaqueType = data.plaqueType;
276
- this.plaqueInscription = data.plaqueInscription;
277
- this.vidiotMapKey = data.vidiotMapKey;
354
+ this.location = coalesceToArray(data.location);
278
355
  this.badgeKey = data.badgeKey;
279
- this.missionName = data.missionName;
280
- this.contactKey = data.contactKey;
356
+ this.missionKey = data.missionKey;
357
+ this.monumentText = data.monumentText;
281
358
  this.inventionLevel = data.inventionLevel;
282
359
  this.inventionTypes = data.inventionTypes;
283
- this.inventionCount = data.inventionCount;
360
+ this.count = data.count;
284
361
  this.notes = data.notes;
285
362
  this.links = data.links ?? [];
286
363
  }
287
364
  }
288
365
 
289
- var __defProp$4 = Object.defineProperty;
366
+ var __defProp$7 = Object.defineProperty;
367
+ var __typeError$3 = (msg) => {
368
+ throw TypeError(msg);
369
+ };
370
+ var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
371
+ var __publicField$7 = (obj, key, value) => __defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
372
+ var __accessCheck$3 = (obj, member, msg) => member.has(obj) || __typeError$3("Cannot " + msg);
373
+ var __privateGet$3 = (obj, member, getter) => (__accessCheck$3(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
374
+ 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);
375
+ var __privateSet$2 = (obj, member, value, setter) => (__accessCheck$3(obj, member, "write to private field"), member.set(obj, value), value);
376
+ var _items;
377
+ class MoralityList {
378
+ constructor(items) {
379
+ __privateAdd$3(this, _items);
380
+ __publicField$7(this, "hero");
381
+ __publicField$7(this, "vigilante");
382
+ __publicField$7(this, "villain");
383
+ __publicField$7(this, "rogue");
384
+ __publicField$7(this, "resistance");
385
+ __publicField$7(this, "loyalist");
386
+ __publicField$7(this, "primal");
387
+ __publicField$7(this, "praetorian");
388
+ __publicField$7(this, "heroic");
389
+ __publicField$7(this, "villainous");
390
+ __publicField$7(this, "paragonCityAccess");
391
+ __publicField$7(this, "rogueIslesAccess");
392
+ __publicField$7(this, "all");
393
+ const set = new Set(items ?? [...MORALITY]);
394
+ this.hero = set.has("hero") || set.has("primal") || set.has("heroic") || set.has("paragon-city-access") || set.has("all");
395
+ this.vigilante = set.has("vigilante") || set.has("primal") || set.has("heroic") || set.has("paragon-city-access") || set.has("rogue-isles-access") || set.has("all");
396
+ this.villain = set.has("villain") || set.has("primal") || set.has("villainous") || set.has("rogue-isles-access") || set.has("all");
397
+ this.rogue = set.has("rogue") || set.has("primal") || set.has("villainous") || set.has("paragon-city-access") || set.has("rogue-isles-access") || set.has("all");
398
+ this.resistance = set.has("resistance") || set.has("praetorian") || set.has("all");
399
+ this.loyalist = set.has("loyalist") || set.has("praetorian") || set.has("all");
400
+ this.primal = this.hero && this.vigilante && this.villain && this.rogue;
401
+ this.praetorian = this.loyalist && this.resistance;
402
+ this.heroic = this.hero && this.vigilante;
403
+ this.villainous = this.villain && this.rogue;
404
+ this.paragonCityAccess = this.heroic && this.rogue;
405
+ this.rogueIslesAccess = this.villainous && this.vigilante;
406
+ this.all = this.primal && this.praetorian;
407
+ __privateSet$2(this, _items, /* @__PURE__ */ new Set());
408
+ if (this.hero) __privateGet$3(this, _items).add("hero");
409
+ if (this.vigilante) __privateGet$3(this, _items).add("vigilante");
410
+ if (this.villain) __privateGet$3(this, _items).add("villain");
411
+ if (this.rogue) __privateGet$3(this, _items).add("rogue");
412
+ if (this.resistance) __privateGet$3(this, _items).add("resistance");
413
+ if (this.loyalist) __privateGet$3(this, _items).add("loyalist");
414
+ }
415
+ get items() {
416
+ return [...__privateGet$3(this, _items)];
417
+ }
418
+ has(morality) {
419
+ switch (morality) {
420
+ case "hero": {
421
+ return this.hero;
422
+ }
423
+ case "vigilante": {
424
+ return this.vigilante;
425
+ }
426
+ case "villain": {
427
+ return this.villain;
428
+ }
429
+ case "rogue": {
430
+ return this.rogue;
431
+ }
432
+ case "resistance": {
433
+ return this.resistance;
434
+ }
435
+ case "loyalist": {
436
+ return this.loyalist;
437
+ }
438
+ case "primal": {
439
+ return this.primal;
440
+ }
441
+ case "praetorian": {
442
+ return this.praetorian;
443
+ }
444
+ case "heroic": {
445
+ return this.hero;
446
+ }
447
+ case "paragon-city-access": {
448
+ return this.paragonCityAccess;
449
+ }
450
+ case "rogue-isles-access": {
451
+ return this.rogueIslesAccess;
452
+ }
453
+ case "villainous": {
454
+ return this.villainous;
455
+ }
456
+ case "all": {
457
+ return this.all;
458
+ }
459
+ default: {
460
+ return false;
461
+ }
462
+ }
463
+ }
464
+ }
465
+ _items = new WeakMap();
466
+
467
+ var __defProp$6 = Object.defineProperty;
290
468
  var __typeError$2 = (msg) => {
291
469
  throw TypeError(msg);
292
470
  };
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);
471
+ var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
472
+ var __publicField$6 = (obj, key, value) => __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
295
473
  var __accessCheck$2 = (obj, member, msg) => member.has(obj) || __typeError$2("Cannot " + msg);
296
474
  var __privateGet$2 = (obj, member, getter) => (__accessCheck$2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
297
475
  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;
476
+ var _requirementsIndex, _zoneKeys;
299
477
  class Badge {
300
478
  constructor(badgeData) {
301
479
  __privateAdd$2(this, _requirementsIndex, {});
480
+ __privateAdd$2(this, _zoneKeys, /* @__PURE__ */ new Set());
302
481
  /**
303
482
  * The database key for this badge.
304
483
  */
305
- __publicField$4(this, "key");
484
+ __publicField$6(this, "key");
306
485
  /**
307
486
  * The type of badge.
308
487
  */
309
- __publicField$4(this, "type");
488
+ __publicField$6(this, "type");
310
489
  /**
311
490
  * The name of this badge.
312
491
  *
313
492
  * May vary by character sex or alignment.
314
493
  */
315
- __publicField$4(this, "name");
494
+ __publicField$6(this, "name");
316
495
  /**
317
- * The character alignments that this badge is available to.
496
+ * The character moralities that this badge is available to.
318
497
  */
319
- __publicField$4(this, "alignment");
498
+ __publicField$6(this, "morality");
320
499
  /**
321
500
  * The badge text as it appears in-game. May vary by character sex or alignment.
322
501
  */
323
- __publicField$4(this, "badgeText");
502
+ __publicField$6(this, "badgeText");
324
503
  /**
325
504
  * Short description of how to acquire the badge. Detailed instructions will be in the notes field.
326
505
  */
327
- __publicField$4(this, "acquisition");
506
+ __publicField$6(this, "acquisition");
328
507
  /**
329
508
  * Absolute URL to this badge's icon.
330
509
  *
331
510
  * May vary by character sex or alignment.
332
511
  */
333
- __publicField$4(this, "icon");
512
+ __publicField$6(this, "icon");
334
513
  /**
335
514
  * Freeform notes or tips about the badge.
336
515
  */
337
- __publicField$4(this, "notes");
516
+ __publicField$6(this, "notes");
338
517
  /**
339
518
  * List of external links. Wiki, forums, etc.
340
519
  */
341
- __publicField$4(this, "links");
342
- /**
343
- * For exploration badges, the key of the {@link Zone} that this badge is found on.
344
- */
345
- __publicField$4(this, "zoneKey");
346
- /**
347
- * For exploration badges, the `/loc` coordinates of the badge.
348
- */
349
- __publicField$4(this, "loc");
350
- /**
351
- * For plaques that appear on a Vidiot Map, the number or letter the badge appears as.
352
- */
353
- __publicField$4(this, "vidiotMapKey");
520
+ __publicField$6(this, "links");
354
521
  /**
355
- * ID used with the in-game `/settitle` command to apply the badge.
522
+ * The id used with the in-game `/settitle` command to apply the badge.
523
+ * The first value is the id for primal characters and the (optional) second number is the id for praetorian characters.
356
524
  */
357
- __publicField$4(this, "setTitle");
525
+ __publicField$6(this, "setTitleId");
358
526
  /**
359
527
  * A description of the effect the badge will have, such as a buff or granting a temporary power.
360
528
  */
361
- __publicField$4(this, "effect");
529
+ __publicField$6(this, "effect");
362
530
  /**
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.
531
+ * Represents the requirements for badges with multiple fulfillment steps, such as visiting monuments for history badges, completing missions, or collecting other badges.
371
532
  */
372
- __publicField$4(this, "requirements");
533
+ __publicField$6(this, "requirements");
373
534
  /**
374
535
  * 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
536
  */
376
- __publicField$4(this, "ignoreInTotals");
537
+ __publicField$6(this, "ignoreInTotals");
377
538
  this.key = new Key(badgeData.key).value;
378
539
  this.type = badgeData.type;
379
540
  this.name = new Alternates(badgeData.name);
380
- this.alignment = new Alignments(badgeData.alignment);
541
+ this.morality = new MoralityList(coalesceToArray(badgeData.morality));
381
542
  this.badgeText = new Alternates(badgeData.badgeText ?? []);
382
543
  this.acquisition = badgeData.acquisition;
383
544
  this.icon = new Alternates(badgeData.icon ?? []);
384
545
  this.notes = badgeData.notes;
385
546
  this.links = badgeData.links ?? [];
386
- this.zoneKey = badgeData.zoneKey;
387
- this.loc = badgeData.loc;
388
547
  this.effect = badgeData.effect;
389
- this.vidiotMapKey = badgeData.vidiotMapKey;
390
- this.setTitle = badgeData.setTitle;
548
+ this.setTitleId = badgeData.setTitleId;
391
549
  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
- });
550
+ this.requirements = badgeData.requirements?.map((requirementData) => {
551
+ if (__privateGet$2(this, _requirementsIndex)[requirementData.key]) throw new Error(`Duplicate badge requirement key [${badgeData.key}:${requirementData.key}]`);
552
+ const requirement = new BadgeRequirement(requirementData);
553
+ __privateGet$2(this, _requirementsIndex)[requirement.key] = requirement;
554
+ if (requirement.location) for (const location of requirement.location) {
555
+ if (location.zoneKey) __privateGet$2(this, _zoneKeys).add(location.zoneKey);
556
+ }
557
+ return requirement;
401
558
  });
402
559
  }
403
560
  getRequirement(key) {
@@ -405,8 +562,37 @@ class Badge {
405
562
  if (result === void 0) throw new Error(`Unknown badge requirement key [${key}]`);
406
563
  return result;
407
564
  }
565
+ /**
566
+ * Return a list of all the zone keys referenced by this badge.
567
+ */
568
+ get zoneKeys() {
569
+ return [...__privateGet$2(this, _zoneKeys)];
570
+ }
571
+ /**
572
+ * The zone key if this badge relates to a single zone.
573
+ */
574
+ get zoneKey() {
575
+ return __privateGet$2(this, _zoneKeys).size === 1 ? __privateGet$2(this, _zoneKeys).values().next().value : void 0;
576
+ }
408
577
  }
409
578
  _requirementsIndex = new WeakMap();
579
+ _zoneKeys = new WeakMap();
580
+ function compareByDefaultName(a, b) {
581
+ const aName = a?.name.default?.value;
582
+ const bName = b?.name.default?.value;
583
+ if (!aName && !bName) return 0;
584
+ if (!aName) return 1;
585
+ if (!bName) return -1;
586
+ return aName.localeCompare(bName);
587
+ }
588
+ function compareByZoneKey(a, b) {
589
+ const aZone = a?.zoneKey;
590
+ const bZone = b?.zoneKey;
591
+ if (!aZone && !bZone) return 0;
592
+ if (!aZone) return 1;
593
+ if (!bZone) return -1;
594
+ return aZone.localeCompare(bZone);
595
+ }
410
596
 
411
597
  var __typeError$1 = (msg) => {
412
598
  throw TypeError(msg);
@@ -416,16 +602,12 @@ var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "rea
416
602
  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
603
  var __privateSet$1 = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
418
604
  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;
605
+ var _badges, _badgeIndex$1, _BadgeIndex_instances, satisfiesQueryPredicate_fn, satisfiesFilterPredicate_fn, sort_fn;
420
606
  class BadgeIndex {
421
- constructor(badges, zones) {
607
+ constructor(badges) {
422
608
  __privateAdd$1(this, _BadgeIndex_instances);
423
609
  __privateAdd$1(this, _badges, []);
424
610
  __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
611
  __privateSet$1(this, _badges, badges);
430
612
  for (const badge of badges) {
431
613
  if (__privateGet$1(this, _badgeIndex$1)[badge.key] !== void 0) throw new Error(`Duplicate badge key [${badge.key}]`);
@@ -433,12 +615,8 @@ class BadgeIndex {
433
615
  }
434
616
  }
435
617
  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];
618
+ if (!key) return void 0;
619
+ return __privateGet$1(this, _badgeIndex$1)[key];
442
620
  }
443
621
  searchBadges(options) {
444
622
  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);
@@ -457,55 +635,47 @@ class BadgeIndex {
457
635
  }
458
636
  _badges = new WeakMap();
459
637
  _badgeIndex$1 = new WeakMap();
460
- _zoneOrder = new WeakMap();
461
638
  _BadgeIndex_instances = new WeakSet();
462
639
  satisfiesQueryPredicate_fn = function(badge, query) {
463
640
  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)));
641
+ 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.setTitleId?.some((x) => x?.toString().includes(queryString)));
465
642
  };
466
643
  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));
644
+ return (!filter?.type || badge.type === filter.type) && (!filter?.zoneKey || badge.zoneKey === filter.zoneKey) && (!filter?.morality || badge.morality.has(filter.morality));
468
645
  };
469
646
  sort_fn = function(badges, sort) {
470
647
  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
- });
648
+ const ascending = sort.dir !== "desc";
649
+ if (sort.by === "badge-name") return badges.sort((a, b) => ascending ? compareByDefaultName(a, b) : compareByDefaultName(b, a));
650
+ if (sort.by === "zone-key") return badges.sort((a, b) => ascending ? compareByZoneKey(a, b) : compareByZoneKey(b, a));
651
+ return sort.dir === "desc" ? badges.reverse() : badges;
482
652
  };
483
653
 
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);
654
+ var __defProp$5 = Object.defineProperty;
655
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
656
+ var __publicField$5 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
487
657
  class BundleMetadata {
488
658
  constructor(bundle) {
489
659
  /**
490
660
  * Name of the content bundle.
491
661
  */
492
- __publicField$3(this, "name");
662
+ __publicField$5(this, "name");
493
663
  /**
494
664
  * Description of the fork.
495
665
  */
496
- __publicField$3(this, "description");
666
+ __publicField$5(this, "description");
497
667
  /**
498
668
  * Repository where the db content package is maintained.
499
669
  */
500
- __publicField$3(this, "repository");
670
+ __publicField$5(this, "repository");
501
671
  /**
502
672
  * List of external links. Wiki, forums, etc.
503
673
  */
504
- __publicField$3(this, "links");
674
+ __publicField$5(this, "links");
505
675
  /**
506
676
  * Change log for this data package.
507
677
  */
508
- __publicField$3(this, "changelog");
678
+ __publicField$5(this, "changelog");
509
679
  this.name = bundle.name;
510
680
  this.description = bundle.description;
511
681
  this.repository = bundle.repository;
@@ -514,92 +684,159 @@ class BundleMetadata {
514
684
  }
515
685
  }
516
686
 
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);
687
+ var __defProp$4 = Object.defineProperty;
688
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
689
+ var __publicField$4 = (obj, key, value) => __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
520
690
  class Zone {
521
691
  constructor(data) {
522
692
  /**
523
693
  * Unique key used to reference this zone.
524
694
  *
525
- * Keys can only contain lowercase letters, numbers and hyphens (`-`).
695
+ * Keys must be unique and can only contain lowercase letters, numbers and hyphens (`-`).
526
696
  */
527
- __publicField$2(this, "key");
697
+ __publicField$4(this, "key");
528
698
  /**
529
699
  * The name of the zone as it appears in-game.
530
700
  */
531
- __publicField$2(this, "name");
701
+ __publicField$4(this, "name");
532
702
  /**
533
703
  * List of external links. Wiki, forums, etc.
534
704
  */
535
- __publicField$2(this, "links");
705
+ __publicField$4(this, "links");
536
706
  this.key = new Key(data.key).value;
537
707
  this.name = data.name;
538
708
  this.links = data.links ?? [];
539
709
  }
540
710
  }
541
711
 
542
- var __defProp$1 = Object.defineProperty;
543
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
544
- var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
712
+ var __defProp$3 = Object.defineProperty;
713
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
714
+ var __publicField$3 = (obj, key, value) => __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
545
715
  class Contact {
546
- constructor(contactData) {
716
+ constructor(data) {
547
717
  /**
548
718
  * Unique key used to reference this contact.
549
719
  *
550
- * Keys can only contain lowercase letters, numbers and hyphens (`-`).
720
+ * Keys must be unique and can only contain lowercase letters, numbers and hyphens (`-`).
551
721
  */
552
- __publicField$1(this, "key");
722
+ __publicField$3(this, "key");
553
723
  /**
554
724
  * The name of this contact.
555
725
  */
556
- __publicField$1(this, "name");
726
+ __publicField$3(this, "name");
557
727
  /**
558
728
  * The contact's title.
559
729
  */
560
- __publicField$1(this, "title");
730
+ __publicField$3(this, "title");
561
731
  /**
562
- * The zone this character is located in.
732
+ * The character moralities that this contact will interact with.
563
733
  */
564
- __publicField$1(this, "zoneKey");
734
+ __publicField$3(this, "morality");
565
735
  /**
566
- * The `/loc` coordinates of the contact.
736
+ * The location of this contact.
567
737
  */
568
- __publicField$1(this, "loc");
738
+ __publicField$3(this, "location");
569
739
  /**
570
740
  * The level range this contact will offer missions for.
571
741
  */
572
- __publicField$1(this, "levelRange");
742
+ __publicField$3(this, "levelRange");
573
743
  /**
574
744
  * Freeform notes or tips about the contact.
575
745
  */
576
- __publicField$1(this, "notes");
746
+ __publicField$3(this, "notes");
577
747
  /**
578
748
  * List of external links. Wiki, forums, etc.
579
749
  */
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 ?? [];
750
+ __publicField$3(this, "links");
751
+ this.key = new Key(data.key).value;
752
+ this.name = data.name;
753
+ this.title = data.title;
754
+ this.morality = new MoralityList(coalesceToArray(data.morality));
755
+ this.location = data.location;
756
+ this.levelRange = data.levelRange;
757
+ this.notes = data.notes;
758
+ this.links = data.links ?? [];
589
759
  }
590
760
  }
591
761
 
592
- var __defProp = Object.defineProperty;
762
+ var __defProp$2 = Object.defineProperty;
763
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
764
+ var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
765
+ class Mission {
766
+ constructor(data) {
767
+ /**
768
+ * Unique key used to reference this mission.
769
+ *
770
+ * Keys must be unique and can only contain lowercase letters, numbers and hyphens (`-`).
771
+ */
772
+ __publicField$2(this, "key");
773
+ /**
774
+ * The name of the mission as it appears from the contact.
775
+ *
776
+ * The name may be different when viewed in Ouroboros as a Flashback.
777
+ */
778
+ __publicField$2(this, "name");
779
+ /**
780
+ * The type of mission... Story arc, task force, trial, etc.
781
+ */
782
+ __publicField$2(this, "type");
783
+ /**
784
+ * The character moralities that may accept the mission.
785
+ */
786
+ __publicField$2(this, "morality");
787
+ /**
788
+ * The keys of any contacts that provide this mission.
789
+ */
790
+ __publicField$2(this, "contactKeys");
791
+ /**
792
+ * The level range this mission is available for.
793
+ */
794
+ __publicField$2(this, "levelRange");
795
+ /**
796
+ * Freeform notes or tips about the mission.
797
+ */
798
+ __publicField$2(this, "notes");
799
+ /**
800
+ * List of external links. Wiki, forums, etc.
801
+ */
802
+ __publicField$2(this, "links");
803
+ /**
804
+ * If the mission is available in Ouroboros as a Flashback.
805
+ */
806
+ __publicField$2(this, "flashback");
807
+ this.key = new Key(data.key).value;
808
+ this.name = data.name;
809
+ this.type = data.type;
810
+ this.morality = new MoralityList(coalesceToArray(data.morality));
811
+ this.contactKeys = coalesceToArray(data.contactKeys);
812
+ this.levelRange = data.levelRange;
813
+ this.notes = data.notes;
814
+ this.links = data.links ?? [];
815
+ this.flashback = createFlashback(data);
816
+ }
817
+ }
818
+ function createFlashback(data) {
819
+ if (!data.flashback) return void 0;
820
+ return {
821
+ id: data.flashback.id,
822
+ levelRange: data.flashback.levelRange ?? data.levelRange,
823
+ name: data.flashback.name ?? data.name,
824
+ morality: new MoralityList(coalesceToArray(data.flashback.morality ?? data.morality)),
825
+ notes: data.flashback.notes
826
+ };
827
+ }
828
+
829
+ var __defProp$1 = Object.defineProperty;
593
830
  var __typeError = (msg) => {
594
831
  throw TypeError(msg);
595
832
  };
596
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
597
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
833
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
834
+ var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
598
835
  var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
599
836
  var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
600
837
  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);
601
838
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
602
- var _archetypeIndex, _zoneIndex, _contactIndex, _badgeIndex;
839
+ var _archetypeIndex, _zoneIndex, _contactIndex, _missionIndex, _badgeIndex;
603
840
  class CohContentDatabase {
604
841
  /**
605
842
  * Initialize the database with a content bundle.
@@ -609,33 +846,38 @@ class CohContentDatabase {
609
846
  __privateAdd(this, _archetypeIndex, {});
610
847
  __privateAdd(this, _zoneIndex, {});
611
848
  __privateAdd(this, _contactIndex, {});
849
+ __privateAdd(this, _missionIndex, {});
612
850
  __privateAdd(this, _badgeIndex);
613
851
  /**
614
852
  * Metadata about the content bundle.
615
853
  */
616
- __publicField(this, "metadata");
854
+ __publicField$1(this, "metadata");
617
855
  /**
618
856
  * List of the game server names.
619
857
  *
620
858
  * Torchbearer, Excelsior, etc.
621
859
  */
622
- __publicField(this, "servers");
860
+ __publicField$1(this, "servers");
623
861
  /**
624
862
  * List of archetypes.
625
863
  */
626
- __publicField(this, "archetypes");
864
+ __publicField$1(this, "archetypes");
627
865
  /**
628
866
  * List of game zones.
629
867
  */
630
- __publicField(this, "zones");
868
+ __publicField$1(this, "zones");
631
869
  /**
632
870
  * List of contacts.
633
871
  */
634
- __publicField(this, "contacts");
872
+ __publicField$1(this, "contacts");
873
+ /**
874
+ * List of missions.
875
+ */
876
+ __publicField$1(this, "missions");
635
877
  /**
636
878
  * List of badges.
637
879
  */
638
- __publicField(this, "badges");
880
+ __publicField$1(this, "badges");
639
881
  this.metadata = new BundleMetadata(bundle);
640
882
  this.servers = bundle.servers ?? [];
641
883
  this.archetypes = bundle.archetypes?.map((data) => {
@@ -656,36 +898,34 @@ class CohContentDatabase {
656
898
  __privateGet(this, _contactIndex)[contact.key] = contact;
657
899
  return contact;
658
900
  }) ?? [];
901
+ this.missions = bundle.missions?.map((data) => {
902
+ if (__privateGet(this, _missionIndex)[data.key] !== void 0) throw new Error(`Duplicate mission key '${data.key}'`);
903
+ const mission = new Mission(data);
904
+ __privateGet(this, _missionIndex)[mission.key] = mission;
905
+ return mission;
906
+ }) ?? [];
659
907
  this.badges = bundle.badges?.map((data) => new Badge(data)) ?? [];
660
- __privateSet(this, _badgeIndex, new BadgeIndex(this.badges, this.zones));
908
+ __privateSet(this, _badgeIndex, new BadgeIndex(this.badges));
661
909
  }
662
910
  getArchetype(key) {
663
- const result = __privateGet(this, _archetypeIndex)[key];
664
- if (result === void 0) throw new Error(`Unknown archetype key '${key}'`);
665
- return result;
911
+ if (!key) return void 0;
912
+ return __privateGet(this, _archetypeIndex)[key];
666
913
  }
667
914
  getZone(key) {
668
- const result = __privateGet(this, _zoneIndex)[key];
669
- if (result === void 0) throw new Error(`Unknown zone key '${key}'`);
670
- return result;
915
+ if (!key) return void 0;
916
+ return __privateGet(this, _zoneIndex)[key];
671
917
  }
672
918
  getContact(key) {
673
- const result = __privateGet(this, _contactIndex)[key];
674
- if (result === void 0) throw new Error(`Unknown contact key '${key}'`);
675
- return result;
676
- }
677
- zoneExists(key) {
678
- return !!__privateGet(this, _zoneIndex)[key];
919
+ if (!key) return void 0;
920
+ return __privateGet(this, _contactIndex)[key];
679
921
  }
680
- contactExists(key) {
681
- return !!__privateGet(this, _contactIndex)[key];
922
+ getMission(key) {
923
+ if (!key) return void 0;
924
+ return __privateGet(this, _missionIndex)[key];
682
925
  }
683
926
  getBadge(key) {
684
927
  return __privateGet(this, _badgeIndex).getBadge(key);
685
928
  }
686
- badgeExists(key) {
687
- return __privateGet(this, _badgeIndex).badgeExists(key);
688
- }
689
929
  /**
690
930
  * Search, sort and filter the badge list.
691
931
  * This is a fairly brute-forced approach and will not be as performant as loading the badge data into a traditional
@@ -699,23 +939,53 @@ class CohContentDatabase {
699
939
  _archetypeIndex = new WeakMap();
700
940
  _zoneIndex = new WeakMap();
701
941
  _contactIndex = new WeakMap();
942
+ _missionIndex = new WeakMap();
702
943
  _badgeIndex = new WeakMap();
703
944
 
945
+ var __defProp = Object.defineProperty;
946
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
947
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
948
+ class Location {
949
+ constructor(data) {
950
+ /**
951
+ * Key of the {@link Zone} that the location references.
952
+ */
953
+ __publicField(this, "zoneKey");
954
+ /**
955
+ * In-game `/loc` coordinates of the location.
956
+ */
957
+ __publicField(this, "coords");
958
+ /**
959
+ * The type of icon to use if the location appears on a map. (Typically the Vidiot map icon).
960
+ */
961
+ __publicField(this, "icon");
962
+ /**
963
+ * The text that should appear in the location icon. (Typically a number or symbol from the Vidiot map).
964
+ */
965
+ __publicField(this, "iconText");
966
+ this.zoneKey = data.zoneKey;
967
+ this.coords = data.coords;
968
+ this.icon = data.icon;
969
+ this.iconText = data.iconText;
970
+ }
971
+ }
972
+
704
973
  const CHANGELOG = [
705
974
  {
706
975
  version: "2.0.0",
707
976
  date: /* @__PURE__ */ new Date("2025-03-12"),
708
977
  description: `* Replaced redundant interfaces with their concrete equivalents.
709
978
  * Server groups are now referred to as 'forks'.
710
- * Replaced enums with union types.
711
- * \`IServerGroupData\` is now \`ContentBundle\` and each database instance is now designed to accept only a single server group.
979
+ * Replaced enums with union types and changed values to \`kebab-case\`.
980
+ * \`IServerGroupData\` is now \`ContentBundle\` and each database instance is now designed to accept only a single bundle.
712
981
  * \`GameMap\` is now \`Zone\`.
713
982
  * Removed the \`serverGroup\` property from entities to simplify the object tree given that only a single context can exist per db now.
714
983
  * Added a simple indexing and search function for badge names, text and acquisition info.
715
984
  * 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.
985
+ * Badge partials are now known as badge requirements.
717
986
  * 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.
987
+ * Added formal support for Missions and Contacts in badge requirements.
988
+ * Move exploration badge locations into badge requirement list.
719
989
  * Standardized pluralization of some field names (name, icon).
720
990
  * Combined \`settitle\` ids into a single tuple field.
721
991
  * Change from GNU to The Unlicense.
@@ -728,33 +998,8 @@ const CHANGELOG = [
728
998
  }
729
999
  ];
730
1000
 
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) {
748
- const key = typeof target === "string" ? target : target.key;
749
- return `zone://${key}`;
750
- }
751
- function zoneLink(target) {
752
- const key = typeof target === "string" ? target : target.key;
753
- return `[${key}](${zoneUri(target)})`;
754
- }
755
-
756
1001
  exports.ALIGNMENT = ALIGNMENT;
757
- exports.Alignments = Alignments;
1002
+ exports.AlignmentList = AlignmentList;
758
1003
  exports.Alternates = Alternates;
759
1004
  exports.Archetype = Archetype;
760
1005
  exports.BADGE_REQUIREMENT_TYPE = BADGE_REQUIREMENT_TYPE;
@@ -768,13 +1013,24 @@ exports.CohContentDatabase = CohContentDatabase;
768
1013
  exports.Contact = Contact;
769
1014
  exports.ENHANCEMENT_CATEGORY = ENHANCEMENT_CATEGORY;
770
1015
  exports.Key = Key;
771
- exports.PLAQUE_TYPE = PLAQUE_TYPE;
1016
+ exports.Location = Location;
1017
+ exports.MISSION_TYPE = MISSION_TYPE;
1018
+ exports.MORALITY = MORALITY;
1019
+ exports.Mission = Mission;
1020
+ exports.MoralityList = MoralityList;
772
1021
  exports.SEX = SEX;
773
1022
  exports.Zone = Zone;
774
1023
  exports.badgeLink = badgeLink;
775
1024
  exports.badgeUri = badgeUri;
1025
+ exports.coalesceToArray = coalesceToArray;
1026
+ exports.compareAlignment = compareAlignment;
1027
+ exports.compareByDefaultName = compareByDefaultName;
1028
+ exports.compareByZoneKey = compareByZoneKey;
1029
+ exports.compareSex = compareSex;
776
1030
  exports.contactLink = contactLink;
777
1031
  exports.contactUri = contactUri;
1032
+ exports.missionLink = missionLink;
1033
+ exports.missionUri = missionUri;
778
1034
  exports.zoneLink = zoneLink;
779
1035
  exports.zoneUri = zoneUri;
780
1036
  //# sourceMappingURL=coh-content-db.js.map