mirror of
https://github.com/maxswa/osrs-json-hiscores.git
synced 2025-10-15 10:19:04 +00:00
Add bosses and support for leagues.
This commit is contained in:
75
README.md
75
README.md
@@ -68,15 +68,15 @@ const topPage = await getSkillPage('overall');
|
|||||||
`getStats` will return a full player object with gamemode.
|
`getStats` will return a full player object with gamemode.
|
||||||
`getStatsByGameMode` will return a stats object and accepts a gamemode parameter:
|
`getStatsByGameMode` will return a stats object and accepts a gamemode parameter:
|
||||||
|
|
||||||
| Game mode | Param |
|
| Game mode | Param |
|
||||||
| ---------------- | :----: |
|
| ---------------- | :-------: |
|
||||||
| Regular | `main` |
|
| Regular | `main` |
|
||||||
| Ironman | `iron` |
|
| Ironman | `iron` |
|
||||||
| Hardcore Ironman | `hc` |
|
| Hardcore Ironman | `hc` |
|
||||||
| Ultimate Ironman | `ult` |
|
| Ultimate Ironman | `ult` |
|
||||||
| Deadman Mode | `dmm` |
|
| Deadman Mode | `dmm` |
|
||||||
| Seasonal Deadman | `sdmm` |
|
| DMM Tournament | `dmmt` |
|
||||||
| DMM Tournament | `dmmt` |
|
| Leagues | `leagues` |
|
||||||
|
|
||||||
`getSkillPage` and `getActivityPage` require a skill/activity and optionally a gamemode and page:
|
`getSkillPage` and `getActivityPage` require a skill/activity and optionally a gamemode and page:
|
||||||
|
|
||||||
@@ -109,6 +109,60 @@ Activities consist of all levels of clue scrolls as well as minigames:
|
|||||||
| Bounty Hunter (Hunter) | `hunterbh` |
|
| Bounty Hunter (Hunter) | `hunterbh` |
|
||||||
| Last Man Standing | `lms` |
|
| Last Man Standing | `lms` |
|
||||||
|
|
||||||
|
### Leagues
|
||||||
|
|
||||||
|
| Name | Param |
|
||||||
|
| ------------- | :---: |
|
||||||
|
| League Points | `lp` |
|
||||||
|
|
||||||
|
### Bosses
|
||||||
|
|
||||||
|
| Boss Name | Param |
|
||||||
|
| -------------------------------- | :----------------------------: |
|
||||||
|
| Abyssal Sire | `abyssalsire` |
|
||||||
|
| Alchemical Hydra | `alchemicalhydra` |
|
||||||
|
| Barrows Chests | `barrowschests` |
|
||||||
|
| Bryophyta | `bryophyta` |
|
||||||
|
| Callisto | `callisto` |
|
||||||
|
| Cerberus | `cerberus` |
|
||||||
|
| Chambers Of Xeric | `chambersofxeric` |
|
||||||
|
| Chambers Of Xeric Challenge Mode | `chambersofxericchallengemode` |
|
||||||
|
| Chaos Elemental | `chaoselemental` |
|
||||||
|
| Chaos Fanatic | `chaosfanatic` |
|
||||||
|
| Commander Zilyana | `commanderzilyana` |
|
||||||
|
| Corporeal Beast | `corporealbeast` |
|
||||||
|
| Crazy Archaeologist | `crazyarchaeologist` |
|
||||||
|
| Dagannoth Prime | `dagannothprime` |
|
||||||
|
| Dagannoth Rex | `dagannothrex` |
|
||||||
|
| Dagannoth Supreme | `dagannothsupreme` |
|
||||||
|
| Deranged Archaeologist | `derangedarchaeologist` |
|
||||||
|
| General Graardor | `generalgraardor` |
|
||||||
|
| Giant Mole | `giantmole` |
|
||||||
|
| Grotesque Guardians | `grotesqueguardians` |
|
||||||
|
| Hespori | `hespori` |
|
||||||
|
| Kalphite Queen | `kalphitequeen` |
|
||||||
|
| King Black Dragon | `kingblackdragon` |
|
||||||
|
| Kraken | `kraken` |
|
||||||
|
| Kreearra | `kreearra` |
|
||||||
|
| K'ril Tsutsaroth | `kriltsutsaroth` |
|
||||||
|
| Mimic | `mimic` |
|
||||||
|
| Obor | `obor` |
|
||||||
|
| Sarachnis | `sarachnis` |
|
||||||
|
| Scorpia | `scorpia` |
|
||||||
|
| Skotizo | `skotizo` |
|
||||||
|
| Gauntlet | `gauntlet` |
|
||||||
|
| Corrupted Gauntlet | `corruptedgauntlet` |
|
||||||
|
| Theatre Of Blood | `theatreofblood` |
|
||||||
|
| Thermonuclear Smoke Devil | `thermonuclearsmokedevil` |
|
||||||
|
| TzKal-Zuk | `tzkalzuk` |
|
||||||
|
| TzTok-Jad | `tztokjad` |
|
||||||
|
| Venenatis | `venenatis` |
|
||||||
|
| Vetion | `vetion` |
|
||||||
|
| Vorkath | `vorkath` |
|
||||||
|
| Wintertodt | `wintertodt` |
|
||||||
|
| Zalcano | `zalcano` |
|
||||||
|
| Zulrah | `zulrah` |
|
||||||
|
|
||||||
## What you'll get
|
## What you'll get
|
||||||
|
|
||||||
`getStats` returns a player object that looks like this:
|
`getStats` returns a player object that looks like this:
|
||||||
@@ -129,7 +183,8 @@ Activities consist of all levels of clue scrolls as well as minigames:
|
|||||||
},
|
},
|
||||||
clues: {},
|
clues: {},
|
||||||
bh: {},
|
bh: {},
|
||||||
lms: {}
|
lms: {},
|
||||||
|
bosses: {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@@ -5,8 +5,6 @@ import {
|
|||||||
getStats,
|
getStats,
|
||||||
getStatsByGamemode,
|
getStatsByGamemode,
|
||||||
} from '../src/index';
|
} from '../src/index';
|
||||||
import { PlayerSkillRow, Player, Stats } from '../src/types';
|
|
||||||
import axios, { AxiosError } from 'axios';
|
|
||||||
|
|
||||||
test('Parse CSV to json', () => {
|
test('Parse CSV to json', () => {
|
||||||
const csv = `40258,2063,218035714
|
const csv = `40258,2063,218035714
|
||||||
@@ -33,16 +31,58 @@ test('Parse CSV to json', () => {
|
|||||||
53099, 80, 2008229
|
53099, 80, 2008229
|
||||||
169127, 73, 1067670
|
169127, 73, 1067670
|
||||||
115543, 82, 2546048
|
115543, 82, 2546048
|
||||||
-1, -1
|
-1, -1
|
||||||
-1, -1
|
-1, -1
|
||||||
32875, 500
|
-1, -1
|
||||||
24817, 476
|
24817, 476
|
||||||
212728, 1
|
212728, 1
|
||||||
94827, 20
|
94827, 20
|
||||||
59099, 74
|
59099, 74
|
||||||
24642, 231
|
24642, 231
|
||||||
5206, 99
|
5206, 99
|
||||||
6293, 51`;
|
6293, 51
|
||||||
|
32875, 500
|
||||||
|
374,2780
|
||||||
|
934,3000
|
||||||
|
1936,1452
|
||||||
|
4919,23
|
||||||
|
101,4038
|
||||||
|
152,334
|
||||||
|
6153,133
|
||||||
|
4501,250
|
||||||
|
6806,603
|
||||||
|
1,17798
|
||||||
|
9160,125
|
||||||
|
1021,2802
|
||||||
|
4295,1655
|
||||||
|
959,2951
|
||||||
|
10009,1
|
||||||
|
1271,2407
|
||||||
|
378,4669
|
||||||
|
543,1567
|
||||||
|
6003,94
|
||||||
|
263,2897
|
||||||
|
4000,1277
|
||||||
|
41016,1477
|
||||||
|
617,2391
|
||||||
|
120,2981
|
||||||
|
1,109
|
||||||
|
26,323
|
||||||
|
198,1101
|
||||||
|
81,3404
|
||||||
|
5027,61
|
||||||
|
63,375
|
||||||
|
2845,6
|
||||||
|
6913,138
|
||||||
|
3999,2000
|
||||||
|
484,8
|
||||||
|
957,47
|
||||||
|
10987,223
|
||||||
|
1923,272
|
||||||
|
8484,1340
|
||||||
|
599,1694
|
||||||
|
-1,-1
|
||||||
|
3810,4583`;
|
||||||
|
|
||||||
expect(parseStats(csv)).toStrictEqual({
|
expect(parseStats(csv)).toStrictEqual({
|
||||||
skills: {
|
skills: {
|
||||||
@@ -85,238 +125,272 @@ test('Parse CSV to json', () => {
|
|||||||
elite: { rank: 5206, score: 99 },
|
elite: { rank: 5206, score: 99 },
|
||||||
master: { rank: 6293, score: 51 },
|
master: { rank: 6293, score: 51 },
|
||||||
},
|
},
|
||||||
|
bosses: {
|
||||||
|
abyssalsire: { rank: 374, score: 2780 },
|
||||||
|
alchemicalhydra: { rank: 934, score: 3000 },
|
||||||
|
barrowschests: { rank: 1936, score: 1452 },
|
||||||
|
bryophyta: { rank: 4919, score: 23 },
|
||||||
|
chambersofxeric: { rank: 101, score: 4038 },
|
||||||
|
chambersofxericchallengemode: { rank: 152, score: 334 },
|
||||||
|
chaoselemental: { rank: -1, score: -1 },
|
||||||
|
chaosfanatic: { rank: -1, score: -1 },
|
||||||
|
commanderzilyana: { rank: 6806, score: 603 },
|
||||||
|
corporealbeast: { rank: 1, score: 17798 },
|
||||||
|
crazyarchaeologist: { rank: 9160, score: 125 },
|
||||||
|
dagannothprime: { rank: 1021, score: 2802 },
|
||||||
|
dagannothrex: { rank: 4295, score: 1655 },
|
||||||
|
dagannothsupreme: { rank: 959, score: 2951 },
|
||||||
|
derangedarchaeologist: { rank: 10009, score: 1 },
|
||||||
|
generalgraardor: { rank: 1271, score: 2407 },
|
||||||
|
giantmole: { rank: 378, score: 4669 },
|
||||||
|
grotesqueguardians: { rank: 543, score: 1567 },
|
||||||
|
hespori: { rank: 6003, score: 94 },
|
||||||
|
kalphitequeen: { rank: 263, score: 2897 },
|
||||||
|
kingblackdragon: { rank: 4000, score: 1277 },
|
||||||
|
kraken: { rank: 41016, score: 1477 },
|
||||||
|
kreearra: { rank: 617, score: 2391 },
|
||||||
|
kriltsutsaroth: { rank: 120, score: 2981 },
|
||||||
|
mimic: { rank: 1, score: 109 },
|
||||||
|
obor: { rank: 26, score: 323 },
|
||||||
|
sarachnis: { rank: 198, score: 1101 },
|
||||||
|
scorpia: { rank: 81, score: 3404 },
|
||||||
|
skotizo: { rank: 5027, score: 61 },
|
||||||
|
gauntlet: { rank: 63, score: 375 },
|
||||||
|
corruptedgauntlet: { rank: 2845, score: 6 },
|
||||||
|
theatreofblood: { rank: 6913, score: 138 },
|
||||||
|
thermonuclearsmokedevil: { rank: 3999, score: 2000 },
|
||||||
|
tzkalzuk: { rank: 484, score: 8 },
|
||||||
|
tztokjad: { rank: 957, score: 47 },
|
||||||
|
venenatis: { rank: 10987, score: 223 },
|
||||||
|
vetion: { rank: 1923, score: 272 },
|
||||||
|
vorkath: { rank: 8484, score: 1340 },
|
||||||
|
wintertodt: { rank: 599, score: 1694 },
|
||||||
|
zalcano: { rank: -1, score: -1 },
|
||||||
|
zulrah: { rank: 3810, score: 4583 },
|
||||||
|
callisto: { rank: -1, score: -1 },
|
||||||
|
cerberus: { rank: -1, score: -1 },
|
||||||
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Get rsn format', async done => {
|
test('Get rsn format', async () => {
|
||||||
const callback = (data: string) => {
|
jest.setTimeout(30000);
|
||||||
expect(data).toBe('Lynx Titan');
|
const data = await getRSNFormat('lYnX tiTaN');
|
||||||
done();
|
expect(data).toBe('Lynx Titan');
|
||||||
};
|
|
||||||
|
|
||||||
getRSNFormat('lYnX tiTaN').then(callback);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Get attack top page', async done => {
|
test('Get attack top page', async () => {
|
||||||
const callback = (data: PlayerSkillRow[]) => {
|
jest.setTimeout(30000);
|
||||||
expect(data).toMatchObject([
|
const data = await getSkillPage('attack');
|
||||||
{
|
expect(data).toMatchObject([
|
||||||
rsn: expect.any(String),
|
{
|
||||||
rank: 1,
|
rsn: expect.any(String),
|
||||||
level: 99,
|
rank: 1,
|
||||||
xp: 200000000,
|
level: 99,
|
||||||
dead: false,
|
xp: 200000000,
|
||||||
},
|
dead: false,
|
||||||
{
|
},
|
||||||
rsn: expect.any(String),
|
{
|
||||||
rank: 2,
|
rsn: expect.any(String),
|
||||||
level: 99,
|
rank: 2,
|
||||||
xp: 200000000,
|
level: 99,
|
||||||
dead: false,
|
xp: 200000000,
|
||||||
},
|
dead: false,
|
||||||
{ rsn: 'Drakon', rank: 3, level: 99, xp: 200000000, dead: false },
|
},
|
||||||
{
|
{ rsn: 'Drakon', rank: 3, level: 99, xp: 200000000, dead: false },
|
||||||
rsn: expect.any(String),
|
{
|
||||||
rank: 4,
|
rsn: expect.any(String),
|
||||||
level: 99,
|
rank: 4,
|
||||||
xp: 200000000,
|
level: 99,
|
||||||
dead: false,
|
xp: 200000000,
|
||||||
},
|
dead: false,
|
||||||
{
|
},
|
||||||
rsn: expect.any(String),
|
{
|
||||||
rank: 5,
|
rsn: expect.any(String),
|
||||||
level: 99,
|
rank: 5,
|
||||||
xp: 200000000,
|
level: 99,
|
||||||
dead: false,
|
xp: 200000000,
|
||||||
},
|
dead: false,
|
||||||
{
|
},
|
||||||
rsn: expect.any(String),
|
{
|
||||||
rank: 6,
|
rsn: expect.any(String),
|
||||||
level: 99,
|
rank: 6,
|
||||||
xp: 200000000,
|
level: 99,
|
||||||
dead: false,
|
xp: 200000000,
|
||||||
},
|
dead: false,
|
||||||
{
|
},
|
||||||
rsn: expect.any(String),
|
{
|
||||||
rank: 7,
|
rsn: expect.any(String),
|
||||||
level: 99,
|
rank: 7,
|
||||||
xp: 200000000,
|
level: 99,
|
||||||
dead: false,
|
xp: 200000000,
|
||||||
},
|
dead: false,
|
||||||
{
|
},
|
||||||
rsn: expect.any(String),
|
{
|
||||||
rank: 8,
|
rsn: expect.any(String),
|
||||||
level: 99,
|
rank: 8,
|
||||||
xp: 200000000,
|
level: 99,
|
||||||
dead: false,
|
xp: 200000000,
|
||||||
},
|
dead: false,
|
||||||
{
|
},
|
||||||
rsn: expect.any(String),
|
{
|
||||||
rank: 9,
|
rsn: expect.any(String),
|
||||||
level: 99,
|
rank: 9,
|
||||||
xp: 200000000,
|
level: 99,
|
||||||
dead: false,
|
xp: 200000000,
|
||||||
},
|
dead: false,
|
||||||
{
|
},
|
||||||
rsn: expect.any(String),
|
{
|
||||||
rank: 10,
|
rsn: expect.any(String),
|
||||||
level: 99,
|
rank: 10,
|
||||||
xp: 200000000,
|
level: 99,
|
||||||
dead: false,
|
xp: 200000000,
|
||||||
},
|
dead: false,
|
||||||
{
|
},
|
||||||
rsn: expect.any(String),
|
{
|
||||||
rank: 11,
|
rsn: expect.any(String),
|
||||||
level: 99,
|
rank: 11,
|
||||||
xp: 200000000,
|
level: 99,
|
||||||
dead: false,
|
xp: 200000000,
|
||||||
},
|
dead: false,
|
||||||
{
|
},
|
||||||
rsn: expect.any(String),
|
{
|
||||||
rank: 12,
|
rsn: expect.any(String),
|
||||||
level: 99,
|
rank: 12,
|
||||||
xp: 200000000,
|
level: 99,
|
||||||
dead: false,
|
xp: 200000000,
|
||||||
},
|
dead: false,
|
||||||
{
|
},
|
||||||
rsn: expect.any(String),
|
{
|
||||||
rank: 13,
|
rsn: expect.any(String),
|
||||||
level: 99,
|
rank: 13,
|
||||||
xp: 200000000,
|
level: 99,
|
||||||
dead: false,
|
xp: 200000000,
|
||||||
},
|
dead: false,
|
||||||
{
|
},
|
||||||
rsn: expect.any(String),
|
{
|
||||||
rank: 14,
|
rsn: expect.any(String),
|
||||||
level: 99,
|
rank: 14,
|
||||||
xp: 200000000,
|
level: 99,
|
||||||
dead: false,
|
xp: 200000000,
|
||||||
},
|
dead: false,
|
||||||
{
|
},
|
||||||
rsn: expect.any(String),
|
{
|
||||||
rank: 15,
|
rsn: expect.any(String),
|
||||||
level: 99,
|
rank: 15,
|
||||||
xp: 200000000,
|
level: 99,
|
||||||
dead: false,
|
xp: 200000000,
|
||||||
},
|
dead: false,
|
||||||
{
|
},
|
||||||
rsn: expect.any(String),
|
{
|
||||||
rank: 16,
|
rsn: expect.any(String),
|
||||||
level: 99,
|
rank: 16,
|
||||||
xp: 200000000,
|
level: 99,
|
||||||
dead: false,
|
xp: 200000000,
|
||||||
},
|
dead: false,
|
||||||
{
|
},
|
||||||
rsn: expect.any(String),
|
{
|
||||||
rank: 17,
|
rsn: expect.any(String),
|
||||||
level: 99,
|
rank: 17,
|
||||||
xp: 200000000,
|
level: 99,
|
||||||
dead: false,
|
xp: 200000000,
|
||||||
},
|
dead: false,
|
||||||
{
|
},
|
||||||
rsn: expect.any(String),
|
{
|
||||||
rank: 18,
|
rsn: expect.any(String),
|
||||||
level: 99,
|
rank: 18,
|
||||||
xp: 200000000,
|
level: 99,
|
||||||
dead: false,
|
xp: 200000000,
|
||||||
},
|
dead: false,
|
||||||
{
|
},
|
||||||
rsn: expect.any(String),
|
{
|
||||||
rank: 19,
|
rsn: expect.any(String),
|
||||||
level: 99,
|
rank: 19,
|
||||||
xp: 200000000,
|
level: 99,
|
||||||
dead: false,
|
xp: 200000000,
|
||||||
},
|
dead: false,
|
||||||
{
|
},
|
||||||
rsn: expect.any(String),
|
{
|
||||||
rank: 20,
|
rsn: expect.any(String),
|
||||||
level: 99,
|
rank: 20,
|
||||||
xp: 200000000,
|
level: 99,
|
||||||
dead: false,
|
xp: 200000000,
|
||||||
},
|
dead: false,
|
||||||
{
|
},
|
||||||
rsn: expect.any(String),
|
{
|
||||||
rank: 21,
|
rsn: expect.any(String),
|
||||||
level: 99,
|
rank: 21,
|
||||||
xp: 200000000,
|
level: 99,
|
||||||
dead: false,
|
xp: 200000000,
|
||||||
},
|
dead: false,
|
||||||
{
|
},
|
||||||
rsn: expect.any(String),
|
{
|
||||||
rank: 22,
|
rsn: expect.any(String),
|
||||||
level: 99,
|
rank: 22,
|
||||||
xp: 200000000,
|
level: 99,
|
||||||
dead: false,
|
xp: 200000000,
|
||||||
},
|
dead: false,
|
||||||
{
|
},
|
||||||
rsn: expect.any(String),
|
{
|
||||||
rank: 23,
|
rsn: expect.any(String),
|
||||||
level: 99,
|
rank: 23,
|
||||||
xp: 200000000,
|
level: 99,
|
||||||
dead: false,
|
xp: 200000000,
|
||||||
},
|
dead: false,
|
||||||
{
|
},
|
||||||
rsn: expect.any(String),
|
{
|
||||||
rank: 24,
|
rsn: expect.any(String),
|
||||||
level: 99,
|
rank: 24,
|
||||||
xp: 200000000,
|
level: 99,
|
||||||
dead: false,
|
xp: 200000000,
|
||||||
},
|
dead: false,
|
||||||
{
|
},
|
||||||
rsn: expect.any(String),
|
{
|
||||||
rank: 25,
|
rsn: expect.any(String),
|
||||||
level: 99,
|
rank: 25,
|
||||||
xp: 200000000,
|
level: 99,
|
||||||
dead: false,
|
xp: 200000000,
|
||||||
},
|
dead: false,
|
||||||
]);
|
},
|
||||||
done();
|
]);
|
||||||
};
|
|
||||||
|
|
||||||
getSkillPage('attack').then(callback);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Get non-existant player', async done => {
|
test('Get non-existant player', async () => {
|
||||||
const callback = (err: AxiosError) => {
|
jest.setTimeout(30000);
|
||||||
|
getStats('fishy').catch(err => {
|
||||||
if (err.response) {
|
if (err.response) {
|
||||||
expect(err.response.status).toBe(404);
|
expect(err.response.status).toBe(404);
|
||||||
}
|
}
|
||||||
done();
|
});
|
||||||
};
|
|
||||||
|
|
||||||
getStats('fishy').catch(callback);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Get stats by gamemode', async done => {
|
test('Get stats by gamemode', async () => {
|
||||||
const callback = (stats: Stats) => {
|
jest.setTimeout(30000);
|
||||||
expect(stats.skills).toStrictEqual({
|
const { skills } = await getStatsByGamemode('Lynx Titan');
|
||||||
overall: { rank: 1, level: 2277, xp: 4600000000 },
|
expect(skills).toMatchObject({
|
||||||
attack: { rank: 15, level: 99, xp: 200000000 },
|
overall: { rank: expect.any(Number), level: 2277, xp: 4600000000 },
|
||||||
defence: { rank: 27, level: 99, xp: 200000000 },
|
attack: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||||
strength: { rank: 18, level: 99, xp: 200000000 },
|
defence: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||||
hitpoints: { rank: 7, level: 99, xp: 200000000 },
|
strength: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||||
ranged: { rank: 7, level: 99, xp: 200000000 },
|
hitpoints: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||||
prayer: { rank: 11, level: 99, xp: 200000000 },
|
ranged: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||||
magic: { rank: 32, level: 99, xp: 200000000 },
|
prayer: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||||
cooking: { rank: 158, level: 99, xp: 200000000 },
|
magic: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||||
woodcutting: { rank: 15, level: 99, xp: 200000000 },
|
cooking: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||||
fletching: { rank: 12, level: 99, xp: 200000000 },
|
woodcutting: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||||
fishing: { rank: 9, level: 99, xp: 200000000 },
|
fletching: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||||
firemaking: { rank: 49, level: 99, xp: 200000000 },
|
fishing: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||||
crafting: { rank: 4, level: 99, xp: 200000000 },
|
firemaking: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||||
smithing: { rank: 3, level: 99, xp: 200000000 },
|
crafting: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||||
mining: { rank: 25, level: 99, xp: 200000000 },
|
smithing: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||||
herblore: { rank: 5, level: 99, xp: 200000000 },
|
mining: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||||
agility: { rank: 24, level: 99, xp: 200000000 },
|
herblore: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||||
thieving: { rank: 12, level: 99, xp: 200000000 },
|
agility: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||||
slayer: { rank: 2, level: 99, xp: 200000000 },
|
thieving: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||||
farming: { rank: 19, level: 99, xp: 200000000 },
|
slayer: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||||
runecraft: { rank: 7, level: 99, xp: 200000000 },
|
farming: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||||
hunter: { rank: 4, level: 99, xp: 200000000 },
|
runecraft: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||||
construction: { rank: 4, level: 99, xp: 200000000 },
|
hunter: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||||
});
|
construction: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||||
done();
|
});
|
||||||
};
|
|
||||||
|
|
||||||
getStatsByGamemode('Lynx Titan').then(callback);
|
|
||||||
});
|
});
|
||||||
|
@@ -13,6 +13,9 @@ import {
|
|||||||
PlayerSkillRow,
|
PlayerSkillRow,
|
||||||
ActivityName,
|
ActivityName,
|
||||||
PlayerActivityRow,
|
PlayerActivityRow,
|
||||||
|
Bosses,
|
||||||
|
LeagueStats,
|
||||||
|
Boss,
|
||||||
} from './types';
|
} from './types';
|
||||||
import {
|
import {
|
||||||
getStatsURL,
|
getStatsURL,
|
||||||
@@ -26,6 +29,7 @@ import {
|
|||||||
numberFromElement,
|
numberFromElement,
|
||||||
rsnFromElement,
|
rsnFromElement,
|
||||||
getActivityPageURL,
|
getActivityPageURL,
|
||||||
|
BOSSES,
|
||||||
} from './utils';
|
} from './utils';
|
||||||
|
|
||||||
export async function getStats(rsn: string): Promise<Player> {
|
export async function getStats(rsn: string): Promise<Player> {
|
||||||
@@ -95,10 +99,10 @@ export async function getStats(rsn: string): Promise<Player> {
|
|||||||
throw Error('Player not found');
|
throw Error('Player not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getStatsByGamemode(
|
export async function getStatsByGamemode<T extends Gamemode = 'main'>(
|
||||||
rsn: string,
|
rsn: string,
|
||||||
mode: Gamemode = 'main'
|
mode: T = 'main' as T
|
||||||
): Promise<Stats> {
|
): Promise<T extends 'leagues' ? LeagueStats : Stats> {
|
||||||
if (typeof rsn !== 'string') {
|
if (typeof rsn !== 'string') {
|
||||||
throw Error('RSN must be a string');
|
throw Error('RSN must be a string');
|
||||||
} else if (!/^[a-zA-Z0-9 _]+$/.test(rsn)) {
|
} else if (!/^[a-zA-Z0-9 _]+$/.test(rsn)) {
|
||||||
@@ -112,7 +116,7 @@ export async function getStatsByGamemode(
|
|||||||
if (response.status !== 200) {
|
if (response.status !== 200) {
|
||||||
throw Error('Player not found');
|
throw Error('Player not found');
|
||||||
}
|
}
|
||||||
const stats: Stats = parseStats(response.data);
|
const stats = parseStats(response.data, mode);
|
||||||
|
|
||||||
return stats;
|
return stats;
|
||||||
}
|
}
|
||||||
@@ -209,7 +213,10 @@ export async function getRSNFormat(rsn: string): Promise<string> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function parseStats(csv: string): Stats {
|
export function parseStats<T extends Gamemode = 'main'>(
|
||||||
|
csv: string,
|
||||||
|
mode: T = 'main' as T
|
||||||
|
): T extends 'leagues' ? LeagueStats : Stats {
|
||||||
const splitCSV = csv
|
const splitCSV = csv
|
||||||
.split('\n')
|
.split('\n')
|
||||||
.filter(entry => !!entry)
|
.filter(entry => !!entry)
|
||||||
@@ -238,43 +245,69 @@ export function parseStats(csv: string): Stats {
|
|||||||
return activity;
|
return activity;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const [lp] = activityObjects.splice(0, 1);
|
||||||
const bhObjects = activityObjects.splice(0, BH_MODES.length);
|
const bhObjects = activityObjects.splice(0, BH_MODES.length);
|
||||||
const [lms] = activityObjects.splice(0, 1);
|
|
||||||
const clueObjects = activityObjects.splice(0, CLUES.length);
|
const clueObjects = activityObjects.splice(0, CLUES.length);
|
||||||
|
const [lms] = activityObjects.splice(0, 1);
|
||||||
|
const bossObjects = activityObjects.splice(0, BOSSES.length);
|
||||||
|
|
||||||
const skills: Skills = skillObjects.reduce<Skills>(
|
const skills: Skills = skillObjects.reduce<Skills>((prev, curr, index) => {
|
||||||
(prev, curr, index) => {
|
const newSkills = { ...prev };
|
||||||
const newSkills = { ...prev };
|
newSkills[SKILLS[index]] = curr;
|
||||||
newSkills[SKILLS[index]] = curr;
|
return newSkills;
|
||||||
return newSkills;
|
}, {} as Skills);
|
||||||
},
|
|
||||||
{} as Skills
|
const bh: BH = bhObjects.reduce<BH>((prev, curr, index) => {
|
||||||
|
const newBH = { ...prev };
|
||||||
|
newBH[BH_MODES[index]] = curr;
|
||||||
|
return newBH;
|
||||||
|
}, {} as BH);
|
||||||
|
|
||||||
|
const clues: Clues = clueObjects.reduce<Clues>((prev, curr, index) => {
|
||||||
|
const newClues = { ...prev };
|
||||||
|
newClues[CLUES[index]] = curr;
|
||||||
|
return newClues;
|
||||||
|
}, {} as Clues);
|
||||||
|
|
||||||
|
// TODO Remove as soon as Jagex's API is fixed
|
||||||
|
const brokenBosses: Boss[] = ['callisto', 'cerberus'];
|
||||||
|
const TEMPBOSSES: Boss[] = BOSSES.reduce<Boss[]>(
|
||||||
|
(prev, curr) => (brokenBosses.includes(curr) ? prev : [...prev, curr]),
|
||||||
|
[]
|
||||||
);
|
);
|
||||||
|
|
||||||
const bh: BH = bhObjects.reduce<BH>(
|
const bosses: Bosses = bossObjects.reduce<Bosses>((prev, curr, index) => {
|
||||||
(prev, curr, index) => {
|
const newBosses = { ...prev };
|
||||||
const newBH = { ...prev };
|
newBosses[TEMPBOSSES[index]] = brokenBosses.includes(BOSSES[index])
|
||||||
newBH[BH_MODES[index]] = curr;
|
? { rank: -1, score: -1 }
|
||||||
return newBH;
|
: curr;
|
||||||
},
|
return newBosses;
|
||||||
{} as BH
|
}, {} as Bosses);
|
||||||
);
|
|
||||||
|
|
||||||
const clues: Clues = clueObjects.reduce<Clues>(
|
// TODO Remove as soon as Jagex's API is fixed
|
||||||
(prev, curr, index) => {
|
brokenBosses.forEach(broken => {
|
||||||
const newClues = { ...prev };
|
bosses[broken] = {
|
||||||
newClues[CLUES[index]] = curr;
|
rank: -1,
|
||||||
return newClues;
|
score: -1,
|
||||||
},
|
};
|
||||||
{} as Clues
|
});
|
||||||
);
|
|
||||||
|
|
||||||
const stats: Stats = {
|
const stats: Stats = {
|
||||||
skills,
|
skills,
|
||||||
bh,
|
bh,
|
||||||
lms,
|
lms,
|
||||||
clues,
|
clues,
|
||||||
|
bosses,
|
||||||
};
|
};
|
||||||
|
|
||||||
return stats;
|
const leagueStats: LeagueStats = {
|
||||||
|
skills,
|
||||||
|
lp,
|
||||||
|
clues,
|
||||||
|
bosses,
|
||||||
|
};
|
||||||
|
|
||||||
|
return (mode === 'leagues' ? leagueStats : stats) as T extends 'leagues'
|
||||||
|
? LeagueStats
|
||||||
|
: Stats;
|
||||||
}
|
}
|
||||||
|
64
src/types.ts
64
src/types.ts
@@ -1,4 +1,11 @@
|
|||||||
export type Gamemode = 'main' | 'iron' | 'hc' | 'ult' | 'dmm' | 'sdmm' | 'dmmt';
|
export type Gamemode =
|
||||||
|
| 'main'
|
||||||
|
| 'iron'
|
||||||
|
| 'hc'
|
||||||
|
| 'ult'
|
||||||
|
| 'dmm'
|
||||||
|
| 'dmmt'
|
||||||
|
| 'leagues';
|
||||||
|
|
||||||
export interface Skill {
|
export interface Skill {
|
||||||
rank: number;
|
rank: number;
|
||||||
@@ -54,6 +61,53 @@ export type BHType = 'rogue' | 'hunter';
|
|||||||
|
|
||||||
export type BH = { [Type in BHType]: Activity };
|
export type BH = { [Type in BHType]: Activity };
|
||||||
|
|
||||||
|
export type Boss =
|
||||||
|
| 'abyssalsire'
|
||||||
|
| 'alchemicalhydra'
|
||||||
|
| 'barrowschests'
|
||||||
|
| 'bryophyta'
|
||||||
|
| 'callisto'
|
||||||
|
| 'cerberus'
|
||||||
|
| 'chambersofxeric'
|
||||||
|
| 'chambersofxericchallengemode'
|
||||||
|
| 'chaoselemental'
|
||||||
|
| 'chaosfanatic'
|
||||||
|
| 'commanderzilyana'
|
||||||
|
| 'corporealbeast'
|
||||||
|
| 'crazyarchaeologist'
|
||||||
|
| 'dagannothprime'
|
||||||
|
| 'dagannothrex'
|
||||||
|
| 'dagannothsupreme'
|
||||||
|
| 'derangedarchaeologist'
|
||||||
|
| 'generalgraardor'
|
||||||
|
| 'giantmole'
|
||||||
|
| 'grotesqueguardians'
|
||||||
|
| 'hespori'
|
||||||
|
| 'kalphitequeen'
|
||||||
|
| 'kingblackdragon'
|
||||||
|
| 'kraken'
|
||||||
|
| 'kreearra'
|
||||||
|
| 'kriltsutsaroth'
|
||||||
|
| 'mimic'
|
||||||
|
| 'obor'
|
||||||
|
| 'sarachnis'
|
||||||
|
| 'scorpia'
|
||||||
|
| 'skotizo'
|
||||||
|
| 'gauntlet'
|
||||||
|
| 'corruptedgauntlet'
|
||||||
|
| 'theatreofblood'
|
||||||
|
| 'thermonuclearsmokedevil'
|
||||||
|
| 'tzkalzuk'
|
||||||
|
| 'tztokjad'
|
||||||
|
| 'venenatis'
|
||||||
|
| 'vetion'
|
||||||
|
| 'vorkath'
|
||||||
|
| 'wintertodt'
|
||||||
|
| 'zalcano'
|
||||||
|
| 'zulrah';
|
||||||
|
|
||||||
|
export type Bosses = { [Type in Boss]: Activity };
|
||||||
|
|
||||||
export type ActivityName =
|
export type ActivityName =
|
||||||
| 'hunterbh'
|
| 'hunterbh'
|
||||||
| 'roguebh'
|
| 'roguebh'
|
||||||
@@ -64,13 +118,19 @@ export type ActivityName =
|
|||||||
| 'mediumclues'
|
| 'mediumclues'
|
||||||
| 'hardclues'
|
| 'hardclues'
|
||||||
| 'eliteclues'
|
| 'eliteclues'
|
||||||
| 'masterclues';
|
| 'masterclues'
|
||||||
|
| Boss;
|
||||||
|
|
||||||
export interface Stats {
|
export interface Stats {
|
||||||
skills: Skills;
|
skills: Skills;
|
||||||
clues: Clues;
|
clues: Clues;
|
||||||
bh: BH;
|
bh: BH;
|
||||||
lms: Activity;
|
lms: Activity;
|
||||||
|
bosses: Bosses;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface LeagueStats extends Omit<Stats, 'bh' | 'lms'> {
|
||||||
|
lp: Activity;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Modes = { [M in Gamemode]?: Stats };
|
export type Modes = { [M in Gamemode]?: Stats };
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { SkillName, ClueType, BHType, Gamemode } from '../types';
|
import { SkillName, ClueType, BHType, Gamemode, Boss } from '../types';
|
||||||
|
|
||||||
export const BASE_URL = 'http://services.runescape.com/m=hiscore_oldschool';
|
export const BASE_URL = 'http://services.runescape.com/m=hiscore_oldschool';
|
||||||
export const STATS_URL = 'index_lite.ws?player=';
|
export const STATS_URL = 'index_lite.ws?player=';
|
||||||
@@ -9,7 +9,7 @@ export const GAMEMODE_URL = {
|
|||||||
hc: '_hardcore_ironman/',
|
hc: '_hardcore_ironman/',
|
||||||
iron: '_ironman/',
|
iron: '_ironman/',
|
||||||
main: '/',
|
main: '/',
|
||||||
sdmm: '_seasonal/',
|
leagues: '_seasonal/',
|
||||||
ult: '_ultimate/',
|
ult: '_ultimate/',
|
||||||
};
|
};
|
||||||
export const SKILLS: SkillName[] = [
|
export const SKILLS: SkillName[] = [
|
||||||
@@ -66,6 +66,51 @@ export const GAMEMODES: Gamemode[] = [
|
|||||||
'hc',
|
'hc',
|
||||||
'ult',
|
'ult',
|
||||||
'dmm',
|
'dmm',
|
||||||
'sdmm',
|
|
||||||
'dmmt',
|
'dmmt',
|
||||||
|
'leagues',
|
||||||
|
];
|
||||||
|
export const BOSSES: Boss[] = [
|
||||||
|
'abyssalsire',
|
||||||
|
'alchemicalhydra',
|
||||||
|
'barrowschests',
|
||||||
|
'bryophyta',
|
||||||
|
'chambersofxeric',
|
||||||
|
'chambersofxericchallengemode',
|
||||||
|
'callisto',
|
||||||
|
'cerberus',
|
||||||
|
'chaoselemental',
|
||||||
|
'chaosfanatic',
|
||||||
|
'commanderzilyana',
|
||||||
|
'corporealbeast',
|
||||||
|
'crazyarchaeologist',
|
||||||
|
'dagannothprime',
|
||||||
|
'dagannothrex',
|
||||||
|
'dagannothsupreme',
|
||||||
|
'derangedarchaeologist',
|
||||||
|
'generalgraardor',
|
||||||
|
'giantmole',
|
||||||
|
'grotesqueguardians',
|
||||||
|
'hespori',
|
||||||
|
'kalphitequeen',
|
||||||
|
'kingblackdragon',
|
||||||
|
'kraken',
|
||||||
|
'kreearra',
|
||||||
|
'kriltsutsaroth',
|
||||||
|
'mimic',
|
||||||
|
'obor',
|
||||||
|
'sarachnis',
|
||||||
|
'scorpia',
|
||||||
|
'skotizo',
|
||||||
|
'gauntlet',
|
||||||
|
'corruptedgauntlet',
|
||||||
|
'theatreofblood',
|
||||||
|
'thermonuclearsmokedevil',
|
||||||
|
'tzkalzuk',
|
||||||
|
'tztokjad',
|
||||||
|
'venenatis',
|
||||||
|
'vetion',
|
||||||
|
'vorkath',
|
||||||
|
'wintertodt',
|
||||||
|
'zalcano',
|
||||||
|
'zulrah',
|
||||||
];
|
];
|
||||||
|
Reference in New Issue
Block a user