warframe-worldstate-parser 2.26.2 → 2.28.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.
Files changed (85) hide show
  1. package/lib/WorldState.js +35 -32
  2. package/lib/{CetusCycle.js → models/CetusCycle.js} +2 -2
  3. package/lib/{DailyDeal.js → models/DailyDeal.js} +6 -0
  4. package/lib/models/DuviriCycle.js +59 -0
  5. package/lib/models/Reward.js +113 -0
  6. package/lib/{WorldstateObject.js → models/WorldstateObject.js} +5 -1
  7. package/lib/supporting/RewardData.js +79 -0
  8. package/lib/{Reward.js → supporting/RewardTypes.js} +2 -183
  9. package/lib/{translation.js → utilities/translation.js} +4 -2
  10. package/package.json +1 -1
  11. package/types/lib/WorldState.d.ts +25 -23
  12. package/types/lib/{CetusCycle.d.ts → models/CetusCycle.d.ts} +2 -2
  13. package/types/lib/{DailyDeal.d.ts → models/DailyDeal.d.ts} +5 -0
  14. package/types/lib/models/DuviriCycle.d.ts +22 -0
  15. package/types/lib/{NightwaveChallenge.d.ts → models/NightwaveChallenge.d.ts} +0 -6
  16. package/types/lib/{SyndicateMission.d.ts → models/SyndicateMission.d.ts} +0 -11
  17. package/types/lib/{WorldstateObject.d.ts → models/WorldstateObject.d.ts} +3 -1
  18. package/types/lib/supporting/RewardData.d.ts +3 -0
  19. package/types/lib/supporting/RewardTypes.d.ts +2 -0
  20. package/types/lib/{translation.d.ts → utilities/translation.d.ts} +2 -1
  21. /package/lib/{Alert.js → models/Alert.js} +0 -0
  22. /package/lib/{CambionCycle.js → models/CambionCycle.js} +0 -0
  23. /package/lib/{ChallengeInstance.js → models/ChallengeInstance.js} +0 -0
  24. /package/lib/{ConclaveChallenge.js → models/ConclaveChallenge.js} +0 -0
  25. /package/lib/{ConstructionProgress.js → models/ConstructionProgress.js} +0 -0
  26. /package/lib/{DarkSector.js → models/DarkSector.js} +0 -0
  27. /package/lib/{DarkSectorBattle.js → models/DarkSectorBattle.js} +0 -0
  28. /package/lib/{EarthCycle.js → models/EarthCycle.js} +0 -0
  29. /package/lib/{Fissure.js → models/Fissure.js} +0 -0
  30. /package/lib/{FlashSale.js → models/FlashSale.js} +0 -0
  31. /package/lib/{GlobalUpgrade.js → models/GlobalUpgrade.js} +0 -0
  32. /package/lib/{Invasion.js → models/Invasion.js} +0 -0
  33. /package/lib/{Kuva.js → models/Kuva.js} +0 -0
  34. /package/lib/{Mission.js → models/Mission.js} +0 -0
  35. /package/lib/{News.js → models/News.js} +0 -0
  36. /package/lib/{Nightwave.js → models/Nightwave.js} +0 -0
  37. /package/lib/{NightwaveChallenge.js → models/NightwaveChallenge.js} +0 -0
  38. /package/lib/{PersistentEnemy.js → models/PersistentEnemy.js} +0 -0
  39. /package/lib/{SentientOutpost.js → models/SentientOutpost.js} +0 -0
  40. /package/lib/{Simaris.js → models/Simaris.js} +0 -0
  41. /package/lib/{Sortie.js → models/Sortie.js} +0 -0
  42. /package/lib/{SortieVariant.js → models/SortieVariant.js} +0 -0
  43. /package/lib/{SteelPathOffering.js → models/SteelPathOffering.js} +0 -0
  44. /package/lib/{SyndicateJob.js → models/SyndicateJob.js} +0 -0
  45. /package/lib/{SyndicateMission.js → models/SyndicateMission.js} +0 -0
  46. /package/lib/{VallisCycle.js → models/VallisCycle.js} +0 -0
  47. /package/lib/{VoidTrader.js → models/VoidTrader.js} +0 -0
  48. /package/lib/{VoidTraderItem.js → models/VoidTraderItem.js} +0 -0
  49. /package/lib/{VoidTraderSchedule.js → models/VoidTraderSchedule.js} +0 -0
  50. /package/lib/{WeeklyChallenge.js → models/WeeklyChallenge.js} +0 -0
  51. /package/lib/{WorldEvent.js → models/WorldEvent.js} +0 -0
  52. /package/lib/{ZarimanCycle.js → models/ZarimanCycle.js} +0 -0
  53. /package/lib/{timeDate.js → utilities/timeDate.js} +0 -0
  54. /package/types/lib/{Alert.d.ts → models/Alert.d.ts} +0 -0
  55. /package/types/lib/{CambionCycle.d.ts → models/CambionCycle.d.ts} +0 -0
  56. /package/types/lib/{ChallengeInstance.d.ts → models/ChallengeInstance.d.ts} +0 -0
  57. /package/types/lib/{ConclaveChallenge.d.ts → models/ConclaveChallenge.d.ts} +0 -0
  58. /package/types/lib/{ConstructionProgress.d.ts → models/ConstructionProgress.d.ts} +0 -0
  59. /package/types/lib/{DarkSector.d.ts → models/DarkSector.d.ts} +0 -0
  60. /package/types/lib/{DarkSectorBattle.d.ts → models/DarkSectorBattle.d.ts} +0 -0
  61. /package/types/lib/{EarthCycle.d.ts → models/EarthCycle.d.ts} +0 -0
  62. /package/types/lib/{Fissure.d.ts → models/Fissure.d.ts} +0 -0
  63. /package/types/lib/{FlashSale.d.ts → models/FlashSale.d.ts} +0 -0
  64. /package/types/lib/{GlobalUpgrade.d.ts → models/GlobalUpgrade.d.ts} +0 -0
  65. /package/types/lib/{Invasion.d.ts → models/Invasion.d.ts} +0 -0
  66. /package/types/lib/{Kuva.d.ts → models/Kuva.d.ts} +0 -0
  67. /package/types/lib/{Mission.d.ts → models/Mission.d.ts} +0 -0
  68. /package/types/lib/{News.d.ts → models/News.d.ts} +0 -0
  69. /package/types/lib/{Nightwave.d.ts → models/Nightwave.d.ts} +0 -0
  70. /package/types/lib/{PersistentEnemy.d.ts → models/PersistentEnemy.d.ts} +0 -0
  71. /package/types/lib/{Reward.d.ts → models/Reward.d.ts} +0 -0
  72. /package/types/lib/{SentientOutpost.d.ts → models/SentientOutpost.d.ts} +0 -0
  73. /package/types/lib/{Simaris.d.ts → models/Simaris.d.ts} +0 -0
  74. /package/types/lib/{Sortie.d.ts → models/Sortie.d.ts} +0 -0
  75. /package/types/lib/{SortieVariant.d.ts → models/SortieVariant.d.ts} +0 -0
  76. /package/types/lib/{SteelPathOffering.d.ts → models/SteelPathOffering.d.ts} +0 -0
  77. /package/types/lib/{SyndicateJob.d.ts → models/SyndicateJob.d.ts} +0 -0
  78. /package/types/lib/{VallisCycle.d.ts → models/VallisCycle.d.ts} +0 -0
  79. /package/types/lib/{VoidTrader.d.ts → models/VoidTrader.d.ts} +0 -0
  80. /package/types/lib/{VoidTraderItem.d.ts → models/VoidTraderItem.d.ts} +0 -0
  81. /package/types/lib/{VoidTraderSchedule.d.ts → models/VoidTraderSchedule.d.ts} +0 -0
  82. /package/types/lib/{WeeklyChallenge.d.ts → models/WeeklyChallenge.d.ts} +0 -0
  83. /package/types/lib/{WorldEvent.d.ts → models/WorldEvent.d.ts} +0 -0
  84. /package/types/lib/{ZarimanCycle.d.ts → models/ZarimanCycle.d.ts} +0 -0
  85. /package/types/lib/{timeDate.d.ts → utilities/timeDate.d.ts} +0 -0
