warframe-worldstate-parser 2.32.0 → 3.0.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/README.md +1 -0
- package/lib/WorldState.js +60 -94
- package/lib/models/Alert.js +18 -44
- package/lib/models/CambionCycle.js +8 -12
- package/lib/models/CetusCycle.js +34 -54
- package/lib/models/ChallengeInstance.js +11 -14
- package/lib/models/ConclaveChallenge.js +24 -44
- package/lib/models/ConstructionProgress.js +10 -22
- package/lib/models/DailyDeal.js +15 -34
- package/lib/models/DarkSector.js +14 -25
- package/lib/models/DarkSectorBattle.js +6 -8
- package/lib/models/DuviriCycle.js +9 -10
- package/lib/models/EarthCycle.js +36 -35
- package/lib/models/Fissure.js +36 -44
- package/lib/models/FlashSale.js +17 -37
- package/lib/models/GlobalUpgrade.js +23 -41
- package/lib/models/Invasion.js +37 -79
- package/lib/models/Kuva.js +20 -26
- package/lib/models/Mission.js +28 -38
- package/lib/models/News.js +34 -54
- package/lib/models/Nightwave.js +22 -48
- package/lib/models/NightwaveChallenge.js +15 -19
- package/lib/models/PersistentEnemy.js +21 -30
- package/lib/models/Reward.js +18 -20
- package/lib/models/SentientOutpost.js +11 -12
- package/lib/models/Simaris.js +9 -21
- package/lib/models/Sortie.js +36 -54
- package/lib/models/SortieVariant.js +23 -25
- package/lib/models/SteelPathOffering.js +26 -9
- package/lib/models/SyndicateJob.js +20 -30
- package/lib/models/SyndicateMission.js +22 -52
- package/lib/models/VallisCycle.js +37 -45
- package/lib/models/VoidTrader.js +35 -54
- package/lib/models/VoidTraderItem.js +5 -8
- package/lib/models/VoidTraderSchedule.js +7 -6
- package/lib/models/WeeklyChallenge.js +9 -17
- package/lib/models/WorldEvent.js +49 -74
- package/lib/models/WorldstateObject.js +23 -34
- package/lib/models/ZarimanCycle.js +34 -54
- package/lib/supporting/Dependency.js +2 -11
- package/lib/supporting/DuviriChoice.js +1 -5
- package/lib/supporting/ExternalMission.js +2 -6
- package/lib/supporting/MarkdownSettings.js +15 -19
- package/lib/supporting/RewardData.js +4 -6
- package/lib/supporting/RewardTypes.js +2 -4
- package/lib/utilities/integrity.js +11 -0
- package/lib/utilities/timeDate.js +16 -18
- package/lib/utilities/translation.js +188 -56
- package/main.js +2 -2
- package/package.json +4 -6
- package/types/lib/WorldState.d.ts +39 -28
- package/types/lib/models/Alert.d.ts +13 -24
- package/types/lib/models/CambionCycle.d.ts +5 -10
- package/types/lib/models/CetusCycle.d.ts +8 -26
- package/types/lib/models/ChallengeInstance.d.ts +7 -9
- package/types/lib/models/ConclaveChallenge.d.ts +11 -24
- package/types/lib/models/ConstructionProgress.d.ts +5 -16
- package/types/lib/models/DailyDeal.d.ts +7 -26
- package/types/lib/models/DarkSector.d.ts +11 -22
- package/types/lib/models/DarkSectorBattle.d.ts +3 -6
- package/types/lib/models/DuviriCycle.d.ts +5 -11
- package/types/lib/models/EarthCycle.d.ts +40 -17
- package/types/lib/models/Fissure.d.ts +10 -17
- package/types/lib/models/FlashSale.d.ts +8 -29
- package/types/lib/models/GlobalUpgrade.d.ts +8 -27
- package/types/lib/models/Invasion.d.ts +18 -53
- package/types/lib/models/Kuva.d.ts +10 -21
- package/types/lib/models/Mission.d.ts +11 -23
- package/types/lib/models/News.d.ts +18 -31
- package/types/lib/models/Nightwave.d.ts +12 -29
- package/types/lib/models/NightwaveChallenge.d.ts +10 -15
- package/types/lib/models/PersistentEnemy.d.ts +9 -20
- package/types/lib/models/Reward.d.ts +34 -18
- package/types/lib/models/SentientOutpost.d.ts +9 -13
- package/types/lib/models/Simaris.d.ts +6 -17
- package/types/lib/models/Sortie.d.ts +16 -25
- package/types/lib/models/SortieVariant.d.ts +13 -15
- package/types/lib/models/SteelPathOffering.d.ts +5 -8
- package/types/lib/models/SyndicateJob.d.ts +13 -14
- package/types/lib/models/SyndicateMission.d.ts +9 -22
- package/types/lib/models/VallisCycle.d.ts +28 -18
- package/types/lib/models/VoidTrader.d.ts +8 -21
- package/types/lib/models/VoidTraderItem.d.ts +4 -6
- package/types/lib/models/VoidTraderSchedule.d.ts +5 -8
- package/types/lib/models/WeeklyChallenge.d.ts +5 -14
- package/types/lib/models/WorldEvent.d.ts +38 -52
- package/types/lib/models/WorldstateObject.d.ts +46 -24
- package/types/lib/models/ZarimanCycle.d.ts +9 -27
- package/types/lib/supporting/Dependency.d.ts +2 -8
- package/types/lib/supporting/DuviriChoice.d.ts +1 -2
- package/types/lib/supporting/ExternalMission.d.ts +3 -7
- package/types/lib/supporting/MarkdownSettings.d.ts +29 -15
- package/types/lib/supporting/RewardData.d.ts +8 -2
- package/types/lib/supporting/RewardTypes.d.ts +2 -2
- package/types/lib/utilities/integrity.d.ts +1 -0
- package/types/lib/utilities/timeDate.d.ts +19 -12
- package/types/lib/utilities/translation.d.ts +188 -23
- package/types/main.d.ts +2 -4
|
@@ -1,40 +1,33 @@
|
|
|
1
|
-
|
|
1
|
+
import { languageString, node, region } from '../utilities/translation.js';
|
|
2
|
+
import { parseDate } from '../utilities/timeDate.js';
|
|
3
|
+
import mdConfig from '../supporting/MarkdownSettings.js';
|
|
4
|
+
|
|
5
|
+
import WorldstateObject from './WorldstateObject.js';
|
|
2
6
|
|
|
3
|
-
const WorldstateObject = require('./WorldstateObject');
|
|
4
7
|
/**
|
|
5
8
|
* Represents a persistent enemy
|
|
6
|
-
* @
|
|
9
|
+
* @augments {WorldstateObject}
|
|
7
10
|
*/
|
|
8
|
-
class PersistentEnemy extends WorldstateObject {
|
|
11
|
+
export default class PersistentEnemy extends WorldstateObject {
|
|
9
12
|
/**
|
|
10
|
-
* @param {
|
|
11
|
-
* @param {
|
|
12
|
-
* @param {MarkdownSettings} deps.mdConfig The markdown settings
|
|
13
|
-
* @param {Translator} deps.translator The string translator
|
|
13
|
+
* @param {object} data The persistent enemy data
|
|
14
|
+
* @param {object} deps The dependencies object
|
|
14
15
|
* @param {string} deps.locale Locale to use for translations
|
|
15
16
|
*/
|
|
16
|
-
constructor(data, {
|
|
17
|
-
super(data
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* The markdown settings
|
|
21
|
-
* @type {MarkdownSettings}
|
|
22
|
-
* @private
|
|
23
|
-
*/
|
|
24
|
-
this.mdConfig = mdConfig;
|
|
25
|
-
Object.defineProperty(this, 'mdConfig', { enumerable: false, configurable: false });
|
|
17
|
+
constructor(data, { locale = 'en' } = { locale: 'en' }) {
|
|
18
|
+
super(data);
|
|
26
19
|
|
|
27
20
|
/**
|
|
28
21
|
* The enemy's type
|
|
29
22
|
* @type {string}
|
|
30
23
|
*/
|
|
31
|
-
this.agentType =
|
|
24
|
+
this.agentType = languageString(data.AgentType, locale);
|
|
32
25
|
|
|
33
26
|
/**
|
|
34
27
|
* The location tag
|
|
35
28
|
* @type {string}
|
|
36
29
|
*/
|
|
37
|
-
this.locationTag =
|
|
30
|
+
this.locationTag = languageString(data.LocTag, locale);
|
|
38
31
|
|
|
39
32
|
/**
|
|
40
33
|
* The enemy's rank
|
|
@@ -43,7 +36,7 @@ class PersistentEnemy extends WorldstateObject {
|
|
|
43
36
|
this.rank = data.Rank;
|
|
44
37
|
|
|
45
38
|
/**
|
|
46
|
-
* The enemy's
|
|
39
|
+
* The enemy's remaining health percentage
|
|
47
40
|
* @type {number}
|
|
48
41
|
*/
|
|
49
42
|
this.healthPercent = Number.parseFloat(data.HealthPercent);
|
|
@@ -58,29 +51,29 @@ class PersistentEnemy extends WorldstateObject {
|
|
|
58
51
|
* The region where the enemy is located
|
|
59
52
|
* @type {string}
|
|
60
53
|
*/
|
|
61
|
-
this.region =
|
|
54
|
+
this.region = region(data.Region, locale);
|
|
62
55
|
|
|
63
56
|
/**
|
|
64
57
|
* The last time the enemy was discovered
|
|
65
58
|
* @type {Date}
|
|
66
59
|
*/
|
|
67
|
-
this.lastDiscoveredTime =
|
|
60
|
+
this.lastDiscoveredTime = parseDate(data.LastDiscoveredTime);
|
|
68
61
|
|
|
69
62
|
/**
|
|
70
63
|
* The node at which the enemy was last discovered
|
|
71
64
|
* @type {string}
|
|
72
65
|
*/
|
|
73
|
-
this.lastDiscoveredAt =
|
|
66
|
+
this.lastDiscoveredAt = node(data.LastDiscoveredLocation, locale);
|
|
74
67
|
|
|
75
68
|
/**
|
|
76
69
|
* Whether or not the enemy is currently available
|
|
77
|
-
* @type {
|
|
70
|
+
* @type {boolean}
|
|
78
71
|
*/
|
|
79
72
|
this.isDiscovered = data.Discovered;
|
|
80
73
|
|
|
81
74
|
/**
|
|
82
75
|
* Whether or not the enemy is using ticketing
|
|
83
|
-
* @type {
|
|
76
|
+
* @type {boolean}
|
|
84
77
|
*/
|
|
85
78
|
this.isUsingTicketing = data.UseTicketing;
|
|
86
79
|
|
|
@@ -93,7 +86,7 @@ class PersistentEnemy extends WorldstateObject {
|
|
|
93
86
|
|
|
94
87
|
/**
|
|
95
88
|
* Returns a string representation of the persistent enemy
|
|
96
|
-
* @returns {string}
|
|
89
|
+
* @returns {string} string representation
|
|
97
90
|
*/
|
|
98
91
|
toString() {
|
|
99
92
|
const status = this.isDiscovered ? 'discovered' : 'not discovered';
|
|
@@ -102,8 +95,6 @@ class PersistentEnemy extends WorldstateObject {
|
|
|
102
95
|
`It has ${this.healthPercent}% health remaining and is currently ${status}`,
|
|
103
96
|
];
|
|
104
97
|
|
|
105
|
-
return lines.join(
|
|
98
|
+
return lines.join(mdConfig.lineEnd);
|
|
106
99
|
}
|
|
107
100
|
}
|
|
108
|
-
|
|
109
|
-
module.exports = PersistentEnemy;
|
package/lib/models/Reward.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import rewardTypes from '../supporting/RewardTypes.js';
|
|
2
|
+
import { languageString } from '../utilities/translation.js';
|
|
3
|
+
import { insist } from '../utilities/integrity.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* An object describing a type of reward, including name, description,
|
|
7
7
|
* test function to verify type from a string, thumbnail url, and color
|
|
8
|
-
* @typedef {
|
|
8
|
+
* @typedef {object} RewardType
|
|
9
9
|
* @property {string} name - Name of the reward type
|
|
10
10
|
* @property {string} description - Description of the reward type
|
|
11
11
|
* @property {string} test - Function for testing the return type against a string
|
|
@@ -19,7 +19,7 @@ const rewardTypes = require('../supporting/RewardTypes');
|
|
|
19
19
|
* @param {Array.<RewardType>} [types] The possible types
|
|
20
20
|
* @returns {string} The type name
|
|
21
21
|
*/
|
|
22
|
-
function getItemType(item, types = rewardTypes) {
|
|
22
|
+
export function getItemType(item, types = rewardTypes) {
|
|
23
23
|
return types.find((t) => t.test(item)).name;
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -29,36 +29,36 @@ function getItemType(item, types = rewardTypes) {
|
|
|
29
29
|
* @param {Array.<RewardType>} [types] The possible types
|
|
30
30
|
* @returns {RewardType} The type
|
|
31
31
|
*/
|
|
32
|
-
function getItemTypeFull(item, types = rewardTypes) {
|
|
32
|
+
export function getItemTypeFull(item, types = rewardTypes) {
|
|
33
33
|
return types.find((t) => t.test(item));
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* Represents a mission reward
|
|
38
38
|
*/
|
|
39
|
-
class Reward {
|
|
39
|
+
export default class Reward {
|
|
40
40
|
/**
|
|
41
|
-
* @param {
|
|
42
|
-
* @param {
|
|
43
|
-
* @param {Translator} deps.translator The string translator
|
|
41
|
+
* @param {object} data The mission data
|
|
42
|
+
* @param {Dependency} deps The dependencies object
|
|
44
43
|
* @param {string} deps.locale Locale to use for translations
|
|
45
44
|
*/
|
|
46
|
-
constructor(data, {
|
|
45
|
+
constructor(data, { locale = 'en' } = { locale: 'en' }) {
|
|
46
|
+
insist(data);
|
|
47
47
|
/**
|
|
48
48
|
* The items being rewarded
|
|
49
49
|
* @type {Array.<string>}
|
|
50
50
|
*/
|
|
51
|
-
this.items = data.items ? data.items.map((i) =>
|
|
51
|
+
this.items = data.items ? data.items.map((i) => languageString(i), locale) : [];
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
54
|
* The counted items being rewarded
|
|
55
|
-
* @type {Array.<
|
|
55
|
+
* @type {Array.<object>}
|
|
56
56
|
*/
|
|
57
57
|
this.countedItems = data.countedItems
|
|
58
58
|
? data.countedItems.map((i) => ({
|
|
59
59
|
count: i.ItemCount,
|
|
60
|
-
type:
|
|
61
|
-
key:
|
|
60
|
+
type: languageString(i.ItemType, locale),
|
|
61
|
+
key: languageString(i.ItemType),
|
|
62
62
|
}))
|
|
63
63
|
: [];
|
|
64
64
|
|
|
@@ -81,7 +81,7 @@ class Reward {
|
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
83
|
* The types of all items that are being rewarded
|
|
84
|
-
* @returns {Array.<string>}
|
|
84
|
+
* @returns {Array.<string>} types as array of string
|
|
85
85
|
*/
|
|
86
86
|
getTypes() {
|
|
87
87
|
return this.items.concat(this.countedItems.map((i) => i.key)).map((t) => getItemType(t));
|
|
@@ -89,7 +89,7 @@ class Reward {
|
|
|
89
89
|
|
|
90
90
|
/**
|
|
91
91
|
* The types of all the items that are being rewarded
|
|
92
|
-
* @returns {Array.<RewardType>}
|
|
92
|
+
* @returns {Array.<RewardType>} array of reward types
|
|
93
93
|
*/
|
|
94
94
|
getTypesFull() {
|
|
95
95
|
return this.items.concat(this.countedItems.map((i) => i.key)).map((t) => getItemTypeFull(t));
|
|
@@ -97,7 +97,7 @@ class Reward {
|
|
|
97
97
|
|
|
98
98
|
/**
|
|
99
99
|
* The reward's string representation
|
|
100
|
-
* @returns {string}
|
|
100
|
+
* @returns {string} reward's string representation
|
|
101
101
|
*/
|
|
102
102
|
toString() {
|
|
103
103
|
const tokens = this.items.concat(this.countedItems.map((i) => `${i.count > 1 ? i.count : ''} ${i.type}`.trim()));
|
|
@@ -109,5 +109,3 @@ class Reward {
|
|
|
109
109
|
return tokens.join(' + ');
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
|
|
113
|
-
module.exports = Reward;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { node, nodeEnemy, nodeMissionType } from '../utilities/translation.js';
|
|
2
2
|
|
|
3
3
|
const duration = 1800;
|
|
4
4
|
|
|
@@ -20,7 +20,7 @@ const sat = () => {
|
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* Mission typeDef
|
|
23
|
-
* @typedef {
|
|
23
|
+
* @typedef {object} Mission
|
|
24
24
|
* @property {string} node Mission node name
|
|
25
25
|
* @property {string} enemy Node enemy
|
|
26
26
|
* @property {string} type Mission type of the node
|
|
@@ -34,29 +34,30 @@ const sat = () => {
|
|
|
34
34
|
* @property {boolean} active Whether or not the mission is active
|
|
35
35
|
* @property {Date} activation When the mission became or becomes active
|
|
36
36
|
* @property {Date} expiry When the mission became or becomes inactive
|
|
37
|
-
* @property {
|
|
37
|
+
* @property {object} previous Estimation data for the last mission that was active.
|
|
38
38
|
* Could also be the current.
|
|
39
39
|
* @property {Date} previous.activation When the mission became or becomes active
|
|
40
40
|
* @property {Date} previous.expiry When the mission became or becomes inactive
|
|
41
41
|
*/
|
|
42
|
-
class SentientOutpost {
|
|
43
|
-
|
|
42
|
+
export default class SentientOutpost {
|
|
43
|
+
#node;
|
|
44
|
+
constructor(data, { locale, sentientData, logger }) {
|
|
44
45
|
// eslint-disable-next-line no-param-reassign
|
|
45
46
|
if (!data) data = '{"sfn":000}';
|
|
46
|
-
|
|
47
|
+
[this.#node] = data.match(/\d{3}/g) || ['000'];
|
|
47
48
|
const id = `CrewBattleNode${node}`;
|
|
48
49
|
/* istanbul ignore if */
|
|
49
50
|
if (node === '000') {
|
|
50
51
|
this.mission = undefined;
|
|
51
52
|
} else {
|
|
52
53
|
this.mission = {
|
|
53
|
-
node:
|
|
54
|
-
faction:
|
|
55
|
-
type:
|
|
54
|
+
node: node(id, locale),
|
|
55
|
+
faction: nodeEnemy(id, locale),
|
|
56
|
+
type: nodeMissionType(id, locale),
|
|
56
57
|
};
|
|
57
58
|
}
|
|
58
59
|
({ activation: this.activation, expiry: this.expiry } = sat());
|
|
59
|
-
this.active =
|
|
60
|
+
this.active = Boolean(this.mission);
|
|
60
61
|
this.id = `${id}:${this.active}`;
|
|
61
62
|
|
|
62
63
|
if (!sentientData) {
|
|
@@ -67,5 +68,3 @@ class SentientOutpost {
|
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
70
|
}
|
|
70
|
-
|
|
71
|
-
module.exports = SentientOutpost;
|
package/lib/models/Simaris.js
CHANGED
|
@@ -1,39 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
import { languageString } from '../utilities/translation.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Contains information about sanctuary targets
|
|
5
5
|
*/
|
|
6
|
-
class Simaris {
|
|
6
|
+
export default class Simaris {
|
|
7
7
|
/**
|
|
8
|
-
* @param {
|
|
9
|
-
* @param {
|
|
10
|
-
* @param {MarkdownSettings} deps.mdConfig The markdown settings
|
|
11
|
-
* @param {Translator} deps.translator The string translator
|
|
8
|
+
* @param {object} data The sanctuary data
|
|
9
|
+
* @param {object} deps The dependencies object
|
|
12
10
|
* @param {string} deps.locale Locale to use for translations
|
|
13
11
|
*/
|
|
14
|
-
constructor(data, {
|
|
15
|
-
if (!data) {
|
|
12
|
+
constructor(data, { locale = 'en' } = { locale: 'en' }) {
|
|
13
|
+
if (!data || !Object.keys(data).length) {
|
|
16
14
|
// eslint-disable-next-line no-param-reassign
|
|
17
15
|
data = {};
|
|
18
16
|
}
|
|
19
17
|
|
|
20
|
-
/**
|
|
21
|
-
* The markdown settings
|
|
22
|
-
* @type {MarkdownSettings}
|
|
23
|
-
* @private
|
|
24
|
-
*/
|
|
25
|
-
this.mdConfig = mdConfig;
|
|
26
|
-
Object.defineProperty(this, 'mdConfig', { enumerable: false, configurable: false });
|
|
27
|
-
|
|
28
18
|
/**
|
|
29
19
|
* The sanctuary target
|
|
30
20
|
* @type {string}
|
|
31
21
|
*/
|
|
32
|
-
this.target =
|
|
22
|
+
this.target = languageString(data.LastCompletedTargetType, locale) || 'N/A';
|
|
33
23
|
|
|
34
24
|
/**
|
|
35
25
|
* Whether or not the target is currently active
|
|
36
|
-
* @type {
|
|
26
|
+
* @type {boolean}
|
|
37
27
|
*/
|
|
38
28
|
this.isTargetActive = !data.LastCompletedTargetType;
|
|
39
29
|
|
|
@@ -46,7 +36,7 @@ class Simaris {
|
|
|
46
36
|
|
|
47
37
|
/**
|
|
48
38
|
* Returns a string representation of the current sanctuary status
|
|
49
|
-
* @returns {string}
|
|
39
|
+
* @returns {string} a string representation of the current sanctuary status
|
|
50
40
|
*/
|
|
51
41
|
toString() {
|
|
52
42
|
return (
|
|
@@ -55,5 +45,3 @@ class Simaris {
|
|
|
55
45
|
);
|
|
56
46
|
}
|
|
57
47
|
}
|
|
58
|
-
|
|
59
|
-
module.exports = Simaris;
|
package/lib/models/Sortie.js
CHANGED
|
@@ -1,93 +1,77 @@
|
|
|
1
|
-
|
|
1
|
+
import wsData from 'warframe-worldstate-data';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import mdConfig from '../supporting/MarkdownSettings.js';
|
|
4
|
+
import { fromNow, parseDate, timeDeltaToString } from '../utilities/timeDate.js';
|
|
5
|
+
import { languageString, sortieBoss, sortieFaction } from '../utilities/translation.js';
|
|
6
|
+
|
|
7
|
+
import WorldstateObject from './WorldstateObject.js';
|
|
8
|
+
import SortieVariant from './SortieVariant.js';
|
|
9
|
+
import Mission from './Mission.js';
|
|
10
|
+
|
|
11
|
+
const { sortie: sortieData } = wsData;
|
|
4
12
|
|
|
5
13
|
/**
|
|
6
14
|
* Represents a daily sortie
|
|
7
|
-
* @
|
|
15
|
+
* @augments {WorldstateObject}
|
|
8
16
|
*/
|
|
9
|
-
class Sortie extends WorldstateObject {
|
|
17
|
+
export default class Sortie extends WorldstateObject {
|
|
10
18
|
/**
|
|
11
|
-
* @param {
|
|
12
|
-
* @param {
|
|
13
|
-
* @param
|
|
14
|
-
* @param {Translator} translator The string translator
|
|
15
|
-
* @param {TimeDateFunctions} timeDate The time and date functions
|
|
16
|
-
* @param {Object} sortieData The data used to parse sorties
|
|
17
|
-
* @param {SortieVariant} SortieVariant The sortie variant parser
|
|
18
|
-
* @param {string} locale Locale to use for translations
|
|
19
|
+
* @param {object} data The data for all daily sorties
|
|
20
|
+
* @param {object} deps The dependencies object
|
|
21
|
+
* @param {string} deps.locale Locale to use for translations
|
|
19
22
|
*/
|
|
20
|
-
constructor(data, {
|
|
21
|
-
super(data
|
|
23
|
+
constructor(data, { locale = 'en' } = { locale: 'en' }) {
|
|
24
|
+
super(data);
|
|
22
25
|
|
|
23
26
|
const opts = {
|
|
24
27
|
mdConfig,
|
|
25
|
-
translator,
|
|
26
|
-
timeDate,
|
|
27
28
|
sortieData,
|
|
28
|
-
SortieVariant,
|
|
29
29
|
locale,
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
/**
|
|
33
|
-
* The markdown settings
|
|
34
|
-
* @type {MarkdownSettings}
|
|
35
|
-
* @private
|
|
36
|
-
*/
|
|
37
|
-
this.mdConfig = mdConfig;
|
|
38
|
-
Object.defineProperty(this, 'mdConfig', { enumerable: false, configurable: false });
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* The time and date functions
|
|
42
|
-
* @type {TimeDateFunctions}
|
|
43
|
-
* @private
|
|
44
|
-
*/
|
|
45
|
-
this.timeDate = timeDate;
|
|
46
|
-
Object.defineProperty(this, 'timeDate', { enumerable: false, configurable: false });
|
|
47
|
-
|
|
48
32
|
/**
|
|
49
33
|
* The date and time at which the sortie starts
|
|
50
34
|
* @type {Date}
|
|
51
35
|
*/
|
|
52
|
-
this.activation =
|
|
36
|
+
this.activation = parseDate(data.Activation);
|
|
53
37
|
|
|
54
38
|
/**
|
|
55
39
|
* The date and time at which the sortie ends
|
|
56
40
|
* @type {Date}
|
|
57
41
|
*/
|
|
58
|
-
this.expiry =
|
|
42
|
+
this.expiry = parseDate(data.Expiry);
|
|
59
43
|
|
|
60
44
|
/**
|
|
61
45
|
* The sortie's reward pool
|
|
62
46
|
* @type {string}
|
|
63
47
|
*/
|
|
64
|
-
this.rewardPool =
|
|
48
|
+
this.rewardPool = languageString(data.Reward, locale);
|
|
65
49
|
|
|
66
50
|
/**
|
|
67
51
|
* The sortie's variants
|
|
68
52
|
* @type {Array.<SortieVariant>}
|
|
69
53
|
*/
|
|
70
|
-
this.variants = (data.Variants
|
|
54
|
+
this.variants = (data.Variants ?? []).map((v) => new SortieVariant(v, opts));
|
|
71
55
|
|
|
72
|
-
this.missions = (data.Missions
|
|
56
|
+
this.missions = (data.Missions ?? []).map((v) => new Mission(v, opts));
|
|
73
57
|
|
|
74
58
|
/**
|
|
75
59
|
* The sortie's boss
|
|
76
60
|
* @type {string}
|
|
77
61
|
*/
|
|
78
|
-
this.boss =
|
|
62
|
+
this.boss = sortieBoss(data.Boss, locale);
|
|
79
63
|
|
|
80
64
|
/**
|
|
81
65
|
* The sortie's faction
|
|
82
66
|
* @type {string}
|
|
83
67
|
*/
|
|
84
|
-
this.faction =
|
|
68
|
+
this.faction = sortieFaction(data.Boss, locale);
|
|
85
69
|
|
|
86
70
|
/**
|
|
87
71
|
* The sortie's faction
|
|
88
72
|
* @type {string}
|
|
89
73
|
*/
|
|
90
|
-
this.factionKey =
|
|
74
|
+
this.factionKey = sortieFaction(data.Boss, 'en');
|
|
91
75
|
|
|
92
76
|
/**
|
|
93
77
|
* Whether this is expired (at time of object creation)
|
|
@@ -97,14 +81,14 @@ class Sortie extends WorldstateObject {
|
|
|
97
81
|
|
|
98
82
|
/**
|
|
99
83
|
* ETA string (at time of object creation)
|
|
100
|
-
* @type {
|
|
84
|
+
* @type {string}
|
|
101
85
|
*/
|
|
102
86
|
this.eta = this.getETAString();
|
|
103
87
|
}
|
|
104
88
|
|
|
105
89
|
/**
|
|
106
90
|
* Get the sortie's boss
|
|
107
|
-
* @returns {string}
|
|
91
|
+
* @returns {string} the sortie's boss
|
|
108
92
|
*/
|
|
109
93
|
getBoss() {
|
|
110
94
|
return this.boss;
|
|
@@ -112,7 +96,7 @@ class Sortie extends WorldstateObject {
|
|
|
112
96
|
|
|
113
97
|
/**
|
|
114
98
|
* Get the sortie's faction
|
|
115
|
-
* @returns {string}
|
|
99
|
+
* @returns {string} the sortie's faction
|
|
116
100
|
*/
|
|
117
101
|
getFaction() {
|
|
118
102
|
return this.faction;
|
|
@@ -120,36 +104,34 @@ class Sortie extends WorldstateObject {
|
|
|
120
104
|
|
|
121
105
|
/**
|
|
122
106
|
* Gets a string indicating how long it will take for the sortie to end
|
|
123
|
-
* @returns {string}
|
|
107
|
+
* @returns {string} estimated time of arrival
|
|
124
108
|
*/
|
|
125
109
|
getETAString() {
|
|
126
|
-
return
|
|
110
|
+
return timeDeltaToString(fromNow(this.expiry));
|
|
127
111
|
}
|
|
128
112
|
|
|
129
113
|
/**
|
|
130
114
|
* Get whether or not the sortie has expired
|
|
131
|
-
* @returns {boolean}
|
|
115
|
+
* @returns {boolean} whether the sortie has expired
|
|
132
116
|
*/
|
|
133
117
|
isExpired() {
|
|
134
|
-
return
|
|
118
|
+
return fromNow(this.expiry) < 0;
|
|
135
119
|
}
|
|
136
120
|
|
|
137
121
|
/**
|
|
138
122
|
* Returns the sortie's string representation
|
|
139
|
-
* @returns {string}
|
|
123
|
+
* @returns {string} the string representation
|
|
140
124
|
*/
|
|
141
125
|
toString() {
|
|
142
126
|
if (this.isExpired()) {
|
|
143
|
-
return `${
|
|
127
|
+
return `${mdConfig.codeBlock}There's currently no sortie${mdConfig.blockEnd}`;
|
|
144
128
|
}
|
|
145
129
|
|
|
146
130
|
const variantString = this.variants.map((v) => v.toString()).join('');
|
|
147
131
|
|
|
148
132
|
return (
|
|
149
|
-
`${
|
|
150
|
-
`${
|
|
133
|
+
`${mdConfig.codeBlock}${this.getBoss()}: ends in ${this.getETAString()}` +
|
|
134
|
+
`${mdConfig.doubleReturn}${variantString}${mdConfig.blockEnd}`
|
|
151
135
|
);
|
|
152
136
|
}
|
|
153
137
|
}
|
|
154
|
-
|
|
155
|
-
module.exports = Sortie;
|
|
@@ -1,59 +1,57 @@
|
|
|
1
|
-
|
|
1
|
+
import { missionType, node, sortieModDesc, sortieModifier } from '../utilities/translation.js';
|
|
2
|
+
import mdConfig from '../supporting/MarkdownSettings.js';
|
|
3
|
+
import { insist } from '../utilities/integrity.js';
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* Represents a sortie variant
|
|
7
|
+
* @class
|
|
5
8
|
*/
|
|
6
|
-
class SortieVariant {
|
|
9
|
+
export default class SortieVariant {
|
|
7
10
|
/**
|
|
8
|
-
*
|
|
9
|
-
* @
|
|
10
|
-
* @param
|
|
11
|
-
* @param
|
|
12
|
-
* @param
|
|
11
|
+
* Make the SortieVariant
|
|
12
|
+
* @class
|
|
13
|
+
* @param {object} data Sortie variant data
|
|
14
|
+
* @param {object} deps Dependencies
|
|
15
|
+
* @param {string} deps.locale Locale to use for translations
|
|
13
16
|
*/
|
|
14
|
-
constructor(data, {
|
|
15
|
-
|
|
16
|
-
* The markdown settings
|
|
17
|
-
* @type {MarkdownSettings}
|
|
18
|
-
* @private
|
|
19
|
-
*/
|
|
20
|
-
this.mdConfig = mdConfig;
|
|
21
|
-
Object.defineProperty(this, 'mdConfig', { enumerable: false, configurable: false });
|
|
22
|
-
|
|
17
|
+
constructor(data, { locale = 'en' } = { locale: 'en' }) {
|
|
18
|
+
insist(data);
|
|
23
19
|
/**
|
|
24
20
|
* The variant's mission type
|
|
25
21
|
* @type {string}
|
|
26
22
|
*/
|
|
27
|
-
this.missionType =
|
|
23
|
+
this.missionType = missionType(data.missionType, locale);
|
|
24
|
+
|
|
25
|
+
this.missionTypeKey = missionType(data.missionType, 'en');
|
|
28
26
|
|
|
29
27
|
/**
|
|
30
28
|
* The variant's modifier
|
|
31
29
|
* @type {string}
|
|
32
30
|
*/
|
|
33
|
-
this.modifier =
|
|
31
|
+
this.modifier = sortieModifier(data.modifierType, locale);
|
|
34
32
|
|
|
35
33
|
/**
|
|
36
34
|
* The variant's modifier description
|
|
37
35
|
* @type {string}
|
|
38
36
|
*/
|
|
39
|
-
this.modifierDescription =
|
|
37
|
+
this.modifierDescription = sortieModDesc(data.modifierType, locale);
|
|
40
38
|
|
|
41
39
|
/**
|
|
42
40
|
* The node where the variant takes place
|
|
43
41
|
* @type {string}
|
|
44
42
|
*/
|
|
45
|
-
this.node =
|
|
43
|
+
this.node = node(data.node, locale);
|
|
44
|
+
|
|
45
|
+
this.nodeKey = node(data.node, 'en');
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
49
|
* Returns a string representation of the sortie variant
|
|
50
|
-
* @returns {string}
|
|
50
|
+
* @returns {string} string representation
|
|
51
51
|
*/
|
|
52
52
|
toString() {
|
|
53
53
|
return this.modifier
|
|
54
|
-
? `${this.node.padEnd(25, ' ')} | ${this.modifier.padEnd(20, ' ')} | ${this.missionType}${
|
|
55
|
-
: `${this.node.padEnd(25, ' ')} | ${this.missionType}${
|
|
54
|
+
? `${this.node.padEnd(25, ' ')} | ${this.modifier.padEnd(20, ' ')} | ${this.missionType}${mdConfig.lineEnd}`
|
|
55
|
+
: `${this.node.padEnd(25, ' ')} | ${this.missionType}${mdConfig.lineEnd}`;
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
|
|
59
|
-
module.exports = SortieVariant;
|