warframe-worldstate-parser 2.32.0 → 3.0.1

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 +4 -6
  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,9 @@
1
- 'use strict';
1
+ import { parseDate } from '../utilities/timeDate.js';
2
+ import { languageString } from '../utilities/translation.js';
2
3
 
3
- module.exports = class VoidTraderSchedule {
4
- constructor(data, { timeDate, translator, locale }) {
5
- this.expiry = timeDate.parseDate(data.Expiry);
6
- this.item = translator.languageString(data.FeaturedItem, locale);
4
+ export default class VoidTraderSchedule {
5
+ constructor(data, { locale = 'en' } = { locale: 'en' }) {
6
+ this.expiry = parseDate(data.Expiry);
7
+ this.item = languageString(data.FeaturedItem, locale);
7
8
  }
8
- };
9
+ }
@@ -1,29 +1,23 @@
1
- 'use strict';
2
-
3
- const WorldstateObject = require('./WorldstateObject');
4
- const ChallengeInstance = require('./ChallengeInstance');
1
+ import WorldstateObject from './WorldstateObject.js';
2
+ import ChallengeInstance from './ChallengeInstance.js';
5
3
 
6
4
  /**
7
5
  * Represents a void trader
8
- * @extends {WorldstateObject}
6
+ * @augments {WorldstateObject}
9
7
  */
10
- class WeeklyChallenge extends WorldstateObject {
8
+ export default class WeeklyChallenge extends WorldstateObject {
11
9
  /**
12
- * @param {Object} data The Void trader 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
10
+ * @param {object} data The Void trader data
17
11
  */
18
- constructor(data, { timeDate, translator }) {
19
- super(data, { timeDate });
12
+ constructor(data) {
13
+ super(data);
20
14
 
21
- this.challenges = data.Challenges.map((challengeData) => new ChallengeInstance(challengeData, { translator }));
15
+ this.challenges = data.Challenges.map((challengeData) => new ChallengeInstance(challengeData));
22
16
  }
23
17
 
24
18
  /**
25
19
  * Returns a string representation of the trader
26
- * @returns {string}
20
+ * @returns {string} string representation
27
21
  */
28
22
  toString() {
29
23
  return `Starts: ${this.getStartString()}\nEnds: ${this.getEndString()}\nChallenges:\n${this.challenges
@@ -31,5 +25,3 @@ class WeeklyChallenge extends WorldstateObject {
31
25
  .join('\n')}`;
32
26
  }
33
27
  }
34
-
35
- module.exports = WeeklyChallenge;
@@ -1,72 +1,49 @@
1
- 'use strict';
1
+ import { fromNow, parseDate } from '../utilities/timeDate.js';
2
+ import { faction, languageString, node, syndicate } from '../utilities/translation.js';
3
+ import mdConfig from '../supporting/MarkdownSettings.js';
2
4
 
3
- const WorldstateObject = require('./WorldstateObject');
4
- const SyndicateJob = require('./SyndicateJob');
5
+ import WorldstateObject from './WorldstateObject.js';
6
+ import SyndicateJob from './SyndicateJob.js';
7
+ import Reward from './Reward.js';
5
8
 
6
9
  /**
7
10
  * Interim step for an event reward system.
8
- * @typedef {Object} InterimStep
9
- *
10
- * @property {Number} goal Goal amount
11
+ * @typedef {object} InterimStep
12
+ * @property {number} goal Goal amount
11
13
  * @property {Reward} reward Reward for reaching the step
12
- * @property {Number} winnerCount Amount of players at this step
13
- * @property {Object} message Message received when reaching the interim step
14
+ * @property {number} winnerCount Amount of players at this step
15
+ * @property {object} message Message received when reaching the interim step
14
16
  */
15
17
 
16
18
  /**
17
19
  * Progress for one of multiple stages
18
- * @typedef {Object} ProgressStep
19
- *
20
- * @property {string} type
21
- * @property {Number} progressAmt
20
+ * @typedef {object} ProgressStep
21
+ * @property {string} type Type of progress
22
+ * @property {number} progressAmt Amount of progress
22
23
  */
23
24
 
24
25
  /**
25
26
  * Represents an in-game special event
26
- *
27
- * @extends {WorldstateObject}
27
+ * @augments {WorldstateObject}
28
28
  */
29
- class WorldEvent extends WorldstateObject {
29
+ export default class WorldEvent extends WorldstateObject {
30
30
  /**
31
- * @param {Object} data The event data
32
- * @param {Object} deps The dependencies object
33
- * @param {MarkdownSettings} deps.mdConfig The markdown settings
34
- * @param {Translator} deps.translator The string translator
35
- * @param {TimeDateFunctions} deps.timeDate The time and date functions
36
- * @param {Reward} deps.Reward The Reward parser
31
+ * @param {object} data The event data
32
+ * @param {object} deps The dependencies object
37
33
  * @param {string} deps.locale Locale to use for translations
38
34
  */
39
- constructor(data, { mdConfig, translator, timeDate, Reward, locale }) {
40
- super(data, { timeDate });
35
+ constructor(data, { locale = 'en' } = { locale: 'en' }) {
36
+ super(data);
41
37
 
42
38
  const opts = {
43
- translator,
44
- mdConfig,
45
- Reward,
46
- timeDate,
47
39
  locale,
48
40
  };
49
41
 
50
- /**
51
- * The markdown settings
52
- * @type {MarkdownSettings}
53
- * @private
54
- */
55
- this.mdConfig = mdConfig;
56
- Object.defineProperty(this, 'mdConfig', { enumerable: false, configurable: false });
57
-
58
- /**
59
- * The time and date functions
60
- * @type {TimeDateFunctions}
61
- */
62
- this.timeDate = timeDate;
63
- Object.defineProperty(this, 'timeDate', { enumerable: false, configurable: false });
64
-
65
42
  /**
66
43
  * The date and time at which the event ends
67
44
  * @type {Date}
68
45
  */
69
- this.expiry = timeDate.parseDate(data.Expiry);
46
+ this.expiry = parseDate(data.Expiry);
70
47
 
71
48
  /**
72
49
  * The event's main score goal
@@ -96,43 +73,43 @@ class WorldEvent extends WorldstateObject {
96
73
  * The faction that the players must fight in the event
97
74
  * @type {string}
98
75
  */
99
- this.faction = translator.faction(data.Faction, locale);
76
+ this.faction = faction(data.Faction, locale);
100
77
 
101
78
  /**
102
79
  * The description of the event
103
80
  * @type {string}
104
81
  */
105
- this.description = translator.languageString(data.Desc, locale);
82
+ this.description = languageString(data.Desc, locale);
106
83
 
107
84
  /**
108
85
  * Tooltip for the event
109
86
  * @type {?string}
110
87
  */
111
- this.tooltip = translator.languageString(data.ToolTip, locale);
88
+ this.tooltip = languageString(data.ToolTip, locale);
112
89
 
113
90
  /**
114
91
  * The node where the event takes place
115
92
  * @type {?string}
116
93
  */
117
- this.node = translator.node(data.Node, locale);
94
+ this.node = node(data.Node, locale);
118
95
 
119
96
  /**
120
97
  * The other nodes where the event takes place
121
98
  * @type {string[]}
122
99
  */
123
- this.concurrentNodes = data.ConcurrentNodes ? data.ConcurrentNodes.map((n) => translator.node(n), locale) : [];
100
+ this.concurrentNodes = data.ConcurrentNodes ? data.ConcurrentNodes.map((n) => node(n), locale) : [];
124
101
 
125
102
  /**
126
103
  * The victim node
127
104
  * @type {?string}
128
105
  */
129
- this.victimNode = translator.node(data.VictimNode, locale);
106
+ this.victimNode = node(data.VictimNode, locale);
130
107
 
131
108
  /**
132
109
  * The score description
133
110
  * @type {?string}
134
111
  */
135
- this.scoreLocTag = data.Fomorian ? 'Fomorian Assault Score' : translator.languageString(data.ScoreLocTag, locale);
112
+ this.scoreLocTag = data.Fomorian ? 'Fomorian Assault Score' : languageString(data.ScoreLocTag, locale);
136
113
 
137
114
  /**
138
115
  * The event's rewards
@@ -150,13 +127,13 @@ class WorldEvent extends WorldstateObject {
150
127
 
151
128
  /**
152
129
  * Health remaining for the target
153
- * @type {Number}
130
+ * @type {number}
154
131
  */
155
132
  this.health =
156
133
  typeof data.HealthPct !== 'undefined' ? Number.parseFloat(((data.HealthPct || 0.0) * 100).toFixed(2)) : undefined;
157
134
 
158
135
  if (data.JobAffiliationTag) {
159
- this.affiliatedWith = translator.syndicate(data.JobAffiliationTag, locale);
136
+ this.affiliatedWith = syndicate(data.JobAffiliationTag, locale);
160
137
  if (data.Jobs) {
161
138
  this.jobs = (data.Jobs || []).map((j) => new SyndicateJob(j, this.expiry, opts));
162
139
  this.previousJobs = (data.PreviousJobs || []).map((j) => new SyndicateJob(j, this.expiry, opts));
@@ -165,7 +142,7 @@ class WorldEvent extends WorldstateObject {
165
142
 
166
143
  /**
167
144
  * Previous job id
168
- * @type {String}
145
+ * @type {string}
169
146
  */
170
147
  this.previousId = (data.JobPreviousVersion || {}).$oid;
171
148
 
@@ -181,9 +158,9 @@ class WorldEvent extends WorldstateObject {
181
158
  goal: Number.parseInt(data.InterimGoals[index], 10),
182
159
  reward: reward ? new Reward(reward, opts) : undefined,
183
160
  message: {
184
- sender: translator.languageString(msg.sender, locale),
185
- subject: translator.languageString(msg.subject, locale),
186
- message: translator.languageString(msg.message, locale),
161
+ sender: languageString(msg.sender, locale),
162
+ subject: languageString(msg.subject, locale),
163
+ message: languageString(msg.message, locale),
187
164
  senderIcon: msg.senderIcon,
188
165
  attachments: msg.attachments,
189
166
  },
@@ -201,14 +178,14 @@ class WorldEvent extends WorldstateObject {
201
178
  if (data.IsMultiProgress) {
202
179
  data.Types.forEach((type, index) => {
203
180
  this.progressSteps[index] = {
204
- type: translator.languageString(type, locale),
181
+ type: languageString(type, locale),
205
182
  progressAmt: Number.parseInt(data.MultiProgress[index], 10),
206
183
  };
207
184
  });
208
185
 
209
186
  /**
210
187
  * Total of all MultiProgress
211
- * @type {Number}
188
+ * @type {number}
212
189
  */
213
190
  this.progressTotal = Number.parseFloat(data.MultiProgress.reduce((accumulator, val) => accumulator + val));
214
191
  }
@@ -220,12 +197,12 @@ class WorldEvent extends WorldstateObject {
220
197
  this.showTotalAtEndOfMission = data.ShowTotalAtEOM;
221
198
  /**
222
199
  * Whether or not the event is personal
223
- * @type {Boolean}
200
+ * @type {boolean}
224
201
  */
225
202
  this.isPersonal = data.Personal;
226
203
  /**
227
204
  * Whether or not the event is community
228
- * @type {Boolean}
205
+ * @type {boolean}
229
206
  */
230
207
  this.isCommunity = data.Community;
231
208
 
@@ -233,50 +210,50 @@ class WorldEvent extends WorldstateObject {
233
210
  * Affectors for this mission
234
211
  * @type {string[]}
235
212
  */
236
- this.regionDrops = (data.RegionDrops || []).map((drop) => translator.languageString(drop, locale));
213
+ this.regionDrops = (data.RegionDrops || []).map((drop) => languageString(drop, locale));
237
214
 
238
215
  /**
239
216
  * Archwing Drops in effect while this event is active
240
217
  * @type {string[]}
241
218
  */
242
- this.archwingDrops = (data.ArchwingDrops || []).map((drop) => translator.languageString(drop, locale));
219
+ this.archwingDrops = (data.ArchwingDrops || []).map((drop) => languageString(drop, locale));
243
220
 
244
221
  this.asString = this.toString();
245
222
 
246
223
  /**
247
224
  * Metadata provided by DE
248
- * @type {Object}
225
+ * @type {object}
249
226
  */
250
227
  this.metadata = JSON.parse((data.Metadata || '{}').replace('" ', '"'));
251
228
 
252
229
  /**
253
230
  * Bonuses given for completion
254
- * @type {Array.<Number>}
231
+ * @type {Array.<number>}
255
232
  */
256
233
  this.completionBonuses = data.CompletionBonus || [];
257
234
 
258
235
  this.scoreVar = data.ScoreVar;
259
236
 
260
- this.altExpiry = timeDate.parseDate(data.AltExpiry);
261
- this.altActivation = timeDate.parseDate(data.AltActivation);
237
+ this.altExpiry = parseDate(data.AltExpiry);
238
+ this.altActivation = parseDate(data.AltActivation);
262
239
 
263
240
  this.nextAlt = {
264
- expiry: timeDate.parseDate(data.NextAltExpiry),
265
- activation: timeDate.parseDate(data.NextAltActivation),
241
+ expiry: parseDate(data.NextAltExpiry),
242
+ activation: parseDate(data.NextAltActivation),
266
243
  };
267
244
  }
268
245
 
269
246
  /**
270
247
  * Get whether or not the event has expired
271
- * @returns {boolean}
248
+ * @returns {boolean} whether the event has expired
272
249
  */
273
250
  getExpired() {
274
- return this.timeDate.fromNow(this.expiry) < 0;
251
+ return fromNow(this.expiry) < 0;
275
252
  }
276
253
 
277
254
  /**
278
255
  * The event's string representation
279
- * @returns {string}
256
+ * @returns {string} the event's string representation
280
257
  */
281
258
  toString() {
282
259
  let lines = [`${this.description} : ${this.faction}`];
@@ -306,8 +283,6 @@ class WorldEvent extends WorldstateObject {
306
283
  );
307
284
  }
308
285
 
309
- return lines.join(this.mdConfig.lineEnd);
286
+ return lines.join(mdConfig.lineEnd);
310
287
  }
311
288
  }
312
-
313
- module.exports = WorldEvent;
@@ -1,39 +1,39 @@
1
- 'use strict';
1
+ import { parseDate, fromNow, timeDeltaToString } from '../utilities/timeDate.js';
2
+ import { insist } from '../utilities/integrity.js';
2
3
 
3
4
  /**
4
- * @typedef {Object} Identifier
5
+ * @typedef {object} Identifier
5
6
  * @property {string} $id older identifier schema
6
7
  * @property {string} $oid newer global identifier schema
7
8
  */
8
9
  /**
9
- * @typedef {Object} LegacyTimestamp
10
+ * @typedef {object} LegacyTimestamp
10
11
  * @property {number} sec second-based timestamp
11
12
  */
12
13
  /**
13
- * @typedef {Object} Timestamp
14
+ * @typedef {object} Timestamp
14
15
  * @property {number} $numberLong millisecond-based timestamp
15
16
  */
16
17
  /**
17
- * @typedef {Object} ContentTimestamp
18
+ * @typedef {object} ContentTimestamp
18
19
  * @property {LegacyTimestamp|Timestamp} $date timestamp number wrapper
19
20
  */
20
21
  /**
21
- * @typedef {Object} BaseContentObject
22
- * @property {Identifier} _id
23
- * @property {ContentTimestamp} Activation
24
- * @property {ContentTimestamp} Expiry
22
+ * @typedef {object} BaseContentObject
23
+ * @property {Identifier} _id object identifier
24
+ * @property {ContentTimestamp} Activation activation timestamp
25
+ * @property {ContentTimestamp} Expiry expiry timestamp
25
26
  */
26
27
 
27
28
  /**
28
29
  * Represents a generic object from Worldstate
29
30
  */
30
- module.exports = class WorldstateObject {
31
+ export default class WorldstateObject {
31
32
  /**
32
33
  * @param {BaseContentObject} data The object data
33
- * @param {TimeDateFunctions} timeDate time date functions
34
- * @param {Translator} translator translation functions
35
34
  */
36
- constructor(data, { timeDate, translator }) {
35
+ constructor(data) {
36
+ insist(data);
37
37
  /**
38
38
  * The object's id field
39
39
  * @type {Identifier.$id|Identifier.$oid}
@@ -41,23 +41,12 @@ module.exports = class WorldstateObject {
41
41
  // eslint-disable-next-line no-underscore-dangle
42
42
  this.id = data._id ? data._id.$oid || data._id.$id : undefined;
43
43
 
44
- /**
45
- * The time and date functions
46
- * @type {TimeDateFunctions}
47
- * @private
48
- */
49
- this.timeDate = timeDate;
50
- Object.defineProperty(this, 'timeDate', { enumerable: false, configurable: false });
51
-
52
- this.translator = translator || require('../utilities/translation');
53
- Object.defineProperty(this, 'translator', { enumerable: false, configurable: false });
54
-
55
44
  if (data.Activation) {
56
45
  /**
57
46
  * The date and time at which the void trader arrives
58
47
  * @type {Date}
59
48
  */
60
- this.activation = timeDate.parseDate(data.Activation);
49
+ this.activation = parseDate(data.Activation);
61
50
 
62
51
  /**
63
52
  * A string indicating how long it will take for the trader to arrive
@@ -72,7 +61,7 @@ module.exports = class WorldstateObject {
72
61
  * The date and time at which the void trader leaves
73
62
  * @type {Date}
74
63
  */
75
- this.expiry = timeDate.parseDate(data.Expiry);
64
+ this.expiry = parseDate(data.Expiry);
76
65
  }
77
66
 
78
67
  if (data.Activation && data.Expiry) {
@@ -86,7 +75,7 @@ module.exports = class WorldstateObject {
86
75
 
87
76
  /**
88
77
  * Returns a string representation of the object
89
- * @returns {string}
78
+ * @returns {string} basic representation from the id
90
79
  */
91
80
  toString() {
92
81
  return `id: ${this.id}`;
@@ -94,25 +83,25 @@ module.exports = class WorldstateObject {
94
83
 
95
84
  /**
96
85
  * Get whether the trader is currently active
97
- * @returns {boolean}
86
+ * @returns {boolean} whether the trader is active
98
87
  */
99
88
  isActive() {
100
- return this.timeDate.fromNow(this.activation) < 0 && this.timeDate.fromNow(this.expiry) > 0;
89
+ return fromNow(this.activation) < 0 && fromNow(this.expiry) > 0;
101
90
  }
102
91
 
103
92
  /**
104
93
  * Get a string indicating how long it will take for the trader to arrive
105
- * @returns {string}
94
+ * @returns {string} time delta string from now to the start
106
95
  */
107
96
  getStartString() {
108
- return this.timeDate.timeDeltaToString(this.timeDate.fromNow(this.activation));
97
+ return timeDeltaToString(fromNow(this.activation));
109
98
  }
110
99
 
111
100
  /**
112
101
  * Get a string indicating how long it will take for the trader to leave
113
- * @returns {string}
102
+ * @returns {string} time delta string from now to the end
114
103
  */
115
104
  getEndString() {
116
- return this.timeDate.timeDeltaToString(this.timeDate.fromNow(this.expiry));
105
+ return timeDeltaToString(fromNow(this.expiry));
117
106
  }
118
- };
107
+ }
@@ -1,6 +1,7 @@
1
- 'use strict';
1
+ import { fromNow, timeDeltaToString } from '../utilities/timeDate.js';
2
+ import mdConfig from '../supporting/MarkdownSettings.js';
2
3
 
3
- const WorldstateObject = require('./WorldstateObject');
4
+ import WorldstateObject from './WorldstateObject.js';
4
5
 
5
6
  // This is a confirmed starting time for Corpus (in millis)
6
7
  // All faction operation should use this as a calculation point
@@ -11,79 +12,60 @@ const stateMaximum = 9000000;
11
12
 
12
13
  /**
13
14
  * Represents the current Zariman Corpus/Grineer Cycle
14
- * @extends {WorldstateObject}
15
+ * @augments {WorldstateObject}
15
16
  */
16
- class ZarimanCycle extends WorldstateObject {
17
+ export default class ZarimanCycle extends WorldstateObject {
17
18
  /**
18
- * @param {Date} bountiesEndDate The current zariman cycle expiry
19
- * @param {Object} deps The dependencies object
20
- * @param {MarkdownSettings} deps.mdConfig The markdown settings
21
- * @param {TimeDateFunctions} deps.timeDate The time and date functions
19
+ * The current zariman cycle, for calculating the other fields
20
+ * @type {object}
21
+ * @private
22
22
  */
23
- constructor(bountiesEndDate, { mdConfig, timeDate }) {
24
- super({ _id: { $oid: 'zarimanCycle0' } }, { 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 end of the Zariman bounties timer, the faction changes exactly half way through
36
- * @type {Date}
37
- * @private
38
- */
39
- this.bountiesEndDate = bountiesEndDate;
40
- Object.defineProperty(this, 'currentTime', { enumerable: false, configurable: false });
23
+ #ec;
24
+ /**
25
+ * The end of the Zariman bounties timer, the faction changes exactly half way through
26
+ * @type {Date}
27
+ * @private
28
+ */
29
+ #bountiesEndDate;
41
30
 
42
- /**
43
- * The time and date functions
44
- * @type {TimeDateFunctions}
45
- * @private
46
- */
47
- this.timeDate = timeDate;
48
- Object.defineProperty(this, 'timeDate', { enumerable: false, configurable: false });
31
+ /**
32
+ * @param {Date} bountiesEndDate The current Zariman cycle expiry
33
+ */
34
+ constructor(bountiesEndDate) {
35
+ super({ _id: { $oid: 'zarimanCycle0' } });
49
36
 
50
- /**
51
- * The current zariman cycle, for calculating the other fields
52
- * @type {Object}
53
- * @private
54
- */
55
- const ec = this.getCurrentZarimanCycle();
56
- Object.defineProperty(this, 'ec', { enumerable: false, configurable: false });
37
+ this.#bountiesEndDate = bountiesEndDate;
38
+ this.#ec = this.getCurrentZarimanCycle();
57
39
 
58
40
  /**
59
41
  * The date and time at which the event ends
60
42
  * @type {Date}
61
43
  */
62
- this.expiry = ec.expiry;
44
+ this.expiry = this.#ec.expiry;
63
45
 
64
46
  /**
65
47
  * The date and time at which the event started
66
48
  * @type {Date}
67
49
  */
68
- this.activation = new Date(ec.start);
50
+ this.activation = new Date(this.#ec.start);
69
51
 
70
52
  /**
71
53
  * Whether or not this it's corpus or grineer
72
54
  * @type {boolean}
73
55
  */
74
- this.isCorpus = ec.isCorpus;
56
+ this.isCorpus = this.#ec.isCorpus;
75
57
 
76
58
  /**
77
59
  * Current cycle state. One of `corpus`, `grineer`
78
60
  * @type {string}
79
61
  */
80
- this.state = ec.state;
62
+ this.state = this.#ec.state;
81
63
 
82
64
  /**
83
65
  * Time remaining string
84
66
  * @type {string}
85
67
  */
86
- this.timeLeft = ec.timeLeft;
68
+ this.timeLeft = this.#ec.timeLeft;
87
69
 
88
70
  this.id = `zarimanCycle${this.expiry.getTime()}`;
89
71
 
@@ -92,18 +74,18 @@ class ZarimanCycle extends WorldstateObject {
92
74
 
93
75
  /**
94
76
  * Get whether the event has expired
95
- * @returns {boolean}
77
+ * @returns {boolean} whether this is expired
96
78
  */
97
79
  getExpired() {
98
- return this.expiry ? this.timeDate.fromNow(this.expiry) < 0 : /* istanbul ignore next */ true;
80
+ return this.expiry ? fromNow(this.expiry) < 0 : /* istanbul ignore next */ true;
99
81
  }
100
82
 
101
83
  getCurrentZarimanCycle() {
102
84
  const now = Date.now();
103
85
  // determine if it is corpus cycle or grineer cycle based on bounty end time
104
86
  // we subtract 5000 millis (5 seconds) to ensure the corpus/grineer calculation is correct
105
- const bountiesClone = this.bountiesEndDate.getTime() - 5000;
106
- const millisLeft = this.timeDate.fromNow(new Date(bountiesClone));
87
+ const bountiesClone = this.#bountiesEndDate.getTime() - 5000;
88
+ const millisLeft = fromNow(new Date(bountiesClone));
107
89
  // the following line is a modulus operation
108
90
  // this ensures that our calculation is correct if bountiesClone is before corpusTimeMillis
109
91
  // if you really care, read https://torstencurdt.com/tech/posts/modulo-of-negative-numbers/
@@ -118,7 +100,7 @@ class ZarimanCycle extends WorldstateObject {
118
100
 
119
101
  return {
120
102
  isCorpus,
121
- timeLeft: this.timeDate.timeDeltaToString(millisLeft),
103
+ timeLeft: timeDeltaToString(millisLeft),
122
104
  expiry,
123
105
  expiresIn: millisLeft,
124
106
  state,
@@ -128,7 +110,7 @@ class ZarimanCycle extends WorldstateObject {
128
110
 
129
111
  /**
130
112
  * The event's string representation
131
- * @returns {string}
113
+ * @returns {string} string representation
132
114
  */
133
115
  toString() {
134
116
  const lines = [
@@ -136,8 +118,6 @@ class ZarimanCycle extends WorldstateObject {
136
118
  `Time remaining until ${this.isCorpus ? 'grineer' : 'corpus'} takeover: ${this.timeLeft}`,
137
119
  ];
138
120
 
139
- return lines.join(this.mdConfig.lineEnd);
121
+ return lines.join(mdConfig.lineEnd);
140
122
  }
141
123
  }
142
-
143
- module.exports = ZarimanCycle;
@@ -1,15 +1,6 @@
1
- 'use strict';
2
-
3
1
  /**
4
2
  * Dependency Object
5
- * @property {MarkdownSettings} mdConfig The markdown settings
6
- * @property {Translator} translator The string translator
7
- * @property {TimeDateFunctions} timeDate The time and date functions
8
- * @property {Mission} Mission The Mission parser
9
- * @property {Reward} Reward The Reward parser
10
3
  * @property {string} locale Locale to use for translations
11
- * @property {Object} logger Generic logger to use if needed
4
+ * @property {object} logger Generic logger to use if needed
12
5
  */
13
- class Dependency {}
14
-
15
- module.exports = Dependency;
6
+ export default class Dependency {}
@@ -1,9 +1,7 @@
1
- 'use strict';
2
-
3
1
  /**
4
2
  * Single category of duviri choices
5
3
  */
6
- class DuviriChoice {
4
+ export default class DuviriChoice {
7
5
  constructor(data) {
8
6
  switch (data.Category) {
9
7
  case 'EXC_NORMAL':
@@ -16,5 +14,3 @@ class DuviriChoice {
16
14
  this.choices = data.Choices;
17
15
  }
18
16
  }
19
-
20
- module.exports = DuviriChoice;