package/lib/WorldState.js CHANGED
@@ -2,39 +2,40 @@
2
2
 
3
3
  const sortieData = require('warframe-worldstate-data').sortie;
4
4
 
5
- const News = require('./News');
6
- const WorldEvent = require('./WorldEvent');
7
- const Alert = require('./Alert');
8
- const Sortie = require('./Sortie');
9
- const SortieVariant = require('./SortieVariant');
10
- const SyndicateMission = require('./SyndicateMission');
11
- const Fissure = require('./Fissure');
12
- const GlobalUpgrade = require('./GlobalUpgrade');
13
- const FlashSale = require('./FlashSale');
14
- const Invasion = require('./Invasion');
15
- const DarkSector = require('./DarkSector');
16
- const DarkSectorBattle = require('./DarkSectorBattle');
17
- const Mission = require('./Mission');
18
- const Reward = require('./Reward');
19
- const VoidTrader = require('./VoidTrader');
20
- const DailyDeal = require('./DailyDeal');
21
- const Simaris = require('./Simaris');
22
- const ConclaveChallenge = require('./ConclaveChallenge');
23
- const PersistentEnemy = require('./PersistentEnemy');
24
- const timeDate = require('./timeDate');
25
- const translator = require('./translation');
26
- const EarthCycle = require('./EarthCycle');
27
- const CetusCycle = require('./CetusCycle');
28
- const ConstructionProgress = require('./ConstructionProgress');
29
- const VallisCycle = require('./VallisCycle');
30
- const ZarimanCycle = require('./ZarimanCycle');
31
- const WeeklyChallenge = require('./WeeklyChallenge');
32
- const Nightwave = require('./Nightwave');
33
- const Kuva = require('./Kuva');
34
- const SentientOutpost = require('./SentientOutpost');
35
- const CambionCycle = require('./CambionCycle');
36
- const SteelPathOffering = require('./SteelPathOffering');
5
+ const News = require('./models/News');
6
+ const WorldEvent = require('./models/WorldEvent');
7
+ const Alert = require('./models/Alert');
8
+ const Sortie = require('./models/Sortie');
9
+ const SortieVariant = require('./models/SortieVariant');
10
+ const SyndicateMission = require('./models/SyndicateMission');
11
+ const Fissure = require('./models/Fissure');
12
+ const GlobalUpgrade = require('./models/GlobalUpgrade');
13
+ const FlashSale = require('./models/FlashSale');
14
+ const Invasion = require('./models/Invasion');
15
+ const DarkSector = require('./models/DarkSector');
16
+ const DarkSectorBattle = require('./models/DarkSectorBattle');
17
+ const Mission = require('./models/Mission');
18
+ const Reward = require('./models/Reward');
19
+ const VoidTrader = require('./models/VoidTrader');
20
+ const DailyDeal = require('./models/DailyDeal');
21
+ const Simaris = require('./models/Simaris');
22
+ const ConclaveChallenge = require('./models/ConclaveChallenge');
23
+ const PersistentEnemy = require('./models/PersistentEnemy');
24
+ const timeDate = require('./utilities/timeDate');
25
+ const translator = require('./utilities/translation');
26
+ const EarthCycle = require('./models/EarthCycle');
27
+ const CetusCycle = require('./models/CetusCycle');
28
+ const ConstructionProgress = require('./models/ConstructionProgress');
29
+ const VallisCycle = require('./models/VallisCycle');
30
+ const ZarimanCycle = require('./models/ZarimanCycle');
31
+ const WeeklyChallenge = require('./models/WeeklyChallenge');
32
+ const Nightwave = require('./models/Nightwave');
33
+ const Kuva = require('./models/Kuva');
34
+ const SentientOutpost = require('./models/SentientOutpost');
35
+ const CambionCycle = require('./models/CambionCycle');
36
+ const SteelPathOffering = require('./models/SteelPathOffering');
37
37
  const Dependency = require('./supporting/Dependency'); // eslint-disable-line no-unused-vars
