warframe-worldstate-parser 4.5.2 → 4.6.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 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,94 @@
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 refPoint = Date.parse('2025-08-07T16:05:29Z');
27
+ const now = Date.now();
28
+ const elapsedInCycle = (now - refPoint) % totalDuration;
29
+ const isDay = elapsedInCycle < dayDuration;
30
+
31
+ let phase = {
32
+ name: 'night',
33
+ remaining: totalDuration - elapsedInCycle,
34
+ duration: nightDuration,
35
+ };
36
+
37
+ if (isDay) {
38
+ phase = {
39
+ name: 'day',
40
+ remaining: dayDuration - elapsedInCycle,
41
+ duration: dayDuration,
42
+ };
43
+ }
44
+
45
+ const activation = new Date(now - (phase.duration - phase.remaining));
46
+ const expiry = new Date(activation.getTime() + phase.duration);
47
+ const timeLeft = timeDeltaToString(phase.remaining);
48
+
49
+ return {
50
+ activation,
51
+ expiry,
52
+ state: phase.name,
53
+ timeLeft,
54
+ isDay,
55
+ };
56
+ }
57
+
58
+ export default class MidrathCycle extends WorldstateObject {
59
+ #mc = getCurrentMidrathCycle();
60
+ constructor() {
61
+ super({ _id: { $oid: 'midrathCycle0' } });
62
+
63
+ this.activation = this.#mc.activation;
64
+
65
+ this.expiry = this.#mc.expiry;
66
+
67
+ this.isDay = this.#mc.isDay;
68
+
69
+ this.state = this.#mc.state;
70
+
71
+ this.timeLeft = this.#mc.timeLeft;
72
+ }
73
+
74
+ /**
75
+ * Get whether or not the event has expired
76
+ * @returns {boolean} Whether or not the event has expired
77
+ */
78
+ getExpired() {
79
+ return fromNow(this.expiry) < 0;
80
+ }
81
+
82
+ /**
83
+ * The event's string representation
84
+ * @returns {string} The string representation of the event
85
+ */
86
+ toString() {
87
+ const lines = [
88
+ `Envoy, it is currently ${this.isDay ? 'Day' : 'Night'}time in Midrath`,
89
+ `Time remaining until ${this.isDay ? 'night' : 'day'}: ${this.timeLeft}`,
90
+ ];
91
+
92
+ return lines.join(mdConfig.lineEnd);
93
+ }
94
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "warframe-worldstate-parser",
3
- "version": "4.5.2",
3
+ "version": "4.6.1",
4
4
  "description": "An Open parser for Warframe's Worldstate in Javascript",
5
5
  "keywords": [
6
6
  "warframe-worldstate",
@@ -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';