gw2e-account-statistics 3.18.1 → 3.19.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.
@@ -34,15 +34,15 @@ function guildCount(accountData) {
34
34
 
35
35
  // The wvw rank
36
36
  function wvwRank(accountData) {
37
- if (!accountData.account) {
37
+ if (!accountData.account || !accountData.account.wvw) {
38
38
  return null;
39
39
  }
40
40
 
41
- if (typeof accountData.account.wvw_rank === 'undefined') {
41
+ if (typeof accountData.account.wvw.rank === 'undefined') {
42
42
  return null;
43
43
  }
44
44
 
45
- return accountData.account.wvw_rank;
45
+ return accountData.account.wvw.rank;
46
46
  }
47
47
 
48
48
  // The amount of seconds played on this account
@@ -38,7 +38,8 @@ exports.default = function (accountData, extraInformation) {
38
38
  _unstableFractalEssenceFromUnlocks: unstableFractalEssenceFromUnlocks(accountData),
39
39
  aureneLegendaryVariantSkins: aureneLegendaryVariantSkins(accountData),
40
40
  suffusedObsidianArmorSkins: suffusedObsidianArmorSkins(accountData),
41
- coloredTitleCount: coloredTitleCount(accountData)
41
+ coloredTitleCount: coloredTitleCount(accountData),
42
+ homesteadDecorationCount: homesteadDecorationCount(accountData)
42
43
  };
43
44
  };
44
45
 
@@ -396,4 +397,15 @@ function unstableFractalEssenceFromUnlocks(accountData) {
396
397
  }
397
398
 
398
399
  return sum;
400
+ }
401
+
402
+ // The amount of homestead decorations on the account
403
+ function homesteadDecorationCount(accountData) {
404
+ if (!accountData.homestead || !accountData.homestead.decorations) {
405
+ return null;
406
+ }
407
+
408
+ return accountData.homestead.decorations.reduce(function (sum, decoration) {
409
+ return sum + decoration.count;
410
+ }, 0);
399
411
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gw2e-account-statistics",
3
- "version": "3.18.1",
3
+ "version": "3.19.0",
4
4
  "description": "Calculate statistics of guildwars2 accounts",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {
@@ -13,7 +13,7 @@ describe('statistics > account', () => {
13
13
  it('can calculate the wvw rank', () => {
14
14
  expect(accountStatistics({}).wvwRank).to.equal(null)
15
15
  expect(accountStatistics({account: {}}).wvwRank).to.equal(null)
16
- expect(accountStatistics({account: {wvw_rank: 123}}).wvwRank).to.equal(123)
16
+ expect(accountStatistics({account: {wvw: {rank: 123}}}).wvwRank).to.equal(123)
17
17
  })
18
18
 
19
19
  it('can calculate the playtime', () => {
@@ -276,4 +276,10 @@ describe('statistics > unlocks', () => {
276
276
  expect(unlocksStatistics({ skins: [1, 2, 7, 9, 10] }, EXTRA_INFO).suffusedObsidianArmorSkins).to.equal(0)
277
277
  expect(unlocksStatistics({ skins: [1, 2, 12171, 12136] }, EXTRA_INFO).suffusedObsidianArmorSkins).to.equal(2)
278
278
  })
279
+
280
+ it('can calculate homestead decoration count', () => {
281
+ expect(unlocksStatistics({}, EXTRA_INFO).homesteadDecorationCount).to.equal(null)
282
+ expect(unlocksStatistics({ homestead: { decorations: [] } }, EXTRA_INFO).homesteadDecorationCount).to.equal(0)
283
+ expect(unlocksStatistics({ homestead: { decorations: [{ id: 1, count: 1 }, { id: 2, count: 2 }] } }, EXTRA_INFO).homesteadDecorationCount).to.equal(3)
284
+ })
279
285
  })