38
+ const DuviriCycle = require('./models/DuviriCycle');
38
39
 
39
40
  // needed for type declarations
40
41
  const MarkdownSettings = require('./supporting/MarkdownSettings');
@@ -328,5 +329,7 @@ module.exports = class WorldState {
328
329
  * @type {Sortie}
329
330
  */
330
331
  [this.archonHunt] = parseArray(deps.Sortie, data.LiteSorties, deps);
332
+
333
+ this.duviriCycle = new DuviriCycle(deps);
331
334
  }
332
335
  };
@@ -68,7 +68,7 @@ class CetusCycle extends WorldstateObject {
68
68
  this.activation = new Date(ec.start);
69
69
 
70
70
  /**
71
- * Whether or not this it's daytime
71
+ * Whether it's daytime
72
72
  * @type {boolean}
73
73
  */
74
74
  this.isDay = ec.dayTime;
@@ -86,7 +86,7 @@ class CetusCycle extends WorldstateObject {
86
86
  this.timeLeft = ec.timeLeft;
87
87
 
88
88
  /**
89
- * Whether or not this is for Cetus Cycle
89
+ * Whether this is for Cetus Cycle
90
90
  * @type {boolean}
91
91
  */
92
92
  this.isCetus = true;
@@ -35,6 +35,12 @@ class DailyDeal {
35
35
  */
36
36
  this.item = translator.languageString(data.StoreItem, locale);
37
37
 
38
+ /**
39
+ * The uniqueName for the item on sale.
40
+ * @type {string}
41
+ */
42
+ this.uniqueName = data.StoreItem;
43
+
38
44
  /**
39
45
  * The date and time at which the deal will expire
40
46
  * @type {Date}
@@ -0,0 +1,59 @@
1
+ 'use strict';
2
+
3
+ const WorldstateObject = require('./WorldstateObject');
4
+
5
+ const cycleTime = 36000;
6
+ const stateTime = 7200;
7
+
8
+ const states = ['sorrow', 'fear', 'joy', 'anger', 'envy'];
9
+
10
+ const getStageInfo = () => {
11
+ const cycleDelta = (Math.floor(Date.now() / 1000) - 52) % cycleTime;
12
+ const stateInd = Math.floor(cycleDelta / stateTime);
13
+ const stateDelta = cycleDelta % stateTime;
14
+ const untilNext = stateTime - stateDelta;
15
+ const expiry = new Date(Date.now() + untilNext * 1000);
16
+ const activation = new Date(expiry.getTime() - stateTime * 1000);
17
+ return {
18
+ state: states[stateInd],
19
+ expiry,
20
+ activation,
21
+ };
22
+ };
23
+
24
+ /**
25
+ * @typedef {WorldstateObject} DuviriCycle
26
+ * @extends {WorldstateObject}
27
+ */
28
+ class DuviriCycle extends WorldstateObject {
29
+ constructor({ timeDate, translator }) {
30
+ super({ _id: { $oid: 'duviriCycle0' } }, { timeDate, translator });
31
+ const { activation, expiry, state } = getStageInfo();
32
+
33
+ /**
34
+ * When the cycle start(s/ed)
35
+ * @type {Date}
36
+ */
37
+ this.activation = activation;
38
+ /**
39
+ * When the cycle end(s/ed)
40
+ * @type {Date}
41
+ */
42
+ this.expiry = expiry;
43
+ /**
44
+ * Current stage key
45
+ * @type {string}
46
+ */
47
+ this.state = state;
48
+
49
+ this.id = `duviriCycle${this.state}${this.expiry.getTime()}`;
50
+ }
51
+
52
+ toString() {
53
+ return `${this.translator.toTitleCase(this.state)} spiral. ${this.translator.toTitleCase(
54
+ states[(states.indexOf(this.state) + 1) % 5]
55
+ )} in ${this.timeDate.timeDeltaToString(new Date(this.expiry).getTime() - Date.now())}`;
56
+ }
57
+ }
58
+
59
+ module.exports = DuviriCycle;
@@ -0,0 +1,113 @@
1
+ 'use strict';
2
+
3
+ const rewardTypes = require('../supporting/RewardTypes');
4
+
5
+ /**
6
+ * An object describing a type of reward, including name, description,
7
+ * test function to verify type from a string, thumbnail url, and color
8
+ * @typedef {Object} RewardType
9
+ * @property {string} name - Name of the reward type
10
+ * @property {string} description - Description of the reward type
11
+ * @property {string} test - Function for testing the return type against a string
12
+ * @property {string} thumbnail - Thumbnail url for this reward type
13
+ * @property {string} color - Summary color representing this reward type
14
+ */
15
+
16
+ /**
17
+ * Returns the type of a given item
18
+ * @param {string} item The item whose type needs to be determined
19
+ * @param {Array.<RewardType>} [types] The possible types
20
+ * @returns {string} The type name
21
+ */
22
+ function getItemType(item, types = rewardTypes) {
23
+ return types.find((t) => t.test(item)).name;
24
+ }
25
+
26
+ /**
27
+ * Returns the full type of a given item
28
+ * @param {string} item The item whose type needs to be determined
29
+ * @param {Array.<RewardType>} [types] The possible types
30
+ * @returns {RewardType} The type
31
+ */
32
+ function getItemTypeFull(item, types = rewardTypes) {
33
+ return types.find((t) => t.test(item));
34
+ }
35
+
36
+ /**
37
+ * Represents a mission reward
38
+ */
39
+ class Reward {
40
+ /**
41
+ * @param {Object} data The mission data
42
+ * @param {Object} deps The dependencies object
43
+ * @param {Translator} deps.translator The string translator
44
+ * @param {string} deps.locale Locale to use for translations
45
+ */
46
+ constructor(data, { translator, locale }) {
47
+ /**
48
+ * The items being rewarded
49
+ * @type {Array.<string>}
50
+ */
51
+ this.items = data.items ? data.items.map((i) => translator.languageString(i), locale) : [];
52
+
53
+ /**
54
+ * The counted items being rewarded
55
+ * @type {Array.<Object>}
56
+ */
57
+ this.countedItems = data.countedItems
58
+ ? data.countedItems.map((i) => ({
59
+ count: i.ItemCount,
60
+ type: translator.languageString(i.ItemType, locale),
61
+ key: translator.languageString(i.ItemType),
62
+ }))
63
+ : [];
64
+
65
+ /**
66
+ * The credits being rewarded
67
+ * @type {number}
68
+ */
69
+ this.credits = data.credits || 0;
70
+
71
+ this.asString = this.toString();
72
+
73
+ this.itemString = this.items
74
+ .concat(this.countedItems.map((i) => `${i.count > 1 ? i.count : ''} ${i.type}`.trim()))
75
+ .join(' + ');
76
+
77
+ this.thumbnail = this.getTypesFull()[0] ? this.getTypesFull()[0].thumbnail : 'https://i.imgur.com/JCKyUXJ.png';
78
+
79
+ this.color = this.getTypesFull()[0] ? this.getTypesFull()[0].color : 0xf1c40f;
80
+ }
81
+
82
+ /**
83
+ * The types of all items that are being rewarded
84
+ * @returns {Array.<string>}
85
+ */
86
+ getTypes() {
87
+ return this.items.concat(this.countedItems.map((i) => i.key)).map((t) => getItemType(t));
88
+ }
89
+
90
+ /**
91
+ * The types of all the items that are being rewarded
92
+ * @returns {Array.<RewardType>}
93
+ */
94
+ getTypesFull() {
95
+ return this.items.concat(this.countedItems.map((i) => i.key)).map((t) => getItemTypeFull(t));
96
+ }
97
+
98
+ /**
99
+ * The reward's string representation
100
+ * @returns {string}
101
+ */
102
+ toString() {
103
+ const tokens = this.items.concat(this.countedItems.map((i) => `${i.count > 1 ? i.count : ''} ${i.type}`.trim()));
104
+
105
+ if (this.credits) {
106
+ tokens.push(`${this.credits}cr`);
107
+ }
108
+
109
+ return tokens.join(' + ');
110
+ }
111
+ }
112
+
113
+ module.exports = Reward;
@@ -31,8 +31,9 @@ module.exports = class WorldstateObject {
31
31
  /**
32
32
  * @param {BaseContentObject} data The object data
33
33
  * @param {TimeDateFunctions} timeDate time date functions
34
+ * @param {Translator} translator translation functions
34
35
  */
35
- constructor(data, { timeDate }) {
36
+ constructor(data, { timeDate, translator }) {
36
37
  /**
37
38
  * The object's id field
38
39
  * @type {Identifier.$id|Identifier.$oid}
@@ -48,6 +49,9 @@ module.exports = class WorldstateObject {
48
49
  this.timeDate = timeDate;
49
50
  Object.defineProperty(this, 'timeDate', { enumerable: false, configurable: false });
50
51
 
52
+ this.translator = translator || require('../utilities/translation');
53
+ Object.defineProperty(this, 'translator', { enumerable: false, configurable: false });
54
+
51
55
  if (data.Activation) {
52
56
  /**
53
57
  * The date and time at which the void trader arrives
@@ -0,0 +1,79 @@
1
+ 'use strict';
2
+
3
+ const resources = [
4
+ 'Alloy Plate',
5
+ 'Argon Crystal',
6
+ 'Circuits',
7
+ 'Control Module',
8
+ 'Cryotic',
9
+ 'Ferrite',
10
+ 'Gallium',
11
+ 'Morphics',
12
+ 'Nano Spores',
13
+ 'Neural Sensors',
14
+ 'Neurodes',
15
+ 'Orokin Cell',
16
+ 'Oxium',
17
+ 'Plastids',
18
+ 'Polymer Bundle',
19
+ 'Rubedo',
20
+ 'Salvage',
21
+ 'Tellurium',
22
+ ];
23
+
24
+ // Aura names
25
+ const auras = [
26
+ 'Brief Respite',
27
+ 'Corrosive Projection',
28
+ 'Dead Eye',
29
+ 'EMP Aura',
30
+ 'Empowered Blades',
31
+ 'Enemy Radar',
32
+ 'Energy Siphon',
33
+ 'Growing Power',
34
+ 'Infested Impedance',
35
+ 'Loot Detector',
36
+ 'Physique',
37
+ 'Pistol Amp',
38
+ 'Pistol Scavenger',
39
+ 'Rejuvenation',
40
+ 'Rifle Amp',
41
+ 'Rifle Scavenger',
42
+ 'Shield Disruption',
43
+ 'Shotgun Amp',
44
+ 'Shotgun Scavenger',
45
+ 'Sniper Scavenger',
46
+ 'Speed Holster',
47
+ 'Sprint Boost',
48
+ 'Stand United',
49
+ 'Steel Charge',
50
+ ];
51
+
52
+ // Nightmare mod names
53
+ const nightmare = [
54
+ 'Accelerated Blast',
55
+ 'Animal Instinct',
56
+ 'Armored Agility',
57
+ 'Blaze',
58
+ 'Chilling Reload',
59
+ 'Constitution',
60
+ 'Drifting Contact',
61
+ 'Focus Energy',
62
+ 'Fortitude',
63
+ 'Hammer Shot',
64
+ 'Ice Storm',
65
+ 'Lethal Torrent',
66
+ 'Rending Strike',
67
+ 'Stunning Speed',
68
+ 'Wildfire',
69
+ 'Seeking Fury',
70
+ 'Streamlined Form',
71
+ 'Shred',
72
+ 'Vigor',
73
+ ];
74
+
75
+ module.exports = {
76
+ nightmare,
77
+ auras,
78
+ resources,
79
+ };
@@ -1,94 +1,12 @@
1
1
  'use strict';
2
2
 
3
- // Resource names
4
- const resources = [
5
- 'Alloy Plate',
6
- 'Argon Crystal',
7
- 'Circuits',
8
- 'Control Module',
9
- 'Cryotic',
10
- 'Ferrite',
11
- 'Gallium',
12
- 'Morphics',
13
- 'Nano Spores',
14
- 'Neural Sensors',
15
- 'Neurodes',
16
- 'Orokin Cell',
17
- 'Oxium',
18
- 'Plastids',
19
- 'Polymer Bundle',
20
- 'Rubedo',
21
- 'Salvage',
22
- 'Tellurium',
23
- ];
24
-
25
- // Aura names
26
- const auras = [
27
- 'Brief Respite',
28
- 'Corrosive Projection',
29
- 'Dead Eye',
30
- 'EMP Aura',
31
- 'Empowered Blades',
32
- 'Enemy Radar',
33
- 'Energy Siphon',
34
- 'Growing Power',
35
- 'Infested Impedance',
36
- 'Loot Detector',
37
- 'Physique',
38
- 'Pistol Amp',
39
- 'Pistol Scavenger',
40
- 'Rejuvenation',
41
- 'Rifle Amp',
42
- 'Rifle Scavenger',
43
- 'Shield Disruption',
44
- 'Shotgun Amp',
45
- 'Shotgun Scavenger',
46
- 'Sniper Scavenger',
47
- 'Speed Holster',
48
- 'Sprint Boost',
49
- 'Stand United',
50
- 'Steel Charge',
51
- ];
52
-
53
- // Nightmare mod names
54
- const nightmare = [
55
- 'Accelerated Blast',
56
- 'Animal Instinct',
57
- 'Armored Agility',
58
- 'Blaze',
59
- 'Chilling Reload',
60
- 'Constitution',
61
- 'Drifting Contact',
62
- 'Focus Energy',
63
- 'Fortitude',
64
- 'Hammer Shot',
65
- 'Ice Storm',
66
- 'Lethal Torrent',
67
- 'Rending Strike',
68
- 'Stunning Speed',
69
- 'Wildfire',
70
- 'Seeking Fury',
71
- 'Streamlined Form',
72
- 'Shred',
73
- 'Vigor',
74
- ];
75
-
76
- /**
77
- * An object describing a type of reward, including name, description,
78
- * test function to verify type from a string, thumbnail url, and color
79
- * @typedef {Object} RewardType
80
- * @property {string} name - Name of the reward type
81
- * @property {string} description - Description of the reward type
82
- * @property {string} test - Function for testing the return type against a string
83
- * @property {string} thumbnail - Thumbnail url for this reward type
84
- * @property {string} color - Summary color representing this reward type
85
- */
3
+ const { auras, nightmare, resources } = require('./RewardData');
86
4
 
87
5
  /**
88
6
  * All possible RewardTypes
89
7
  * @type {Array.<RewardType>}
90
8
  */
91
- const rewardTypes = [
9
+ module.exports = [
92
10
  {
93
11
  name: 'vauban',
94
12
  description: 'Vauban parts',
@@ -410,102 +328,3 @@ const rewardTypes = [
410
328
  color: 0x4f545c,
411
329
  },
412
330
  ];
413
-
414
- /**
415
- * Returns the type of a given item
416
- * @param {string} item The item whose type needs to be determined
417
- * @param {Array.<RewardType>} [types] The possible types
418
- * @returns {string} The type name
419
- */
420
- function getItemType(item, types = rewardTypes) {
421
- return types.find((t) => t.test(item)).name;
422
- }
423
-
424
- /**
425
- * Returns the full type of a given item
426
- * @param {string} item The item whose type needs to be determined
427
- * @param {Array.<RewardType>} [types] The possible types
428
- * @returns {RewardType} The type
429
- */
430
- function getItemTypeFull(item, types = rewardTypes) {
431
- return types.find((t) => t.test(item));
432
- }
433
-
434
- /**
435
- * Represents a mission reward
436
- */
437
- class Reward {
438
- /**
439
- * @param {Object} data The mission data
440
- * @param {Object} deps The dependencies object
441
- * @param {Translator} deps.translator The string translator
442
- * @param {string} deps.locale Locale to use for translations
443
- */
444
- constructor(data, { translator, locale }) {
445
- /**
446
- * The items being rewarded
447
- * @type {Array.<string>}
448
- */
449
- this.items = data.items ? data.items.map((i) => translator.languageString(i), locale) : [];
450
-
451
- /**
452
- * The counted items being rewarded
453
- * @type {Array.<Object>}
454
- */
455
- this.countedItems = data.countedItems
456
- ? data.countedItems.map((i) => ({
457
- count: i.ItemCount,
458
- type: translator.languageString(i.ItemType, locale),
459
- key: translator.languageString(i.ItemType),
460
- }))
461
- : [];
462
-
463
- /**
464
- * The credits being rewarded
465
- * @type {number}
466
- */
467
- this.credits = data.credits || 0;
468
-
469
- this.asString = this.toString();
470
-
471
- this.itemString = this.items
472
- .concat(this.countedItems.map((i) => `${i.count > 1 ? i.count : ''} ${i.type}`.trim()))
473
- .join(' + ');
474
-
475
- this.thumbnail = this.getTypesFull()[0] ? this.getTypesFull()[0].thumbnail : 'https://i.imgur.com/JCKyUXJ.png';
476
-
477
- this.color = this.getTypesFull()[0] ? this.getTypesFull()[0].color : 0xf1c40f;
478
- }
479
-
480
- /**
481
- * The types of all items that are being rewarded
482
- * @returns {Array.<string>}
483
- */
484
- getTypes() {
485
- return this.items.concat(this.countedItems.map((i) => i.key)).map((t) => getItemType(t));
486
- }
487
-
488
- /**
489
- * The types of all the items that are being rewarded
490
- * @returns {Array.<RewardType>}
491
- */
492
- getTypesFull() {
493
- return this.items.concat(this.countedItems.map((i) => i.key)).map((t) => getItemTypeFull(t));
494
- }
495
-
496
- /**
497
- * The reward's string representation
498
- * @returns {string}
499
- */
500
- toString() {
501
- const tokens = this.items.concat(this.countedItems.map((i) => `${i.count > 1 ? i.count : ''} ${i.type}`.trim()));
502
-
503
- if (this.credits) {
504
- tokens.push(`${this.credits}cr`);
505
- }
506
-
507
- return tokens.join(' + ');
508
- }
509
- }
510
-
511
- module.exports = Reward;
@@ -204,10 +204,10 @@ function steelPath(dataOverride) {
204
204
 
205
205
  /**
206
206
  * An object containing functions to convert in-game names to their localizations
207
- * @typedef {Object.<function>} Translator
207
+ * @typedef {Record<string, function>} Translator
208
208
  * @property {function} faction - Converts faction names
209
209
  * @property {function} node - Converts star map node names
210
- * @property {function} nodeMissionType - Returns the mission type of a given node
210
+ * @property {function} nodeMissionType - Returns the mission type of given node
211
211
  * @property {function} nodeEnemy - Returns the faction that controls a given node
212
212
  * @property {function} languageString - Converts generic language strings
213
213
  * @property {function} languageDesc - Converts generic language strings
@@ -225,6 +225,7 @@ function steelPath(dataOverride) {
225
225
  * @property {function} region - Converts persistent enemy region indicies
226
226
  * @property {function} conclaveChallenge - Convert conclave identifiers into standing data
227
227
  * @property {function} steelPath - Retrieve Steel Path rotation data for locale
228
+ * @property {function} toTitleCase - Format provided string as titlecase
228
229
  */
229
230
  module.exports = {
230
231
  faction,
@@ -249,4 +250,5 @@ module.exports = {
249
250
  region,
250
251
  conclaveChallenge,
251
252
  steelPath,
253
+ toTitleCase,
252
254
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "warframe-worldstate-parser",
3
- "version": "2.26.2",
3
+ "version": "2.28.0",
4
4
  "description": "An Open parser for Warframe's Worldstate in Javascript",
5
5
  "types": "./types/main.d.ts",
6
6
  "main": "main.js",
@@ -127,28 +127,30 @@ declare class WorldState {
127
127
  * @type {SteelPathOffering}
128
128
  */
129
129
  steelPath: SteelPathOffering;
130
+ duviriCycle: DuviriCycle;
130
131
  }
131
- import News = require("./News");
132
- import WorldEvent = require("./WorldEvent");
133
- import Alert = require("./Alert");
134
- import SyndicateMission = require("./SyndicateMission");
135
- import Fissure = require("./Fissure");
136
- import GlobalUpgrade = require("./GlobalUpgrade");
137
- import FlashSale = require("./FlashSale");
138
- import Invasion = require("./Invasion");
139
- import DarkSector = require("./DarkSector");
140
- import DailyDeal = require("./DailyDeal");
141
- import Simaris = require("./Simaris");
142
- import ConclaveChallenge = require("./ConclaveChallenge");
143
- import PersistentEnemy = require("./PersistentEnemy");
144
- import EarthCycle = require("./EarthCycle");
145
- import CetusCycle = require("./CetusCycle");
146
- import CambionCycle = require("./CambionCycle");
147
- import ZarimanCycle = require("./ZarimanCycle");
148
- import WeeklyChallenge = require("./WeeklyChallenge");
149
- import ConstructionProgress = require("./ConstructionProgress");
150
- import VallisCycle = require("./VallisCycle");
151
- import Nightwave = require("./Nightwave");
152
- import SentientOutpost = require("./SentientOutpost");
153
- import SteelPathOffering = require("./SteelPathOffering");
132
+ import News = require("./models/News");
133
+ import WorldEvent = require("./models/WorldEvent");
134
+ import Alert = require("./models/Alert");
135
+ import SyndicateMission = require("./models/SyndicateMission");
136
+ import Fissure = require("./models/Fissure");
137
+ import GlobalUpgrade = require("./models/GlobalUpgrade");
138
+ import FlashSale = require("./models/FlashSale");
139
+ import Invasion = require("./models/Invasion");
140
+ import DarkSector = require("./models/DarkSector");
141
+ import DailyDeal = require("./models/DailyDeal");
142
+ import Simaris = require("./models/Simaris");
143
+ import ConclaveChallenge = require("./models/ConclaveChallenge");
144
+ import PersistentEnemy = require("./models/PersistentEnemy");
145
+ import EarthCycle = require("./models/EarthCycle");
146
+ import CetusCycle = require("./models/CetusCycle");
147
+ import CambionCycle = require("./models/CambionCycle");
148
+ import ZarimanCycle = require("./models/ZarimanCycle");
149
+ import WeeklyChallenge = require("./models/WeeklyChallenge");
150
+ import ConstructionProgress = require("./models/ConstructionProgress");
151
+ import VallisCycle = require("./models/VallisCycle");
152
+ import Nightwave = require("./models/Nightwave");
153
+ import SentientOutpost = require("./models/SentientOutpost");
154
+ import SteelPathOffering = require("./models/SteelPathOffering");
155
+ import DuviriCycle = require("./models/DuviriCycle");
154
156
  import Dependency = require("./supporting/Dependency");
@@ -27,7 +27,7 @@ declare class CetusCycle extends WorldstateObject {
27
27
  */
28
28
  private bountiesEndDate;
29
29
  /**
30
- * Whether or not this it's daytime
30
+ * Whether it's daytime
31
31
  * @type {boolean}
32
32
  */
33
33
  isDay: boolean;
@@ -42,7 +42,7 @@ declare class CetusCycle extends WorldstateObject {
42
42
  */
43
43
  timeLeft: string;
44
44
  /**
45
- * Whether or not this is for Cetus Cycle
45
+ * Whether this is for Cetus Cycle
46
46
  * @type {boolean}
47
47
  */
48
48
  isCetus: boolean;
@@ -34,6 +34,11 @@ declare class DailyDeal {
34
34
  * @type {string}
35
35
  */
36
36
  item: string;
37
+ /**
38
+ * The uniqueName for the item on sale.
39
+ * @type {string}
40
+ */
41
+ uniqueName: string;
37
42
  /**
38
43
  * The date and time at which the deal will expire
39
44
  * @type {Date}
@@ -0,0 +1,22 @@
1
+ export = DuviriCycle;
2
+ /**
3
+ * @typedef {WorldstateObject} DuviriCycle
4
+ * @extends {WorldstateObject}
5
+ */
6
+ declare class DuviriCycle extends WorldstateObject {
7
+ constructor({ timeDate, translator }: {
8
+ timeDate: any;
9
+ translator: any;
10
+ });
11
+ /**
12
+ * Current stage key
13
+ * @type {string}
14
+ */
15
+ state: string;
16
+ id: string;
17
+ }
18
+ declare namespace DuviriCycle {
19
+ export { DuviriCycle };
20
+ }
21
+ import WorldstateObject = require("./WorldstateObject");
22
+ type DuviriCycle = WorldstateObject;
@@ -36,12 +36,6 @@ declare class NightwaveChallenge extends WorldstateObject {
36
36
  * @type {string}
37
37
  */
38
38
  title: string;
39
- /**
40
- * Generated id from expiry, challenge string,
41
- * and whether or not it has `[PH]` (designating placeholder text)
42
- * @type {string}
43
- */
44
- id: string;
45
39
  /**
46
40
  * Reputation reward for ranking up in the Nightwave
47
41
  * @type {Number}
@@ -24,12 +24,6 @@ declare class SyndicateMission extends WorldstateObject {
24
24
  * @private
25
25
  */
26
26
  private mdConfig;
27
- /**
28
- * The translation functions
29
- * @type {Translator}
30
- * @private
31
- */
32
- private translator;
33
27
  /**
34
28
  * The syndicate that is offering the mission
35
29
  * @type {string}
@@ -50,11 +44,6 @@ declare class SyndicateMission extends WorldstateObject {
50
44
  * @type {Array.<SyndicateJob>}
51
45
  */
52
46
  jobs: Array<SyndicateJob>;
53
- /**
54
- * Unique identifier for this mission set built from the end time and syndicate
55
- * @type {string}
56
- */
57
- id: string;
58
47
  /**
59
48
  * ETA string (at time of object creation)
60
49
  * @type {String}
@@ -3,8 +3,9 @@ declare class WorldstateObject {
3
3
  /**
4
4
  * @param {BaseContentObject} data The object data
5
5
  * @param {TimeDateFunctions} timeDate time date functions
6
+ * @param {Translator} translator translation functions
6
7
  */
7
- constructor(data: BaseContentObject, { timeDate }: TimeDateFunctions);
8
+ constructor(data: BaseContentObject, { timeDate, translator }: TimeDateFunctions);
8
9
  /**
9
10
  * The object's id field
10
11
  * @type {Identifier.$id|Identifier.$oid}
@@ -16,6 +17,7 @@ declare class WorldstateObject {
16
17
  * @private
17
18
  */
18
19
  private timeDate;
20
+ translator: any;
19
21
  /**
20
22
  * The date and time at which the void trader arrives
21
23
  * @type {Date}
@@ -0,0 +1,3 @@
1
+ export const nightmare: string[];
2
+ export const auras: string[];
3
+ export const resources: string[];
@@ -0,0 +1,2 @@
1
+ declare const _exports: Array<RewardType>;
2
+ export = _exports;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * An object containing functions to convert in-game names to their localizations
3
3
  */
4
- export type Translator = any;
4
+ export type Translator = Record<string, Function>;
5
5
  export function faction(key: any, dataOverride: any): any;
6
6
  export function node(key: any, dataOverride: any): any;
7
7
  export function nodeMissionType(key: any, dataOverride: any): any;
@@ -24,3 +24,4 @@ export function sortieFaction(key: any, dataOverride: any): any;
24
24
  export function region(key: any, dataOverride: any): any;
25
25
  export function conclaveChallenge(key: any, dataOverride: any): any;
26
26
  export function steelPath(dataOverride: any): any;
27
+ export function toTitleCase(str: any): any;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes