Add Guardians of the Rift.

This commit is contained in:
maxswa
2022-04-18 15:44:45 -04:00
parent 3a72315498
commit e77737f422
6 changed files with 33 additions and 5 deletions

View File

@@ -110,6 +110,7 @@ Activities consist of all levels of clue scrolls as well as minigames and bosses
| Bounty Hunter (Hunter) | `hunterBH` | | Bounty Hunter (Hunter) | `hunterBH` |
| Last Man Standing | `lastManStanding` | | Last Man Standing | `lastManStanding` |
| Soul Wars Zeal | `soulWarsZeal` | | Soul Wars Zeal | `soulWarsZeal` |
| Rifts Closed | `riftsClosed` |
### Leagues ### Leagues
@@ -193,6 +194,7 @@ Activities consist of all levels of clue scrolls as well as minigames and bosses
bountyHunter: {}, bountyHunter: {},
lastManStanding: {}, lastManStanding: {},
soulWarsZeal: {}, soulWarsZeal: {},
riftsClosed: {},
bosses: {} bosses: {}
} }
} }

View File

@@ -88,6 +88,7 @@ test('Parse CSV to json', () => {
1,6143 1,6143
4814,898 4814,898
37,225 37,225
23,467
382,2780 382,2780
944,3000 944,3000
1981,1452 1981,1452
@@ -171,6 +172,7 @@ test('Parse CSV to json', () => {
}, },
lastManStanding: { rank: 4814, score: 898 }, lastManStanding: { rank: 4814, score: 898 },
soulWarsZeal: { rank: 37, score: 225 }, soulWarsZeal: { rank: 37, score: 225 },
riftsClosed: { rank: 23, score: 467 },
clues: { clues: {
all: { rank: 32, score: 12148 }, all: { rank: 32, score: 12148 },
beginner: { rank: 3105, score: 76 }, beginner: { rank: 3105, score: 76 },
@@ -236,9 +238,11 @@ test('Parse CSV to json', () => {
}); });
test('Parse CSV with unknown activity', () => { test('Parse CSV with unknown activity', () => {
const statsWithUnknownActivity = lynxTitanStats + ` const statsWithUnknownActivity = `${lynxTitanStats}
-1,-1`; -1,-1`;
expect(() => parseStats(statsWithUnknownActivity)).toThrow(INVALID_FORMAT_ERROR); expect(() => parseStats(statsWithUnknownActivity)).toThrow(
INVALID_FORMAT_ERROR
);
}); });
test('Parse invalid CSV', () => { test('Parse invalid CSV', () => {

View File

@@ -29,6 +29,7 @@
-1,-1 -1,-1
-1,-1 -1,-1
-1,-1 -1,-1
-1,-1
347584,22 347584,22
-1,-1 -1,-1
-1,-1 -1,-1
Can't render this file because it has a wrong number of fields in line 25.

View File

@@ -28,7 +28,8 @@ import {
getActivityPageURL, getActivityPageURL,
httpGet, httpGet,
BOSSES, BOSSES,
INVALID_FORMAT_ERROR INVALID_FORMAT_ERROR,
EXTRA_ACTIVITY_COUNT
} from './utils'; } from './utils';
/** /**
@@ -75,7 +76,14 @@ export function parseStats(csv: string): Stats {
.filter((entry) => !!entry) .filter((entry) => !!entry)
.map((stat) => stat.split(',')); .map((stat) => stat.split(','));
if (splitCSV.length !== SKILLS.length + BH_MODES.length + CLUES.length + BOSSES.length + 3) { if (
splitCSV.length !==
SKILLS.length +
BH_MODES.length +
CLUES.length +
BOSSES.length +
EXTRA_ACTIVITY_COUNT
) {
throw Error(INVALID_FORMAT_ERROR); throw Error(INVALID_FORMAT_ERROR);
} }
@@ -105,7 +113,10 @@ export function parseStats(csv: string): Stats {
const [leaguePoints] = activityObjects.splice(0, 1); const [leaguePoints] = activityObjects.splice(0, 1);
const bhObjects = activityObjects.splice(0, BH_MODES.length); const bhObjects = activityObjects.splice(0, BH_MODES.length);
const clueObjects = activityObjects.splice(0, CLUES.length); const clueObjects = activityObjects.splice(0, CLUES.length);
const [lastManStanding, soulWarsZeal] = activityObjects.splice(0, 2); const [lastManStanding, soulWarsZeal, riftsClosed] = activityObjects.splice(
0,
3
);
const bossObjects = activityObjects.splice(0, BOSSES.length); const bossObjects = activityObjects.splice(0, BOSSES.length);
const skills: Skills = skillObjects.reduce<Skills>((prev, curr, index) => { const skills: Skills = skillObjects.reduce<Skills>((prev, curr, index) => {
@@ -138,6 +149,7 @@ export function parseStats(csv: string): Stats {
bountyHunter, bountyHunter,
lastManStanding, lastManStanding,
soulWarsZeal, soulWarsZeal,
riftsClosed,
clues, clues,
bosses bosses
}; };

View File

@@ -119,6 +119,7 @@ export type ActivityName =
| 'rogueBH' | 'rogueBH'
| 'lastManStanding' | 'lastManStanding'
| 'soulWarsZeal' | 'soulWarsZeal'
| 'riftsClosed'
| 'allClues' | 'allClues'
| 'beginnerClues' | 'beginnerClues'
| 'easyClues' | 'easyClues'
@@ -135,6 +136,7 @@ export interface Stats {
bountyHunter: BH; bountyHunter: BH;
lastManStanding: Activity; lastManStanding: Activity;
soulWarsZeal: Activity; soulWarsZeal: Activity;
riftsClosed: Activity;
bosses: Bosses; bosses: Bosses;
} }
export type Modes = { [M in Gamemode]?: Stats }; export type Modes = { [M in Gamemode]?: Stats };

View File

@@ -132,6 +132,7 @@ export const ACTIVITIES: ActivityName[] = [
'masterClues', 'masterClues',
'lastManStanding', 'lastManStanding',
'soulWarsZeal', 'soulWarsZeal',
'riftsClosed',
...BOSSES ...BOSSES
]; ];
@@ -247,5 +248,11 @@ export const FORMATTED_BH_NAMES: FormattedBHNames = {
export const FORMATTED_LMS = 'Last Man Standing'; export const FORMATTED_LMS = 'Last Man Standing';
export const FORMATTED_SOUL_WARS = 'Soul Wars Zeal'; export const FORMATTED_SOUL_WARS = 'Soul Wars Zeal';
export const FORMATTED_LEAGUE_POINTS = 'League Points'; export const FORMATTED_LEAGUE_POINTS = 'League Points';
export const FORMATTED_RIFTS_CLOSED = 'Rifts Closed';
/**
* Count of activities not including bosses, bounty hunter, or clues.
*/
export const EXTRA_ACTIVITY_COUNT = 4;
export const INVALID_FORMAT_ERROR = 'Invalid hiscores format'; export const INVALID_FORMAT_ERROR = 'Invalid hiscores format';