mirror of
https://github.com/maxswa/osrs-json-hiscores.git
synced 2025-10-15 10:19:04 +00:00
Compare commits
11 Commits
add-nex
...
add-guardi
Author | SHA1 | Date | |
---|---|---|---|
![]() |
e77737f422 | ||
![]() |
3a72315498 | ||
![]() |
c1c9833ad0 | ||
![]() |
9fe03746e1 | ||
![]() |
66a4fb47a6 | ||
![]() |
83c44148a7 | ||
![]() |
44dea6b35c | ||
![]() |
0bf491638c | ||
![]() |
febca534b0 | ||
![]() |
8daee5c39b | ||
![]() |
f98cf8aaaa |
@@ -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: {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -11,7 +11,8 @@ import {
|
|||||||
getPlayerTableURL,
|
getPlayerTableURL,
|
||||||
getSkillPageURL,
|
getSkillPageURL,
|
||||||
getStatsURL,
|
getStatsURL,
|
||||||
BOSSES
|
BOSSES,
|
||||||
|
INVALID_FORMAT_ERROR
|
||||||
} from '../src/index';
|
} from '../src/index';
|
||||||
|
|
||||||
const B0ATY_NAME = 'B0ATY';
|
const B0ATY_NAME = 'B0ATY';
|
||||||
@@ -87,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
|
||||||
@@ -170,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 },
|
||||||
@@ -234,6 +237,18 @@ test('Parse CSV to json', () => {
|
|||||||
expect(parseStats(csv)).toStrictEqual(expectedOutput);
|
expect(parseStats(csv)).toStrictEqual(expectedOutput);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Parse CSV with unknown activity', () => {
|
||||||
|
const statsWithUnknownActivity = `${lynxTitanStats}
|
||||||
|
-1,-1`;
|
||||||
|
expect(() => parseStats(statsWithUnknownActivity)).toThrow(
|
||||||
|
INVALID_FORMAT_ERROR
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Parse invalid CSV', () => {
|
||||||
|
expect(() => parseStats('invalid')).toThrow(INVALID_FORMAT_ERROR);
|
||||||
|
});
|
||||||
|
|
||||||
describe('Get name format', () => {
|
describe('Get name format', () => {
|
||||||
it('gets a name with a space', async () => {
|
it('gets a name with a space', async () => {
|
||||||
const data = await getRSNFormat(LYNX_TITAN_SPACE_NAME);
|
const data = await getRSNFormat(LYNX_TITAN_SPACE_NAME);
|
||||||
|
@@ -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
|
||||||
@@ -80,4 +81,5 @@
|
|||||||
-1,-1
|
-1,-1
|
||||||
-1,-1
|
-1,-1
|
||||||
-1,-1
|
-1,-1
|
||||||
|
-1,-1
|
||||||
-1,-1
|
-1,-1
|
Can't render this file because it has a wrong number of fields in line 25.
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "osrs-json-hiscores",
|
"name": "osrs-json-hiscores",
|
||||||
"version": "2.6.0",
|
"version": "2.7.0",
|
||||||
"description": "The Old School Runescape API wrapper that does more!",
|
"description": "The Old School Runescape API wrapper that does more!",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"types": "lib/index.d.ts",
|
"types": "lib/index.d.ts",
|
||||||
|
@@ -27,7 +27,9 @@ import {
|
|||||||
rsnFromElement,
|
rsnFromElement,
|
||||||
getActivityPageURL,
|
getActivityPageURL,
|
||||||
httpGet,
|
httpGet,
|
||||||
BOSSES
|
BOSSES,
|
||||||
|
INVALID_FORMAT_ERROR,
|
||||||
|
EXTRA_ACTIVITY_COUNT
|
||||||
} from './utils';
|
} from './utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -74,6 +76,17 @@ 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 +
|
||||||
|
EXTRA_ACTIVITY_COUNT
|
||||||
|
) {
|
||||||
|
throw Error(INVALID_FORMAT_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
const skillObjects: Skill[] = splitCSV
|
const skillObjects: Skill[] = splitCSV
|
||||||
.filter((stat) => stat.length === 3)
|
.filter((stat) => stat.length === 3)
|
||||||
.map((stat) => {
|
.map((stat) => {
|
||||||
@@ -100,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) => {
|
||||||
@@ -133,6 +149,7 @@ export function parseStats(csv: string): Stats {
|
|||||||
bountyHunter,
|
bountyHunter,
|
||||||
lastManStanding,
|
lastManStanding,
|
||||||
soulWarsZeal,
|
soulWarsZeal,
|
||||||
|
riftsClosed,
|
||||||
clues,
|
clues,
|
||||||
bosses
|
bosses
|
||||||
};
|
};
|
||||||
|
@@ -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 };
|
||||||
|
@@ -132,6 +132,7 @@ export const ACTIVITIES: ActivityName[] = [
|
|||||||
'masterClues',
|
'masterClues',
|
||||||
'lastManStanding',
|
'lastManStanding',
|
||||||
'soulWarsZeal',
|
'soulWarsZeal',
|
||||||
|
'riftsClosed',
|
||||||
...BOSSES
|
...BOSSES
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -247,3 +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';
|
||||||
|
@@ -2460,9 +2460,9 @@ flatted@^3.1.0:
|
|||||||
integrity sha512-zAoAQiudy+r5SvnSw3KJy5os/oRJYHzrzja/tBDqrZtNhUw8bt6y8OBzMWcjWr+8liV8Eb6yOhw8WZ7VFZ5ZzA==
|
integrity sha512-zAoAQiudy+r5SvnSw3KJy5os/oRJYHzrzja/tBDqrZtNhUw8bt6y8OBzMWcjWr+8liV8Eb6yOhw8WZ7VFZ5ZzA==
|
||||||
|
|
||||||
follow-redirects@^1.14.0:
|
follow-redirects@^1.14.0:
|
||||||
version "1.14.4"
|
version "1.14.8"
|
||||||
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.4.tgz#838fdf48a8bbdd79e52ee51fb1c94e3ed98b9379"
|
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.8.tgz#016996fb9a11a100566398b1c6839337d7bfa8fc"
|
||||||
integrity sha512-zwGkiSXC1MUJG/qmeIFH2HBJx9u0V46QGUe3YR1fXG8bXQxq7fLj0RjLZQ5nubr9qNJUZrH+xUcwXEoXNpfS+g==
|
integrity sha512-1x0S9UVJHsQprFcEC/qnNzBLcIxsjAV905f/UkQxbclCsoTWlacCNOpQa/anodLl2uaEKFhfWOvM2Qg77+15zA==
|
||||||
|
|
||||||
for-in@^1.0.2:
|
for-in@^1.0.2:
|
||||||
version "1.0.2"
|
version "1.0.2"
|
||||||
|
Reference in New Issue
Block a user