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` |
| Last Man Standing | `lastManStanding` |
| Soul Wars Zeal | `soulWarsZeal` |
| Rifts Closed | `riftsClosed` |
### Leagues
@@ -193,6 +194,7 @@ Activities consist of all levels of clue scrolls as well as minigames and bosses
bountyHunter: {},
lastManStanding: {},
soulWarsZeal: {},
riftsClosed: {},
bosses: {}
}
}

View File

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

View File

@@ -29,6 +29,7 @@
-1,-1
-1,-1
-1,-1
-1,-1
347584,22
-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,
httpGet,
BOSSES,
INVALID_FORMAT_ERROR
INVALID_FORMAT_ERROR,
EXTRA_ACTIVITY_COUNT
} from './utils';
/**
@@ -75,7 +76,14 @@ 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 + 3) {
if (
splitCSV.length !==
SKILLS.length +
BH_MODES.length +
CLUES.length +
BOSSES.length +
EXTRA_ACTIVITY_COUNT
) {
throw Error(INVALID_FORMAT_ERROR);
}
@@ -105,7 +113,10 @@ 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] = activityObjects.splice(0, 2);
const [lastManStanding, soulWarsZeal, riftsClosed] = activityObjects.splice(
0,
3
);
const bossObjects = activityObjects.splice(0, BOSSES.length);
const skills: Skills = skillObjects.reduce<Skills>((prev, curr, index) => {
@@ -138,6 +149,7 @@ export function parseStats(csv: string): Stats {
bountyHunter,
lastManStanding,
soulWarsZeal,
riftsClosed,
clues,
bosses
};

View File

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

View File

@@ -132,6 +132,7 @@ export const ACTIVITIES: ActivityName[] = [
'masterClues',
'lastManStanding',
'soulWarsZeal',
'riftsClosed',
...BOSSES
];
@@ -247,5 +248,11 @@ export const FORMATTED_BH_NAMES: FormattedBHNames = {
export const FORMATTED_LMS = 'Last Man Standing';
export const FORMATTED_SOUL_WARS = 'Soul Wars Zeal';
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';