warframe-worldstate-parser 4.2.2 → 4.3.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
@@ -32,6 +32,7 @@ import WorldEvent from './models/WorldEvent.js';
32
32
  import News from './models/News.js';
33
33
  import Kinepage from './models/Kinepage.js';
34
34
  import DeepArchimedea from './models/DeepArchidemea.js';
35
+ import Calendar from './models/Calendar.js';
35
36
 
36
37
  const { sortieData } = wsData;
37
38
 
@@ -376,6 +377,8 @@ export class WorldState {
376
377
  */
377
378
  this.deepArchimedea = new DeepArchimedea(activation, expiry, tmp.lqo27);
378
379
  }
380
+
381
+ this.calendar = parseArray(Calendar, data.KnownCalendarSeasons, deps);
379
382
  }
380
383
  }
381
384
 
@@ -0,0 +1,59 @@
1
+ import {
2
+ languageDesc,
3
+ languageString,
4
+ parseDate,
5
+ translateCalendarEvent,
6
+ translateSeason,
7
+ } from 'warframe-worldstate-data/utilities';
8
+
9
+ const EventTypes = Object.freeze({
10
+ PLOT: 'CET_PLOT',
11
+ REWARD: 'CET_REWARD',
12
+ CHALLENGE: 'CET_CHALLENGE',
13
+ UPGRADE: 'CET_UPGRADE',
14
+ });
15
+
16
+ /**
17
+ * Event data for a 1999 calendar day
18
+ * @param {object} event raw event data
19
+ */
20
+ class DayEvent {
21
+ constructor(event) {
22
+ this.type = translateCalendarEvent(event.type);
23
+
24
+ if (event.challenge) this.challenge = this.eventDescription(event.challenge);
25
+
26
+ if (event.upgrade) this.upgrade = this.eventDescription(event.upgrade);
27
+
28
+ if (event.reward) this.reward = languageString(event.reward);
29
+
30
+ if (event.type === EventTypes.PLOT) {
31
+ this.dialogueName = event.dialogueName;
32
+ this.dialogueConvo = event.dialogueConvo;
33
+ }
34
+ }
35
+
36
+ eventDescription(name) {
37
+ return { title: languageString(name), description: languageDesc(name) };
38
+ }
39
+ }
40
+
41
+ export default class Calendar {
42
+ constructor(calendar) {
43
+ this.activation = parseDate(calendar.Activation);
44
+
45
+ this.expiry = parseDate(calendar.Expiry);
46
+
47
+ this.days = Array.isArray(calendar.Days)
48
+ ? calendar.Days.filter(Boolean).map((d) => ({ ...d, events: d.events.map((e) => new DayEvent(e)) }))
49
+ : [];
50
+
51
+ this.season = translateSeason(calendar.Season);
52
+
53
+ this.yearIteration = calendar.YearIteration;
54
+
55
+ this.version = calendar.Version;
56
+
57
+ this.requirements = calendar.UpgradeAvaliabilityRequirements;
58
+ }
59
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "warframe-worldstate-parser",
3
- "version": "4.2.2",
3
+ "version": "4.3.0",
4
4
  "description": "An Open parser for Warframe's Worldstate in Javascript",
5
5
  "keywords": [
6
6
  "warframe-worldstate",
@@ -154,6 +154,7 @@ export class WorldState {
154
154
  * @type {DeepArchimedea}
155
155
  */
156
156
  deepArchimedea: DeepArchimedea;
157
+ calendar: WorldstateObject[];
157
158
  }
158
159
  declare function _default(json: any, deps: any): Promise<WorldState>;
159
160
  export default _default;
@@ -0,0 +1,10 @@
1
+ export default class Calendar {
2
+ constructor(calendar: any);
3
+ activation: any;
4
+ expiry: any;
5
+ days: any;
6
+ season: any;
7
+ yearIteration: any;
8
+ version: any;
9
+ requirements: any;
10
+ }