From 2877b9c8a151097abb3b9c0547528bb8bd0432ba Mon Sep 17 00:00:00 2001 From: David Vorona Date: Fri, 15 Jul 2022 14:11:02 -0700 Subject: [PATCH] Add support for PvP Arena activity --- README.md | 2 ++ __tests__/hiscores.test.ts | 2 ++ __tests__/lynxTitanNamePage.html | 4 ++++ __tests__/lynxTitanStats.csv | 1 + src/hiscores.ts | 5 +++-- src/types.ts | 2 ++ src/utils/constants.ts | 2 ++ 7 files changed, 16 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ea3e4e7..acbd88f 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,7 @@ Activities consist of all levels of clue scrolls as well as minigames and bosses | Bounty Hunter (Rogue) | `rogueBH` | | Bounty Hunter (Hunter) | `hunterBH` | | Last Man Standing | `lastManStanding` | +| PvP Arena | `pvpArena` | | Soul Wars Zeal | `soulWarsZeal` | | Rifts Closed | `riftsClosed` | @@ -193,6 +194,7 @@ Activities consist of all levels of clue scrolls as well as minigames and bosses leaguePoints: {}, bountyHunter: {}, lastManStanding: {}, + pvpArena: {}, soulWarsZeal: {}, riftsClosed: {}, bosses: {} diff --git a/__tests__/hiscores.test.ts b/__tests__/hiscores.test.ts index 7bce9ca..5b76930 100644 --- a/__tests__/hiscores.test.ts +++ b/__tests__/hiscores.test.ts @@ -87,6 +87,7 @@ test('Parse CSV to json', () => { 392,250 1,6143 4814,898 + 13,4057 37,225 25,1110 382,2780 @@ -171,6 +172,7 @@ test('Parse CSV to json', () => { rogue: { rank: 89912, score: 37 } }, lastManStanding: { rank: 4814, score: 898 }, + pvpArena: { rank: 13, score: 4057 }, soulWarsZeal: { rank: 37, score: 225 }, riftsClosed: { rank: 25, score: 1110 }, clues: { diff --git a/__tests__/lynxTitanNamePage.html b/__tests__/lynxTitanNamePage.html index 83ed3ef..ce0e7a4 100644 --- a/__tests__/lynxTitanNamePage.html +++ b/__tests__/lynxTitanNamePage.html @@ -75,6 +75,10 @@ .lmsrank:before { content: url('https://www.runescape.com/img/rsp777/game_icon_lmsrank.png?2'); } + + .pvparenarank:before { + content: url('https://www.runescape.com/img/rsp777/game_icon_pvparenarank.png?2'); + } .soulwarszeal:before { content: url('https://www.runescape.com/img/rsp777/game_icon_soulwarszeal.png?2'); diff --git a/__tests__/lynxTitanStats.csv b/__tests__/lynxTitanStats.csv index 7908a3d..7e60d96 100644 --- a/__tests__/lynxTitanStats.csv +++ b/__tests__/lynxTitanStats.csv @@ -82,4 +82,5 @@ -1,-1 -1,-1 -1,-1 +-1,-1 -1,-1 \ No newline at end of file diff --git a/src/hiscores.ts b/src/hiscores.ts index 95b468a..efdd572 100644 --- a/src/hiscores.ts +++ b/src/hiscores.ts @@ -75,7 +75,7 @@ export function parseStats(csv: string): Stats { .filter((entry) => !!entry) .map((stat) => stat.split(',')); - if (splitCSV.length !== SKILLS.length + BH_MODES.length + CLUES.length + BOSSES.length + 4) { + if (splitCSV.length !== SKILLS.length + BH_MODES.length + CLUES.length + BOSSES.length + 5) { throw Error(INVALID_FORMAT_ERROR); } @@ -105,7 +105,7 @@ export function parseStats(csv: string): Stats { const [leaguePoints] = activityObjects.splice(0, 1); const bhObjects = activityObjects.splice(0, BH_MODES.length); const clueObjects = activityObjects.splice(0, CLUES.length); - const [lastManStanding, soulWarsZeal, riftsClosed] = activityObjects.splice(0, 3); + const [lastManStanding, pvpArena, soulWarsZeal, riftsClosed] = activityObjects.splice(0, 4); const bossObjects = activityObjects.splice(0, BOSSES.length); const skills: Skills = skillObjects.reduce((prev, curr, index) => { @@ -137,6 +137,7 @@ export function parseStats(csv: string): Stats { leaguePoints, bountyHunter, lastManStanding, + pvpArena, soulWarsZeal, riftsClosed, clues, diff --git a/src/types.ts b/src/types.ts index 215ba4e..01c8f9f 100644 --- a/src/types.ts +++ b/src/types.ts @@ -118,6 +118,7 @@ export type ActivityName = | 'hunterBH' | 'rogueBH' | 'lastManStanding' + | 'pvpArena' | 'soulWarsZeal' | 'riftsClosed' | 'allClues' @@ -135,6 +136,7 @@ export interface Stats { leaguePoints: Activity; bountyHunter: BH; lastManStanding: Activity; + pvpArena: Activity; soulWarsZeal: Activity; riftsClosed: Activity; bosses: Bosses; diff --git a/src/utils/constants.ts b/src/utils/constants.ts index b2f3937..7925b73 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -131,6 +131,7 @@ export const ACTIVITIES: ActivityName[] = [ 'eliteClues', 'masterClues', 'lastManStanding', + 'pvpArena', 'soulWarsZeal', 'riftsClosed', ...BOSSES @@ -246,6 +247,7 @@ export const FORMATTED_BH_NAMES: FormattedBHNames = { }; export const FORMATTED_LMS = 'Last Man Standing'; +export const FORMATTED_PVP_ARENA = 'PvP Arena'; export const FORMATTED_SOUL_WARS = 'Soul Wars Zeal'; export const FORMATTED_LEAGUE_POINTS = 'League Points'; export const FORMATTED_RIFTS_CLOSED = 'Rifts Closed';