mirror of
https://github.com/maxswa/osrs-json-hiscores.git
synced 2025-10-15 10:19:04 +00:00
Compare commits
6 Commits
fix-tests-
...
add-guardi
Author | SHA1 | Date | |
---|---|---|---|
![]() |
e77737f422 | ||
![]() |
3a72315498 | ||
![]() |
c1c9833ad0 | ||
![]() |
9fe03746e1 | ||
![]() |
66a4fb47a6 | ||
![]() |
83c44148a7 |
@@ -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: {}
|
||||
}
|
||||
}
|
||||
|
@@ -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', () => {
|
||||
|
@@ -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.
|
@@ -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
|
||||
};
|
||||
|
@@ -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 };
|
||||
|
@@ -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';
|
||||
|
@@ -2460,9 +2460,9 @@ flatted@^3.1.0:
|
||||
integrity sha512-zAoAQiudy+r5SvnSw3KJy5os/oRJYHzrzja/tBDqrZtNhUw8bt6y8OBzMWcjWr+8liV8Eb6yOhw8WZ7VFZ5ZzA==
|
||||
|
||||
follow-redirects@^1.14.0:
|
||||
version "1.14.4"
|
||||
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.4.tgz#838fdf48a8bbdd79e52ee51fb1c94e3ed98b9379"
|
||||
integrity sha512-zwGkiSXC1MUJG/qmeIFH2HBJx9u0V46QGUe3YR1fXG8bXQxq7fLj0RjLZQ5nubr9qNJUZrH+xUcwXEoXNpfS+g==
|
||||
version "1.14.8"
|
||||
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.8.tgz#016996fb9a11a100566398b1c6839337d7bfa8fc"
|
||||
integrity sha512-1x0S9UVJHsQprFcEC/qnNzBLcIxsjAV905f/UkQxbclCsoTWlacCNOpQa/anodLl2uaEKFhfWOvM2Qg77+15zA==
|
||||
|
||||
for-in@^1.0.2:
|
||||
version "1.0.2"
|
||||
|
Reference in New Issue
Block a user