warframe-worldstate-parser 2.32.0 → 3.0.0

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 (98) hide show
  1. package/README.md +1 -0
  2. package/lib/WorldState.js +60 -94
  3. package/lib/models/Alert.js +18 -44
  4. package/lib/models/CambionCycle.js +8 -12
  5. package/lib/models/CetusCycle.js +34 -54
  6. package/lib/models/ChallengeInstance.js +11 -14
  7. package/lib/models/ConclaveChallenge.js +24 -44
  8. package/lib/models/ConstructionProgress.js +10 -22
  9. package/lib/models/DailyDeal.js +15 -34
  10. package/lib/models/DarkSector.js +14 -25
  11. package/lib/models/DarkSectorBattle.js +6 -8
  12. package/lib/models/DuviriCycle.js +9 -10
  13. package/lib/models/EarthCycle.js +36 -35
  14. package/lib/models/Fissure.js +36 -44
  15. package/lib/models/FlashSale.js +17 -37
  16. package/lib/models/GlobalUpgrade.js +23 -41
  17. package/lib/models/Invasion.js +37 -79
  18. package/lib/models/Kuva.js +20 -26
  19. package/lib/models/Mission.js +28 -38
  20. package/lib/models/News.js +34 -54
  21. package/lib/models/Nightwave.js +22 -48
  22. package/lib/models/NightwaveChallenge.js +15 -19
  23. package/lib/models/PersistentEnemy.js +21 -30
  24. package/lib/models/Reward.js +18 -20
  25. package/lib/models/SentientOutpost.js +11 -12
  26. package/lib/models/Simaris.js +9 -21
  27. package/lib/models/Sortie.js +36 -54
  28. package/lib/models/SortieVariant.js +23 -25
  29. package/lib/models/SteelPathOffering.js +26 -9
  30. package/lib/models/SyndicateJob.js +20 -30
  31. package/lib/models/SyndicateMission.js +22 -52
  32. package/lib/models/VallisCycle.js +37 -45
  33. package/lib/models/VoidTrader.js +35 -54
  34. package/lib/models/VoidTraderItem.js +5 -8
  35. package/lib/models/VoidTraderSchedule.js +7 -6
  36. package/lib/models/WeeklyChallenge.js +9 -17
  37. package/lib/models/WorldEvent.js +49 -74
  38. package/lib/models/WorldstateObject.js +23 -34
  39. package/lib/models/ZarimanCycle.js +34 -54
  40. package/lib/supporting/Dependency.js +2 -11
  41. package/lib/supporting/DuviriChoice.js +1 -5
  42. package/lib/supporting/ExternalMission.js +2 -6
  43. package/lib/supporting/MarkdownSettings.js +15 -19
  44. package/lib/supporting/RewardData.js +4 -6
  45. package/lib/supporting/RewardTypes.js +2 -4
  46. package/lib/utilities/integrity.js +11 -0
  47. package/lib/utilities/timeDate.js +16 -18
  48. package/lib/utilities/translation.js +188 -56
  49. package/main.js +2 -2
  50. package/package.json +3 -5
  51. package/types/lib/WorldState.d.ts +39 -28
  52. package/types/lib/models/Alert.d.ts +13 -24
  53. package/types/lib/models/CambionCycle.d.ts +5 -10
  54. package/types/lib/models/CetusCycle.d.ts +8 -26
  55. package/types/lib/models/ChallengeInstance.d.ts +7 -9
  56. package/types/lib/models/ConclaveChallenge.d.ts +11 -24
  57. package/types/lib/models/ConstructionProgress.d.ts +5 -16
  58. package/types/lib/models/DailyDeal.d.ts +7 -26
  59. package/types/lib/models/DarkSector.d.ts +11 -22
  60. package/types/lib/models/DarkSectorBattle.d.ts +3 -6
  61. package/types/lib/models/DuviriCycle.d.ts +5 -11
  62. package/types/lib/models/EarthCycle.d.ts +40 -17
  63. package/types/lib/models/Fissure.d.ts +10 -17
  64. package/types/lib/models/FlashSale.d.ts +8 -29
  65. package/types/lib/models/GlobalUpgrade.d.ts +8 -27
  66. package/types/lib/models/Invasion.d.ts +18 -53
  67. package/types/lib/models/Kuva.d.ts +10 -21
  68. package/types/lib/models/Mission.d.ts +11 -23
  69. package/types/lib/models/News.d.ts +18 -31
  70. package/types/lib/models/Nightwave.d.ts +12 -29
  71. package/types/lib/models/NightwaveChallenge.d.ts +10 -15
  72. package/types/lib/models/PersistentEnemy.d.ts +9 -20
  73. package/types/lib/models/Reward.d.ts +34 -18
  74. package/types/lib/models/SentientOutpost.d.ts +9 -13
  75. package/types/lib/models/Simaris.d.ts +6 -17
  76. package/types/lib/models/Sortie.d.ts +16 -25
  77. package/types/lib/models/SortieVariant.d.ts +13 -15
  78. package/types/lib/models/SteelPathOffering.d.ts +5 -8
  79. package/types/lib/models/SyndicateJob.d.ts +13 -14
  80. package/types/lib/models/SyndicateMission.d.ts +9 -22
  81. package/types/lib/models/VallisCycle.d.ts +28 -18
  82. package/types/lib/models/VoidTrader.d.ts +8 -21
  83. package/types/lib/models/VoidTraderItem.d.ts +4 -6
  84. package/types/lib/models/VoidTraderSchedule.d.ts +5 -8
  85. package/types/lib/models/WeeklyChallenge.d.ts +5 -14
  86. package/types/lib/models/WorldEvent.d.ts +38 -52
  87. package/types/lib/models/WorldstateObject.d.ts +46 -24
  88. package/types/lib/models/ZarimanCycle.d.ts +9 -27
  89. package/types/lib/supporting/Dependency.d.ts +2 -8
  90. package/types/lib/supporting/DuviriChoice.d.ts +1 -2
  91. package/types/lib/supporting/ExternalMission.d.ts +3 -7
  92. package/types/lib/supporting/MarkdownSettings.d.ts +29 -15
  93. package/types/lib/supporting/RewardData.d.ts +8 -2
  94. package/types/lib/supporting/RewardTypes.d.ts +2 -2
  95. package/types/lib/utilities/integrity.d.ts +1 -0
  96. package/types/lib/utilities/timeDate.d.ts +19 -12
  97. package/types/lib/utilities/translation.d.ts +188 -23
  98. package/types/main.d.ts +2 -4
