warframe-worldstate-parser 2.24.0 → 2.24.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.
- package/lib/WorldState.js +4 -1
- package/lib/ZarimanCycle.js +24 -19
- package/package.json +1 -1
- package/types/lib/ZarimanCycle.d.ts +6 -6
package/lib/WorldState.js
CHANGED
|
@@ -242,11 +242,14 @@ module.exports = class WorldState {
|
|
|
242
242
|
*/
|
|
243
243
|
this.cambionCycle = new CambionCycle(this.cetusCycle, deps);
|
|
244
244
|
|
|
245
|
+
const zarimanSynd = safeArray(data.SyndicateMissions).filter((syndicate) => syndicate.Tag === 'ZarimanSyndicate');
|
|
246
|
+
const zarimanBountyEnd = timeDate.parseDate(zarimanSynd.length > 0 ? zarimanSynd[0].Expiry : { $date: 0 });
|
|
247
|
+
|
|
245
248
|
/**
|
|
246
249
|
* The current Zariman cycle based off current time
|
|
247
250
|
* @type {ZarimanCycle}
|
|
248
251
|
*/
|
|
249
|
-
this.zarimanCycle = new ZarimanCycle(
|
|
252
|
+
this.zarimanCycle = new ZarimanCycle(zarimanBountyEnd, deps);
|
|
250
253
|
|
|
251
254
|
/**
|
|
252
255
|
* Weekly challenges
|
package/lib/ZarimanCycle.js
CHANGED
|
@@ -5,9 +5,9 @@ const WorldstateObject = require('./WorldstateObject');
|
|
|
5
5
|
// This is a confirmed starting time for Corpus (in millis)
|
|
6
6
|
// All faction operation should use this as a calculation point
|
|
7
7
|
// Unless there's a better logic
|
|
8
|
-
const corpusTimeMillis =
|
|
9
|
-
const fullCycle =
|
|
10
|
-
const stateMaximum =
|
|
8
|
+
const corpusTimeMillis = 1655182800000;
|
|
9
|
+
const fullCycle = 18000000;
|
|
10
|
+
const stateMaximum = 9000000;
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Represents the current Zariman Corpus/Grineer Cycle
|
|
@@ -15,12 +15,12 @@ const stateMaximum = 14400000;
|
|
|
15
15
|
*/
|
|
16
16
|
module.exports = class ZarimanCycle extends WorldstateObject {
|
|
17
17
|
/**
|
|
18
|
-
* @param {Date}
|
|
18
|
+
* @param {Date} bountiesEndDate The current zariman cycle expiry
|
|
19
19
|
* @param {Object} deps The dependencies object
|
|
20
20
|
* @param {MarkdownSettings} deps.mdConfig The markdown settings
|
|
21
21
|
* @param {TimeDateFunctions} deps.timeDate The time and date functions
|
|
22
22
|
*/
|
|
23
|
-
constructor(
|
|
23
|
+
constructor(bountiesEndDate, { mdConfig, timeDate }) {
|
|
24
24
|
super({ _id: { $oid: 'zarimanCycle0' } }, { timeDate });
|
|
25
25
|
|
|
26
26
|
/**
|
|
@@ -36,7 +36,7 @@ module.exports = class ZarimanCycle extends WorldstateObject {
|
|
|
36
36
|
* @type {Date}
|
|
37
37
|
* @private
|
|
38
38
|
*/
|
|
39
|
-
this.
|
|
39
|
+
this.bountiesEndDate = bountiesEndDate;
|
|
40
40
|
Object.defineProperty(this, 'currentTime', { enumerable: false, configurable: false });
|
|
41
41
|
|
|
42
42
|
/**
|
|
@@ -68,10 +68,10 @@ module.exports = class ZarimanCycle extends WorldstateObject {
|
|
|
68
68
|
this.activation = new Date(ec.start);
|
|
69
69
|
|
|
70
70
|
/**
|
|
71
|
-
* Whether or not this it's
|
|
71
|
+
* Whether or not this it's corpus or grineer
|
|
72
72
|
* @type {boolean}
|
|
73
73
|
*/
|
|
74
|
-
this.isCorpus = ec.
|
|
74
|
+
this.isCorpus = ec.isCorpus;
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
77
|
* Current cycle state. One of `corpus`, `grineer`
|
|
@@ -95,24 +95,29 @@ module.exports = class ZarimanCycle extends WorldstateObject {
|
|
|
95
95
|
* @returns {boolean}
|
|
96
96
|
*/
|
|
97
97
|
getExpired() {
|
|
98
|
-
return this.timeDate.fromNow(this.expiry) < 0;
|
|
98
|
+
return this.expiry ? this.timeDate.fromNow(this.expiry) < 0 : true;
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
getCurrentZarimanCycle() {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
//
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
//
|
|
108
|
-
|
|
102
|
+
const now = Date.now();
|
|
103
|
+
// determine if it is corpus cycle or grineer cycle based on bounty end time
|
|
104
|
+
// 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));
|
|
107
|
+
// the following line is a modulus operation
|
|
108
|
+
// this ensures that our calculation is correct if bountiesClone is before corpusTimeMillis
|
|
109
|
+
// if you really care, read https://torstencurdt.com/tech/posts/modulo-of-negative-numbers/
|
|
110
|
+
const cycleTimeElapsed = (((bountiesClone - corpusTimeMillis) % fullCycle) + fullCycle) % fullCycle;
|
|
111
|
+
const cycleTimeLeft = fullCycle - cycleTimeElapsed;
|
|
112
|
+
// if timeInCycle is more than 2.5 hours, it is corpus, otherwise it is grineer
|
|
113
|
+
const isCorpus = cycleTimeLeft > stateMaximum;
|
|
109
114
|
|
|
110
115
|
const minutesCoef = 1000 * 60;
|
|
111
|
-
const expiry = new Date(Math.round((
|
|
112
|
-
const state =
|
|
116
|
+
const expiry = new Date(Math.round((now + millisLeft) / minutesCoef) * minutesCoef);
|
|
117
|
+
const state = isCorpus ? 'corpus' : 'grineer';
|
|
113
118
|
|
|
114
119
|
return {
|
|
115
|
-
|
|
120
|
+
isCorpus,
|
|
116
121
|
timeLeft: this.timeDate.timeDeltaToString(millisLeft),
|
|
117
122
|
expiry,
|
|
118
123
|
expiresIn: millisLeft,
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export = ZarimanCycle;
|
|
2
2
|
declare class ZarimanCycle extends WorldstateObject {
|
|
3
3
|
/**
|
|
4
|
-
* @param {Date}
|
|
4
|
+
* @param {Date} bountiesEndDate The current zariman cycle expiry
|
|
5
5
|
* @param {Object} deps The dependencies object
|
|
6
6
|
* @param {MarkdownSettings} deps.mdConfig The markdown settings
|
|
7
7
|
* @param {TimeDateFunctions} deps.timeDate The time and date functions
|
|
8
8
|
*/
|
|
9
|
-
constructor(
|
|
9
|
+
constructor(bountiesEndDate: Date, { mdConfig, timeDate }: {
|
|
10
10
|
mdConfig: MarkdownSettings;
|
|
11
11
|
timeDate: TimeDateFunctions;
|
|
12
12
|
});
|
|
@@ -21,9 +21,9 @@ declare class ZarimanCycle extends WorldstateObject {
|
|
|
21
21
|
* @type {Date}
|
|
22
22
|
* @private
|
|
23
23
|
*/
|
|
24
|
-
private
|
|
24
|
+
private bountiesEndDate;
|
|
25
25
|
/**
|
|
26
|
-
* Whether or not this it's
|
|
26
|
+
* Whether or not this it's corpus or grineer
|
|
27
27
|
* @type {boolean}
|
|
28
28
|
*/
|
|
29
29
|
isCorpus: boolean;
|
|
@@ -44,10 +44,10 @@ declare class ZarimanCycle extends WorldstateObject {
|
|
|
44
44
|
*/
|
|
45
45
|
getExpired(): boolean;
|
|
46
46
|
getCurrentZarimanCycle(): {
|
|
47
|
-
|
|
47
|
+
isCorpus: boolean;
|
|
48
48
|
timeLeft: any;
|
|
49
49
|
expiry: Date;
|
|
50
|
-
expiresIn:
|
|
50
|
+
expiresIn: any;
|
|
51
51
|
state: string;
|
|
52
52
|
start: number;
|
|
53
53
|
};
|