warframe-worldstate-parser 2.31.1 → 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 +19 -17
  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 +14 -14
  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 +50 -28
  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
package/README.md CHANGED
@@ -6,6 +6,7 @@ Parse the Warframe worldstate into useable javascript objects.
6
6
  [![Crowdin](https://d322cqt584bo4o.cloudfront.net/genesis-parser/localized.svg)](https://crowdin.com/project/genesis-parser)
7
7
  [![Coverage Status](https://coveralls.io/repos/github/WFCD/warframe-worldstate-parser/badge.svg?branch=master)](https://coveralls.io/github/WFCD/warframe-worldstate-parser?branch=master)
8
8
  [![Discord](https://img.shields.io/discord/256087517353213954.svg?logo=discord)](https://discord.gg/jGZxH9f)
9
+ [![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)
9
10
 
10
11
  ## Documentation
11
12
  You can find the documentation [here](https://wfcd.github.io/warframe-worldstate-parser/)
package/lib/WorldState.js CHANGED
@@ -1,45 +1,37 @@
1
- 'use strict';
2
-
3
- const sortieData = require('warframe-worldstate-data').sortie;
4
-
5
- const News = require('./models/News');
6
- const WorldEvent = require('./models/WorldEvent');
7
- const Alert = require('./models/Alert');
8
- const Sortie = require('./models/Sortie');
9
- const SortieVariant = require('./models/SortieVariant');
10
- const SyndicateMission = require('./models/SyndicateMission');
11
- const Fissure = require('./models/Fissure');
12
- const GlobalUpgrade = require('./models/GlobalUpgrade');
13
- const FlashSale = require('./models/FlashSale');
14
- const Invasion = require('./models/Invasion');
15
- const DarkSector = require('./models/DarkSector');
16
- const DarkSectorBattle = require('./models/DarkSectorBattle');
17
- const Mission = require('./models/Mission');
18
- const Reward = require('./models/Reward');
19
- const VoidTrader = require('./models/VoidTrader');
20
- const DailyDeal = require('./models/DailyDeal');
21
- const Simaris = require('./models/Simaris');
22
- const ConclaveChallenge = require('./models/ConclaveChallenge');
23
- const PersistentEnemy = require('./models/PersistentEnemy');
24
- const timeDate = require('./utilities/timeDate');
25
- const translator = require('./utilities/translation');
26
- const EarthCycle = require('./models/EarthCycle');
27
- const CetusCycle = require('./models/CetusCycle');
28
- const ConstructionProgress = require('./models/ConstructionProgress');
29
- const VallisCycle = require('./models/VallisCycle');
30
- const ZarimanCycle = require('./models/ZarimanCycle');
31
- const WeeklyChallenge = require('./models/WeeklyChallenge');
32
- const Nightwave = require('./models/Nightwave');
33
- const Kuva = require('./models/Kuva');
34
- const SentientOutpost = require('./models/SentientOutpost');
35
- const CambionCycle = require('./models/CambionCycle');
36
- const SteelPathOffering = require('./models/SteelPathOffering');
37
- const Dependency = require('./supporting/Dependency'); // eslint-disable-line no-unused-vars
38
- const DuviriCycle = require('./models/DuviriCycle');
39
- const DuviriChoice = require('./supporting/DuviriChoice');
40
-
41
- // needed for type declarations
42
- const MarkdownSettings = require('./supporting/MarkdownSettings');
1
+ import wsData from 'warframe-worldstate-data';
2
+
3
+ import EarthCycle from './models/EarthCycle.js';
4
+ import CetusCycle from './models/CetusCycle.js';
5
+ import ConstructionProgress from './models/ConstructionProgress.js';
6
+ import VallisCycle from './models/VallisCycle.js';
7
+ import ZarimanCycle from './models/ZarimanCycle.js';
8
+ import Nightwave from './models/Nightwave.js';
9
+ import Kuva from './models/Kuva.js';
10
+ import SentientOutpost from './models/SentientOutpost.js';
11
+ import CambionCycle from './models/CambionCycle.js';
12
+ import SteelPathOffering from './models/SteelPathOffering.js';
13
+ import Dependency from './supporting/Dependency.js'; // eslint-disable-line no-unused-vars
14
+ import DuviriCycle from './models/DuviriCycle.js';
15
+ import { parseDate } from './utilities/timeDate.js';
16
+ import WeeklyChallenge from './models/WeeklyChallenge.js';
17
+ import Sortie from './models/Sortie.js';
18
+ import DuviriChoice from './supporting/DuviriChoice.js';
19
+ import VoidTrader from './models/VoidTrader.js';
20
+ import PersistentEnemy from './models/PersistentEnemy.js';
21
+ import ConclaveChallenge from './models/ConclaveChallenge.js';
22
+ import Simaris from './models/Simaris.js';
23
+ import DailyDeal from './models/DailyDeal.js';
24
+ import DarkSector from './models/DarkSector.js';
25
+ import Invasion from './models/Invasion.js';
26
+ import FlashSale from './models/FlashSale.js';
27
+ import GlobalUpgrade from './models/GlobalUpgrade.js';
28
+ import Fissure from './models/Fissure.js';
29
+ import SyndicateMission from './models/SyndicateMission.js';
30
+ import Alert from './models/Alert.js';
31
+ import WorldEvent from './models/WorldEvent.js';
32
+ import News from './models/News.js';
33
+
34
+ const { sortieData } = wsData;
43
35
 
44
36
  const safeArray = (arr) => arr || [];
45
37
  const safeObj = (obj) => obj || {};
@@ -49,44 +41,20 @@ const safeObj = (obj) => obj || {};
49
41
  * @type {Dependency}
50
42
  */
51
43
  const defaultDeps = {
52
- News,
53
- WorldEvent,
54
- Alert,
55
- Sortie,
56
- SortieVariant,
57
- SyndicateMission,
58
- Fissure,
59
- GlobalUpgrade,
60
- FlashSale,
61
- Invasion,
62
- DarkSector,
63
- DarkSectorBattle,
64
- Mission,
65
- Reward,
66
- VoidTrader,
67
- DailyDeal,
68
- Simaris,
69
- ConclaveChallenge,
70
- PersistentEnemy,
71
- WeeklyChallenge,
72
- timeDate,
73
- translator,
74
44
  sortieData,
75
- mdConfig: new MarkdownSettings(),
76
45
  locale: 'en',
77
46
  logger: console,
78
- DuviriChoice,
79
47
  };
80
48
 
81
49
  /**
82
50
  *
83
- * @param {Object} ParserClass class for parsing data
51
+ * @param {object} ParserClass class for parsing data
84
52
  * @param {Array<BaseContentObject>} dataArray array of raw data
85
53
  * @param {Dependency} deps shared dependency object
86
54
  * @param {*} [uniqueField] field to treat as unique
87
- * @returns {WorldstateObject[]}
55
+ * @returns {WorldstateObject[]} array of parsed objects
88
56
  */
89
- function parseArray(ParserClass, dataArray, deps, uniqueField) {
57
+ export function parseArray(ParserClass, dataArray, deps, uniqueField) {
90
58
  const arr = (dataArray || []).map((d) => new ParserClass(d, deps));
91
59
  if (uniqueField) {
92
60
  const utemp = {};
@@ -106,7 +74,7 @@ function parseArray(ParserClass, dataArray, deps, uniqueField) {
106
74
  /**
107
75
  * Parses Warframe Worldstate JSON
108
76
  */
109
- module.exports = class WorldState {
77
+ export default class WorldState {
110
78
  /**
111
79
  * Generates the worldstate json as a string into usable objects
112
80
  * @param {string} json The worldstate JSON string
@@ -135,7 +103,7 @@ module.exports = class WorldState {
135
103
  * @type {Array.<News>}
136
104
  */
137
105
  this.news = parseArray(
138
- deps.News,
106
+ News,
139
107
  data.Events
140
108
  ? data.Events.filter((e) => typeof e.Messages.find((msg) => msg.LanguageCode === deps.locale) !== 'undefined')
141
109
  : [],
@@ -146,63 +114,61 @@ module.exports = class WorldState {
146
114
  * The current events
147
115
  * @type {Array.<WorldEvent>}
148
116
  */
149
- this.events = parseArray(deps.WorldEvent, data.Goals, deps);
117
+ this.events = parseArray(WorldEvent, data.Goals, deps);
150
118
 
151
119
  /**
152
120
  * The current alerts
153
121
  * @type {Array.<Alert>}
154
122
  */
155
- this.alerts = parseArray(deps.Alert, data.Alerts, deps);
123
+ this.alerts = parseArray(Alert, data.Alerts, deps);
156
124
 
157
125
  /**
158
126
  * The current sortie
159
127
  * @type {Sortie}
160
128
  */
161
- [this.sortie] = parseArray(deps.Sortie, data.Sorties, deps);
129
+ [this.sortie] = parseArray(Sortie, data.Sorties, deps);
162
130
 
163
131
  /**
164
132
  * The current syndicate missions
165
133
  * @type {Array.<SyndicateMission>}
166
134
  */
167
- this.syndicateMissions = parseArray(deps.SyndicateMission, data.SyndicateMissions, deps, 'syndicate');
135
+ this.syndicateMissions = parseArray(SyndicateMission, data.SyndicateMissions, deps, 'syndicate');
168
136
 
169
137
  /**
170
138
  * The current fissures: 'ActiveMissions' & 'VoidStorms'
171
139
  * @type {Array.<Fissure>}
172
140
  */
173
- this.fissures = parseArray(deps.Fissure, data.ActiveMissions, deps).concat(
174
- parseArray(deps.Fissure, data.VoidStorms, deps)
175
- );
141
+ this.fissures = parseArray(Fissure, data.ActiveMissions, deps).concat(parseArray(Fissure, data.VoidStorms, deps));
176
142
 
177
143
  /**
178
144
  * The current global upgrades
179
145
  * @type {Array.<GlobalUpgrade>}
180
146
  */
181
- this.globalUpgrades = parseArray(deps.GlobalUpgrade, data.GlobalUpgrades, deps);
147
+ this.globalUpgrades = parseArray(GlobalUpgrade, data.GlobalUpgrades, deps);
182
148
 
183
149
  /**
184
150
  * The current flash sales
185
151
  * @type {Array.<FlashSale>}
186
152
  */
187
- this.flashSales = parseArray(deps.FlashSale, data.FlashSales, deps);
153
+ this.flashSales = parseArray(FlashSale, data.FlashSales, deps);
188
154
 
189
155
  /**
190
156
  * The current invasions
191
157
  * @type {Array.<Invasion>}
192
158
  */
193
- this.invasions = parseArray(deps.Invasion, data.Invasions, deps);
159
+ this.invasions = parseArray(Invasion, data.Invasions, deps);
194
160
 
195
161
  /**
196
162
  * The state of the dark sectors
197
163
  * @type {Array.<DarkSector>}
198
164
  */
199
- this.darkSectors = parseArray(deps.DarkSector, data.BadlandNodes, deps);
165
+ this.darkSectors = parseArray(DarkSector, data.BadlandNodes, deps);
200
166
 
201
167
  /**
202
168
  * The state of all Void Traders
203
169
  * @type {VoidTrader[]}
204
170
  */
205
- this.voidTraders = parseArray(deps.VoidTrader, data.VoidTraders, deps).sort(
171
+ this.voidTraders = parseArray(VoidTrader, data.VoidTraders, deps).sort(
206
172
  (a, b) => Date.parse(a.activation) - Date.parse(b.activation)
207
173
  );
208
174
 
@@ -217,25 +183,25 @@ module.exports = class WorldState {
217
183
  * The current daily deals
218
184
  * @type {Array.<DailyDeal>}
219
185
  */
220
- this.dailyDeals = parseArray(deps.DailyDeal, data.DailyDeals, deps);
186
+ this.dailyDeals = parseArray(DailyDeal, data.DailyDeals, deps);
221
187
 
222
188
  /**
223
189
  * The state of the sanctuary synthesis targets
224
190
  * @type {Simaris}
225
191
  */
226
- this.simaris = new deps.Simaris(safeObj(data.LibraryInfo), deps);
192
+ this.simaris = new Simaris(safeObj(data.LibraryInfo), deps);
227
193
 
228
194
  /**
229
195
  * The current conclave challenges
230
196
  * @type {Array.<ConclaveChallenge>}
231
197
  */
232
- this.conclaveChallenges = parseArray(deps.ConclaveChallenge, data.PVPChallengeInstances, deps);
198
+ this.conclaveChallenges = parseArray(ConclaveChallenge, data.PVPChallengeInstances, deps);
233
199
 
234
200
  /**
235
201
  * The currently active persistent enemies
236
202
  * @type {Array.<PersistentEnemy>}
237
203
  */
238
- this.persistentEnemies = parseArray(deps.PersistentEnemy, data.PersistentEnemies, deps);
204
+ this.persistentEnemies = parseArray(PersistentEnemy, data.PersistentEnemies, deps);
239
205
 
240
206
  /**
241
207
  * The current earth cycle
@@ -244,7 +210,7 @@ module.exports = class WorldState {
244
210
  this.earthCycle = new EarthCycle(deps);
245
211
 
246
212
  const cetusSynd = safeArray(data.SyndicateMissions).filter((syndicate) => syndicate.Tag === 'CetusSyndicate');
247
- const cetusBountyEnd = timeDate.parseDate(cetusSynd.length > 0 ? cetusSynd[0].Expiry : { $date: 0 });
213
+ const cetusBountyEnd = parseDate(cetusSynd.length > 0 ? cetusSynd[0].Expiry : { $date: 0 });
248
214
 
249
215
  /**
250
216
  * The current Cetus cycle
@@ -259,7 +225,7 @@ module.exports = class WorldState {
259
225
  this.cambionCycle = new CambionCycle(this.cetusCycle, deps);
260
226
 
261
227
  const zarimanSynd = safeArray(data.SyndicateMissions).filter((syndicate) => syndicate.Tag === 'ZarimanSyndicate');
262
- const zarimanBountyEnd = timeDate.parseDate(zarimanSynd.length > 0 ? zarimanSynd[0].Expiry : { $date: 0 });
228
+ const zarimanBountyEnd = parseDate(zarimanSynd.length > 0 ? zarimanSynd[0].Expiry : { $date: 0 });
263
229
 
264
230
  /**
265
231
  * The current Zariman cycle based off current time
@@ -271,7 +237,7 @@ module.exports = class WorldState {
271
237
  * Weekly challenges
272
238
  * @type {Array.<WeeklyChallenge>}
273
239
  */
274
- this.weeklyChallenges = data.WeeklyChallenges ? new deps.WeeklyChallenge(data.WeeklyChallenges, deps) : [];
240
+ this.weeklyChallenges = data.WeeklyChallenges ? new WeeklyChallenge(data.WeeklyChallenges, deps) : [];
275
241
 
276
242
  const projectPCTwithOid = data.ProjectPct
277
243
  ? {
@@ -333,16 +299,16 @@ module.exports = class WorldState {
333
299
  */
334
300
  this.steelPath = new SteelPathOffering(deps);
335
301
 
336
- [this.vaultTrader] = parseArray(deps.VoidTrader, data.PrimeVaultTraders, deps);
302
+ [this.vaultTrader] = parseArray(VoidTrader, data.PrimeVaultTraders, deps);
337
303
 
338
304
  /**
339
305
  * The current archon hunt
340
306
  * @type {Sortie}
341
307
  */
342
- [this.archonHunt] = parseArray(deps.Sortie, data.LiteSorties, deps);
308
+ [this.archonHunt] = parseArray(Sortie, data.LiteSorties, deps);
343
309
 
344
- deps.duviriChoices = parseArray(deps.DuviriChoice, data.EndlessXpChoices, deps);
310
+ deps.duviriChoices = parseArray(DuviriChoice, data.EndlessXpChoices, deps);
345
311
 
346
312
  this.duviriCycle = new DuviriCycle(deps);
347
313
  }
348
- };
314
+ }
@@ -1,49 +1,25 @@
1
- 'use strict';
1
+ import mdConfig from '../supporting/MarkdownSettings.js';
2
+ import { fromNow, timeDeltaToString } from '../utilities/timeDate.js';
2
3
 
3
- const WorldstateObject = require('./WorldstateObject');
4
+ import WorldstateObject from './WorldstateObject.js';
5
+ import Mission from './Mission.js';
4
6
 
5
7
  /**
6
8
  * Represents an alert
7
- * @extends {WorldstateObject}
9
+ * @augments {WorldstateObject}
8
10
  */
9
- class Alert extends WorldstateObject {
11
+ export default class Alert extends WorldstateObject {
10
12
  /**
11
- * @param {Object} data The alert data
12
- * @param {MarkdownSettings} mdConfig The markdown settings
13
- * @param {Translator} translator The string translator
14
- * @param {TimeDateFunctions} timeDate The time and date functions
15
- * @param {Mission} Mission The Mission parser
16
- * @param {Reward} Reward The Reward parser
13
+ * @param {object} data The alert data
17
14
  * @param {string} locale Locale to use for translations
18
15
  */
19
- constructor(data, { mdConfig, translator, timeDate, Mission, Reward, locale }) {
20
- super(data, { timeDate });
16
+ constructor(data, { locale = 'en' } = { locale: 'en' }) {
17
+ super(data);
21
18
 
22
19
  const deps = {
23
- mdConfig,
24
- translator,
25
- timeDate,
26
- Mission,
27
- Reward,
28
20
  locale,
29
21
  };
30
22
 
31
- /**
32
- * The markdown settings
33
- * @type {MarkdownSettings}
34
- * @private
35
- */
36
- this.mdConfig = mdConfig;
37
- Object.defineProperty(this, 'mdConfig', { enumerable: false, configurable: false });
38
-
39
- /**
40
- * The time and date functions
41
- * @type {TimeDateFunctions}
42
- * @private
43
- */
44
- this.timeDate = timeDate;
45
- Object.defineProperty(this, 'timeDate', { enumerable: false, configurable: false });
46
-
47
23
  /**
48
24
  * The mission that the players have to complete
49
25
  * @type {Mission}
@@ -52,7 +28,7 @@ class Alert extends WorldstateObject {
52
28
 
53
29
  /**
54
30
  * ETA string (at time of object creation)
55
- * @type {String}
31
+ * @type {string}
56
32
  */
57
33
  this.eta = this.getETAString();
58
34
 
@@ -64,14 +40,14 @@ class Alert extends WorldstateObject {
64
40
 
65
41
  /**
66
42
  * A tag that DE occasionally provides, such as `LotusGift`
67
- * @type {String}
43
+ * @type {string}
68
44
  */
69
45
  this.tag = data.Tag || undefined;
70
46
  }
71
47
 
72
48
  /**
73
49
  * Get the alert's description text
74
- * @returns {string}
50
+ * @returns {string} the description
75
51
  */
76
52
  getDescription() {
77
53
  return this.mission.description;
@@ -79,7 +55,7 @@ class Alert extends WorldstateObject {
79
55
 
80
56
  /**
81
57
  * Get the alert's reward
82
- * @returns {Reward}
58
+ * @returns {Reward} the reward
83
59
  */
84
60
  getReward() {
85
61
  return this.mission.reward;
@@ -87,15 +63,15 @@ class Alert extends WorldstateObject {
87
63
 
88
64
  /**
89
65
  * Get a string indicating how much time is left before the alert expires
90
- * @returns {string}
66
+ * @returns {string} the time left
91
67
  */
92
68
  getETAString() {
93
- return this.timeDate.timeDeltaToString(this.timeDate.fromNow(this.expiry));
69
+ return timeDeltaToString(fromNow(this.expiry));
94
70
  }
95
71
 
96
72
  /**
97
73
  * Get an array containing the types of all of the alert's rewards
98
- * @returns {Array.<string>}
74
+ * @returns {Array.<string>} an array containing the types of all of the alert's rewards
99
75
  */
100
76
  getRewardTypes() {
101
77
  return this.mission.reward.getTypes();
@@ -103,13 +79,11 @@ class Alert extends WorldstateObject {
103
79
 
104
80
  /**
105
81
  * The alert's string representation
106
- * @returns {string}
82
+ * @returns {string} the string representation
107
83
  */
108
84
  toString() {
109
85
  const lines = [this.mission.toString(), this.getETAString()];
110
86
 
111
- return `${this.mdConfig.codeMulti}${lines.join(this.mdConfig.lineEnd)}${this.mdConfig.blockEnd}`;
87
+ return `${mdConfig.codeBlock}${lines.join(mdConfig.lineEnd)}${mdConfig.blockEnd}`;
112
88
  }
113
89
  }
114
-
115
- module.exports = Alert;
@@ -1,20 +1,18 @@
1
- 'use strict';
1
+ import { fromNow } from '../utilities/timeDate.js';
2
2
 
3
- const WorldstateObject = require('./WorldstateObject');
3
+ import WorldstateObject from './WorldstateObject.js';
4
4
 
5
5
  /**
6
6
  * Represents the current Cambion Drift Fass/Vome Cycle
7
- * @extends {WorldstateObject}
7
+ * @augments {WorldstateObject}
8
8
  * @property {string} timeLeft time rendering of amount of time left
9
9
  */
10
- class CambionCycle extends WorldstateObject {
10
+ export default class CambionCycle extends WorldstateObject {
11
11
  /**
12
12
  * @param {CetusCycle} cetusCycle Match data from cetus cycle for data
13
- * @param {Object} deps The dependencies object
14
- * @param {TimeDateFunctions} deps.timeDate The time and date functions
15
13
  */
16
- constructor(cetusCycle, { timeDate }) {
17
- super({ _id: { $oid: 'cambionCycle0' } }, { timeDate });
14
+ constructor(cetusCycle) {
15
+ super({ _id: { $oid: 'cambionCycle0' } });
18
16
 
19
17
  ({ activation: this.activation, expiry: this.expiry, timeLeft: this.timeLeft } = cetusCycle);
20
18
 
@@ -26,11 +24,9 @@ class CambionCycle extends WorldstateObject {
26
24
 
27
25
  /**
28
26
  * Get whether the event has expired
29
- * @returns {boolean}
27
+ * @returns {boolean} whether the event has expired
30
28
  */
31
29
  getExpired() {
32
- return this.timeDate.fromNow(this.expiry) < 0;
30
+ return fromNow(this.expiry) < 0;
33
31
  }
34
32
  }
35
-
36
- module.exports = CambionCycle;
@@ -1,6 +1,7 @@
1
- 'use strict';
1
+ import mdConfig from '../supporting/MarkdownSettings.js';
2
+ import { fromNow, timeDeltaToString } from '../utilities/timeDate.js';
2
3
 
3
- const WorldstateObject = require('./WorldstateObject');
4
+ import WorldstateObject from './WorldstateObject.js';
4
5
 
5
6
  const nightTime = 3000;
6
7
 
@@ -11,79 +12,60 @@ const maximums = {
11
12
 
12
13
  /**
13
14
  * Represents the current Earth Day/Night Cycle
14
- * @extends {WorldstateObject}
15
+ * @augments {WorldstateObject}
15
16
  */
16
- class CetusCycle extends WorldstateObject {
17
+ export default class CetusCycle extends WorldstateObject {
17
18
  /**
18
- * @param {Date} bountiesEndDate The end date for Ostron bounties
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 end of the Ostron bounties timer (marks the end of night)
20
+ * @type {Date}
21
+ * @private
22
22
  */
23
- constructor(bountiesEndDate, { mdConfig, timeDate }) {
24
- super({ _id: { $oid: 'cetusCycle0' } }, { 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 Ostron bounties timer (marks the end of night)
36
- * @type {Date}
37
- * @private
38
- */
39
- this.bountiesEndDate = bountiesEndDate;
40
- Object.defineProperty(this, 'bountiesEndDate', { enumerable: false, configurable: false });
23
+ #bountiesEndDate;
24
+ /**
25
+ * The current cetus cycle, for calculating the other fields
26
+ * @type {object}
27
+ * @private
28
+ */
29
+ #ec;
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 end date for Ostron bounties
33
+ */
34
+ constructor(bountiesEndDate) {
35
+ super({ _id: { $oid: 'cetusCycle0' } });
49
36
 
50
- /**
51
- * The current cetus cycle, for calculating the other fields
52
- * @type {Object}
53
- * @private
54
- */
55
- const ec = this.getCurrentCetusCycle();
56
- Object.defineProperty(this, 'ec', { enumerable: false, configurable: false });
37
+ this.#bountiesEndDate = bountiesEndDate;
38
+ this.#ec = this.getCurrentCetusCycle();
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 it's daytime
72
54
  * @type {boolean}
73
55
  */
74
- this.isDay = ec.dayTime;
56
+ this.isDay = this.#ec.dayTime;
75
57
 
76
58
  /**
77
59
  * Current cycle state. One of `day`, `night`
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
  /**
89
71
  * Whether this is for Cetus Cycle
@@ -98,17 +80,17 @@ class CetusCycle extends WorldstateObject {
98
80
 
99
81
  /**
100
82
  * Get whether or not the event has expired
101
- * @returns {boolean}
83
+ * @returns {boolean} whether the event has expired
102
84
  */
103
85
  getExpired() {
104
- return this.timeDate.fromNow(this.expiry) < 0;
86
+ return fromNow(this.expiry) < 0;
105
87
  }
106
88
 
107
89
  getCurrentCetusCycle() {
108
90
  const now = Date.now();
109
- const bountiesClone = this.bountiesEndDate;
91
+ const bountiesClone = this.#bountiesEndDate;
110
92
  bountiesClone.setSeconds(0);
111
- let millisLeft = this.timeDate.fromNow(bountiesClone);
93
+ let millisLeft = fromNow(bountiesClone);
112
94
  const secondsToNightEnd = (millisLeft / 1000).toFixed(0);
113
95
  const dayTime = secondsToNightEnd > nightTime;
114
96
 
@@ -120,7 +102,7 @@ class CetusCycle extends WorldstateObject {
120
102
 
121
103
  return {
122
104
  dayTime,
123
- timeLeft: this.timeDate.timeDeltaToString(millisLeft),
105
+ timeLeft: timeDeltaToString(millisLeft),
124
106
  expiry,
125
107
  expiresIn: millisLeft,
126
108
  state,
@@ -130,7 +112,7 @@ class CetusCycle extends WorldstateObject {
130
112
 
131
113
  /**
132
114
  * The event's string representation
133
- * @returns {string}
115
+ * @returns {string} The string representation of the event
134
116
  */
135
117
  toString() {
136
118
  const lines = [
@@ -138,8 +120,6 @@ class CetusCycle extends WorldstateObject {
138
120
  `Time remaining until ${this.isDay ? 'night' : 'day'}: ${this.timeLeft}`,
139
121
  ];
140
122
 
141
- return lines.join(this.mdConfig.lineEnd);
123
+ return lines.join(mdConfig.lineEnd);
142
124
  }
143
125
  }
144
-
145
- module.exports = CetusCycle;