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
@@ -1,45 +1,44 @@
1
- 'use strict';
1
+ import { languageString } from '../utilities/translation.js';
2
2
 
3
3
  /**
4
4
  * Describes a world challenge instance
5
5
  */
6
- class ChallengeInstance {
6
+ export default class ChallengeInstance {
7
7
  /**
8
- * @param {Object} data The challenge instance data
8
+ * @param {object} data The challenge instance data
9
9
  * @param {Dependency} deps The dependencies object
10
- * @param {Translator} deps.translator The string translator
11
10
  * @param {string} deps.locale Locale to use for translations
12
11
  */
13
- constructor(data, { translator, locale }) {
12
+ constructor(data, { locale = 'en' } = { locale: 'en' }) {
14
13
  /**
15
14
  * Type of challenge
16
15
  * @type {string}
17
16
  */
18
- this.type = translator.languageString(data.Type, locale);
17
+ this.type = languageString(data.Type, locale);
19
18
 
20
19
  /**
21
20
  * Minimum enemy level to fulfill challenge
22
- * @type {Number}
21
+ * @type {number}
23
22
  */
24
23
  this.minEnemyLevel = Number(data.MinimumEnemyLevel);
25
24
 
26
25
  /**
27
26
  * Required number of units to complete challenge
28
- * @type {Number}
27
+ * @type {number}
29
28
  */
30
29
  this.requiredAmount = Number(data.RequiredCount);
31
30
 
32
31
  /**
33
32
  * Waypoint for amount of units between progression updates
34
- * @type {Number}
33
+ * @type {number}
35
34
  */
36
35
  this.progressAmount = Number(data.ProgressIndicatorFreq);
37
36
 
38
37
  /**
39
38
  * Required damage type
40
- * @type {String|undefined}
39
+ * @type {string | undefined}
41
40
  */
42
- this.damageType = data.DamageType ? translator.languageString(data.DamageType, locale) : undefined;
41
+ this.damageType = data.DamageType ? languageString(data.DamageType, locale) : undefined;
43
42
 
44
43
  /**
45
44
  * Target to fulfill challenge
@@ -47,7 +46,7 @@ class ChallengeInstance {
47
46
  */
48
47
  this.target =
49
48
  data.VictimType && data.VictimType[0]
50
- ? translator.languageString(data.VictimType[0], locale)
49
+ ? languageString(data.VictimType[0], locale)
51
50
  : // eslint-disable-next-line no-underscore-dangle
52
51
  data.Script._faction;
53
52
  }
@@ -56,5 +55,3 @@ class ChallengeInstance {
56
55
  return `Task: ${this.type}\nAmount: ${this.requiredAmount}\nTarget: ${this.target}`;
57
56
  }
58
57
  }
59
-
60
- module.exports = ChallengeInstance;
@@ -1,50 +1,32 @@
1
- 'use strict';
1
+ import { parseDate, fromNow, timeDeltaToString } from '../utilities/timeDate.js';
2
+ import { conclaveMode, conclaveCategory, conclaveChallenge } from '../utilities/translation.js';
2
3
 
3
- const WorldstateObject = require('./WorldstateObject');
4
+ import WorldstateObject from './WorldstateObject.js';
4
5
 
5
6
  /**
6
7
  * Represents a Conclave challenge
7
- * @extends {WorldstateObject}
8
+ * @augments {WorldstateObject}
8
9
  */
9
- class ConclaveChallenge extends WorldstateObject {
10
+ export default class ConclaveChallenge extends WorldstateObject {
10
11
  /**
11
- * @param {Object} data The challenge data
12
- * @param {Object} deps The dependencies object
13
- * @param {MarkdownSettings} deps.mdConfig The markdown settings
14
- * @param {Translator} deps.translator The string translator
15
- * @param {TimeDateFunctions} deps.timeDate The time and date functions
12
+ * @param {object} data The challenge data
13
+ * @param {object} deps The dependencies object
16
14
  * @param {string} deps.locale Locale to use for translations
17
15
  */
18
- constructor(data, { mdConfig, translator, timeDate, locale }) {
19
- super(data, { timeDate });
20
-
21
- /**
22
- * The markdown settings
23
- * @type {MarkdownSettings}
24
- * @private
25
- */
26
- this.mdConfig = mdConfig;
27
- Object.defineProperty(this, 'mdConfig', { enumerable: false, configurable: false });
28
-
29
- /**
30
- * Time and date functions
31
- * @type {TimeDateFunctions}
32
- * @private
33
- */
34
- this.timeDate = timeDate;
35
- Object.defineProperty(this, 'timeDate', { enumerable: false, configurable: false });
16
+ constructor(data, { locale = 'en' } = { locale: 'en' }) {
17
+ super(data);
36
18
 
37
19
  /**
38
20
  * The time and date at which the challenge expires
39
21
  * @type {Date}
40
22
  */
41
- this.expiry = timeDate.parseDate(data.endDate);
23
+ this.expiry = parseDate(data.endDate);
42
24
 
43
25
  /**
44
26
  * The time and date at which the challenge starts
45
27
  * @type {Date}
46
28
  */
47
- this.activation = timeDate.parseDate(data.startDate);
29
+ this.activation = parseDate(data.startDate);
48
30
 
49
31
  /**
50
32
  * The number of times that the challenge's objective needs to be completed
@@ -56,17 +38,17 @@ class ConclaveChallenge extends WorldstateObject {
56
38
  * The PVP mode that the challenge must be completed in
57
39
  * @type {string}
58
40
  */
59
- this.mode = translator.conclaveMode(data.PVPMode, locale);
41
+ this.mode = conclaveMode(data.PVPMode, locale);
60
42
 
61
43
  /**
62
44
  * The challenge's category (daily, weekly...)
63
45
  * @type {string}
64
46
  */
65
- this.category = translator.conclaveCategory(data.Category, locale);
47
+ this.category = conclaveCategory(data.Category, locale);
66
48
 
67
49
  /**
68
50
  * ETA string (at time of object creation)
69
- * @type {String}
51
+ * @type {string}
70
52
  */
71
53
  this.eta = this.getEndString();
72
54
 
@@ -108,11 +90,11 @@ class ConclaveChallenge extends WorldstateObject {
108
90
 
109
91
  /**
110
92
  * Standing granted by completing challenge.
111
- * @type {Number}
93
+ * @type {number}
112
94
  */
113
95
  this.standing = undefined;
114
96
 
115
- const challenge = translator.conclaveChallenge(data.challengeTypeRefID, locale);
97
+ const challenge = conclaveChallenge(data.challengeTypeRefID, locale);
116
98
 
117
99
  ({ title: this.title, description: this.description, standing: this.standing } = challenge);
118
100
 
@@ -125,7 +107,7 @@ class ConclaveChallenge extends WorldstateObject {
125
107
 
126
108
  /**
127
109
  * Get whether or not the challenge is daily
128
- * @returns {boolean}
110
+ * @returns {boolean} whether the category is daily
129
111
  */
130
112
  isDaily() {
131
113
  return this.category.toLowerCase() === 'day';
@@ -133,7 +115,7 @@ class ConclaveChallenge extends WorldstateObject {
133
115
 
134
116
  /**
135
117
  * Get whether or not this is the weekly root challenge
136
- * @returns {boolean}
118
+ * @returns {boolean} whether this is the root challenge
137
119
  */
138
120
  isRootChallenge() {
139
121
  return this.category.toLowerCase() === 'week_root';
@@ -141,28 +123,26 @@ class ConclaveChallenge extends WorldstateObject {
141
123
 
142
124
  /**
143
125
  * Get whether or not the challenge has expired
144
- * @returns {boolean}
126
+ * @returns {boolean} Whether or not the challenge has expired
145
127
  */
146
128
  isExpired() {
147
- return this.timeDate.fromNow(this.expiry) < 0;
129
+ return fromNow(this.expiry) < 0;
148
130
  }
149
131
 
150
132
  /**
151
133
  * Get a string indicating how much time is left before the challenge expires
152
- * @returns {string}
134
+ * @returns {string} The time left before the challenge expires
153
135
  */
154
136
  getEndString() {
155
- const timeDelta = this.timeDate.fromNow(this.expiry);
156
- return this.timeDate.timeDeltaToString(timeDelta);
137
+ const timeDelta = fromNow(this.expiry);
138
+ return timeDeltaToString(timeDelta);
157
139
  }
158
140
 
159
141
  /**
160
142
  * The conclave challenge's string representation
161
- * @returns {string}
143
+ * @returns {string} The string representation of the conclave challenge
162
144
  */
163
145
  toString() {
164
146
  return `${this.description} on ${this.mode} ${this.amount} times in a ${this.category}`;
165
147
  }
166
148
  }
167
-
168
- module.exports = ConclaveChallenge;
@@ -1,27 +1,17 @@
1
- 'use strict';
1
+ import mdConfig from '../supporting/MarkdownSettings.js';
2
2
 
3
- const WorldstateObject = require('./WorldstateObject');
3
+ import WorldstateObject from './WorldstateObject.js';
4
4
 
5
5
  /**
6
6
  * Represents enemy construction progress
7
- * @extends {WorldstateObject}
7
+ * @augments {WorldstateObject}
8
8
  */
9
- class ConstructionProgress extends WorldstateObject {
9
+ export default class ConstructionProgress extends WorldstateObject {
10
10
  /**
11
- * @param {Object} data The construction data
12
- * @param {Object} deps The dependencies object
13
- * @param {MarkdownSettings} deps.mdConfig The markdown settings
11
+ * @param {object} data The construction data
14
12
  */
15
- constructor(data, { mdConfig, timeDate }) {
16
- super(data, { timeDate });
17
-
18
- /**
19
- * The markdown settings
20
- * @type {MarkdownSettings}
21
- * @private
22
- */
23
- this.mdConfig = mdConfig;
24
- Object.defineProperty(this, 'mdConfig', { enumerable: false, configurable: false });
13
+ constructor(data) {
14
+ super(data);
25
15
 
26
16
  this.fomorianProgress = (data.ProjectPct[0] || 0.0).toFixed(2);
27
17
  this.razorbackProgress = (data.ProjectPct[1] || 0.0).toFixed(2);
@@ -30,14 +20,12 @@ class ConstructionProgress extends WorldstateObject {
30
20
 
31
21
  /**
32
22
  * The alert's string representation
33
- * @returns {string}
23
+ * @returns {string} string representation
34
24
  */
35
25
  toString() {
36
26
  return (
37
- `${this.mdConfig.codeMulti}Fomorian: ${this.fomorianProgress}%${this.mdConfig.lineEnd}Razorback: ` +
38
- `${this.razorbackProgress}%${this.mdConfig.lineEnd}Unknown: ${this.unknownProgress}%${this.mdConfig.blockEnd}`
27
+ `${mdConfig.codeBlock}Fomorian: ${this.fomorianProgress}%${mdConfig.lineEnd}Razorback: ` +
28
+ `${this.razorbackProgress}%${mdConfig.lineEnd}Unknown: ${this.unknownProgress}%${mdConfig.blockEnd}`
39
29
  );
40
30
  }
41
31
  }
42
-
43
- module.exports = ConstructionProgress;
@@ -1,39 +1,22 @@
1
- 'use strict';
1
+ import mdConfig from '../supporting/MarkdownSettings.js';
2
+ import { languageString } from '../utilities/translation.js';
3
+ import { parseDate, timeDeltaToString, fromNow } from '../utilities/timeDate.js';
2
4
 
3
5
  /**
4
6
  * Represents a daily deal
5
7
  */
6
- class DailyDeal {
8
+ export default class DailyDeal {
7
9
  /**
8
- * @param {Object} data The deal 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 {TimeDateFunctions} deps.timeDate The time and date functions
10
+ * @param {object} data The deal data
11
+ * @param {object} deps The dependencies object
13
12
  * @param {string} deps.locale Locale to use for translations
14
13
  */
15
- constructor(data, { mdConfig, translator, timeDate, locale }) {
16
- /**
17
- * The markdown settings
18
- * @type {MarkdownSettings}
19
- * @private
20
- */
21
- this.mdConfig = mdConfig;
22
- Object.defineProperty(this, 'mdConfig', { enumerable: false, configurable: false });
23
-
24
- /**
25
- * The time and date functions
26
- * @type {TimeDateFunctions}
27
- * @private
28
- */
29
- this.timeDate = timeDate;
30
- Object.defineProperty(this, 'timeDate', { enumerable: false, configurable: false });
31
-
14
+ constructor(data, { locale = 'en' } = { locale: 'en' }) {
32
15
  /**
33
16
  * The item that is being offered in the sale
34
17
  * @type {string}
35
18
  */
36
- this.item = translator.languageString(data.StoreItem, locale);
19
+ this.item = languageString(data.StoreItem, locale);
37
20
 
38
21
  /**
39
22
  * The uniqueName for the item on sale.
@@ -45,13 +28,13 @@ class DailyDeal {
45
28
  * The date and time at which the deal will expire
46
29
  * @type {Date}
47
30
  */
48
- this.expiry = timeDate.parseDate(data.Expiry);
31
+ this.expiry = parseDate(data.Expiry);
49
32
 
50
33
  /**
51
34
  * The date and time at which the deal will or did start
52
35
  * @type {Date}
53
36
  */
54
- this.activation = timeDate.parseDate(data.Activation);
37
+ this.activation = parseDate(data.Activation);
55
38
 
56
39
  /**
57
40
  * The item's original price
@@ -85,7 +68,7 @@ class DailyDeal {
85
68
 
86
69
  /**
87
70
  * ETA string (at time of object creation)
88
- * @type {String}
71
+ * @type {string}
89
72
  */
90
73
  this.eta = this.getETAString();
91
74
 
@@ -98,15 +81,15 @@ class DailyDeal {
98
81
 
99
82
  /**
100
83
  * Get a string indicating how much time is left before the deal expires
101
- * @returns {string}
84
+ * @returns {string} estimated time remaining on the deal
102
85
  */
103
86
  getETAString() {
104
- return this.timeDate.timeDeltaToString(this.timeDate.fromNow(this.expiry));
87
+ return timeDeltaToString(fromNow(this.expiry));
105
88
  }
106
89
 
107
90
  /**
108
91
  * Returns a string representation of the daily deal
109
- * @returns {string}
92
+ * @returns {string} The string representation of the daily deal
110
93
  */
111
94
  toString() {
112
95
  const lines = [
@@ -115,8 +98,6 @@ class DailyDeal {
115
98
  `${this.sold} / ${this.total} sold`,
116
99
  `Expires in ${this.getETAString()}`,
117
100
  ];
118
- return lines.join(this.mdConfig.lineEnd);
101
+ return lines.join(mdConfig.lineEnd);
119
102
  }
120
103
  }
121
-
122
- module.exports = DailyDeal;
@@ -1,33 +1,24 @@
1
- 'use strict';
1
+ import { parseDate } from '../utilities/timeDate.js';
2
+ import { languageString } from '../utilities/translation.js';
2
3
 
3
- const WorldstateObject = require('./WorldstateObject');
4
+ import WorldstateObject from './WorldstateObject.js';
5
+ import Mission from './Mission.js';
6
+ import DarkSectorBattle from './DarkSectorBattle.js';
4
7
 
5
8
  /**
6
9
  * Represents a dark sector
7
- * @extends {WorldstateObject}
10
+ * @augments {WorldstateObject}
8
11
  */
9
- class DarkSector extends WorldstateObject {
12
+ export default class DarkSector extends WorldstateObject {
10
13
  /**
11
- * @param {Object} data The dark sector data
12
- * @param {Object} deps The dependencies object
13
- * @param {MarkdownSettings} deps.mdConfig The markdown settings
14
- * @param {Translator} deps.translator The string translator
15
- * @param {TimeDateFunctions} deps.timeDate The time and date functions
16
- * @param {Mission} deps.Mission The mission parser
17
- * @param {DarkSectorBattle} deps.DarkSectorBattle The dark sector battle parser
18
- * @param {Reward} deps.Reward The reward parser
14
+ * @param {object} data The dark sector 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, DarkSectorBattle, Reward, locale }) {
22
- super(data, { timeDate });
18
+ constructor(data, { locale = 'en' } = { locale: 'en' }) {
19
+ super(data);
23
20
 
24
21
  const deps = {
25
- translator,
26
- Mission,
27
- DarkSectorBattle,
28
- mdConfig,
29
- Reward,
30
- timeDate,
31
22
  locale,
32
23
  };
33
24
 
@@ -57,7 +48,7 @@ class DarkSector extends WorldstateObject {
57
48
 
58
49
  /**
59
50
  * Whether the dark sector holder is an alliance or not
60
- * @type {Boolean}
51
+ * @type {boolean}
61
52
  */
62
53
  this.isAlliance = data.DefenderInfo.IsAlliance;
63
54
 
@@ -84,14 +75,14 @@ class DarkSector extends WorldstateObject {
84
75
  * @type {Date}
85
76
  */
86
77
  this.defenderDeployemntActivation = data.DefenderInfo.DeploymentActivationTime
87
- ? timeDate.parseDate(data.DefenderInfo.DeploymentActivationTime)
78
+ ? parseDate(data.DefenderInfo.DeploymentActivationTime)
88
79
  : 0;
89
80
 
90
81
  /**
91
82
  * The solar rail type
92
83
  * @type {string}
93
84
  */
94
- this.railType = translator.languageString(data.DefenderInfo.RailType, locale);
85
+ this.railType = languageString(data.DefenderInfo.RailType, locale);
95
86
 
96
87
  /**
97
88
  * The MOTD set by the dark sector holder
@@ -162,5 +153,3 @@ class DarkSector extends WorldstateObject {
162
153
  this.history = data.History ? data.History.map((b) => new DarkSectorBattle(b, deps)) : [];
163
154
  }
164
155
  }
165
-
166
- module.exports = DarkSector;
@@ -1,13 +1,13 @@
1
- 'use strict';
1
+ import { parseDate } from '../utilities/timeDate.js';
2
2
 
3
3
  /**
4
4
  * Represents a battle over a dark sector
5
5
  */
6
- class DarkSectorBattle {
6
+ export default class DarkSectorBattle {
7
7
  /**
8
- * @param {Object} data The battle data
8
+ * @param {object} data The battle data
9
9
  */
10
- constructor(data, { timeDate }) {
10
+ constructor(data) {
11
11
  /**
12
12
  * The defenders of the dark sector
13
13
  * @type {string}
@@ -45,14 +45,12 @@ class DarkSectorBattle {
45
45
  * The date and time at which the battle started
46
46
  * @type {Date}
47
47
  */
48
- this.start = timeDate.parseDate(data.Start);
48
+ this.start = parseDate(data.Start);
49
49
 
50
50
  /**
51
51
  * The date and time at which the battle ended
52
52
  * @type {Date}
53
53
  */
54
- this.end = timeDate.parseDate(data.End);
54
+ this.end = parseDate(data.End);
55
55
  }
56
56
  }
57
-
58
- module.exports = DarkSectorBattle;
@@ -1,6 +1,7 @@
1
- 'use strict';
1
+ import { toTitleCase } from '../utilities/translation.js';
2
+ import { timeDeltaToString } from '../utilities/timeDate.js';
2
3
 
3
- const WorldstateObject = require('./WorldstateObject');
4
+ import WorldstateObject from './WorldstateObject.js';
4
5
 
5
6
  const cycleTime = 36000;
6
7
  const stateTime = 7200;
@@ -27,11 +28,11 @@ const getStageInfo = () => {
27
28
 
28
29
  /**
29
30
  * @typedef {WorldstateObject} DuviriCycle
30
- * @extends {WorldstateObject}
31
+ * @augments {WorldstateObject}
31
32
  */
32
- class DuviriCycle extends WorldstateObject {
33
- constructor({ timeDate, translator, duviriChoices }) {
34
- super({ _id: { $oid: 'duviriCycle0' } }, { timeDate, translator });
33
+ export default class DuviriCycle extends WorldstateObject {
34
+ constructor({ duviriChoices }) {
35
+ super({ _id: { $oid: 'duviriCycle0' } });
35
36
  const { activation, expiry, state } = getStageInfo();
36
37
 
37
38
  /**
@@ -58,10 +59,8 @@ class DuviriCycle extends WorldstateObject {
58
59
  }
59
60
 
60
61
  toString() {
61
- return `${this.translator.toTitleCase(this.state)} spiral. ${this.translator.toTitleCase(
62
+ return `${toTitleCase(this.state)} spiral. ${toTitleCase(
62
63
  states[(states.indexOf(this.state) + 1) % 5]
63
- )} in ${this.timeDate.timeDeltaToString(new Date(this.expiry).getTime() - Date.now())}`;
64
+ )} in ${timeDeltaToString(new Date(this.expiry).getTime() - Date.now())}`;
64
65
  }
65
66
  }
66
-
67
- module.exports = DuviriCycle;
@@ -1,7 +1,24 @@
1
- 'use strict';
1
+ import { fromNow } 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
 
6
+ /**
7
+ * @typedef {object} EarthCycle
8
+ * @property {Date} expiry The date and time at which the event ends
9
+ * @property {Date} activation The date and time at which the event started
10
+ * @property {boolean} isDay Whether or not this it's daytime
11
+ * @property {string} state Current cycle state. One of `day`, `night`
12
+ * @property {string} timeLeft Time remaining string
13
+ * @property {Date} rounded The date and time at which the event ends, rounded to the nearest minute
14
+ * @property {Date} start The date and time at which the event started, 4 hours before the end
15
+ * @property {boolean} expired Whether or not the event has expired
16
+ */
17
+
18
+ /**
19
+ * Get the current Earth Day/Night Cycle
20
+ * @returns {EarthCycle} The current Earth Day/Night Cycle
21
+ */
5
22
  function getCurrentEarthCycle() {
6
23
  const now = Date.now();
7
24
  const cycleSeconds = Math.floor(now / 1000) % 28800; // One cycle = 8 hours = 28800 seconds
@@ -38,80 +55,64 @@ function getCurrentEarthCycle() {
38
55
 
39
56
  /**
40
57
  * Represents the current Earth Day/Night Cycle
41
- * @extends {WorldstateObject}
58
+ * @augments {WorldstateObject}
42
59
  */
43
- class EarthCycle extends WorldstateObject {
44
- /**
45
- * @param {Object} data The event data
46
- * @param {Object} deps The dependencies object
47
- * @param {MarkdownSettings} deps.mdConfig The markdown settings
48
- */
49
- constructor({ mdConfig, timeDate }) {
50
- super({ _id: { $oid: 'earthCycle0' } }, { timeDate });
51
-
52
- const ec = getCurrentEarthCycle();
53
-
54
- /**
55
- * The markdown settings
56
- * @type {MarkdownSettings}
57
- * @private
58
- */
59
- this.mdConfig = mdConfig;
60
- Object.defineProperty(this, 'mdConfig', { enumerable: false, configurable: false });
60
+ export default class EarthCycle extends WorldstateObject {
61
+ #ec = getCurrentEarthCycle();
62
+ constructor() {
63
+ super({ _id: { $oid: 'earthCycle0' } });
61
64
 
62
65
  /**
63
66
  * The date and time at which the event ends
64
67
  * @type {Date}
65
68
  */
66
- this.expiry = ec.expiry;
69
+ this.expiry = this.#ec.expiry;
67
70
 
68
71
  /**
69
72
  * The date and time at which the event started
70
73
  * @type {Date}
71
74
  */
72
- this.activation = ec.start;
75
+ this.activation = this.#ec.start;
73
76
 
74
77
  /**
75
78
  * Whether or not this it's daytime
76
79
  * @type {boolean}
77
80
  */
78
- this.isDay = ec.dayTime;
81
+ this.isDay = this.#ec.dayTime;
79
82
 
80
83
  /**
81
84
  * Current cycle state. One of `day`, `night`
82
85
  * @type {string}
83
86
  */
84
- this.state = ec.state;
87
+ this.state = this.#ec.state;
85
88
 
86
89
  /**
87
90
  * Time remaining string
88
91
  * @type {string}
89
92
  */
90
- this.timeLeft = ec.timeLeft;
93
+ this.timeLeft = this.#ec.timeLeft;
91
94
 
92
- this.id = `earthCycle${ec.rounded.getTime()}`;
95
+ this.id = `earthCycle${this.#ec.rounded.getTime()}`;
93
96
  }
94
97
 
95
98
  /**
96
99
  * Get whether or not the event has expired
97
- * @returns {boolean}
100
+ * @returns {boolean} Whether or not the event has expired
98
101
  */
99
102
  getExpired() {
100
- return this.timeDate.fromNow(this.expiry) < 0;
103
+ return fromNow(this.expiry) < 0;
101
104
  }
102
105
 
103
106
  /**
104
107
  * The event's string representation
105
- * @returns {string}
108
+ * @returns {string} The string representation of the event
106
109
  */
107
110
  toString() {
108
111
  const lines = [
109
- `Operator, Earth is currently in ${this.dayTime ? 'Day' : 'Night'}time`,
110
- `Time remaining until ${this.dayTime ? 'night' : 'day'}: ${this.timeLeft}`,
112
+ `Operator, Earth is currently in ${this.isDay ? 'Day' : 'Night'}time`,
113
+ `Time remaining until ${this.isDay ? 'night' : 'day'}: ${this.timeLeft}`,
111
114
  ];
112
115
 
113
- return lines.join(this.mdConfig.lineEnd);
116
+ return lines.join(mdConfig.lineEnd);
114
117
  }
115
118
  }
116
-
117
- module.exports = EarthCycle;