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.
- package/README.md +1 -0
- package/lib/WorldState.js +60 -94
- package/lib/models/Alert.js +18 -44
- package/lib/models/CambionCycle.js +8 -12
- package/lib/models/CetusCycle.js +34 -54
- package/lib/models/ChallengeInstance.js +11 -14
- package/lib/models/ConclaveChallenge.js +24 -44
- package/lib/models/ConstructionProgress.js +10 -22
- package/lib/models/DailyDeal.js +15 -34
- package/lib/models/DarkSector.js +14 -25
- package/lib/models/DarkSectorBattle.js +6 -8
- package/lib/models/DuviriCycle.js +9 -10
- package/lib/models/EarthCycle.js +36 -35
- package/lib/models/Fissure.js +36 -44
- package/lib/models/FlashSale.js +17 -37
- package/lib/models/GlobalUpgrade.js +23 -41
- package/lib/models/Invasion.js +37 -79
- package/lib/models/Kuva.js +20 -26
- package/lib/models/Mission.js +28 -38
- package/lib/models/News.js +34 -54
- package/lib/models/Nightwave.js +22 -48
- package/lib/models/NightwaveChallenge.js +15 -19
- package/lib/models/PersistentEnemy.js +21 -30
- package/lib/models/Reward.js +18 -20
- package/lib/models/SentientOutpost.js +11 -12
- package/lib/models/Simaris.js +9 -21
- package/lib/models/Sortie.js +36 -54
- package/lib/models/SortieVariant.js +23 -25
- package/lib/models/SteelPathOffering.js +26 -9
- package/lib/models/SyndicateJob.js +20 -30
- package/lib/models/SyndicateMission.js +22 -52
- package/lib/models/VallisCycle.js +37 -45
- package/lib/models/VoidTrader.js +35 -54
- package/lib/models/VoidTraderItem.js +5 -8
- package/lib/models/VoidTraderSchedule.js +7 -6
- package/lib/models/WeeklyChallenge.js +9 -17
- package/lib/models/WorldEvent.js +49 -74
- package/lib/models/WorldstateObject.js +23 -34
- package/lib/models/ZarimanCycle.js +34 -54
- package/lib/supporting/Dependency.js +2 -11
- package/lib/supporting/DuviriChoice.js +1 -5
- package/lib/supporting/ExternalMission.js +2 -6
- package/lib/supporting/MarkdownSettings.js +15 -19
- package/lib/supporting/RewardData.js +4 -6
- package/lib/supporting/RewardTypes.js +2 -4
- package/lib/utilities/integrity.js +11 -0
- package/lib/utilities/timeDate.js +16 -18
- package/lib/utilities/translation.js +188 -56
- package/main.js +2 -2
- package/package.json +3 -5
- package/types/lib/WorldState.d.ts +39 -28
- package/types/lib/models/Alert.d.ts +13 -24
- package/types/lib/models/CambionCycle.d.ts +5 -10
- package/types/lib/models/CetusCycle.d.ts +8 -26
- package/types/lib/models/ChallengeInstance.d.ts +7 -9
- package/types/lib/models/ConclaveChallenge.d.ts +11 -24
- package/types/lib/models/ConstructionProgress.d.ts +5 -16
- package/types/lib/models/DailyDeal.d.ts +7 -26
- package/types/lib/models/DarkSector.d.ts +11 -22
- package/types/lib/models/DarkSectorBattle.d.ts +3 -6
- package/types/lib/models/DuviriCycle.d.ts +5 -11
- package/types/lib/models/EarthCycle.d.ts +40 -17
- package/types/lib/models/Fissure.d.ts +10 -17
- package/types/lib/models/FlashSale.d.ts +8 -29
- package/types/lib/models/GlobalUpgrade.d.ts +8 -27
- package/types/lib/models/Invasion.d.ts +18 -53
- package/types/lib/models/Kuva.d.ts +10 -21
- package/types/lib/models/Mission.d.ts +11 -23
- package/types/lib/models/News.d.ts +18 -31
- package/types/lib/models/Nightwave.d.ts +12 -29
- package/types/lib/models/NightwaveChallenge.d.ts +10 -15
- package/types/lib/models/PersistentEnemy.d.ts +9 -20
- package/types/lib/models/Reward.d.ts +34 -18
- package/types/lib/models/SentientOutpost.d.ts +9 -13
- package/types/lib/models/Simaris.d.ts +6 -17
- package/types/lib/models/Sortie.d.ts +16 -25
- package/types/lib/models/SortieVariant.d.ts +13 -15
- package/types/lib/models/SteelPathOffering.d.ts +5 -8
- package/types/lib/models/SyndicateJob.d.ts +13 -14
- package/types/lib/models/SyndicateMission.d.ts +9 -22
- package/types/lib/models/VallisCycle.d.ts +28 -18
- package/types/lib/models/VoidTrader.d.ts +8 -21
- package/types/lib/models/VoidTraderItem.d.ts +4 -6
- package/types/lib/models/VoidTraderSchedule.d.ts +5 -8
- package/types/lib/models/WeeklyChallenge.d.ts +5 -14
- package/types/lib/models/WorldEvent.d.ts +38 -52
- package/types/lib/models/WorldstateObject.d.ts +46 -24
- package/types/lib/models/ZarimanCycle.d.ts +9 -27
- package/types/lib/supporting/Dependency.d.ts +2 -8
- package/types/lib/supporting/DuviriChoice.d.ts +1 -2
- package/types/lib/supporting/ExternalMission.d.ts +3 -7
- package/types/lib/supporting/MarkdownSettings.d.ts +29 -15
- package/types/lib/supporting/RewardData.d.ts +8 -2
- package/types/lib/supporting/RewardTypes.d.ts +2 -2
- package/types/lib/utilities/integrity.d.ts +1 -0
- package/types/lib/utilities/timeDate.d.ts +19 -12
- package/types/lib/utilities/translation.d.ts +188 -23
- package/types/main.d.ts +2 -4
|
@@ -1,45 +1,44 @@
|
|
|
1
|
-
|
|
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 {
|
|
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, {
|
|
12
|
+
constructor(data, { locale = 'en' } = { locale: 'en' }) {
|
|
14
13
|
/**
|
|
15
14
|
* Type of challenge
|
|
16
15
|
* @type {string}
|
|
17
16
|
*/
|
|
18
|
-
this.type =
|
|
17
|
+
this.type = languageString(data.Type, locale);
|
|
19
18
|
|
|
20
19
|
/**
|
|
21
20
|
* Minimum enemy level to fulfill challenge
|
|
22
|
-
* @type {
|
|
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 {
|
|
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 {
|
|
33
|
+
* @type {number}
|
|
35
34
|
*/
|
|
36
35
|
this.progressAmount = Number(data.ProgressIndicatorFreq);
|
|
37
36
|
|
|
38
37
|
/**
|
|
39
38
|
* Required damage type
|
|
40
|
-
* @type {
|
|
39
|
+
* @type {string | undefined}
|
|
41
40
|
*/
|
|
42
|
-
this.damageType = data.DamageType ?
|
|
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
|
-
?
|
|
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
|
-
|
|
1
|
+
import { parseDate, fromNow, timeDeltaToString } from '../utilities/timeDate.js';
|
|
2
|
+
import { conclaveMode, conclaveCategory, conclaveChallenge } from '../utilities/translation.js';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
import WorldstateObject from './WorldstateObject.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Represents a Conclave challenge
|
|
7
|
-
* @
|
|
8
|
+
* @augments {WorldstateObject}
|
|
8
9
|
*/
|
|
9
|
-
class ConclaveChallenge extends WorldstateObject {
|
|
10
|
+
export default class ConclaveChallenge extends WorldstateObject {
|
|
10
11
|
/**
|
|
11
|
-
* @param {
|
|
12
|
-
* @param {
|
|
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, {
|
|
19
|
-
super(data
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
47
|
+
this.category = conclaveCategory(data.Category, locale);
|
|
66
48
|
|
|
67
49
|
/**
|
|
68
50
|
* ETA string (at time of object creation)
|
|
69
|
-
* @type {
|
|
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 {
|
|
93
|
+
* @type {number}
|
|
112
94
|
*/
|
|
113
95
|
this.standing = undefined;
|
|
114
96
|
|
|
115
|
-
const challenge =
|
|
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
|
|
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 =
|
|
156
|
-
return
|
|
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
|
-
|
|
1
|
+
import mdConfig from '../supporting/MarkdownSettings.js';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import WorldstateObject from './WorldstateObject.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Represents enemy construction progress
|
|
7
|
-
* @
|
|
7
|
+
* @augments {WorldstateObject}
|
|
8
8
|
*/
|
|
9
|
-
class ConstructionProgress extends WorldstateObject {
|
|
9
|
+
export default class ConstructionProgress extends WorldstateObject {
|
|
10
10
|
/**
|
|
11
|
-
* @param {
|
|
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
|
|
16
|
-
super(data
|
|
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
|
-
`${
|
|
38
|
-
`${this.razorbackProgress}%${
|
|
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;
|
package/lib/models/DailyDeal.js
CHANGED
|
@@ -1,39 +1,22 @@
|
|
|
1
|
-
|
|
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 {
|
|
9
|
-
* @param {
|
|
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, {
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 {
|
|
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
|
|
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(
|
|
101
|
+
return lines.join(mdConfig.lineEnd);
|
|
119
102
|
}
|
|
120
103
|
}
|
|
121
|
-
|
|
122
|
-
module.exports = DailyDeal;
|
package/lib/models/DarkSector.js
CHANGED
|
@@ -1,33 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
import { parseDate } from '../utilities/timeDate.js';
|
|
2
|
+
import { languageString } from '../utilities/translation.js';
|
|
2
3
|
|
|
3
|
-
|
|
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
|
-
* @
|
|
10
|
+
* @augments {WorldstateObject}
|
|
8
11
|
*/
|
|
9
|
-
class DarkSector extends WorldstateObject {
|
|
12
|
+
export default class DarkSector extends WorldstateObject {
|
|
10
13
|
/**
|
|
11
|
-
* @param {
|
|
12
|
-
* @param {
|
|
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, {
|
|
22
|
-
super(data
|
|
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 {
|
|
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
|
-
?
|
|
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 =
|
|
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
|
-
|
|
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 {
|
|
8
|
+
* @param {object} data The battle data
|
|
9
9
|
*/
|
|
10
|
-
constructor(data
|
|
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 =
|
|
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 =
|
|
54
|
+
this.end = parseDate(data.End);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
|
|
58
|
-
module.exports = DarkSectorBattle;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { toTitleCase } from '../utilities/translation.js';
|
|
2
|
+
import { timeDeltaToString } from '../utilities/timeDate.js';
|
|
2
3
|
|
|
3
|
-
|
|
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
|
-
* @
|
|
31
|
+
* @augments {WorldstateObject}
|
|
31
32
|
*/
|
|
32
|
-
class DuviriCycle extends WorldstateObject {
|
|
33
|
-
constructor({
|
|
34
|
-
super({ _id: { $oid: 'duviriCycle0' } }
|
|
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 `${
|
|
62
|
+
return `${toTitleCase(this.state)} spiral. ${toTitleCase(
|
|
62
63
|
states[(states.indexOf(this.state) + 1) % 5]
|
|
63
|
-
)} in ${
|
|
64
|
+
)} in ${timeDeltaToString(new Date(this.expiry).getTime() - Date.now())}`;
|
|
64
65
|
}
|
|
65
66
|
}
|
|
66
|
-
|
|
67
|
-
module.exports = DuviriCycle;
|
package/lib/models/EarthCycle.js
CHANGED
|
@@ -1,7 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
import { fromNow } from '../utilities/timeDate.js';
|
|
2
|
+
import mdConfig from '../supporting/MarkdownSettings.js';
|
|
2
3
|
|
|
3
|
-
|
|
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
|
-
* @
|
|
58
|
+
* @augments {WorldstateObject}
|
|
42
59
|
*/
|
|
43
|
-
class EarthCycle extends WorldstateObject {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
|
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.
|
|
110
|
-
`Time remaining until ${this.
|
|
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(
|
|
116
|
+
return lines.join(mdConfig.lineEnd);
|
|
114
117
|
}
|
|
115
118
|
}
|
|
116
|
-
|
|
117
|
-
module.exports = EarthCycle;
|