gw2e-account-statistics 3.12.0 → 3.14.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.
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ exports.__esModule = true;
4
+
5
+ var _aureneLegendaryVariants = require('@gw2efficiency/game-data/skins/categories/aurene-legendary-variants');
6
+
7
+ var _aureneLegendaryVariants2 = _interopRequireDefault(_aureneLegendaryVariants);
8
+
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+
11
+ var aureneLegendaryVariantSkinIds = _aureneLegendaryVariants2.default.map(function (x) {
12
+ return x.id;
13
+ });
14
+
15
+ exports.default = aureneLegendaryVariantSkinIds;
@@ -8,7 +8,8 @@ exports.default = function (accountData) {
8
8
  wvwRank: wvwRank(accountData),
9
9
  playtime: playtime(accountData),
10
10
  playtimePerDay: playtimePerDay(accountData),
11
- _luckFromAccount: luckFromAccount(accountData)
11
+ _luckFromAccount: luckFromAccount(accountData),
12
+ totalStorageSlots: totalStorageSlots(accountData)
12
13
  };
13
14
  };
14
15
 
@@ -82,4 +83,23 @@ function luckFromAccount(accountData) {
82
83
  }
83
84
 
84
85
  return accountData.luck;
86
+ }
87
+
88
+ // Total Storage Slots on the account
89
+ function totalStorageSlots(accountData) {
90
+ if (!accountData.characters || !accountData.bank || !accountData.shared) {
91
+ return null;
92
+ }
93
+
94
+ var totalInventorySlots = accountData.characters.reduce(function (totalInventorySlots, character) {
95
+ return totalInventorySlots + (character.bags || []).filter(Boolean).reduce(function (totalLength, elem) {
96
+ return totalLength + (elem.inventory || []).length;
97
+ }, 0);
98
+ }, 0);
99
+
100
+ var totalBankSlots = accountData.bank.length || 0;
101
+
102
+ var totalSharedSlots = accountData.shared.length || 0;
103
+
104
+ return (totalInventorySlots || 0) + (totalBankSlots || 0) + (totalSharedSlots || 0);
85
105
  }
@@ -34,7 +34,8 @@ exports.default = function (accountData, extraInformation) {
34
34
  nightfury: skinExists(accountData, 6161),
35
35
  _fractalRelicsFromTitles: fractalRelicsFromTitles(accountData),
36
36
  _pristineFractalRelicsFromTitles: pristineFractalRelicsFromTitles(accountData),
37
- _unstableFractalEssenceFromUnlocks: unstableFractalEssenceFromUnlocks(accountData)
37
+ _unstableFractalEssenceFromUnlocks: unstableFractalEssenceFromUnlocks(accountData),
38
+ aureneLegendaryVariantSkins: aureneLegendaryVariantSkins(accountData)
38
39
  };
39
40
  };
40
41
 
@@ -54,6 +55,10 @@ var _abyssalFractalWeapons = require('../static/abyssalFractalWeapons');
54
55
 
55
56
  var _abyssalFractalWeapons2 = _interopRequireDefault(_abyssalFractalWeapons);
56
57
 
58
+ var _aureneLegendaryVariants = require('../gameData/aureneLegendaryVariants');
59
+
60
+ var _aureneLegendaryVariants2 = _interopRequireDefault(_aureneLegendaryVariants);
61
+
57
62
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
58
63
 
59
64
  // The unlocked dyes on the account
@@ -251,7 +256,7 @@ function fractalSkins(accountData) {
251
256
  }).length;
252
257
  }
253
258
 
254
- // The immportal weapon skins unlocked on the account
259
+ // The immortal weapon skins unlocked on the account
255
260
  function immortalSkins(accountData) {
256
261
  if (!accountData.skins) {
257
262
  return null;
@@ -262,6 +267,17 @@ function immortalSkins(accountData) {
262
267
  }).length;
263
268
  }
264
269
 
270
+ // The aurene legendary variant skins unlocked on the account
271
+ function aureneLegendaryVariantSkins(accountData) {
272
+ if (!accountData.skins) {
273
+ return null;
274
+ }
275
+
276
+ return accountData.skins.filter(function (x) {
277
+ return _aureneLegendaryVariants2.default.indexOf(x) !== -1;
278
+ }).length;
279
+ }
280
+
265
281
  // Check if a skin exists on the account
266
282
  function skinExists(accountData, id) {
267
283
  if (!accountData.skins) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gw2e-account-statistics",
3
- "version": "3.12.0",
3
+ "version": "3.14.0",
4
4
  "description": "Calculate statistics of guildwars2 accounts",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {
@@ -19,7 +19,7 @@
19
19
  "mockdate": "^2.0.0"
20
20
  },
21
21
  "dependencies": {
22
- "@gw2efficiency/game-data": "^0.1.19",
22
+ "@gw2efficiency/game-data": "^0.1.38",
23
23
  "array-unique": "^0.3.2",
24
24
  "gw2e-account-value": "^3.13.1",
25
25
  "gw2e-static-data": "^0.5.7",
@@ -38,4 +38,11 @@ describe('statistics > account', () => {
38
38
  expect(accountStatistics({luck: null})._luckFromAccount).to.equal(null)
39
39
  expect(accountStatistics({luck: 120})._luckFromAccount).to.equal(120)
40
40
  })
41
+
42
+ it('can calculate total storage slots', () => {
43
+ expect(accountStatistics({}).totalStorageSlots).to.equal(null)
44
+ expect(accountStatistics({characters: null, bank: null, shared: null}).totalStorageSlots).to.equal(null)
45
+ expect(accountStatistics({characters: [], bank: null, shared: [1, 2]}).totalStorageSlots).to.equal(null)
46
+ expect(accountStatistics({characters: [{bags: [{inventory: [1, 2, 3]}]}], bank: [4, 5, 6], shared: [7, 8]}).totalStorageSlots).to.equal(8)
47
+ })
41
48
  })
@@ -248,4 +248,11 @@ describe('statistics > unlocks', () => {
248
248
  expect(unlocksStatistics({skins: [1, 2], novelties: [1, 2]}, EXTRA_INFO)._unstableFractalEssenceFromUnlocks).to.equal(0)
249
249
  expect(unlocksStatistics({skins: [9607, 9603], novelties: [141]}, EXTRA_INFO)._unstableFractalEssenceFromUnlocks).to.equal(2 * 480 + 450)
250
250
  })
251
+
252
+ it('can calculate aurene legendary variant skin count', () => {
253
+ expect(unlocksStatistics({}, EXTRA_INFO).aureneLegendaryVariantSkins).to.equal(null)
254
+ expect(unlocksStatistics({ skins: [] }, EXTRA_INFO).aureneLegendaryVariantSkins).to.equal(0)
255
+ expect(unlocksStatistics({ skins: [1, 2, 7, 9, 10] }, EXTRA_INFO).aureneLegendaryVariantSkins).to.equal(0)
256
+ expect(unlocksStatistics({ skins: [1, 2, 10515, 10739] }, EXTRA_INFO).aureneLegendaryVariantSkins).to.equal(2)
257
+ })
251
258
  })