coh-content-db 2.0.0-rc.10 → 2.0.0-rc.12

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.
@@ -105,7 +105,7 @@ var __publicField$a = (obj, key, value) => __defNormalProp$a(obj, typeof key !==
105
105
  var __accessCheck$6 = (obj, member, msg) => member.has(obj) || __typeError$6("Cannot " + msg);
106
106
  var __privateGet$5 = (obj, member, getter) => (__accessCheck$6(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
107
107
  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);
108
- var __privateSet$4 = (obj, member, value, setter) => (__accessCheck$6(obj, member, "write to private field"), member.set(obj, value), value);
108
+ var __privateSet$5 = (obj, member, value, setter) => (__accessCheck$6(obj, member, "write to private field"), member.set(obj, value), value);
109
109
  var _items$1;
110
110
  class AlignmentList {
111
111
  constructor(items) {
@@ -121,7 +121,7 @@ class AlignmentList {
121
121
  this.praetorian = set.has("praetorian") || set.has("all");
122
122
  this.primal = this.hero && this.villain;
123
123
  this.all = this.hero && this.villain && this.praetorian;
124
- __privateSet$4(this, _items$1, /* @__PURE__ */ new Set());
124
+ __privateSet$5(this, _items$1, /* @__PURE__ */ new Set());
125
125
  if (this.hero) __privateGet$5(this, _items$1).add("hero");
126
126
  if (this.villain) __privateGet$5(this, _items$1).add("villain");
127
127
  if (this.praetorian) __privateGet$5(this, _items$1).add("praetorian");
@@ -160,7 +160,7 @@ var __typeError$5 = (msg) => {
160
160
  var __accessCheck$5 = (obj, member, msg) => member.has(obj) || __typeError$5("Cannot " + msg);
161
161
  var __privateGet$4 = (obj, member, getter) => (__accessCheck$5(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
162
162
  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);
163
- var __privateSet$3 = (obj, member, value, setter) => (__accessCheck$5(obj, member, "write to private field"), member.set(obj, value), value);
163
+ var __privateSet$4 = (obj, member, value, setter) => (__accessCheck$5(obj, member, "write to private field"), member.set(obj, value), value);
164
164
  var __privateMethod$2 = (obj, member, method) => (__accessCheck$5(obj, member, "access private method"), method);
165
165
  var _sortedValues, _Alternates_instances, compareAlternates_fn;
166
166
  class Alternates {
@@ -172,10 +172,10 @@ class Alternates {
172
172
  __privateAdd$5(this, _Alternates_instances);
173
173
  __privateAdd$5(this, _sortedValues, []);
174
174
  if (Array.isArray(value)) {
175
- __privateSet$3(this, _sortedValues, value.sort());
175
+ __privateSet$4(this, _sortedValues, value.sort());
176
176
  __privateGet$4(this, _sortedValues).sort((a, b) => __privateMethod$2(this, _Alternates_instances, compareAlternates_fn).call(this, a, b));
177
177
  } else {
178
- __privateSet$3(this, _sortedValues, [{ value }]);
178
+ __privateSet$4(this, _sortedValues, [{ value }]);
179
179
  }
180
180
  }
181
181
  getValue(alignment, sex) {
@@ -224,7 +224,7 @@ var __typeError$4 = (msg) => {
224
224
  var __accessCheck$4 = (obj, member, msg) => member.has(obj) || __typeError$4("Cannot " + msg);
225
225
  var __privateGet$3 = (obj, member, getter) => (__accessCheck$4(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
226
226
  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);
227
- var __privateSet$2 = (obj, member, value, setter) => (__accessCheck$4(obj, member, "write to private field"), member.set(obj, value), value);
227
+ var __privateSet$3 = (obj, member, value, setter) => (__accessCheck$4(obj, member, "write to private field"), member.set(obj, value), value);
228
228
  var __privateMethod$1 = (obj, member, method) => (__accessCheck$4(obj, member, "access private method"), method);
229
229
  var _value, _Key_instances, validateKey_fn;
230
230
  const INVALID_KEY_PATTERN = /[^a-z0-9-]/;
@@ -233,7 +233,7 @@ class Key {
233
233
  __privateAdd$4(this, _Key_instances);
234
234
  __privateAdd$4(this, _value);
235
235
  __privateMethod$1(this, _Key_instances, validateKey_fn).call(this, value);
236
- __privateSet$2(this, _value, value);
236
+ __privateSet$3(this, _value, value);
237
237
  }
238
238
  get value() {
239
239
  return __privateGet$3(this, _value);
@@ -370,7 +370,7 @@ var __publicField$7 = (obj, key, value) => __defNormalProp$7(obj, typeof key !==
370
370
  var __accessCheck$3 = (obj, member, msg) => member.has(obj) || __typeError$3("Cannot " + msg);
371
371
  var __privateGet$2 = (obj, member, getter) => (__accessCheck$3(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
372
372
  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);
373
- var __privateSet$1 = (obj, member, value, setter) => (__accessCheck$3(obj, member, "write to private field"), member.set(obj, value), value);
373
+ var __privateSet$2 = (obj, member, value, setter) => (__accessCheck$3(obj, member, "write to private field"), member.set(obj, value), value);
374
374
  var _items;
375
375
  class MoralityList {
376
376
  constructor(items) {
@@ -402,7 +402,7 @@ class MoralityList {
402
402
  this.paragonCityAccess = this.heroic && this.rogue;
403
403
  this.rogueIslesAccess = this.villainous && this.vigilante;
404
404
  this.all = this.primal && this.praetorian;
405
- __privateSet$1(this, _items, /* @__PURE__ */ new Set());
405
+ __privateSet$2(this, _items, /* @__PURE__ */ new Set());
406
406
  if (this.hero) __privateGet$2(this, _items).add("hero");
407
407
  if (this.vigilante) __privateGet$2(this, _items).add("vigilante");
408
408
  if (this.villain) __privateGet$2(this, _items).add("villain");
@@ -463,79 +463,117 @@ class MoralityList {
463
463
  _items = new WeakMap();
464
464
 
465
465
  var __defProp$6 = Object.defineProperty;
466
+ var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
467
+ var __publicField$6 = (obj, key, value) => __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
468
+ class AbstractIndex {
469
+ /**
470
+ * Create a new index.
471
+ * @param keyField The field of the values that will act as the key.
472
+ * @param values Values to index.
473
+ */
474
+ constructor(keyField, values) {
475
+ __publicField$6(this, "_values", []);
476
+ __publicField$6(this, "_hashTable", {});
477
+ this._values = values ?? [];
478
+ this._hashTable = {};
479
+ for (const value of this.values) {
480
+ const key = value[keyField];
481
+ if (this._hashTable[key] !== void 0) throw new Error(`Duplicate key [${key}]`);
482
+ this._hashTable[key] = value;
483
+ }
484
+ }
485
+ /**
486
+ * Return all indexed values
487
+ */
488
+ get values() {
489
+ return this._values;
490
+ }
491
+ /**
492
+ * Get a value from the index
493
+ * @param key Key string
494
+ */
495
+ get(key) {
496
+ if (!key) return void 0;
497
+ return this._hashTable[key];
498
+ }
499
+ }
500
+
501
+ var __defProp$5 = Object.defineProperty;
466
502
  var __typeError$2 = (msg) => {
467
503
  throw TypeError(msg);
468
504
  };
469
- var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
470
- var __publicField$6 = (obj, key, value) => __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
505
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
506
+ var __publicField$5 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
471
507
  var __accessCheck$2 = (obj, member, msg) => member.has(obj) || __typeError$2("Cannot " + msg);
472
508
  var __privateGet$1 = (obj, member, getter) => (__accessCheck$2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
473
509
  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);
510
+ var __privateSet$1 = (obj, member, value, setter) => (__accessCheck$2(obj, member, "write to private field"), member.set(obj, value), value);
474
511
  var _requirementsIndex, _zoneKeys;
475
512
  class Badge {
476
513
  constructor(badgeData) {
477
- __privateAdd$2(this, _requirementsIndex, {});
514
+ __privateAdd$2(this, _requirementsIndex);
478
515
  __privateAdd$2(this, _zoneKeys, /* @__PURE__ */ new Set());
479
516
  /**
480
517
  * The database key for this badge.
481
518
  */
482
- __publicField$6(this, "key");
519
+ __publicField$5(this, "key");
483
520
  /**
484
521
  * The type of badge.
485
522
  */
486
- __publicField$6(this, "type");
523
+ __publicField$5(this, "type");
487
524
  /**
488
525
  * The name of this badge.
489
526
  *
490
527
  * May vary by character sex or alignment.
491
528
  */
492
- __publicField$6(this, "name");
529
+ __publicField$5(this, "name");
530
+ /**
531
+ * The date that the badge was added to the game.
532
+ */
533
+ __publicField$5(this, "releaseDate");
493
534
  /**
494
535
  * The character moralities that this badge is available to.
495
536
  */
496
- __publicField$6(this, "morality");
537
+ __publicField$5(this, "morality");
497
538
  /**
498
539
  * The badge text as it appears in-game. May vary by character sex or alignment.
499
540
  */
500
- __publicField$6(this, "badgeText");
541
+ __publicField$5(this, "badgeText");
501
542
  /**
502
543
  * Short description of how to acquire the badge. Detailed instructions will be in the notes field.
503
544
  */
504
- __publicField$6(this, "acquisition");
545
+ __publicField$5(this, "acquisition");
505
546
  /**
506
547
  * Absolute URL to this badge's icon.
507
548
  *
508
549
  * May vary by character sex or alignment.
509
550
  */
510
- __publicField$6(this, "icon");
551
+ __publicField$5(this, "icon");
511
552
  /**
512
553
  * Freeform notes or tips about the badge.
513
554
  */
514
- __publicField$6(this, "notes");
555
+ __publicField$5(this, "notes");
515
556
  /**
516
557
  * List of external links. Wiki, forums, etc.
517
558
  */
518
- __publicField$6(this, "links");
559
+ __publicField$5(this, "links");
519
560
  /**
520
561
  * The id used with the in-game `/settitle` command to apply the badge.
521
562
  * The first value is the id for primal characters and the (optional) second number is the id for praetorian characters.
522
563
  */
523
- __publicField$6(this, "setTitleId");
564
+ __publicField$5(this, "setTitleId");
524
565
  /**
525
566
  * A description of the effect the badge will have, such as a buff or granting a temporary power.
526
567
  */
527
- __publicField$6(this, "effect");
528
- /**
529
- * Represents the requirements for badges with multiple fulfillment steps, such as visiting monuments for history badges, completing missions, or collecting other badges.
530
- */
531
- __publicField$6(this, "requirements");
568
+ __publicField$5(this, "effect");
532
569
  /**
533
570
  * 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.
534
571
  */
535
- __publicField$6(this, "ignoreInTotals");
572
+ __publicField$5(this, "ignoreInTotals");
536
573
  this.key = new Key(badgeData.key).value;
537
574
  this.type = badgeData.type;
538
575
  this.name = new Alternates(badgeData.name);
576
+ this.releaseDate = new Date(badgeData.releaseDate);
539
577
  this.morality = new MoralityList(coalesceToArray(badgeData.morality));
540
578
  this.badgeText = new Alternates(badgeData.badgeText ?? []);
541
579
  this.acquisition = badgeData.acquisition;
@@ -545,20 +583,21 @@ class Badge {
545
583
  this.effect = badgeData.effect;
546
584
  this.setTitleId = badgeData.setTitleId;
547
585
  this.ignoreInTotals = badgeData.ignoreInTotals ?? false;
548
- this.requirements = badgeData.requirements?.map((requirementData) => {
549
- if (__privateGet$1(this, _requirementsIndex)[requirementData.key]) throw new Error(`Duplicate badge requirement key [${badgeData.key}:${requirementData.key}]`);
550
- const requirement = new BadgeRequirement(requirementData);
551
- __privateGet$1(this, _requirementsIndex)[requirement.key] = requirement;
586
+ __privateSet$1(this, _requirementsIndex, new AbstractIndex("key", badgeData.requirements?.map((x) => new BadgeRequirement(x))));
587
+ for (const requirement of __privateGet$1(this, _requirementsIndex).values) {
552
588
  if (requirement.location) for (const location of requirement.location) {
553
589
  if (location.zoneKey) __privateGet$1(this, _zoneKeys).add(location.zoneKey);
554
590
  }
555
- return requirement;
556
- });
591
+ }
592
+ }
593
+ /**
594
+ * Represents the requirements for badges with multiple fulfillment steps, such as visiting monuments for history badges, completing missions, or collecting other badges.
595
+ */
596
+ get requirements() {
597
+ return __privateGet$1(this, _requirementsIndex).values;
557
598
  }
558
599
  getRequirement(key) {
559
- const result = __privateGet$1(this, _requirementsIndex)[key];
560
- if (result === void 0) throw new Error(`Unknown badge requirement key [${key}]`);
561
- return result;
600
+ return __privateGet$1(this, _requirementsIndex).get(key);
562
601
  }
563
602
  /**
564
603
  * Return a list of all the zone keys referenced by this badge.
@@ -591,41 +630,13 @@ function compareByZoneKey(a, b) {
591
630
  if (!bZone) return -1;
592
631
  return aZone.localeCompare(bZone);
593
632
  }
594
-
595
- var __defProp$5 = Object.defineProperty;
596
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
597
- var __publicField$5 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
598
- class AbstractIndex {
599
- /**
600
- * Create a new index.
601
- * @param keyField The field of the values that will act as the key.
602
- * @param values Values to index.
603
- */
604
- constructor(keyField, values) {
605
- __publicField$5(this, "_values", []);
606
- __publicField$5(this, "_hashTable", {});
607
- this._values = values ?? [];
608
- this._hashTable = {};
609
- for (const value of this.values) {
610
- const key = value[keyField];
611
- if (this._hashTable[key] !== void 0) throw new Error(`Duplicate key [${key}]`);
612
- this._hashTable[key] = value;
613
- }
614
- }
615
- /**
616
- * Return all indexed values
617
- */
618
- get values() {
619
- return this._values;
620
- }
621
- /**
622
- * Get a value from the index
623
- * @param key Key string
624
- */
625
- get(key) {
626
- if (!key) return void 0;
627
- return this._hashTable[key];
628
- }
633
+ function compareByReleaseDate(a, b) {
634
+ const aReleaseDate = a?.releaseDate?.getTime();
635
+ const bReleaseDate = b?.releaseDate?.getTime();
636
+ if (aReleaseDate === bReleaseDate) return 0;
637
+ if (!aReleaseDate) return 1;
638
+ if (!bReleaseDate) return -1;
639
+ return aReleaseDate < bReleaseDate ? -1 : 1;
629
640
  }
630
641
 
631
642
  var __typeError$1 = (msg) => {
@@ -658,7 +669,9 @@ class BadgeIndex extends AbstractIndex {
658
669
  _BadgeIndex_instances = new WeakSet();
659
670
  satisfiesQueryPredicate_fn = function(badge, query) {
660
671
  const queryString = query?.str?.toLowerCase() ?? "";
661
- 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)));
672
+ const fields = query?.fields ? new Set(query?.fields) : /* @__PURE__ */ new Set(["name"]);
673
+ if (fields.size === 0) return true;
674
+ 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)));
662
675
  };
663
676
  satisfiesFilterPredicate_fn = function(badge, filter) {
664
677
  return (!filter?.type || badge.type === filter.type) && (!filter?.zoneKey || badge.zoneKey === filter.zoneKey) && (!filter?.morality || badge.morality.has(filter.morality));
@@ -668,6 +681,7 @@ sort_fn = function(badges, sort) {
668
681
  const ascending = sort.dir !== "desc";
669
682
  if (sort.by === "badge-name") return badges.sort((a, b) => ascending ? compareByDefaultName(a, b) : compareByDefaultName(b, a));
670
683
  if (sort.by === "zone-key") return badges.sort((a, b) => ascending ? compareByZoneKey(a, b) : compareByZoneKey(b, a));
684
+ if (sort.by === "release-date") return badges.sort((a, b) => ascending ? compareByReleaseDate(a, b) : compareByReleaseDate(b, a));
671
685
  return sort.dir === "desc" ? badges.reverse() : badges;
672
686
  };
673
687
 
@@ -1005,5 +1019,5 @@ class Location {
1005
1019
  }
1006
1020
  }
1007
1021
 
1008
- export { ALIGNMENT, AlignmentList, Alternates, Archetype, BADGE_REQUIREMENT_TYPE, BADGE_TYPE, Badge, BadgeIndex, BadgeRequirement, BundleHeader, CohContentDatabase, Contact, ENHANCEMENT_CATEGORY, Key, Location, MISSION_TYPE, MORALITY, Mission, MoralityList, SEX, Zone, badgeLink, badgeUri, coalesceToArray, compareAlignment, compareByDefaultName, compareByZoneKey, compareSex, contactLink, contactUri, missionLink, missionUri, zoneLink, zoneUri };
1022
+ export { ALIGNMENT, AlignmentList, Alternates, Archetype, BADGE_REQUIREMENT_TYPE, BADGE_TYPE, Badge, BadgeIndex, BadgeRequirement, BundleHeader, CohContentDatabase, Contact, ENHANCEMENT_CATEGORY, Key, Location, MISSION_TYPE, MORALITY, Mission, MoralityList, SEX, Zone, badgeLink, badgeUri, coalesceToArray, compareAlignment, compareByDefaultName, compareByReleaseDate, compareByZoneKey, compareSex, contactLink, contactUri, missionLink, missionUri, zoneLink, zoneUri };
1009
1023
  //# sourceMappingURL=coh-content-db.mjs.map