gw2e-account-statistics 3.13.0 → 3.14.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.
@@ -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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gw2e-account-statistics",
3
- "version": "3.13.0",
3
+ "version": "3.14.1",
4
4
  "description": "Calculate statistics of guildwars2 accounts",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {
@@ -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
  })
@@ -41,10 +41,17 @@ describe('statistics > aggregate', () => {
41
41
  imperialEverbloom: 1,
42
42
  clockworkInfusion: 1,
43
43
  jotunInfusion: 1,
44
+ wurmsBlessingEnrichment: 1,
45
+ echoOfTheDragonvoid: 1,
46
+ moteOfDarkness: 1,
47
+ possessionInfusion: 1,
48
+ silentSymphony: 1,
49
+ arcaneFlowInfusion: 1,
50
+ mistwalkerInfusion: 1,
44
51
 
45
52
  // (!) Has to be ignored, else it's counting double
46
53
  celestialInfusion: 999
47
- }).totalAuras).to.equal(32)
54
+ }).totalAuras).to.equal(39)
48
55
  })
49
56
 
50
57
  it('can calculate death count per hour', () => {
@@ -150,7 +150,14 @@ describe('statistics > items', () => {
150
150
  jotunInfusion: null,
151
151
  _legendaryDivinationsFromItems: null,
152
152
  marshFrog: null,
153
- miniProfessorMew: null
153
+ miniProfessorMew: null,
154
+ wurmsBlessingEnrichment: null,
155
+ echoOfTheDragonvoid: null,
156
+ moteOfDarkness: null,
157
+ possessionInfusion: null,
158
+ silentSymphony: null,
159
+ arcaneFlowInfusion: null,
160
+ mistwalkerInfusion: null
154
161
  }
155
162
 
156
163
  const bothPermissions = {bank: null, characters: null}