warframe-worldstate-parser 4.5.2 → 4.6.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/lib/WorldState.js
CHANGED
|
@@ -33,6 +33,7 @@ import News from './models/News.js';
|
|
|
33
33
|
import Kinepage from './models/Kinepage.js';
|
|
34
34
|
import DeepArchimedea from './models/DeepArchidemea.js';
|
|
35
35
|
import Calendar from './models/Calendar.js';
|
|
36
|
+
import MidrathCycle from './models/MidrathCycle.js';
|
|
36
37
|
|
|
37
38
|
const { sortieData } = wsData;
|
|
38
39
|
|
|
@@ -278,6 +279,12 @@ export class WorldState {
|
|
|
278
279
|
*/
|
|
279
280
|
this.zarimanCycle = new ZarimanCycle(zarimanBountyEnd, deps);
|
|
280
281
|
|
|
282
|
+
/**
|
|
283
|
+
* Midrath cycle (soulframe)
|
|
284
|
+
* @type {MidrathCycle}
|
|
285
|
+
*/
|
|
286
|
+
this.midrathCycle = new MidrathCycle();
|
|
287
|
+
|
|
281
288
|
/**
|
|
282
289
|
* Weekly challenges
|
|
283
290
|
* @type {Array.<WeeklyChallenge>}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { timeDeltaToString, fromNow } from 'warframe-worldstate-data/utilities';
|
|
2
|
+
|
|
3
|
+
import mdConfig from '../supporting/MarkdownSettings.js';
|
|
4
|
+
|
|
5
|
+
import WorldstateObject from './WorldstateObject.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {object} MidrathCycle
|
|
9
|
+
* @property {Date} expiry The date and time at which the event ends
|
|
10
|
+
* @property {Date} activation The date and time at which the event started
|
|
11
|
+
* @property {boolean} isDay Whether or not this it's daytime
|
|
12
|
+
* @property {string} state Current cycle state. One of `day`, `night`
|
|
13
|
+
* @property {string} timeLeft Time remaining string
|
|
14
|
+
* @property {boolean} expired Whether or not the event has expired
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Get the current Midrath cycle time
|
|
19
|
+
* @returns {MidrathCycle} Current midrath cycle time
|
|
20
|
+
*/
|
|
21
|
+
function getCurrentMidrathCycle() {
|
|
22
|
+
const dayDuration = 32 * 60 * 1000; // 32 minutes in milliseconds
|
|
23
|
+
const nightDuration = 16 * 60 * 1000; // 16 minutes in milliseconds
|
|
24
|
+
const totalDuration = dayDuration + nightDuration;
|
|
25
|
+
|
|
26
|
+
const now = new Date();
|
|
27
|
+
const elapsedInCycle = (now.getTime() - 222000) % totalDuration;
|
|
28
|
+
const isDay = elapsedInCycle < dayDuration;
|
|
29
|
+
|
|
30
|
+
let phase = {
|
|
31
|
+
name: 'night',
|
|
32
|
+
remaining: totalDuration - elapsedInCycle,
|
|
33
|
+
duration: nightDuration,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
if (isDay) {
|
|
37
|
+
phase = {
|
|
38
|
+
name: 'day',
|
|
39
|
+
remaining: dayDuration - elapsedInCycle,
|
|
40
|
+
duration: dayDuration,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const activation = new Date(now.getTime() - (phase.duration - phase.remaining));
|
|
45
|
+
const expiry = new Date(activation.getTime() + phase.duration);
|
|
46
|
+
const timeLeft = timeDeltaToString(phase.remaining);
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
activation,
|
|
50
|
+
expiry,
|
|
51
|
+
state: phase.name,
|
|
52
|
+
timeLeft,
|
|
53
|
+
isDay,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export default class MidrathCycle extends WorldstateObject {
|
|
58
|
+
#mc = getCurrentMidrathCycle();
|
|
59
|
+
constructor() {
|
|
60
|
+
super({ _id: { $oid: 'midrathCycle0' } });
|
|
61
|
+
|
|
62
|
+
this.activation = this.#mc.activation;
|
|
63
|
+
|
|
64
|
+
this.expiry = this.#mc.expiry;
|
|
65
|
+
|
|
66
|
+
this.isDay = this.#mc.isDay;
|
|
67
|
+
|
|
68
|
+
this.state = this.#mc.state;
|
|
69
|
+
|
|
70
|
+
this.timeLeft = this.#mc.timeLeft;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Get whether or not the event has expired
|
|
75
|
+
* @returns {boolean} Whether or not the event has expired
|
|
76
|
+
*/
|
|
77
|
+
getExpired() {
|
|
78
|
+
return fromNow(this.expiry) < 0;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* The event's string representation
|
|
83
|
+
* @returns {string} The string representation of the event
|
|
84
|
+
*/
|
|
85
|
+
toString() {
|
|
86
|
+
const lines = [
|
|
87
|
+
`Envoy, it is currently ${this.isDay ? 'Day' : 'Night'}time in Midrath`,
|
|
88
|
+
`Time remaining until ${this.isDay ? 'night' : 'day'}: ${this.timeLeft}`,
|
|
89
|
+
];
|
|
90
|
+
|
|
91
|
+
return lines.join(mdConfig.lineEnd);
|
|
92
|
+
}
|
|
93
|
+
}
|
package/package.json
CHANGED
|
@@ -116,6 +116,11 @@ export class WorldState {
|
|
|
116
116
|
* @type {ZarimanCycle}
|
|
117
117
|
*/
|
|
118
118
|
zarimanCycle: ZarimanCycle;
|
|
119
|
+
/**
|
|
120
|
+
* Midrath cycle (soulframe)
|
|
121
|
+
* @type {MidrathCycle}
|
|
122
|
+
*/
|
|
123
|
+
midrathCycle: MidrathCycle;
|
|
119
124
|
/**
|
|
120
125
|
* Weekly challenges
|
|
121
126
|
* @type {Array.<WeeklyChallenge>}
|
|
@@ -182,6 +187,7 @@ import EarthCycle from './models/EarthCycle.js';
|
|
|
182
187
|
import CetusCycle from './models/CetusCycle.js';
|
|
183
188
|
import CambionCycle from './models/CambionCycle.js';
|
|
184
189
|
import ZarimanCycle from './models/ZarimanCycle.js';
|
|
190
|
+
import MidrathCycle from './models/MidrathCycle.js';
|
|
185
191
|
import WeeklyChallenge from './models/WeeklyChallenge.js';
|
|
186
192
|
import ConstructionProgress from './models/ConstructionProgress.js';
|
|
187
193
|
import VallisCycle from './models/VallisCycle.js';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export default class MidrathCycle extends WorldstateObject {
|
|
2
|
+
constructor();
|
|
3
|
+
isDay: any;
|
|
4
|
+
state: any;
|
|
5
|
+
timeLeft: any;
|
|
6
|
+
/**
|
|
7
|
+
* Get whether or not the event has expired
|
|
8
|
+
* @returns {boolean} Whether or not the event has expired
|
|
9
|
+
*/
|
|
10
|
+
getExpired(): boolean;
|
|
11
|
+
#private;
|
|
12
|
+
}
|
|
13
|
+
export type MidrathCycle = {
|
|
14
|
+
/**
|
|
15
|
+
* The date and time at which the event ends
|
|
16
|
+
*/
|
|
17
|
+
expiry: Date;
|
|
18
|
+
/**
|
|
19
|
+
* The date and time at which the event started
|
|
20
|
+
*/
|
|
21
|
+
activation: Date;
|
|
22
|
+
/**
|
|
23
|
+
* Whether or not this it's daytime
|
|
24
|
+
*/
|
|
25
|
+
isDay: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Current cycle state. One of `day`, `night`
|
|
28
|
+
*/
|
|
29
|
+
state: string;
|
|
30
|
+
/**
|
|
31
|
+
* Time remaining string
|
|
32
|
+
*/
|
|
33
|
+
timeLeft: string;
|
|
34
|
+
/**
|
|
35
|
+
* Whether or not the event has expired
|
|
36
|
+
*/
|
|
37
|
+
expired: boolean;
|
|
38
|
+
};
|
|
39
|
+
import WorldstateObject from './WorldstateObject.js';
|