coh-content-db 2.0.0-rc.1 → 2.0.0-rc.11

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