@@ -1,8 +1,10 @@
1
- 'use strict';
1
+ import { createHash } from 'node:crypto';
2
+
3
+ import { node, nodeMissionType } from '../utilities/translation.js';
2
4
 
3
5
  /**
4
6
  * External mission data retrieved from https://10o.io/kuvalog.json
5
- * @typedef {Object} ExternalMission
7
+ * @typedef {object} ExternalMission
6
8
  * @property {Date} activation start time
7
9
  * @property {Date} expiry end timer
8
10
  * @property {string} node formatted node name with planet
@@ -15,7 +17,7 @@
15
17
 
16
18
  /**
17
19
  * Stores and parses kuva data from https://10o.io/kuvalog.json
18
- * @typedef {Object} Kuva
20
+ * @typedef {object} Kuva
19
21
  * @property {ExternalMission[]} kuva currently active kuva missions
20
22
  * @property {ExternalMission} arbitration current arbitration
21
23
  */
@@ -24,7 +26,7 @@ const HOURS_2 = 7200000;
24
26
 
25
27
  /**
26
28
  * Truncate time for a semlar-provided mission
27
- * @param {Object} mission parsed mission with re-aligned field names
29
+ * @param {object} mission parsed mission with re-aligned field names
28
30
  */
29
31
  const truncateTime = (mission) => {
30
32
  mission.expiry.setHours(mission.activation.getHours() + 1);
@@ -36,7 +38,7 @@ const truncateTime = (mission) => {
36
38
 
37
39
  /**
38
40
  * Scrub unnecessary details from the mission
39
- * @param {Object} mission parsed mission with re-aligned field names
41
+ * @param {object} mission parsed mission with re-aligned field names
40
42
  */
41
43
  const scrub = (mission) => {
42
44
  /* eslint-disable no-param-reassign */
@@ -48,16 +50,15 @@ const scrub = (mission) => {
48
50
  /* eslint-enable no-param-reassign */
49
51
  };
50
52
 
51
- const hash = (str) => require('crypto').createHash('sha256').update(str, 'utf8').digest('hex');
53
+ const hash = (str) => createHash('sha256').update(str, 'utf8').digest('hex');
52
54
 
53
55
  /**
54
56
  * Parse kuva & arbitration data
55
- * @param {Object} data Data to split for kuva/arbitration
56
- * @param {Object.<function>} translator Translator functions
57
+ * @param {object} data Data to split for kuva/arbitration
57
58
  * @param {string} locale locale to translate
58
59
  * @returns {Kuva} Split parsed data
59
60
  */
60
- const parse = (data, translator, locale) => {
61
+ const parse = (data, locale) => {
61
62
  const parsed = { kuva: [], arbitration: {} };
62
63
  const now = new Date();
63
64
  data.forEach((mission) => {
@@ -65,10 +66,10 @@ const parse = (data, translator, locale) => {
65
66
  activation: new Date(mission.start),
66
67
  expiry: new Date(mission.end),
67
68
  ...mission.solnodedata,
68
- node: translator.node(mission.solnode, locale),
69
- nodeKey: translator.node(mission.solnode, 'en'),
70
- type: translator.nodeMissionType(mission.solnode, locale),
71
- typeKey: translator.nodeMissionType(mission.solnode, 'en'),
69
+ node: node(mission.solnode, locale),
70
+ nodeKey: node(mission.solnode, 'en'),
71
+ type: nodeMissionType(mission.solnode, locale),
72
+ typeKey: nodeMissionType(mission.solnode, 'en'),
72
73
  };
73
74
  truncateTime(p);
74
75
  p.id = hash(JSON.stringify(p));
@@ -98,30 +99,23 @@ const parse = (data, translator, locale) => {
98
99
  * @property {ExternalMission[]} kuva currently active kuva missions
99
100
  * @property {ExternalMission} arbitration current arbitration
100
101
  */
101
- module.exports = class Kuva {
102
- constructor({ kuvaData, translator, locale, logger }) {
103
- /**
104
- * The translation functions
105
- * @type {Translator}
106
- * @private
107
- */
108
- this.translator = translator;
109
- Object.defineProperty(this, 'translator', { enumerable: false, configurable: false });
102
+ export default class Kuva {
103
+ #locale;
110
104
 
105
+ constructor({ kuvaData, locale, logger }) {
111
106
  /**
112
107
  * The locale to leverage for translations
113
108
  * @type {string}
114
109
  * @private
115
110
  */
116
- this.locale = locale;
117
- Object.defineProperty(this, 'locale', { enumerable: false, configurable: false });
111
+ this.#locale = locale;
118
112
 
119
113
  if (!kuvaData) {
120
114
  // eslint-ignore-next-line no-console
121
115
  logger.debug('No defined kuva data, skipping data');
122
116
  } else {
123
- const parsed = parse(kuvaData, this.translator, this.locale);
117
+ const parsed = parse(kuvaData, this.locale);
124
118
  ({ kuva: this.kuva, arbitration: this.arbitration } = parsed);
125
119
  }
126
120
  }
127
- };
121
+ }
@@ -1,74 +1,64 @@
1
- 'use strict';
1
+ import mdConfig from '../supporting/MarkdownSettings.js';
2
+ import { languageString, faction, missionType, node } from '../utilities/translation.js';
3
+ import { insist } from '../utilities/integrity.js';
4
+
5
+ import Reward from './Reward.js';
2
6
 
3
7
  /**
4
8
  * Represents an in-game mission
5
9
  */
6
- module.exports = class Mission {
10
+ export default class Mission {
7
11
  /**
8
- * @param {Object} data The mission data
9
- * @param {Object} deps The dependencies object
10
- * @param {MarkdownSettings} deps.mdConfig The markdown settings
11
- * @param {Translator} deps.translator The string translator
12
- * @param {Reward} deps.Reward The Reward parser
13
- * @param {string} deps.locale Locale to use for translations
12
+ * @param {object} data The mission data
13
+ * @param {string} locale Locale to use for translations
14
14
  */
15
- constructor(data, { mdConfig, translator, Reward, locale }) {
15
+ constructor(data, { locale = 'en' } = { locale: 'en' }) {
16
16
  const deps = {
17
- mdConfig,
18
- translator,
19
- Reward,
20
17
  locale,
21
18
  };
22
-
23
- /**
24
- * The markdown settings
25
- * @type {MarkdownSettings}
26
- * @private
27
- */
28
- this.mdConfig = mdConfig;
29
- Object.defineProperty(this, 'mdConfig', { enumerable: false, configurable: false });
19
+ insist(data);
30
20
 
31
21
  /**
32
22
  * The mission's description
33
23
  * @type {?string}
34
24
  */
35
- this.description = translator.languageString(data.descText, locale);
25
+ this.description = languageString(data.descText, locale);
36
26
 
37
27
  /**
38
28
  * The node where the mission takes place
39
29
  * @type {string}
40
30
  */
41
- this.node = translator.node(data.location || data.node, locale);
31
+ this.node = node(data.location || data.node, locale);
42
32
 
43
33
  /**
44
34
  * Unlocalized {@link mission#node}
45
35
  * @type {string}
46
36
  */
47
- this.nodeKey = translator.node(data.location || data.node, 'en');
37
+ this.nodeKey = node(data.location || data.node, 'en');
48
38
 
49
39
  /**
50
40
  * The mission's type
51
41
  * @type {string}
52
42
  */
53
- this.type = translator.missionType(data.missionType, locale);
43
+ this.type = missionType(data.missionType, locale);
54
44
 
55
45
  /**
56
46
  * The mission's type
57
47
  * @type {string}
58
48
  */
59
- this.typeKey = translator.missionType(data.missionType, 'en');
49
+ this.typeKey = missionType(data.missionType, 'en');
60
50
 
61
51
  /**
62
52
  * The factions that the players must fight in the mission
63
53
  * @type {string}
64
54
  */
65
- this.faction = translator.faction(data.faction, locale);
55
+ this.faction = faction(data.faction, locale);
66
56
 
67
57
  /**
68
58
  * The factions that the players must fight in the mission
69
59
  * @type {string}
70
60
  */
71
- this.factionKey = translator.faction(data.faction, 'en');
61
+ this.factionKey = faction(data.faction, 'en');
72
62
 
73
63
  /**
74
64
  * The mission's reward
@@ -116,25 +106,25 @@ module.exports = class Mission {
116
106
  * Override for the map on this mission
117
107
  * @type {string}
118
108
  */
119
- this.levelOverride = translator.languageString(data.levelOverride, locale);
109
+ this.levelOverride = languageString(data.levelOverride, locale);
120
110
 
121
111
  /**
122
112
  * Enemy specification for the mission
123
- * @type {String}
113
+ * @type {string}
124
114
  */
125
- this.enemySpec = translator.languageString(data.enemySpec, locale);
115
+ this.enemySpec = languageString(data.enemySpec, locale);
126
116
 
127
117
  /**
128
118
  * Array of strings denoting extra spawners for a mission
129
119
  * @type {string[]}
130
120
  */
131
- this.advancedSpawners = (data.advancedSpawners || []).map((spawner) => translator.languageString(spawner, locale));
121
+ this.advancedSpawners = (data.advancedSpawners || []).map((spawner) => languageString(spawner, locale));
132
122
 
133
123
  /**
134
124
  * Items required to enter the mission
135
125
  * @type {string[]}
136
126
  */
137
- this.requiredItems = (data.requiredItems || []).map((reqItem) => translator.languageString(reqItem, locale));
127
+ this.requiredItems = (data.requiredItems || []).map((reqItem) => languageString(reqItem, locale));
138
128
 
139
129
  /**
140
130
  * Whether or not the required items are consumed
@@ -146,7 +136,7 @@ module.exports = class Mission {
146
136
  * Target for the mission
147
137
  * @type {string}
148
138
  */
149
- this.target = translator.languageString(data.vipAgent, locale);
139
+ this.target = languageString(data.vipAgent, locale);
150
140
 
151
141
  /**
152
142
  * Whether or not leaders are always allowed
@@ -164,18 +154,18 @@ module.exports = class Mission {
164
154
  * Affectors for this mission
165
155
  * @type {string[]}
166
156
  */
167
- this.levelAuras = (data.levelAuras || []).map((aura) => translator.languageString(aura, locale));
157
+ this.levelAuras = (data.levelAuras || []).map((aura) => languageString(aura, locale));
168
158
 
169
159
  /**
170
160
  * Only weapon allowed for the mission
171
161
  * @type {string}
172
162
  */
173
- this.exclusiveWeapon = translator.languageString(data.exclusiveWeapon, locale);
163
+ this.exclusiveWeapon = languageString(data.exclusiveWeapon, locale);
174
164
  }
175
165
 
176
166
  /**
177
167
  * The Mission's string representation
178
- * @returns {string}
168
+ * @returns {string} Mission's string representation
179
169
  */
180
170
  toString() {
181
171
  const lines = [this.reward.toString()];
@@ -184,6 +174,6 @@ module.exports = class Mission {
184
174
  lines.push(this.node);
185
175
  lines.push(`level ${this.minEnemyLevel} - ${this.maxEnemyLevel}`);
186
176
 
187
- return lines.join(this.mdConfig.lineEnd);
177
+ return lines.join(mdConfig.lineEnd);
188
178
  }
189
- };
179
+ }
@@ -1,6 +1,8 @@
1
- 'use strict';
1
+ import mdConfig from '../supporting/MarkdownSettings.js';
2
+ import { languageString } from '../utilities/translation.js';
3
+ import { fromNow, parseDate, timeDeltaToString, toNow } from '../utilities/timeDate.js';
2
4
 
3
- const WorldstateObject = require('./WorldstateObject');
5
+ import WorldstateObject from './WorldstateObject.js';
4
6
 
5
7
  const updateReg = /(update|hotfix)/i;
6
8
  const primeAccessReg = /(access)/i;
@@ -9,35 +11,15 @@ const langString = /(\/Lotus\/Language\/)/i;
9
11
 
10
12
  /**
11
13
  * Represents a game news item
12
- * @extends {WorldstateObject}
14
+ * @augments {WorldstateObject}
13
15
  */
14
- class News extends WorldstateObject {
16
+ export default class News extends WorldstateObject {
15
17
  /**
16
- * @param {Object} data The news data
17
- * @param {Dependency} deps The dependencies object
18
- * @param {MarkdownSettings} deps.mdConfig The markdown settings
19
- * @param {Translator} deps.translator The string translator
20
- * @param {TimeDateFunctions} deps.timeDate The time and date functions
21
- * @param {locale} deps.locale Locale to use for determining language
18
+ * @param {object} data The news data
19
+ * @param {string} locale Locale to use for determining language
22
20
  */
23
- constructor(data, { mdConfig, translator, timeDate, locale }) {
24
- super(data, { timeDate });
25
-
26
- /**
27
- * The markdown settings
28
- * @type {MarkdownSettings}
29
- * @private
30
- */
31
- this.mdConfig = mdConfig;
32
- Object.defineProperty(this, 'mdConfig', { enumerable: false, configurable: false });
33
-
34
- /**
35
- * The time and date functions
36
- * @type {TimeDateFunctions}
37
- * @private
38
- */
39
- this.timeDate = timeDate;
40
- Object.defineProperty(this, 'timeDate', { enumerable: false, configurable: false });
21
+ constructor(data, { locale = 'en' } = { locale: 'en' }) {
22
+ super(data);
41
23
 
42
24
  /**
43
25
  * The news message
@@ -45,7 +27,7 @@ class News extends WorldstateObject {
45
27
  */
46
28
  this.message = (data.Messages.find((msg) => msg.LanguageCode === locale) || { Message: '' }).Message;
47
29
  if (langString.test(this.message)) {
48
- this.message = translator.languageString(this.message, locale);
30
+ this.message = languageString(this.message, locale);
49
31
  }
50
32
 
51
33
  /**
@@ -76,34 +58,34 @@ class News extends WorldstateObject {
76
58
  * The date at which the post was published
77
59
  * @type {Date}
78
60
  */
79
- this.date = timeDate.parseDate(data.Date);
61
+ this.date = parseDate(data.Date);
80
62
 
81
63
  /**
82
64
  * The date at which the event starts
83
65
  * @type {?Date}
84
66
  */
85
- this.startDate = data.EventStartDate ? timeDate.parseDate(data.EventStartDate) : undefined;
67
+ this.startDate = data.EventStartDate ? parseDate(data.EventStartDate) : undefined;
86
68
 
87
69
  /**
88
70
  * The date at which the event ends
89
71
  * @type {?Date}
90
72
  */
91
- this.endDate = data.EventEndDate ? timeDate.parseDate(data.EventEndDate) : undefined;
73
+ this.endDate = data.EventEndDate ? parseDate(data.EventEndDate) : undefined;
92
74
 
93
75
  /**
94
76
  * ETA string (at time of object creation)
95
- * @type {String}
77
+ * @type {string}
96
78
  */
97
79
  this.eta = this.getETAString();
98
80
 
99
81
  /**
100
- * Whther or not this is an update news item
82
+ * Whether this is an update news item
101
83
  * @type {boolean}
102
84
  */
103
85
  this.update = this.isUpdate();
104
86
 
105
87
  /**
106
- * Whther or not this is a prime access news item
88
+ * Whether this is a prime access news item
107
89
  * @type {boolean}
108
90
  */
109
91
  this.primeAccess = this.isPrimeAccess();
@@ -116,14 +98,14 @@ class News extends WorldstateObject {
116
98
 
117
99
  /**
118
100
  * Translation of the news item
119
- * @type {Object.<string, string>}
101
+ * @type {Record<string, string>}
120
102
  */
121
103
  this.translations = {};
122
104
  data.Messages.forEach((message) => {
123
- this.translations[message.LanguageCode] = message.Message;
105
+ this.translations[message.LanguageCode ?? 'en'] = message.Message;
124
106
 
125
107
  if (langString.test(message.Message)) {
126
- this.translations[message.LanguageCode] = translator.languageString(message.Message, message.LanguageCode);
108
+ this.translations[message.LanguageCode] = languageString(message.Message, message.LanguageCode);
127
109
  }
128
110
  });
129
111
 
@@ -137,36 +119,36 @@ class News extends WorldstateObject {
137
119
  /**
138
120
  * Get a string indicating how long it will take for the event to start or
139
121
  * how long it's been since the news went up
140
- * @returns {string}
122
+ * @returns {string} the estimated time of arrival for the event
141
123
  */
142
124
  getETAString() {
143
125
  if (this.endDate) {
144
- const timeDelta = this.timeDate.fromNow(this.endDate);
145
- return `in ${this.timeDate.timeDeltaToString(timeDelta)}`;
126
+ const timeDelta = fromNow(this.endDate);
127
+ return `in ${timeDeltaToString(timeDelta)}`;
146
128
  }
147
- const timeDelta = this.timeDate.toNow(this.date);
148
- return `${this.timeDate.timeDeltaToString(timeDelta)} ago`;
129
+ const timeDelta = toNow(this.date);
130
+ return `${timeDeltaToString(timeDelta)} ago`;
149
131
  }
150
132
 
151
133
  /**
152
134
  * Whether or not this is about a game update
153
- * @returns {boolean}
135
+ * @returns {boolean} whether the news is about an update
154
136
  */
155
137
  isUpdate() {
156
138
  return updateReg.test(this.link);
157
139
  }
158
140
 
159
141
  /**
160
- * Whether or not this is about a new Prime Access
161
- * @returns {boolean}
142
+ * Whether this is about a new Prime Access
143
+ * @returns {boolean} whether the news is about a new Prime Access
162
144
  */
163
145
  isPrimeAccess() {
164
146
  return primeAccessReg.test(this.link);
165
147
  }
166
148
 
167
149
  /**
168
- * Whether or not this is about a new Prime Access
169
- * @returns {boolean}
150
+ * Whether this is about a new stream
151
+ * @returns {boolean} whether the news is for a stream
170
152
  */
171
153
  isStream() {
172
154
  return streamReg.test(this.message);
@@ -174,23 +156,21 @@ class News extends WorldstateObject {
174
156
 
175
157
  /**
176
158
  * String representation
177
- * @returns {string}
159
+ * @returns {string} string representation
178
160
  */
179
161
  toString() {
180
162
  return (
181
- `[${this.getETAString()}] ${this.mdConfig.linkBegin}${this.message}` +
182
- `${this.mdConfig.linkMid}${this.link}${this.mdConfig.linkEnd}`
163
+ `[${this.getETAString()}] ${mdConfig.linkBegin}${this.message}` +
164
+ `${mdConfig.linkMid}${this.link}${mdConfig.linkEnd}`
183
165
  );
184
166
  }
185
167
 
186
168
  /**
187
169
  * The title of the news item in the specified language
188
170
  * @param {string} langCode Ex. 'es', 'de', 'fr'
189
- * @returns {string}
171
+ * @returns {string} The title of the news item in the specified language
190
172
  */
191
173
  getTitle(langCode) {
192
174
  return langCode in this.translations ? this.translations[langCode] : this.message;
193
175
  }
194
176
  }
195
-
196
- module.exports = News;
@@ -1,56 +1,32 @@
1
- 'use strict';
1
+ import { languageString } from '../utilities/translation.js';
2
+ import { fromNow, timeDeltaToString } from '../utilities/timeDate.js';
3
+ import mdConfig from '../supporting/MarkdownSettings.js';
2
4
 
3
- const WorldstateObject = require('./WorldstateObject');
4
- const NightwaveChallenge = require('./NightwaveChallenge');
5
+ import WorldstateObject from './WorldstateObject.js';
6
+ import NightwaveChallenge from './NightwaveChallenge.js';
5
7
 
6
8
  /**
7
9
  * Represents an alert
8
- * @extends {WorldstateObject}
10
+ * @augments {WorldstateObject}
9
11
  */
10
- class Nightwave extends WorldstateObject {
12
+ export default class Nightwave extends WorldstateObject {
11
13
  /**
12
- * @param {Object} data The alert data
13
- * @param {Object} deps The dependencies object
14
- * @param {MarkdownSettings} deps.mdConfig The markdown settings
15
- * @param {Translator} deps.translator The string translator
16
- * @param {TimeDateFunctions} deps.timeDate The time and date functions
17
- * @param {Mission} deps.Mission The Mission parser
18
- * @param {Reward} deps.Reward The Reward parser
14
+ * @param {object} data The alert data
15
+ * @param {object} deps The dependencies object
19
16
  * @param {string} deps.locale Locale to use for translations
20
17
  */
21
- constructor(data, { mdConfig, translator, timeDate, Mission, Reward, locale }) {
22
- super(data, { timeDate });
18
+ constructor(data, { locale = 'en' } = { locale: 'en' }) {
19
+ super(data);
23
20
 
24
21
  this.id = `nightwave${new Date(this.expiry).getTime()}`;
25
22
 
26
23
  const deps = {
27
- mdConfig,
28
- translator,
29
- timeDate,
30
- Mission,
31
- Reward,
32
24
  locale,
33
25
  };
34
26
 
35
- /**
36
- * The markdown settings
37
- * @type {MarkdownSettings}
38
- * @private
39
- */
40
- this.mdConfig = mdConfig;
41
- Object.defineProperty(this, 'mdConfig', { enumerable: false, configurable: false });
42
-
43
- /**
44
- * The time and date functions
45
- * @type {TimeDateFunctions}
46
- * @private
47
- */
48
- this.timeDate = timeDate;
49
- Object.defineProperty(this, 'timeDate', { enumerable: false, configurable: false });
50
-
51
27
  /**
52
28
  * The current season. 0-indexed.
53
- * @type {Number}
29
+ * @type {number}
54
30
  */
55
31
  this.season = data.Season;
56
32
 
@@ -58,17 +34,17 @@ class Nightwave extends WorldstateObject {
58
34
  * Descriptor for affiliation
59
35
  * @type {string}
60
36
  */
61
- this.tag = translator.languageString(data.AffiliationTag, locale);
37
+ this.tag = languageString(data.AffiliationTag, locale);
62
38
 
63
39
  /**
64
40
  * The current season's current phase. 0-indexed.
65
- * @type {Number}
41
+ * @type {number}
66
42
  */
67
43
  this.phase = data.Phase;
68
44
 
69
45
  /**
70
46
  * Misc params provided.
71
- * @type {Object}
47
+ * @type {object}
72
48
  */
73
49
  this.params = JSON.parse(data.Params || '{}');
74
50
 
@@ -89,29 +65,27 @@ class Nightwave extends WorldstateObject {
89
65
 
90
66
  /**
91
67
  * Get a string indicating how much time is left before the alert expires
92
- * @returns {string}
68
+ * @returns {string} estimated timer of the alert
93
69
  */
94
70
  getETAString() {
95
- return this.timeDate.timeDeltaToString(this.timeDate.fromNow(this.expiry));
71
+ return timeDeltaToString(fromNow(this.expiry));
96
72
  }
97
73
 
98
74
  /**
99
75
  * Get an array containing the types of all of the nightwave season's rewards
100
- * @returns {Array.<string>}
76
+ * @returns {Array.<string>} an array containing the types of all of the nightwave season's rewards
101
77
  */
102
- // eslint-disable-next-line class-methods-use-this
103
78
  getRewardTypes() {
104
79
  return [];
105
80
  }
106
81
 
107
82
  /**
108
83
  * The alert's string representation
109
- * @returns {string}
84
+ * @returns {string} string representation of the alert
110
85
  */
111
- // eslint-disable-next-line class-methods-use-this
112
86
  toString() {
113
- return '';
87
+ return `${mdConfig.codeBlock}Nightwave Season ${this.season + 1} - ${this.tag} - Phase ${this.phase + 1}${
88
+ mdConfig.blockEnd
89
+ }`;
114
90
  }
115
91
  }
116
-
117
- module.exports = Nightwave;
@@ -1,33 +1,31 @@
1
- 'use strict';
1
+ import { languageDesc, languageString } from '../utilities/translation.js';
2
2
 
3
- const WorldstateObject = require('./WorldstateObject');
3
+ import WorldstateObject from './WorldstateObject.js';
4
4
 
5
5
  const repBase = 1000;
6
6
 
7
7
  /**
8
8
  * Represents an alert
9
- * @extends {WorldstateObject}
9
+ * @augments {WorldstateObject}
10
10
  */
11
- class NightwaveChallenge extends WorldstateObject {
11
+ export default class NightwaveChallenge extends WorldstateObject {
12
12
  /**
13
- * @param {Object} data The alert data
14
- * @param {Object} deps The dependencies object
15
- * @param {Translator} deps.translator The string translator
16
- * @param {TimeDateFunctions} deps.timeDate The time and date functions
13
+ * @param {object} data The alert data
14
+ * @param {object} deps The dependencies object
17
15
  * @param {string} deps.locale Locale to use for translations
18
16
  */
19
- constructor(data, { translator, timeDate, locale }) {
20
- super(data, { timeDate });
17
+ constructor(data, { locale = 'en' } = { locale: 'en' }) {
18
+ super(data);
21
19
 
22
20
  /**
23
21
  * Whether or not this is a daily challenge
24
- * @type {Boolean}
22
+ * @type {boolean}
25
23
  */
26
24
  this.isDaily = data.Daily || false;
27
25
 
28
26
  /**
29
27
  * Whether or not the challenge is an elite challenge
30
- * @type {Boolean}
28
+ * @type {boolean}
31
29
  */
32
30
  this.isElite = /hard/gi.test(data.Challenge);
33
31
 
@@ -35,13 +33,13 @@ class NightwaveChallenge extends WorldstateObject {
35
33
  * The descriptor for this challenge
36
34
  * @type {string}
37
35
  */
38
- this.desc = translator.languageDesc(data.Challenge, locale);
36
+ this.desc = languageDesc(data.Challenge, locale);
39
37
 
40
38
  /**
41
39
  * The title for this challenge
42
40
  * @type {string}
43
41
  */
44
- this.title = translator.languageString(data.Challenge, locale);
42
+ this.title = languageString(data.Challenge, locale);
45
43
 
46
44
  /**
47
45
  * Generated id from expiry, challenge string,
@@ -52,16 +50,14 @@ class NightwaveChallenge extends WorldstateObject {
52
50
 
53
51
  /**
54
52
  * Reputation reward for ranking up in the Nightwave
55
- * @type {Number}
53
+ * @type {number}
56
54
  */
57
55
  this.reputation = repBase + (!this.isDaily ? 3500 : 0) + (this.isElite ? 2500 : 0);
58
56
 
59
57
  /**
60
58
  * Whether this challenge is permanent
61
- * @type {Boolean}
59
+ * @type {boolean}
62
60
  */
63
- this.isPermanent = !!data?.Permanent;
61
+ this.isPermanent = Boolean(data?.Permanent);
64
62
  }
65
63
  }
66
-
67
- module.exports = NightwaveChallenge;