mirror of
https://github.com/maxswa/osrs-json-hiscores.git
synced 2025-10-15 10:19:04 +00:00
Compare commits
71 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
fd24890f67 | ||
![]() |
3ba434978a | ||
![]() |
44ecdf5434 | ||
![]() |
99fc97f05e | ||
![]() |
b3fc5846f3 | ||
![]() |
1deed9f450 | ||
![]() |
0be3f0b636 | ||
![]() |
ec1ed53669 | ||
![]() |
d0f5285470 | ||
![]() |
9c56e44344 | ||
![]() |
e5b3075ebd | ||
![]() |
8bb50b73b2 | ||
![]() |
cb482ad720 | ||
![]() |
0fbd85aa07 | ||
![]() |
e634b107b1 | ||
![]() |
29db21493c | ||
![]() |
b117cfcf41 | ||
![]() |
d895326d9f | ||
![]() |
1f7a25d421 | ||
![]() |
057812681b | ||
![]() |
ee510ec69a | ||
![]() |
6adcb02545 | ||
![]() |
dacbd90189 | ||
![]() |
3b502cb7cf | ||
![]() |
b3f81e66eb | ||
![]() |
01150b6234 | ||
![]() |
ca4d75f2c7 | ||
![]() |
03b2ef42d2 | ||
![]() |
7e2603b235 | ||
![]() |
92452e240c | ||
![]() |
d01b36422e | ||
![]() |
3bc1352838 | ||
![]() |
91066b5366 | ||
![]() |
4872d04301 | ||
![]() |
55312ba0fd | ||
![]() |
331a448503 | ||
![]() |
84c704a846 | ||
![]() |
561495632c | ||
![]() |
bdfdf1eb14 | ||
![]() |
e349776060 | ||
![]() |
546bc5acf7 | ||
![]() |
66528cd9d9 | ||
![]() |
99ea3fb722 | ||
![]() |
7f16d26e3c | ||
![]() |
ed9fcf47b3 | ||
![]() |
bb935bb6c9 | ||
![]() |
d046fffa9e | ||
![]() |
5483e54d78 | ||
![]() |
97532b0c03 | ||
![]() |
f9a56e2b3a | ||
![]() |
9f43f0c39f | ||
![]() |
d67ffa3e20 | ||
![]() |
7bdde9f5d1 | ||
![]() |
b4a50e69c8 | ||
![]() |
7935c5a523 | ||
![]() |
f1e2155428 | ||
![]() |
dd90fe1260 | ||
![]() |
12c4e530a2 | ||
![]() |
5a2b0d9ad8 | ||
![]() |
c43858eac1 | ||
![]() |
0d0081f4f6 | ||
![]() |
3570f0f07d | ||
![]() |
3ddda54e02 | ||
![]() |
388f01522a | ||
![]() |
24b3de2a29 | ||
![]() |
fc7897d4c7 | ||
![]() |
72ea31490f | ||
![]() |
66825955c1 | ||
![]() |
4b4bf8c702 | ||
![]() |
53981e7468 | ||
![]() |
a90e5b98dd |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
.idea/
|
||||
node_modules
|
||||
/lib
|
||||
/lib
|
||||
.vscode
|
92
README.md
92
README.md
@@ -5,22 +5,24 @@
|
||||
[](https://github.com/maxswa/osrs-json-hiscores/blob/master/src/types.ts)
|
||||
[](https://github.com/maxswa/osrs-json-hiscores/actions/workflows/main.yml?query=branch%3Amain)
|
||||
|
||||
**The Old School Runescape API wrapper that does more!**
|
||||
**The Old School RuneScape API wrapper that does more!**
|
||||
|
||||
## What it does
|
||||
|
||||
The official hiscores API for Old School Runescape (OSRS) returns CSV.
|
||||
This wrapper converts it to json and provides extra information about the given player. By comparing player info it infers the player's game mode, as well as any previous modes (de-ultimated, de-ironed and/or died as a hardcore ironman).
|
||||
The official hiscores API for Old School RuneScape (OSRS) can return CSV or a simple JSON array.
|
||||
This wrapper converts the hiscores data into a more usable JSON object and provides extra information about the given player. By comparing player info it infers the player's game mode, as well as any previous modes (de-ultimated, de-ironed and/or died as a hardcore ironman).
|
||||
|
||||
Additional functions are provided that screen-scrape the OSRS leaderboards and return a list of players as json.
|
||||
Additional functions are provided that screen-scrape the OSRS leaderboards and return a list of players as json. Also simple utility functions are provided to fetch the raw responses from Jagex's APIs, if desired.
|
||||
|
||||
`osrs-json-hiscores` has TypeScript support, with full definitions for all functions and custom data types.
|
||||
|
||||
---
|
||||
|
||||
### Disclaimer
|
||||
### ⚠ Disclaimer ⚠
|
||||
|
||||
Jagex does not provide `Access-Control-Allow-Origin` headers in their responses. This means that [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) will block all browser requests to their hiscores API. In order to get around this, osrs-json-hiscores should be installed on the server side and exposed to the front end via a simple API. Here is an example of this in use: [codesandbox.io/s/osrs-json-hiscores-demo](https://codesandbox.io/s/osrs-json-hiscores-demo-qz656)
|
||||
Jagex does not provide `Access-Control-Allow-Origin` headers in their responses. This means that [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) will block all browser requests to their hiscores API. In order to get around this, osrs-json-hiscores needs to be installed on the server side and exposed to the front end via a simple API. Here is an example of this in use: [codesandbox.io/s/osrs-json-hiscores-demo](https://codesandbox.io/s/osrs-json-hiscores-demo-qz656)
|
||||
|
||||
TLDR: You cannot use this library directly in your client side app e.g. React or Vue, you must set up a server which uses this lib internally and have your client fetch data from your server.
|
||||
|
||||
---
|
||||
|
||||
@@ -42,27 +44,14 @@ $ yarn add osrs-json-hiscores
|
||||
|
||||
Install the package and then import it into your project:
|
||||
|
||||
```javascript
|
||||
const hiscores = require('osrs-json-hiscores');
|
||||
```typescript
|
||||
import { getStatsByGamemode, getSkillPage } from 'osrs-json-hiscores';
|
||||
```
|
||||
|
||||
Once you import it you can call the functions asynchronously:
|
||||
|
||||
```javascript
|
||||
hiscores
|
||||
.getStats('Lynx Titan')
|
||||
.then((res) => console.log(res))
|
||||
.catch((err) => console.error(err));
|
||||
```
|
||||
|
||||
If you are using TypeScript or transpiling your JS you can use ES6 syntax:
|
||||
|
||||
```javascript
|
||||
import hiscores, { getSkillPage } from 'osrs-json-hiscores';
|
||||
|
||||
// ...
|
||||
|
||||
const stats = await hiscores.getStats('Lynx Titan');
|
||||
```typescript
|
||||
const stats = await getStatsByGamemode('Lynx Titan');
|
||||
const topPage = await getSkillPage('overall');
|
||||
```
|
||||
|
||||
@@ -81,9 +70,8 @@ const topPage = await getSkillPage('overall');
|
||||
|
||||
`getSkillPage` and `getActivityPage` require a skill / activity and optionally a gamemode and page:
|
||||
|
||||
```javascript
|
||||
hiscores
|
||||
.getSkillPage('attack', 'main', 1)
|
||||
```typescript
|
||||
getSkillPage('attack', 'main', 1)
|
||||
.then((res) => console.log(res))
|
||||
.catch((err) => console.error(err));
|
||||
```
|
||||
@@ -104,22 +92,25 @@ Activities consist of all levels of clue scrolls as well as minigames and bosses
|
||||
|
||||
### Minigames
|
||||
|
||||
| Minigame | Param |
|
||||
| ------------------------------- | :---------------: |
|
||||
| Bounty Hunter (Legacy - Rogue) | `rogueBH` |
|
||||
| Bounty Hunter (Legacy - Hunter) | `hunterBH` |
|
||||
| Bounty Hunter (Rogue) | `rogueBHV2` |
|
||||
| Bounty Hunter (Hunter) | `hunterBHV2` |
|
||||
| Last Man Standing | `lastManStanding` |
|
||||
| PvP Arena | `pvpArena` |
|
||||
| Soul Wars Zeal | `soulWarsZeal` |
|
||||
| Rifts Closed | `riftsClosed` |
|
||||
| Minigame | Param |
|
||||
| ------------------------------- | :-----------------: |
|
||||
| Bounty Hunter (Legacy - Rogue) | `rogueBH` |
|
||||
| Bounty Hunter (Legacy - Hunter) | `hunterBH` |
|
||||
| Bounty Hunter (Rogue) | `rogueBHV2` |
|
||||
| Bounty Hunter (Hunter) | `hunterBHV2` |
|
||||
| LMS - Rank | `lastManStanding` |
|
||||
| PvP Arena - Rank | `pvpArena` |
|
||||
| Soul Wars Zeal | `soulWarsZeal` |
|
||||
| Rifts closed | `riftsClosed` |
|
||||
| Colosseum Glory | `colosseumGlory` |
|
||||
| Collections Logged | `collectionsLogged` |
|
||||
|
||||
### Leagues
|
||||
### Points
|
||||
|
||||
| Activity | Param |
|
||||
| ------------- | :------------: |
|
||||
| League Points | `leaguePoints` |
|
||||
| Activity | Param |
|
||||
| -------------- | :-------------: |
|
||||
| League Points | `leaguePoints` |
|
||||
| Deadman Points | `deadmanPoints` |
|
||||
|
||||
### Bosses
|
||||
|
||||
@@ -127,6 +118,8 @@ Activities consist of all levels of clue scrolls as well as minigames and bosses
|
||||
| --------------------------------- | :----------------------------: |
|
||||
| Abyssal Sire | `abyssalSire` |
|
||||
| Alchemical Hydra | `alchemicalHydra` |
|
||||
| Amoxliatl | `amoxliatl` |
|
||||
| Araxxor | `araxxor` |
|
||||
| Artio | `artio` |
|
||||
| Barrows Chests | `barrows` |
|
||||
| Bryophyta | `bryophyta` |
|
||||
@@ -144,6 +137,7 @@ Activities consist of all levels of clue scrolls as well as minigames and bosses
|
||||
| Dagannoth Rex | `dagannothRex` |
|
||||
| Dagannoth Supreme | `dagannothSupreme` |
|
||||
| Deranged Archaeologist | `derangedArchaeologist` |
|
||||
| Duke Sucellus | `dukeSucellus` |
|
||||
| General Graardor | `generalGraardor` |
|
||||
| Giant Mole | `giantMole` |
|
||||
| Grotesque Guardians | `grotesqueGuardians` |
|
||||
@@ -153,19 +147,26 @@ Activities consist of all levels of clue scrolls as well as minigames and bosses
|
||||
| Kraken | `kraken` |
|
||||
| Kreearra | `kreeArra` |
|
||||
| K'ril Tsutsaroth | `krilTsutsaroth` |
|
||||
| Lunar Chests | `lunarChests` |
|
||||
| Mimic | `mimic` |
|
||||
| Nex | `nex` |
|
||||
| The Nightmare of Ashihama | `nightmare` |
|
||||
| Nightmare | `nightmare` |
|
||||
| Phosani's Nightmare | `phosanisNightmare` |
|
||||
| Obor | `obor` |
|
||||
| Phantom Muspah | `phantomMuspah` |
|
||||
| Sarachnis | `sarachnis` |
|
||||
| Scorpia | `scorpia` |
|
||||
| Scurrius | `scurrius` |
|
||||
| Skotizo | `skotizo` |
|
||||
| Sol Heredit | `solHeredit` |
|
||||
| Spindel | `spindel` |
|
||||
| Tempoross | `tempoross` |
|
||||
| The Gauntlet | `gauntlet` |
|
||||
| The Corrupted Gauntlet | `corruptedGauntlet` |
|
||||
| The Hueycoatl | `hueycoatl` |
|
||||
| The Leviathan | `leviathan` |
|
||||
| The Royal Titans | `royalTitans` |
|
||||
| The Whisperer | `whisperer` |
|
||||
| Theatre Of Blood | `theatreOfBlood` |
|
||||
| Theatre Of Blood: Hard Mode | `theatreOfBloodHardMode` |
|
||||
| Thermonuclear Smoke Devil | `thermonuclearSmokeDevil` |
|
||||
@@ -173,6 +174,7 @@ Activities consist of all levels of clue scrolls as well as minigames and bosses
|
||||
| Tombs of Amascut: Expert Mode | `tombsOfAmascutExpertMode` |
|
||||
| TzKal-Zuk | `tzKalZuk` |
|
||||
| TzTok-Jad | `tzTokJad` |
|
||||
| Vardorvis | `vardorvis` |
|
||||
| Venenatis | `venenatis` |
|
||||
| Vetion | `vetion` |
|
||||
| Vorkath | `vorkath` |
|
||||
@@ -184,7 +186,7 @@ Activities consist of all levels of clue scrolls as well as minigames and bosses
|
||||
|
||||
`getStats` returns a player object that looks like this:
|
||||
|
||||
```javascript
|
||||
```typescript
|
||||
{
|
||||
name: 'Lynx Titan',
|
||||
mode: 'main',
|
||||
@@ -205,6 +207,8 @@ Activities consist of all levels of clue scrolls as well as minigames and bosses
|
||||
pvpArena: {},
|
||||
soulWarsZeal: {},
|
||||
riftsClosed: {},
|
||||
colosseumGlory: {},
|
||||
collectionsLogged: {},
|
||||
bosses: {}
|
||||
}
|
||||
}
|
||||
@@ -212,7 +216,7 @@ Activities consist of all levels of clue scrolls as well as minigames and bosses
|
||||
|
||||
`getSkillPage` returns and array of 25 players (This represents a page on the hiscores):
|
||||
|
||||
```javascript
|
||||
```typescript
|
||||
[
|
||||
{ rank: 1, name: 'Lynx Titan', level: 2277, xp: 4600000000, dead: false },
|
||||
{},
|
||||
@@ -225,7 +229,7 @@ Activities consist of all levels of clue scrolls as well as minigames and bosses
|
||||
|
||||
Get the properly formatted name of any skill, boss, clue or other activity:
|
||||
|
||||
```javascript
|
||||
```typescript
|
||||
// kril === "K'ril Tsutsaroth"
|
||||
const kril = FORMATTED_BOSS_NAMES['krilTsutsaroth'];
|
||||
```
|
||||
|
2517
__tests__/attackTopPage.html
vendored
2517
__tests__/attackTopPage.html
vendored
File diff suppressed because it is too large
Load Diff
2580
__tests__/b0atyNamePage.html
vendored
2580
__tests__/b0atyNamePage.html
vendored
File diff suppressed because it is too large
Load Diff
108
__tests__/b0atyStats.csv
Normal file
108
__tests__/b0atyStats.csv
Normal file
@@ -0,0 +1,108 @@
|
||||
2210,2277,1150073045
|
||||
23988,99,33320012
|
||||
3114,99,51215128
|
||||
1203,99,200000000
|
||||
1372,99,196290925
|
||||
3458,99,159426771
|
||||
2746,99,17744970
|
||||
2031,99,91566360
|
||||
161852,99,13386665
|
||||
25801,99,19461878
|
||||
64826,99,13473417
|
||||
26528,99,16672481
|
||||
20829,99,19483653
|
||||
58378,99,14103220
|
||||
13188,99,16573909
|
||||
36283,99,15061037
|
||||
17137,99,14670565
|
||||
8751,99,16169665
|
||||
60803,99,14390315
|
||||
1718,99,57850681
|
||||
2117,99,110369178
|
||||
5540,99,22739567
|
||||
22326,99,18052465
|
||||
1467,99,18050183
|
||||
-1,-1
|
||||
-1,-1
|
||||
38135,10
|
||||
19368,3
|
||||
146220,8
|
||||
100923,7
|
||||
433,9802
|
||||
1542,825
|
||||
158,6000
|
||||
2572,1606
|
||||
47979,311
|
||||
1081,460
|
||||
880,600
|
||||
4258,6785
|
||||
-1,-1
|
||||
7596,14780
|
||||
8124,1060
|
||||
10438,43487
|
||||
1114,1155
|
||||
3497,2192
|
||||
3204,4796
|
||||
1087,984
|
||||
2230,2328
|
||||
51533,143
|
||||
4243,1830
|
||||
256985,5
|
||||
54424,293
|
||||
114691,58
|
||||
11700,2657
|
||||
211708,34
|
||||
1779,736
|
||||
24958,215
|
||||
46504,116
|
||||
66096,287
|
||||
3133,2000
|
||||
26682,198
|
||||
19337,1078
|
||||
25021,1062
|
||||
19290,1088
|
||||
89474,25
|
||||
7535,1320
|
||||
23251,1228
|
||||
82016,477
|
||||
876,3642
|
||||
7073,310
|
||||
2476,2046
|
||||
55411,580
|
||||
68801,2899
|
||||
4608,1740
|
||||
3079,1444
|
||||
8344,324
|
||||
540,53
|
||||
38395,626
|
||||
4176,749
|
||||
5519,500
|
||||
1394,217
|
||||
26127,379
|
||||
49730,249
|
||||
57206,91
|
||||
6106,1245
|
||||
185920,29
|
||||
3232,49
|
||||
4276,1569
|
||||
57314,273
|
||||
256794,7
|
||||
113862,201
|
||||
1969,538
|
||||
12346,671
|
||||
5606,149
|
||||
550,2450
|
||||
25557,310
|
||||
1391,538
|
||||
9325,3066
|
||||
131996,37
|
||||
214,1720
|
||||
8902,7
|
||||
148385,8
|
||||
6120,2113
|
||||
287,7096
|
||||
97368,51
|
||||
15591,2780
|
||||
1000405,67
|
||||
213696,25
|
||||
240082,340
|
Can't render this file because it has a wrong number of fields in line 25.
|
678
__tests__/b0atyStats.json
Normal file
678
__tests__/b0atyStats.json
Normal file
@@ -0,0 +1,678 @@
|
||||
{
|
||||
"skills": [
|
||||
{
|
||||
"id": 0,
|
||||
"name": "Overall",
|
||||
"rank": 2210,
|
||||
"level": 2277,
|
||||
"xp": 1150073045
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"name": "Attack",
|
||||
"rank": 23988,
|
||||
"level": 99,
|
||||
"xp": 33320012
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"name": "Defence",
|
||||
"rank": 3114,
|
||||
"level": 99,
|
||||
"xp": 51215128
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"name": "Strength",
|
||||
"rank": 1203,
|
||||
"level": 99,
|
||||
"xp": 200000000
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"name": "Hitpoints",
|
||||
"rank": 1372,
|
||||
"level": 99,
|
||||
"xp": 196290925
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"name": "Ranged",
|
||||
"rank": 3458,
|
||||
"level": 99,
|
||||
"xp": 159426771
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"name": "Prayer",
|
||||
"rank": 2746,
|
||||
"level": 99,
|
||||
"xp": 17744970
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"name": "Magic",
|
||||
"rank": 2031,
|
||||
"level": 99,
|
||||
"xp": 91566360
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
"name": "Cooking",
|
||||
"rank": 161852,
|
||||
"level": 99,
|
||||
"xp": 13386665
|
||||
},
|
||||
{
|
||||
"id": 9,
|
||||
"name": "Woodcutting",
|
||||
"rank": 25801,
|
||||
"level": 99,
|
||||
"xp": 19461878
|
||||
},
|
||||
{
|
||||
"id": 10,
|
||||
"name": "Fletching",
|
||||
"rank": 64826,
|
||||
"level": 99,
|
||||
"xp": 13473417
|
||||
},
|
||||
{
|
||||
"id": 11,
|
||||
"name": "Fishing",
|
||||
"rank": 26528,
|
||||
"level": 99,
|
||||
"xp": 16672481
|
||||
},
|
||||
{
|
||||
"id": 12,
|
||||
"name": "Firemaking",
|
||||
"rank": 20829,
|
||||
"level": 99,
|
||||
"xp": 19483653
|
||||
},
|
||||
{
|
||||
"id": 13,
|
||||
"name": "Crafting",
|
||||
"rank": 58378,
|
||||
"level": 99,
|
||||
"xp": 14103220
|
||||
},
|
||||
{
|
||||
"id": 14,
|
||||
"name": "Smithing",
|
||||
"rank": 13188,
|
||||
"level": 99,
|
||||
"xp": 16573909
|
||||
},
|
||||
{
|
||||
"id": 15,
|
||||
"name": "Mining",
|
||||
"rank": 36283,
|
||||
"level": 99,
|
||||
"xp": 15061037
|
||||
},
|
||||
{
|
||||
"id": 16,
|
||||
"name": "Herblore",
|
||||
"rank": 17137,
|
||||
"level": 99,
|
||||
"xp": 14670565
|
||||
},
|
||||
{
|
||||
"id": 17,
|
||||
"name": "Agility",
|
||||
"rank": 8751,
|
||||
"level": 99,
|
||||
"xp": 16169665
|
||||
},
|
||||
{
|
||||
"id": 18,
|
||||
"name": "Thieving",
|
||||
"rank": 60803,
|
||||
"level": 99,
|
||||
"xp": 14390315
|
||||
},
|
||||
{
|
||||
"id": 19,
|
||||
"name": "Slayer",
|
||||
"rank": 1718,
|
||||
"level": 99,
|
||||
"xp": 57850681
|
||||
},
|
||||
{
|
||||
"id": 20,
|
||||
"name": "Farming",
|
||||
"rank": 2117,
|
||||
"level": 99,
|
||||
"xp": 110369178
|
||||
},
|
||||
{
|
||||
"id": 21,
|
||||
"name": "Runecraft",
|
||||
"rank": 5540,
|
||||
"level": 99,
|
||||
"xp": 22739567
|
||||
},
|
||||
{
|
||||
"id": 22,
|
||||
"name": "Hunter",
|
||||
"rank": 22326,
|
||||
"level": 99,
|
||||
"xp": 18052465
|
||||
},
|
||||
{
|
||||
"id": 23,
|
||||
"name": "Construction",
|
||||
"rank": 1467,
|
||||
"level": 99,
|
||||
"xp": 18050183
|
||||
}
|
||||
],
|
||||
"activities": [
|
||||
{
|
||||
"id": 0,
|
||||
"name": "League Points",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"name": "Deadman Points",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"name": "Bounty Hunter - Hunter",
|
||||
"rank": 38135,
|
||||
"score": 10
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"name": "Bounty Hunter - Rogue",
|
||||
"rank": 19368,
|
||||
"score": 3
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"name": "Bounty Hunter (Legacy) - Hunter",
|
||||
"rank": 146220,
|
||||
"score": 8
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"name": "Bounty Hunter (Legacy) - Rogue",
|
||||
"rank": 100923,
|
||||
"score": 7
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"name": "Clue Scrolls (all)",
|
||||
"rank": 433,
|
||||
"score": 9802
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"name": "Clue Scrolls (beginner)",
|
||||
"rank": 1542,
|
||||
"score": 825
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
"name": "Clue Scrolls (easy)",
|
||||
"rank": 158,
|
||||
"score": 6000
|
||||
},
|
||||
{
|
||||
"id": 9,
|
||||
"name": "Clue Scrolls (medium)",
|
||||
"rank": 2572,
|
||||
"score": 1606
|
||||
},
|
||||
{
|
||||
"id": 10,
|
||||
"name": "Clue Scrolls (hard)",
|
||||
"rank": 47979,
|
||||
"score": 311
|
||||
},
|
||||
{
|
||||
"id": 11,
|
||||
"name": "Clue Scrolls (elite)",
|
||||
"rank": 1081,
|
||||
"score": 460
|
||||
},
|
||||
{
|
||||
"id": 12,
|
||||
"name": "Clue Scrolls (master)",
|
||||
"rank": 880,
|
||||
"score": 600
|
||||
},
|
||||
{
|
||||
"id": 13,
|
||||
"name": "LMS - Rank",
|
||||
"rank": 4258,
|
||||
"score": 6785
|
||||
},
|
||||
{
|
||||
"id": 14,
|
||||
"name": "PvP Arena - Rank",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 15,
|
||||
"name": "Soul Wars Zeal",
|
||||
"rank": 7596,
|
||||
"score": 14780
|
||||
},
|
||||
{
|
||||
"id": 16,
|
||||
"name": "Rifts closed",
|
||||
"rank": 8124,
|
||||
"score": 1060
|
||||
},
|
||||
{
|
||||
"id": 17,
|
||||
"name": "Colosseum Glory",
|
||||
"rank": 10438,
|
||||
"score": 43487
|
||||
},
|
||||
{
|
||||
"id": 18,
|
||||
"name": "Collections Logged",
|
||||
"rank": 1114,
|
||||
"score": 1155
|
||||
},
|
||||
{
|
||||
"id": 19,
|
||||
"name": "Abyssal Sire",
|
||||
"rank": 3497,
|
||||
"score": 2192
|
||||
},
|
||||
{
|
||||
"id": 20,
|
||||
"name": "Alchemical Hydra",
|
||||
"rank": 3204,
|
||||
"score": 4796
|
||||
},
|
||||
{
|
||||
"id": 21,
|
||||
"name": "Amoxliatl",
|
||||
"rank": 1087,
|
||||
"score": 984
|
||||
},
|
||||
{
|
||||
"id": 22,
|
||||
"name": "Araxxor",
|
||||
"rank": 2230,
|
||||
"score": 2328
|
||||
},
|
||||
{
|
||||
"id": 23,
|
||||
"name": "Artio",
|
||||
"rank": 51533,
|
||||
"score": 143
|
||||
},
|
||||
{
|
||||
"id": 24,
|
||||
"name": "Barrows Chests",
|
||||
"rank": 4243,
|
||||
"score": 1830
|
||||
},
|
||||
{
|
||||
"id": 25,
|
||||
"name": "Bryophyta",
|
||||
"rank": 256985,
|
||||
"score": 5
|
||||
},
|
||||
{
|
||||
"id": 26,
|
||||
"name": "Callisto",
|
||||
"rank": 54424,
|
||||
"score": 293
|
||||
},
|
||||
{
|
||||
"id": 27,
|
||||
"name": "Calvar'ion",
|
||||
"rank": 114691,
|
||||
"score": 58
|
||||
},
|
||||
{
|
||||
"id": 28,
|
||||
"name": "Cerberus",
|
||||
"rank": 11700,
|
||||
"score": 2657
|
||||
},
|
||||
{
|
||||
"id": 29,
|
||||
"name": "Chambers of Xeric",
|
||||
"rank": 211708,
|
||||
"score": 34
|
||||
},
|
||||
{
|
||||
"id": 30,
|
||||
"name": "Chambers of Xeric: Challenge Mode",
|
||||
"rank": 1779,
|
||||
"score": 736
|
||||
},
|
||||
{
|
||||
"id": 31,
|
||||
"name": "Chaos Elemental",
|
||||
"rank": 24958,
|
||||
"score": 215
|
||||
},
|
||||
{
|
||||
"id": 32,
|
||||
"name": "Chaos Fanatic",
|
||||
"rank": 46504,
|
||||
"score": 116
|
||||
},
|
||||
{
|
||||
"id": 33,
|
||||
"name": "Commander Zilyana",
|
||||
"rank": 66096,
|
||||
"score": 287
|
||||
},
|
||||
{
|
||||
"id": 34,
|
||||
"name": "Corporeal Beast",
|
||||
"rank": 3133,
|
||||
"score": 2000
|
||||
},
|
||||
{
|
||||
"id": 35,
|
||||
"name": "Crazy Archaeologist",
|
||||
"rank": 26682,
|
||||
"score": 198
|
||||
},
|
||||
{
|
||||
"id": 36,
|
||||
"name": "Dagannoth Prime",
|
||||
"rank": 19337,
|
||||
"score": 1078
|
||||
},
|
||||
{
|
||||
"id": 37,
|
||||
"name": "Dagannoth Rex",
|
||||
"rank": 25021,
|
||||
"score": 1062
|
||||
},
|
||||
{
|
||||
"id": 38,
|
||||
"name": "Dagannoth Supreme",
|
||||
"rank": 19290,
|
||||
"score": 1088
|
||||
},
|
||||
{
|
||||
"id": 39,
|
||||
"name": "Deranged Archaeologist",
|
||||
"rank": 89474,
|
||||
"score": 25
|
||||
},
|
||||
{
|
||||
"id": 40,
|
||||
"name": "Duke Sucellus",
|
||||
"rank": 7535,
|
||||
"score": 1320
|
||||
},
|
||||
{
|
||||
"id": 41,
|
||||
"name": "General Graardor",
|
||||
"rank": 23251,
|
||||
"score": 1228
|
||||
},
|
||||
{
|
||||
"id": 42,
|
||||
"name": "Giant Mole",
|
||||
"rank": 82016,
|
||||
"score": 477
|
||||
},
|
||||
{
|
||||
"id": 43,
|
||||
"name": "Grotesque Guardians",
|
||||
"rank": 876,
|
||||
"score": 3642
|
||||
},
|
||||
{
|
||||
"id": 44,
|
||||
"name": "Hespori",
|
||||
"rank": 7073,
|
||||
"score": 310
|
||||
},
|
||||
{
|
||||
"id": 45,
|
||||
"name": "Kalphite Queen",
|
||||
"rank": 2476,
|
||||
"score": 2046
|
||||
},
|
||||
{
|
||||
"id": 46,
|
||||
"name": "King Black Dragon",
|
||||
"rank": 55411,
|
||||
"score": 580
|
||||
},
|
||||
{
|
||||
"id": 47,
|
||||
"name": "Kraken",
|
||||
"rank": 68801,
|
||||
"score": 2899
|
||||
},
|
||||
{
|
||||
"id": 48,
|
||||
"name": "Kree'Arra",
|
||||
"rank": 4608,
|
||||
"score": 1740
|
||||
},
|
||||
{
|
||||
"id": 49,
|
||||
"name": "K'ril Tsutsaroth",
|
||||
"rank": 3079,
|
||||
"score": 1444
|
||||
},
|
||||
{
|
||||
"id": 50,
|
||||
"name": "Lunar Chests",
|
||||
"rank": 8344,
|
||||
"score": 324
|
||||
},
|
||||
{
|
||||
"id": 51,
|
||||
"name": "Mimic",
|
||||
"rank": 540,
|
||||
"score": 53
|
||||
},
|
||||
{
|
||||
"id": 52,
|
||||
"name": "Nex",
|
||||
"rank": 38395,
|
||||
"score": 626
|
||||
},
|
||||
{
|
||||
"id": 53,
|
||||
"name": "Nightmare",
|
||||
"rank": 4176,
|
||||
"score": 749
|
||||
},
|
||||
{
|
||||
"id": 54,
|
||||
"name": "Phosani's Nightmare",
|
||||
"rank": 5519,
|
||||
"score": 500
|
||||
},
|
||||
{
|
||||
"id": 55,
|
||||
"name": "Obor",
|
||||
"rank": 1394,
|
||||
"score": 217
|
||||
},
|
||||
{
|
||||
"id": 56,
|
||||
"name": "Phantom Muspah",
|
||||
"rank": 26127,
|
||||
"score": 379
|
||||
},
|
||||
{
|
||||
"id": 57,
|
||||
"name": "Sarachnis",
|
||||
"rank": 49730,
|
||||
"score": 249
|
||||
},
|
||||
{
|
||||
"id": 58,
|
||||
"name": "Scorpia",
|
||||
"rank": 57206,
|
||||
"score": 91
|
||||
},
|
||||
{
|
||||
"id": 59,
|
||||
"name": "Scurrius",
|
||||
"rank": 6106,
|
||||
"score": 1245
|
||||
},
|
||||
{
|
||||
"id": 60,
|
||||
"name": "Skotizo",
|
||||
"rank": 185920,
|
||||
"score": 29
|
||||
},
|
||||
{
|
||||
"id": 61,
|
||||
"name": "Sol Heredit",
|
||||
"rank": 3232,
|
||||
"score": 49
|
||||
},
|
||||
{
|
||||
"id": 62,
|
||||
"name": "Spindel",
|
||||
"rank": 4276,
|
||||
"score": 1569
|
||||
},
|
||||
{
|
||||
"id": 63,
|
||||
"name": "Tempoross",
|
||||
"rank": 57314,
|
||||
"score": 273
|
||||
},
|
||||
{
|
||||
"id": 64,
|
||||
"name": "The Gauntlet",
|
||||
"rank": 256794,
|
||||
"score": 7
|
||||
},
|
||||
{
|
||||
"id": 65,
|
||||
"name": "The Corrupted Gauntlet",
|
||||
"rank": 113862,
|
||||
"score": 201
|
||||
},
|
||||
{
|
||||
"id": 66,
|
||||
"name": "The Hueycoatl",
|
||||
"rank": 1969,
|
||||
"score": 538
|
||||
},
|
||||
{
|
||||
"id": 67,
|
||||
"name": "The Leviathan",
|
||||
"rank": 12346,
|
||||
"score": 671
|
||||
},
|
||||
{
|
||||
"id": 68,
|
||||
"name": "The Royal Titans",
|
||||
"rank": 5606,
|
||||
"score": 149
|
||||
},
|
||||
{
|
||||
"id": 69,
|
||||
"name": "The Whisperer",
|
||||
"rank": 550,
|
||||
"score": 2450
|
||||
},
|
||||
{
|
||||
"id": 70,
|
||||
"name": "Theatre of Blood",
|
||||
"rank": 25557,
|
||||
"score": 310
|
||||
},
|
||||
{
|
||||
"id": 71,
|
||||
"name": "Theatre of Blood: Hard Mode",
|
||||
"rank": 1391,
|
||||
"score": 538
|
||||
},
|
||||
{
|
||||
"id": 72,
|
||||
"name": "Thermonuclear Smoke Devil",
|
||||
"rank": 9325,
|
||||
"score": 3066
|
||||
},
|
||||
{
|
||||
"id": 73,
|
||||
"name": "Tombs of Amascut",
|
||||
"rank": 131996,
|
||||
"score": 37
|
||||
},
|
||||
{
|
||||
"id": 74,
|
||||
"name": "Tombs of Amascut: Expert Mode",
|
||||
"rank": 214,
|
||||
"score": 1720
|
||||
},
|
||||
{
|
||||
"id": 75,
|
||||
"name": "TzKal-Zuk",
|
||||
"rank": 8902,
|
||||
"score": 7
|
||||
},
|
||||
{
|
||||
"id": 76,
|
||||
"name": "TzTok-Jad",
|
||||
"rank": 148385,
|
||||
"score": 8
|
||||
},
|
||||
{
|
||||
"id": 77,
|
||||
"name": "Vardorvis",
|
||||
"rank": 6120,
|
||||
"score": 2113
|
||||
},
|
||||
{
|
||||
"id": 78,
|
||||
"name": "Venenatis",
|
||||
"rank": 287,
|
||||
"score": 7096
|
||||
},
|
||||
{
|
||||
"id": 79,
|
||||
"name": "Vet'ion",
|
||||
"rank": 97368,
|
||||
"score": 51
|
||||
},
|
||||
{
|
||||
"id": 80,
|
||||
"name": "Vorkath",
|
||||
"rank": 15591,
|
||||
"score": 2780
|
||||
},
|
||||
{
|
||||
"id": 81,
|
||||
"name": "Wintertodt",
|
||||
"rank": 1000405,
|
||||
"score": 67
|
||||
},
|
||||
{
|
||||
"id": 82,
|
||||
"name": "Zalcano",
|
||||
"rank": 213696,
|
||||
"score": 25
|
||||
},
|
||||
{
|
||||
"id": 83,
|
||||
"name": "Zulrah",
|
||||
"rank": 240082,
|
||||
"score": 340
|
||||
}
|
||||
]
|
||||
}
|
@@ -12,8 +12,10 @@ import {
|
||||
getSkillPageURL,
|
||||
getStatsURL,
|
||||
BOSSES,
|
||||
INVALID_FORMAT_ERROR,
|
||||
BH_MODES
|
||||
InvalidFormatError,
|
||||
BH_MODES,
|
||||
parseJsonStats,
|
||||
HiscoresResponse
|
||||
} from '../src/index';
|
||||
|
||||
const B0ATY_NAME = 'B0ATY';
|
||||
@@ -25,7 +27,13 @@ const LYNX_TITAN_FORMATTED_NAME = 'Lynx Titan';
|
||||
|
||||
const attackTopPage = readFileSync(`${__dirname}/attackTopPage.html`, 'utf8');
|
||||
const b0atyNamePage = readFileSync(`${__dirname}/b0atyNamePage.html`, 'utf8');
|
||||
const lynxTitanStats = readFileSync(`${__dirname}/lynxTitanStats.csv`, 'utf8');
|
||||
const b0atyStatsCsv = readFileSync(`${__dirname}/b0atyStats.csv`, 'utf8');
|
||||
const b0atyStatsJson: HiscoresResponse = JSON.parse(
|
||||
readFileSync(`${__dirname}/b0atyStats.json`, 'utf8')
|
||||
);
|
||||
const lynxTitanStats = JSON.parse(
|
||||
readFileSync(`${__dirname}/lynxTitanStats.json`, 'utf8')
|
||||
);
|
||||
const lynxTitanNamePage = readFileSync(
|
||||
`${__dirname}/lynxTitanNamePage.html`,
|
||||
'utf8'
|
||||
@@ -46,7 +54,7 @@ jest.spyOn(axios, 'get').mockImplementation((url) => {
|
||||
if (getSkillPageURL('main', 'attack', 1) === url) {
|
||||
return Promise.resolve({ data: attackTopPage });
|
||||
}
|
||||
if (getStatsURL('main', LYNX_TITAN_FORMATTED_NAME) === url) {
|
||||
if (getStatsURL('main', LYNX_TITAN_FORMATTED_NAME, true) === url) {
|
||||
return Promise.resolve({ status: 200, data: lynxTitanStats });
|
||||
}
|
||||
throw new Error(`No mock response for URL: ${url}`);
|
||||
@@ -78,6 +86,7 @@ test('Parse CSV to json', () => {
|
||||
810,99,37688883
|
||||
92,99,32005622
|
||||
23423,478
|
||||
89554,301
|
||||
89914,35
|
||||
99834,25
|
||||
99831,23
|
||||
@@ -93,8 +102,12 @@ test('Parse CSV to json', () => {
|
||||
13,4057
|
||||
37,225
|
||||
25,1110
|
||||
7827,43249
|
||||
1114,1155
|
||||
382,2780
|
||||
944,3000
|
||||
561,398429
|
||||
37,111
|
||||
704,892
|
||||
1981,1452
|
||||
4981,23
|
||||
@@ -112,6 +125,7 @@ test('Parse CSV to json', () => {
|
||||
4342,1655
|
||||
966,2951
|
||||
10151,1
|
||||
1289,2477
|
||||
1288,2407
|
||||
377,4669
|
||||
545,1567
|
||||
@@ -121,6 +135,7 @@ test('Parse CSV to json', () => {
|
||||
41643,1477
|
||||
625,2391
|
||||
120,2981
|
||||
54,2958
|
||||
1,109
|
||||
99,39002
|
||||
3,22666
|
||||
@@ -129,11 +144,17 @@ test('Parse CSV to json', () => {
|
||||
44,6233
|
||||
201,1101
|
||||
82,3404
|
||||
555,7079
|
||||
5085,61
|
||||
8731,1423
|
||||
678,903
|
||||
18823,23
|
||||
63,375
|
||||
2870,6
|
||||
891,9102
|
||||
2871,7
|
||||
5606,149
|
||||
2872,8
|
||||
6984,138
|
||||
23,923141
|
||||
4043,2000
|
||||
@@ -141,6 +162,7 @@ test('Parse CSV to json', () => {
|
||||
289,13070
|
||||
489,8
|
||||
967,47
|
||||
968,48
|
||||
11155,223
|
||||
1940,272
|
||||
8623,1340
|
||||
@@ -176,16 +198,19 @@ test('Parse CSV to json', () => {
|
||||
construction: { rank: 92, level: 99, xp: 32005622 }
|
||||
},
|
||||
leaguePoints: { rank: 23423, score: 478 },
|
||||
deadmanPoints: { rank: 89554, score: 301 },
|
||||
bountyHunter: {
|
||||
hunterV2: { rank: 89914, score: 35 },
|
||||
rogueV2: { rank: 99834, score: 25 },
|
||||
hunter: { rank: 99831, score: 23 },
|
||||
rogue: { rank: 89912, score: 37 },
|
||||
rogue: { rank: 89912, score: 37 }
|
||||
},
|
||||
lastManStanding: { rank: 4814, score: 898 },
|
||||
pvpArena: { rank: 13, score: 4057 },
|
||||
soulWarsZeal: { rank: 37, score: 225 },
|
||||
riftsClosed: { rank: 25, score: 1110 },
|
||||
colosseumGlory: { rank: 7827, score: 43249 },
|
||||
collectionsLogged: { rank: 1114, score: 1155 },
|
||||
clues: {
|
||||
all: { rank: 32, score: 12148 },
|
||||
beginner: { rank: 3105, score: 76 },
|
||||
@@ -198,6 +223,8 @@ test('Parse CSV to json', () => {
|
||||
bosses: {
|
||||
abyssalSire: { rank: 382, score: 2780 },
|
||||
alchemicalHydra: { rank: 944, score: 3000 },
|
||||
amoxliatl: { rank: 561, score: 398429 },
|
||||
araxxor: { rank: 37, score: 111 },
|
||||
artio: { rank: 704, score: 892 },
|
||||
barrows: { rank: 1981, score: 1452 },
|
||||
bryophyta: { rank: 4981, score: 23 },
|
||||
@@ -215,6 +242,7 @@ test('Parse CSV to json', () => {
|
||||
dagannothRex: { rank: 4342, score: 1655 },
|
||||
dagannothSupreme: { rank: 966, score: 2951 },
|
||||
derangedArchaeologist: { rank: 10151, score: 1 },
|
||||
dukeSucellus: { rank: 1289, score: 2477 },
|
||||
generalGraardor: { rank: 1288, score: 2407 },
|
||||
giantMole: { rank: 377, score: 4669 },
|
||||
grotesqueGuardians: { rank: 545, score: 1567 },
|
||||
@@ -224,6 +252,7 @@ test('Parse CSV to json', () => {
|
||||
kraken: { rank: 41643, score: 1477 },
|
||||
kreeArra: { rank: 625, score: 2391 },
|
||||
krilTsutsaroth: { rank: 120, score: 2981 },
|
||||
lunarChests: { rank: 54, score: 2958 },
|
||||
mimic: { rank: 1, score: 109 },
|
||||
nex: { rank: 99, score: 39002 },
|
||||
nightmare: { rank: 3, score: 22666 },
|
||||
@@ -232,11 +261,17 @@ test('Parse CSV to json', () => {
|
||||
phantomMuspah: { rank: 44, score: 6233 },
|
||||
sarachnis: { rank: 201, score: 1101 },
|
||||
scorpia: { rank: 82, score: 3404 },
|
||||
scurrius: { rank: 555, score: 7079 },
|
||||
skotizo: { rank: 5085, score: 61 },
|
||||
solHeredit: { rank: 8731, score: 1423 },
|
||||
spindel: { rank: 678, score: 903 },
|
||||
tempoross: { rank: 18823, score: 23 },
|
||||
gauntlet: { rank: 63, score: 375 },
|
||||
corruptedGauntlet: { rank: 2870, score: 6 },
|
||||
hueycoatl: { rank: 891, score: 9102 },
|
||||
leviathan: { rank: 2871, score: 7 },
|
||||
royalTitans: { rank: 5606, score: 149 },
|
||||
whisperer: { rank: 2872, score: 8 },
|
||||
theatreOfBlood: { rank: 6984, score: 138 },
|
||||
theatreOfBloodHardMode: { rank: 23, score: 923141 },
|
||||
thermonuclearSmokeDevil: { rank: 4043, score: 2000 },
|
||||
@@ -244,6 +279,7 @@ test('Parse CSV to json', () => {
|
||||
tombsOfAmascutExpertMode: { rank: 289, score: 13070 },
|
||||
tzKalZuk: { rank: 489, score: 8 },
|
||||
tzTokJad: { rank: 967, score: 47 },
|
||||
vardorvis: { rank: 968, score: 48 },
|
||||
venenatis: { rank: 11155, score: 223 },
|
||||
vetion: { rank: 1940, score: 272 },
|
||||
vorkath: { rank: 8623, score: 1340 },
|
||||
@@ -260,12 +296,12 @@ test('Parse CSV with unknown activity', () => {
|
||||
const statsWithUnknownActivity = `${lynxTitanStats}
|
||||
-1,-1`;
|
||||
expect(() => parseStats(statsWithUnknownActivity)).toThrow(
|
||||
INVALID_FORMAT_ERROR
|
||||
InvalidFormatError
|
||||
);
|
||||
});
|
||||
|
||||
test('Parse invalid CSV', () => {
|
||||
expect(() => parseStats('invalid')).toThrow(INVALID_FORMAT_ERROR);
|
||||
expect(() => parseStats('invalid')).toThrow(InvalidFormatError);
|
||||
});
|
||||
|
||||
describe('Get name format', () => {
|
||||
@@ -525,13 +561,13 @@ describe('Get stats options', () => {
|
||||
beforeEach(() => {
|
||||
axios.get = jest.fn(
|
||||
(url) =>
|
||||
new Promise<any>((resolve) =>
|
||||
new Promise<any>((resolve) => {
|
||||
resolve(
|
||||
url === getPlayerTableURL('main', rsn)
|
||||
? { data: lynxTitanNamePage }
|
||||
: { status: 200, data: lynxTitanStats }
|
||||
)
|
||||
)
|
||||
);
|
||||
})
|
||||
);
|
||||
axiosMock = axios.get as any;
|
||||
axiosMock.mockClear();
|
||||
@@ -539,11 +575,11 @@ describe('Get stats options', () => {
|
||||
it('fetches all gamemodes and formatted RSN when no options provided', async () => {
|
||||
await getStats(rsn);
|
||||
expect(axiosMock.mock.calls.map((val) => val[0])).toEqual([
|
||||
getStatsURL('main', rsn),
|
||||
getStatsURL('main', rsn, true),
|
||||
getPlayerTableURL('main', rsn),
|
||||
getStatsURL('ironman', rsn),
|
||||
getStatsURL('hardcore', rsn),
|
||||
getStatsURL('ultimate', rsn)
|
||||
getStatsURL('ironman', rsn, true),
|
||||
getStatsURL('hardcore', rsn, true),
|
||||
getStatsURL('ultimate', rsn, true)
|
||||
]);
|
||||
});
|
||||
it('skips fetching formatted RSN when option is provided', async () => {
|
||||
@@ -564,4 +600,16 @@ describe('Get stats options', () => {
|
||||
)
|
||||
).toBeFalsy();
|
||||
});
|
||||
it('omits excluded gamemodes', async () => {
|
||||
const response = await getStats(rsn, {
|
||||
otherGamemodes: ['ironman', 'ultimate']
|
||||
});
|
||||
expect(response.hardcore).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
test('CSV and JSON parsing outputs identical object', async () => {
|
||||
const csvOutput = parseStats(b0atyStatsCsv);
|
||||
const jsonOutput = parseJsonStats(b0atyStatsJson);
|
||||
expect(csvOutput).toEqual(jsonOutput);
|
||||
});
|
||||
|
2573
__tests__/lynxTitanNamePage.html
vendored
2573
__tests__/lynxTitanNamePage.html
vendored
File diff suppressed because it is too large
Load Diff
@@ -1,94 +0,0 @@
|
||||
1,2277,4600000000
|
||||
15,99,200000000
|
||||
28,99,200000000
|
||||
18,99,200000000
|
||||
7,99,200000000
|
||||
8,99,200000000
|
||||
11,99,200000000
|
||||
32,99,200000000
|
||||
159,99,200000000
|
||||
15,99,200000000
|
||||
12,99,200000000
|
||||
9,99,200000000
|
||||
48,99,200000000
|
||||
4,99,200000000
|
||||
3,99,200000000
|
||||
25,99,200000000
|
||||
5,99,200000000
|
||||
23,99,200000000
|
||||
12,99,200000000
|
||||
2,99,200000000
|
||||
19,99,200000000
|
||||
7,99,200000000
|
||||
4,99,200000000
|
||||
4,99,200000000
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
347584,22
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-1,-1
|
||||
-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.
|
678
__tests__/lynxTitanStats.json
Normal file
678
__tests__/lynxTitanStats.json
Normal file
@@ -0,0 +1,678 @@
|
||||
{
|
||||
"skills": [
|
||||
{
|
||||
"id": 0,
|
||||
"name": "Overall",
|
||||
"rank": 1,
|
||||
"level": 2277,
|
||||
"xp": 4600000000
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"name": "Attack",
|
||||
"rank": 15,
|
||||
"level": 99,
|
||||
"xp": 200000000
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"name": "Defence",
|
||||
"rank": 28,
|
||||
"level": 99,
|
||||
"xp": 200000000
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"name": "Strength",
|
||||
"rank": 18,
|
||||
"level": 99,
|
||||
"xp": 200000000
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"name": "Hitpoints",
|
||||
"rank": 7,
|
||||
"level": 99,
|
||||
"xp": 200000000
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"name": "Ranged",
|
||||
"rank": 8,
|
||||
"level": 99,
|
||||
"xp": 200000000
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"name": "Prayer",
|
||||
"rank": 11,
|
||||
"level": 99,
|
||||
"xp": 200000000
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"name": "Magic",
|
||||
"rank": 30,
|
||||
"level": 99,
|
||||
"xp": 200000000
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
"name": "Cooking",
|
||||
"rank": 149,
|
||||
"level": 99,
|
||||
"xp": 200000000
|
||||
},
|
||||
{
|
||||
"id": 9,
|
||||
"name": "Woodcutting",
|
||||
"rank": 15,
|
||||
"level": 99,
|
||||
"xp": 200000000
|
||||
},
|
||||
{
|
||||
"id": 10,
|
||||
"name": "Fletching",
|
||||
"rank": 12,
|
||||
"level": 99,
|
||||
"xp": 200000000
|
||||
},
|
||||
{
|
||||
"id": 11,
|
||||
"name": "Fishing",
|
||||
"rank": 9,
|
||||
"level": 99,
|
||||
"xp": 200000000
|
||||
},
|
||||
{
|
||||
"id": 12,
|
||||
"name": "Firemaking",
|
||||
"rank": 48,
|
||||
"level": 99,
|
||||
"xp": 200000000
|
||||
},
|
||||
{
|
||||
"id": 13,
|
||||
"name": "Crafting",
|
||||
"rank": 4,
|
||||
"level": 99,
|
||||
"xp": 200000000
|
||||
},
|
||||
{
|
||||
"id": 14,
|
||||
"name": "Smithing",
|
||||
"rank": 3,
|
||||
"level": 99,
|
||||
"xp": 200000000
|
||||
},
|
||||
{
|
||||
"id": 15,
|
||||
"name": "Mining",
|
||||
"rank": 23,
|
||||
"level": 99,
|
||||
"xp": 200000000
|
||||
},
|
||||
{
|
||||
"id": 16,
|
||||
"name": "Herblore",
|
||||
"rank": 5,
|
||||
"level": 99,
|
||||
"xp": 200000000
|
||||
},
|
||||
{
|
||||
"id": 17,
|
||||
"name": "Agility",
|
||||
"rank": 24,
|
||||
"level": 99,
|
||||
"xp": 200000000
|
||||
},
|
||||
{
|
||||
"id": 18,
|
||||
"name": "Thieving",
|
||||
"rank": 12,
|
||||
"level": 99,
|
||||
"xp": 200000000
|
||||
},
|
||||
{
|
||||
"id": 19,
|
||||
"name": "Slayer",
|
||||
"rank": 2,
|
||||
"level": 99,
|
||||
"xp": 200000000
|
||||
},
|
||||
{
|
||||
"id": 20,
|
||||
"name": "Farming",
|
||||
"rank": 19,
|
||||
"level": 99,
|
||||
"xp": 200000000
|
||||
},
|
||||
{
|
||||
"id": 21,
|
||||
"name": "Runecraft",
|
||||
"rank": 6,
|
||||
"level": 99,
|
||||
"xp": 200000000
|
||||
},
|
||||
{
|
||||
"id": 22,
|
||||
"name": "Hunter",
|
||||
"rank": 3,
|
||||
"level": 99,
|
||||
"xp": 200000000
|
||||
},
|
||||
{
|
||||
"id": 23,
|
||||
"name": "Construction",
|
||||
"rank": 4,
|
||||
"level": 99,
|
||||
"xp": 200000000
|
||||
}
|
||||
],
|
||||
"activities": [
|
||||
{
|
||||
"id": 0,
|
||||
"name": "League Points",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"name": "Deadman Points",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"name": "Bounty Hunter - Hunter",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"name": "Bounty Hunter - Rogue",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"name": "Bounty Hunter (Legacy) - Hunter",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"name": "Bounty Hunter (Legacy) - Rogue",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"name": "Clue Scrolls (all)",
|
||||
"rank": 937868,
|
||||
"score": 22
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"name": "Clue Scrolls (beginner)",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
"name": "Clue Scrolls (easy)",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 9,
|
||||
"name": "Clue Scrolls (medium)",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 10,
|
||||
"name": "Clue Scrolls (hard)",
|
||||
"rank": 578038,
|
||||
"score": 22
|
||||
},
|
||||
{
|
||||
"id": 11,
|
||||
"name": "Clue Scrolls (elite)",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 12,
|
||||
"name": "Clue Scrolls (master)",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 13,
|
||||
"name": "LMS - Rank",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 14,
|
||||
"name": "PvP Arena - Rank",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 15,
|
||||
"name": "Soul Wars Zeal",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 16,
|
||||
"name": "Rifts closed",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 17,
|
||||
"name": "Colosseum Glory",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 18,
|
||||
"name": "Collections Logged",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 19,
|
||||
"name": "Abyssal Sire",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 20,
|
||||
"name": "Alchemical Hydra",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 21,
|
||||
"name": "Amoxliatl",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 22,
|
||||
"name": "Araxxor",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 23,
|
||||
"name": "Artio",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 24,
|
||||
"name": "Barrows Chests",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 25,
|
||||
"name": "Bryophyta",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 26,
|
||||
"name": "Callisto",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 27,
|
||||
"name": "Calvar'ion",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 28,
|
||||
"name": "Cerberus",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 29,
|
||||
"name": "Chambers of Xeric",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 30,
|
||||
"name": "Chambers of Xeric: Challenge Mode",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 31,
|
||||
"name": "Chaos Elemental",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 32,
|
||||
"name": "Chaos Fanatic",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 33,
|
||||
"name": "Commander Zilyana",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 34,
|
||||
"name": "Corporeal Beast",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 35,
|
||||
"name": "Crazy Archaeologist",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 36,
|
||||
"name": "Dagannoth Prime",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 37,
|
||||
"name": "Dagannoth Rex",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 38,
|
||||
"name": "Dagannoth Supreme",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 39,
|
||||
"name": "Deranged Archaeologist",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 40,
|
||||
"name": "Duke Sucellus",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 41,
|
||||
"name": "General Graardor",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 42,
|
||||
"name": "Giant Mole",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 43,
|
||||
"name": "Grotesque Guardians",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 44,
|
||||
"name": "Hespori",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 45,
|
||||
"name": "Kalphite Queen",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 46,
|
||||
"name": "King Black Dragon",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 47,
|
||||
"name": "Kraken",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 48,
|
||||
"name": "Kree'Arra",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 49,
|
||||
"name": "K'ril Tsutsaroth",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 50,
|
||||
"name": "Lunar Chests",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 51,
|
||||
"name": "Mimic",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 52,
|
||||
"name": "Nex",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 53,
|
||||
"name": "Nightmare",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 54,
|
||||
"name": "Phosani's Nightmare",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 55,
|
||||
"name": "Obor",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 56,
|
||||
"name": "Phantom Muspah",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 57,
|
||||
"name": "Sarachnis",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 58,
|
||||
"name": "Scorpia",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 59,
|
||||
"name": "Scurrius",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 60,
|
||||
"name": "Skotizo",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 61,
|
||||
"name": "Sol Heredit",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 62,
|
||||
"name": "Spindel",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 63,
|
||||
"name": "Tempoross",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 64,
|
||||
"name": "The Gauntlet",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 65,
|
||||
"name": "The Corrupted Gauntlet",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 66,
|
||||
"name": "The Hueycoatl",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 67,
|
||||
"name": "The Leviathan",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 68,
|
||||
"name": "The Royal Titans",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 69,
|
||||
"name": "The Whisperer",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 70,
|
||||
"name": "Theatre of Blood",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 71,
|
||||
"name": "Theatre of Blood: Hard Mode",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 72,
|
||||
"name": "Thermonuclear Smoke Devil",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 73,
|
||||
"name": "Tombs of Amascut",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 74,
|
||||
"name": "Tombs of Amascut: Expert Mode",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 75,
|
||||
"name": "TzKal-Zuk",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 76,
|
||||
"name": "TzTok-Jad",
|
||||
"rank": 317,
|
||||
"score": 186
|
||||
},
|
||||
{
|
||||
"id": 77,
|
||||
"name": "Vardorvis",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 78,
|
||||
"name": "Venenatis",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 79,
|
||||
"name": "Vet'ion",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 80,
|
||||
"name": "Vorkath",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 81,
|
||||
"name": "Wintertodt",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 82,
|
||||
"name": "Zalcano",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
},
|
||||
{
|
||||
"id": 83,
|
||||
"name": "Zulrah",
|
||||
"rank": -1,
|
||||
"score": -1
|
||||
}
|
||||
]
|
||||
}
|
46
package.json
46
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "osrs-json-hiscores",
|
||||
"version": "2.14.1",
|
||||
"version": "2.21.0",
|
||||
"description": "The Old School Runescape API wrapper that does more!",
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
@@ -61,18 +61,23 @@
|
||||
"@typescript-eslint"
|
||||
],
|
||||
"extends": [
|
||||
"eslint-config-airbnb-typescript",
|
||||
"airbnb-base",
|
||||
"airbnb-typescript/base",
|
||||
"prettier"
|
||||
],
|
||||
"ignorePatterns": [
|
||||
"**/@types/*"
|
||||
]
|
||||
],
|
||||
"rules": {
|
||||
"max-classes-per-file": "off"
|
||||
}
|
||||
},
|
||||
"prettier": {
|
||||
"trailingComma": "none",
|
||||
"tabWidth": 2,
|
||||
"semi": true,
|
||||
"singleQuote": true
|
||||
"singleQuote": true,
|
||||
"endOfLine": "auto"
|
||||
},
|
||||
"jest": {
|
||||
"transform": {
|
||||
@@ -90,28 +95,25 @@
|
||||
"testEnvironment": "node"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^0.21.1",
|
||||
"jsdom": "^16.3.0",
|
||||
"axios": "^1.6.2",
|
||||
"jsdom": "^22.1.0",
|
||||
"useragent-generator": "^1.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^26.0.21",
|
||||
"@types/jsdom": "^16.2.3",
|
||||
"@typescript-eslint/eslint-plugin": "^4.19.0",
|
||||
"@typescript-eslint/parser": "^4.19.0",
|
||||
"eslint": "^7.22.0",
|
||||
"eslint-config-airbnb-typescript": "^12.3.1",
|
||||
"eslint-config-prettier": "^8.1.0",
|
||||
"eslint-plugin-import": "^2.22.1",
|
||||
"eslint-plugin-jsx-a11y": "^6.4.1",
|
||||
"eslint-plugin-react": "^7.23.1",
|
||||
"eslint-plugin-react-hooks": "^4.2.0",
|
||||
"@types/jest": "^29.5.3",
|
||||
"@types/jsdom": "^21.1.1",
|
||||
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
||||
"@typescript-eslint/parser": "^6.0.0",
|
||||
"eslint": "^8.44.0",
|
||||
"eslint-config-airbnb-typescript": "^17.1.0",
|
||||
"eslint-config-prettier": "^8.8.0",
|
||||
"eslint-plugin-import": "^2.27.5",
|
||||
"husky": "^5.2.0",
|
||||
"jest": "^26.6.3",
|
||||
"lint-staged": "^10.5.4",
|
||||
"jest": "^29.6.1",
|
||||
"lint-staged": "^13.2.3",
|
||||
"np": "^7.7.0",
|
||||
"prettier": "^2.2.1",
|
||||
"ts-jest": "^26.5.4",
|
||||
"typescript": "^4.2.3"
|
||||
"prettier": "^3.0.0",
|
||||
"ts-jest": "^29.1.1",
|
||||
"typescript": "^5.1.6"
|
||||
}
|
||||
}
|
||||
|
287
src/hiscores.ts
287
src/hiscores.ts
@@ -1,4 +1,4 @@
|
||||
import { AxiosRequestConfig, AxiosResponse } from 'axios';
|
||||
import axios, { AxiosRequestConfig } from 'axios';
|
||||
import { BinaryData, JSDOM } from 'jsdom';
|
||||
import {
|
||||
Player,
|
||||
@@ -14,7 +14,8 @@ import {
|
||||
ActivityName,
|
||||
PlayerActivityRow,
|
||||
Bosses,
|
||||
GetStatsOptions
|
||||
GetStatsOptions,
|
||||
HiscoresResponse
|
||||
} from './types';
|
||||
import {
|
||||
getStatsURL,
|
||||
@@ -30,10 +31,52 @@ import {
|
||||
getActivityPageURL,
|
||||
httpGet,
|
||||
BOSSES,
|
||||
INVALID_FORMAT_ERROR,
|
||||
validateRSN
|
||||
InvalidFormatError,
|
||||
PlayerNotFoundError,
|
||||
HiScoresError,
|
||||
validateRSN,
|
||||
FORMATTED_SKILL_NAMES,
|
||||
FORMATTED_BH_NAMES,
|
||||
FORMATTED_CLUE_NAMES,
|
||||
FORMATTED_BOSS_NAMES,
|
||||
FORMATTED_LEAGUE_POINTS,
|
||||
FORMATTED_LMS,
|
||||
FORMATTED_PVP_ARENA,
|
||||
FORMATTED_SOUL_WARS,
|
||||
FORMATTED_RIFTS_CLOSED,
|
||||
FORMATTED_DEADMAN_POINTS,
|
||||
FORMATTED_COLOSSEUM_GLORY,
|
||||
FORMATTED_COLLECTIONS_LOGGED
|
||||
} from './utils';
|
||||
|
||||
/**
|
||||
* Gets a player's stats from the official OSRS JSON endpoint.
|
||||
*
|
||||
* @param rsn Username of the player.
|
||||
* @param mode Gamemode to fetch ranks for.
|
||||
* @param config Optional axios request config object.
|
||||
* @returns Official JSON stats object.
|
||||
*/
|
||||
export async function getOfficialStats(
|
||||
rsn: string,
|
||||
mode: Gamemode = 'main',
|
||||
config?: AxiosRequestConfig
|
||||
): Promise<HiscoresResponse> {
|
||||
validateRSN(rsn);
|
||||
|
||||
const url = getStatsURL(mode, rsn, true);
|
||||
try {
|
||||
const response = await httpGet<HiscoresResponse>(url, config);
|
||||
return response.data;
|
||||
} catch (err) {
|
||||
if (!axios.isAxiosError(err)) throw err;
|
||||
|
||||
if (err.response?.status === 404) throw new PlayerNotFoundError();
|
||||
|
||||
throw new HiScoresError();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Screen scrapes the hiscores to get the formatted rsn of a player.
|
||||
*
|
||||
@@ -60,12 +103,88 @@ export async function getRSNFormat(
|
||||
if (anchor) {
|
||||
return rsnFromElement(anchor);
|
||||
}
|
||||
throw Error('Player not found');
|
||||
throw new PlayerNotFoundError();
|
||||
} catch {
|
||||
throw Error('Player not found');
|
||||
throw new HiScoresError();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses official JSON object of raw stats and returns a stats object.
|
||||
*
|
||||
* @param csv Raw JSON from the official OSRS API.
|
||||
* @returns Parsed stats object.
|
||||
*/
|
||||
export function parseJsonStats(json: HiscoresResponse): Stats {
|
||||
const getActivity = (formattedName: string): Activity => {
|
||||
const hiscoresActivity = json.activities.find(
|
||||
// We must match on name here since id is not guaranteed to be the same between updates
|
||||
({ name }) => name.toLowerCase() === formattedName.toLowerCase()
|
||||
);
|
||||
return {
|
||||
rank: hiscoresActivity?.rank ?? -1,
|
||||
score: hiscoresActivity?.score ?? -1
|
||||
};
|
||||
};
|
||||
const reduceActivity = <Key extends string, Reduced = Record<Key, Activity>>(
|
||||
keys: Key[],
|
||||
formattedNames: Record<Key, string>
|
||||
): Reduced =>
|
||||
keys.reduce<Reduced>(
|
||||
(reducer, key) => ({
|
||||
...reducer,
|
||||
[key]: getActivity(formattedNames[key])
|
||||
}),
|
||||
{} as Reduced
|
||||
);
|
||||
|
||||
const skills = SKILLS.reduce<Skills>((skillsObject, skillName) => {
|
||||
const hiscoresSkill = json.skills.find(
|
||||
// We must match on name here since id is not guaranteed to be the same between updates
|
||||
({ name }) =>
|
||||
name.toLowerCase() === FORMATTED_SKILL_NAMES[skillName].toLowerCase()
|
||||
);
|
||||
return {
|
||||
...skillsObject,
|
||||
[skillName]: {
|
||||
rank: hiscoresSkill?.rank ?? -1,
|
||||
level: hiscoresSkill?.level ?? -1,
|
||||
xp: hiscoresSkill?.xp ?? -1
|
||||
}
|
||||
};
|
||||
}, {} as Skills);
|
||||
|
||||
const bountyHunter = reduceActivity(BH_MODES, FORMATTED_BH_NAMES);
|
||||
const clues = reduceActivity(CLUES, FORMATTED_CLUE_NAMES);
|
||||
const bosses = reduceActivity(BOSSES, FORMATTED_BOSS_NAMES);
|
||||
|
||||
const leaguePoints = getActivity(FORMATTED_LEAGUE_POINTS);
|
||||
const deadmanPoints = getActivity(FORMATTED_DEADMAN_POINTS);
|
||||
const lastManStanding = getActivity(FORMATTED_LMS);
|
||||
const pvpArena = getActivity(FORMATTED_PVP_ARENA);
|
||||
const soulWarsZeal = getActivity(FORMATTED_SOUL_WARS);
|
||||
const riftsClosed = getActivity(FORMATTED_RIFTS_CLOSED);
|
||||
const colosseumGlory = getActivity(FORMATTED_COLOSSEUM_GLORY);
|
||||
const collectionsLogged = getActivity(FORMATTED_COLLECTIONS_LOGGED);
|
||||
|
||||
const stats: Stats = {
|
||||
skills,
|
||||
leaguePoints,
|
||||
deadmanPoints,
|
||||
bountyHunter,
|
||||
lastManStanding,
|
||||
pvpArena,
|
||||
soulWarsZeal,
|
||||
riftsClosed,
|
||||
colosseumGlory,
|
||||
collectionsLogged,
|
||||
clues,
|
||||
bosses
|
||||
};
|
||||
|
||||
return stats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses CSV string of raw stats and returns a stats object.
|
||||
*
|
||||
@@ -78,11 +197,8 @@ 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 + 5
|
||||
) {
|
||||
throw Error(INVALID_FORMAT_ERROR);
|
||||
if (splitCSV.length !== SKILLS.length + ACTIVITIES.length) {
|
||||
throw new InvalidFormatError();
|
||||
}
|
||||
|
||||
const skillObjects: Skill[] = splitCSV
|
||||
@@ -108,15 +224,17 @@ export function parseStats(csv: string): Stats {
|
||||
return activity;
|
||||
});
|
||||
|
||||
const [leaguePoints] = activityObjects.splice(0, 1);
|
||||
const [leaguePoints, deadmanPoints] = activityObjects.splice(0, 2);
|
||||
const bhObjects = activityObjects.splice(0, BH_MODES.length);
|
||||
const clueObjects = activityObjects.splice(0, CLUES.length);
|
||||
const [
|
||||
lastManStanding,
|
||||
pvpArena,
|
||||
soulWarsZeal,
|
||||
riftsClosed
|
||||
] = activityObjects.splice(0, 4);
|
||||
riftsClosed,
|
||||
colosseumGlory,
|
||||
collectionsLogged
|
||||
] = activityObjects.splice(0, 6);
|
||||
const bossObjects = activityObjects.splice(0, BOSSES.length);
|
||||
|
||||
const skills: Skills = skillObjects.reduce<Skills>((prev, curr, index) => {
|
||||
@@ -146,11 +264,14 @@ export function parseStats(csv: string): Stats {
|
||||
const stats: Stats = {
|
||||
skills,
|
||||
leaguePoints,
|
||||
deadmanPoints,
|
||||
bountyHunter,
|
||||
lastManStanding,
|
||||
pvpArena,
|
||||
soulWarsZeal,
|
||||
riftsClosed,
|
||||
colosseumGlory,
|
||||
collectionsLogged,
|
||||
clues,
|
||||
bosses
|
||||
};
|
||||
@@ -179,91 +300,70 @@ export async function getStats(
|
||||
];
|
||||
const shouldGetFormattedRsn = options?.shouldGetFormattedRsn ?? true;
|
||||
|
||||
const mainRes = await httpGet<string>(
|
||||
getStatsURL('main', rsn),
|
||||
options?.axiosConfigs?.main
|
||||
);
|
||||
if (mainRes.status === 200) {
|
||||
const emptyResponse: AxiosResponse<string> = {
|
||||
status: 404,
|
||||
data: '',
|
||||
statusText: '',
|
||||
headers: {},
|
||||
config: {}
|
||||
};
|
||||
const getModeStats = async (
|
||||
mode: Extract<Gamemode, 'ironman' | 'hardcore' | 'ultimate'>
|
||||
): Promise<AxiosResponse<string>> =>
|
||||
otherGamemodes.includes(mode)
|
||||
? httpGet<string>(
|
||||
getStatsURL(mode, rsn),
|
||||
options?.axiosConfigs?.[mode]
|
||||
).catch((err) => err)
|
||||
: emptyResponse;
|
||||
const formattedName = shouldGetFormattedRsn
|
||||
? await getRSNFormat(rsn, options?.axiosConfigs?.rsn).catch(
|
||||
const main = await getOfficialStats(rsn, 'main', options?.axiosConfigs?.main);
|
||||
|
||||
const getModeStats = async (
|
||||
mode: Extract<Gamemode, 'ironman' | 'hardcore' | 'ultimate'>
|
||||
): Promise<HiscoresResponse | undefined> =>
|
||||
otherGamemodes.includes(mode)
|
||||
? getOfficialStats(rsn, mode, options?.axiosConfigs?.[mode]).catch(
|
||||
() => undefined
|
||||
)
|
||||
: undefined;
|
||||
const formattedName = shouldGetFormattedRsn
|
||||
? await getRSNFormat(rsn, options?.axiosConfigs?.rsn).catch(() => undefined)
|
||||
: undefined;
|
||||
|
||||
const player: Player = {
|
||||
name: formattedName ?? rsn,
|
||||
mode: 'main',
|
||||
dead: false,
|
||||
deulted: false,
|
||||
deironed: false
|
||||
};
|
||||
player.main = parseStats(mainRes.data);
|
||||
const player: Player = {
|
||||
name: formattedName ?? rsn,
|
||||
mode: 'main',
|
||||
dead: false,
|
||||
deulted: false,
|
||||
deironed: false
|
||||
};
|
||||
player.main = parseJsonStats(main);
|
||||
|
||||
const ironRes = await getModeStats('ironman');
|
||||
if (ironRes.status === 200) {
|
||||
player.ironman = parseStats(ironRes.data);
|
||||
const hcRes = await getModeStats('hardcore');
|
||||
const ultRes = await getModeStats('ultimate');
|
||||
if (hcRes.status === 200) {
|
||||
player.mode = 'hardcore';
|
||||
player.hardcore = parseStats(hcRes.data);
|
||||
if (
|
||||
player.ironman.skills.overall.xp !== player.hardcore.skills.overall.xp
|
||||
) {
|
||||
player.dead = true;
|
||||
player.mode = 'ironman';
|
||||
}
|
||||
if (
|
||||
player.main.skills.overall.xp !== player.ironman.skills.overall.xp
|
||||
) {
|
||||
player.deironed = true;
|
||||
player.mode = 'main';
|
||||
}
|
||||
} else if (ultRes.status === 200) {
|
||||
player.mode = 'ultimate';
|
||||
player.ultimate = parseStats(ultRes.data);
|
||||
if (
|
||||
player.ironman.skills.overall.xp !== player.ultimate.skills.overall.xp
|
||||
) {
|
||||
player.deulted = true;
|
||||
player.mode = 'ironman';
|
||||
}
|
||||
if (
|
||||
player.main.skills.overall.xp !== player.ironman.skills.overall.xp
|
||||
) {
|
||||
player.deironed = true;
|
||||
player.mode = 'main';
|
||||
}
|
||||
} else {
|
||||
const iron = await getModeStats('ironman');
|
||||
if (iron) {
|
||||
player.ironman = parseJsonStats(iron);
|
||||
const hc = await getModeStats('hardcore');
|
||||
const ult = await getModeStats('ultimate');
|
||||
if (hc) {
|
||||
player.mode = 'hardcore';
|
||||
player.hardcore = parseJsonStats(hc);
|
||||
if (
|
||||
player.ironman.skills.overall.xp !== player.hardcore.skills.overall.xp
|
||||
) {
|
||||
player.dead = true;
|
||||
player.mode = 'ironman';
|
||||
if (
|
||||
player.main.skills.overall.xp !== player.ironman.skills.overall.xp
|
||||
) {
|
||||
player.deironed = true;
|
||||
player.mode = 'main';
|
||||
}
|
||||
}
|
||||
if (player.main.skills.overall.xp !== player.ironman.skills.overall.xp) {
|
||||
player.deironed = true;
|
||||
player.mode = 'main';
|
||||
}
|
||||
} else if (ult) {
|
||||
player.mode = 'ultimate';
|
||||
player.ultimate = parseJsonStats(ult);
|
||||
if (
|
||||
player.ironman.skills.overall.xp !== player.ultimate.skills.overall.xp
|
||||
) {
|
||||
player.deulted = true;
|
||||
player.mode = 'ironman';
|
||||
}
|
||||
if (player.main.skills.overall.xp !== player.ironman.skills.overall.xp) {
|
||||
player.deironed = true;
|
||||
player.mode = 'main';
|
||||
}
|
||||
} else {
|
||||
player.mode = 'ironman';
|
||||
if (player.main.skills.overall.xp !== player.ironman.skills.overall.xp) {
|
||||
player.deironed = true;
|
||||
player.mode = 'main';
|
||||
}
|
||||
}
|
||||
|
||||
return player;
|
||||
}
|
||||
throw Error('Player not found');
|
||||
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -283,11 +383,8 @@ export async function getStatsByGamemode(
|
||||
if (!GAMEMODES.includes(mode)) {
|
||||
throw Error('Invalid game mode');
|
||||
}
|
||||
const response = await httpGet<string>(getStatsURL(mode, rsn), config);
|
||||
if (response.status !== 200) {
|
||||
throw Error('Player not found');
|
||||
}
|
||||
const stats = parseStats(response.data);
|
||||
const response = await getOfficialStats(rsn, mode, config);
|
||||
const stats = parseJsonStats(response);
|
||||
|
||||
return stats;
|
||||
}
|
||||
|
61
src/types.ts
61
src/types.ts
@@ -69,6 +69,8 @@ export type BH = { [Type in BHType]: Activity };
|
||||
export type Boss =
|
||||
| 'abyssalSire'
|
||||
| 'alchemicalHydra'
|
||||
| 'amoxliatl'
|
||||
| 'araxxor'
|
||||
| 'artio'
|
||||
| 'barrows'
|
||||
| 'bryophyta'
|
||||
@@ -86,6 +88,7 @@ export type Boss =
|
||||
| 'dagannothRex'
|
||||
| 'dagannothSupreme'
|
||||
| 'derangedArchaeologist'
|
||||
| 'dukeSucellus'
|
||||
| 'generalGraardor'
|
||||
| 'giantMole'
|
||||
| 'grotesqueGuardians'
|
||||
@@ -95,6 +98,7 @@ export type Boss =
|
||||
| 'kraken'
|
||||
| 'kreeArra'
|
||||
| 'krilTsutsaroth'
|
||||
| 'lunarChests'
|
||||
| 'mimic'
|
||||
| 'nex'
|
||||
| 'nightmare'
|
||||
@@ -103,11 +107,17 @@ export type Boss =
|
||||
| 'phantomMuspah'
|
||||
| 'sarachnis'
|
||||
| 'scorpia'
|
||||
| 'scurrius'
|
||||
| 'skotizo'
|
||||
| 'solHeredit'
|
||||
| 'spindel'
|
||||
| 'tempoross'
|
||||
| 'gauntlet'
|
||||
| 'corruptedGauntlet'
|
||||
| 'hueycoatl'
|
||||
| 'leviathan'
|
||||
| 'royalTitans'
|
||||
| 'whisperer'
|
||||
| 'theatreOfBlood'
|
||||
| 'theatreOfBloodHardMode'
|
||||
| 'thermonuclearSmokeDevil'
|
||||
@@ -115,6 +125,7 @@ export type Boss =
|
||||
| 'tombsOfAmascutExpertMode'
|
||||
| 'tzKalZuk'
|
||||
| 'tzTokJad'
|
||||
| 'vardorvis'
|
||||
| 'venenatis'
|
||||
| 'vetion'
|
||||
| 'vorkath'
|
||||
@@ -126,6 +137,7 @@ export type Bosses = { [Type in Boss]: Activity };
|
||||
|
||||
export type ActivityName =
|
||||
| 'leaguePoints'
|
||||
| 'deadmanPoints'
|
||||
| 'hunterBHV2'
|
||||
| 'rogueBHV2'
|
||||
| 'hunterBH'
|
||||
@@ -141,17 +153,28 @@ export type ActivityName =
|
||||
| 'hardClues'
|
||||
| 'eliteClues'
|
||||
| 'masterClues'
|
||||
| 'colosseumGlory'
|
||||
| 'collectionsLogged'
|
||||
| Boss;
|
||||
|
||||
export interface Stats {
|
||||
skills: Skills;
|
||||
clues: Clues;
|
||||
/**
|
||||
* Will only contain rank and score data for the `seasonal` gamemode.
|
||||
*/
|
||||
leaguePoints: Activity;
|
||||
/**
|
||||
* Will only contain rank and score data for the `tournament` gamemode.
|
||||
*/
|
||||
deadmanPoints: Activity;
|
||||
bountyHunter: BH;
|
||||
lastManStanding: Activity;
|
||||
pvpArena: Activity;
|
||||
soulWarsZeal: Activity;
|
||||
riftsClosed: Activity;
|
||||
colosseumGlory: Activity;
|
||||
collectionsLogged: Activity;
|
||||
bosses: Bosses;
|
||||
}
|
||||
export type Modes = { [M in Gamemode]?: Stats };
|
||||
@@ -195,3 +218,41 @@ export interface GetStatsOptions {
|
||||
rsn?: AxiosRequestConfig;
|
||||
};
|
||||
}
|
||||
|
||||
export interface HiscoresCommon {
|
||||
/**
|
||||
* This field behaves more like an index than a true unique ID.
|
||||
*/
|
||||
id: number;
|
||||
/**
|
||||
* The display name of this skill / activity.
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* The player's official hiscores rank in this skill / activity.
|
||||
*/
|
||||
rank: number;
|
||||
}
|
||||
|
||||
export interface HiscoresSkill extends HiscoresCommon {
|
||||
/**
|
||||
* The player's current level in this skill.
|
||||
*/
|
||||
level: number;
|
||||
/**
|
||||
* The player's current experience in this skill.
|
||||
*/
|
||||
xp: number;
|
||||
}
|
||||
|
||||
export interface HiscoresActivity extends HiscoresCommon {
|
||||
/**
|
||||
* The player's current score in this activity.
|
||||
*/
|
||||
score: number;
|
||||
}
|
||||
|
||||
export interface HiscoresResponse {
|
||||
skills: HiscoresSkill[];
|
||||
activities: HiscoresActivity[];
|
||||
}
|
||||
|
@@ -9,6 +9,7 @@ import {
|
||||
|
||||
export const BASE_URL = 'https://secure.runescape.com/m=hiscore_oldschool';
|
||||
export const STATS_URL = 'index_lite.ws?player=';
|
||||
export const JSON_STATS_URL = 'index_lite.json?player=';
|
||||
export const SCORES_URL = 'overall.ws?';
|
||||
|
||||
export type GamemodeUrl = {
|
||||
@@ -75,6 +76,8 @@ export const GAMEMODES: Gamemode[] = [
|
||||
export const BOSSES: Boss[] = [
|
||||
'abyssalSire',
|
||||
'alchemicalHydra',
|
||||
'amoxliatl',
|
||||
'araxxor',
|
||||
'artio',
|
||||
'barrows',
|
||||
'bryophyta',
|
||||
@@ -92,6 +95,7 @@ export const BOSSES: Boss[] = [
|
||||
'dagannothRex',
|
||||
'dagannothSupreme',
|
||||
'derangedArchaeologist',
|
||||
'dukeSucellus',
|
||||
'generalGraardor',
|
||||
'giantMole',
|
||||
'grotesqueGuardians',
|
||||
@@ -101,6 +105,7 @@ export const BOSSES: Boss[] = [
|
||||
'kraken',
|
||||
'kreeArra',
|
||||
'krilTsutsaroth',
|
||||
'lunarChests',
|
||||
'mimic',
|
||||
'nex',
|
||||
'nightmare',
|
||||
@@ -109,11 +114,17 @@ export const BOSSES: Boss[] = [
|
||||
'phantomMuspah',
|
||||
'sarachnis',
|
||||
'scorpia',
|
||||
'scurrius',
|
||||
'skotizo',
|
||||
'solHeredit',
|
||||
'spindel',
|
||||
'tempoross',
|
||||
'gauntlet',
|
||||
'corruptedGauntlet',
|
||||
'hueycoatl',
|
||||
'leviathan',
|
||||
'royalTitans',
|
||||
'whisperer',
|
||||
'theatreOfBlood',
|
||||
'theatreOfBloodHardMode',
|
||||
'thermonuclearSmokeDevil',
|
||||
@@ -121,6 +132,7 @@ export const BOSSES: Boss[] = [
|
||||
'tombsOfAmascutExpertMode',
|
||||
'tzKalZuk',
|
||||
'tzTokJad',
|
||||
'vardorvis',
|
||||
'venenatis',
|
||||
'vetion',
|
||||
'vorkath',
|
||||
@@ -130,6 +142,7 @@ export const BOSSES: Boss[] = [
|
||||
];
|
||||
export const ACTIVITIES: ActivityName[] = [
|
||||
'leaguePoints',
|
||||
'deadmanPoints',
|
||||
'hunterBHV2',
|
||||
'rogueBHV2',
|
||||
'hunterBH',
|
||||
@@ -145,6 +158,8 @@ export const ACTIVITIES: ActivityName[] = [
|
||||
'pvpArena',
|
||||
'soulWarsZeal',
|
||||
'riftsClosed',
|
||||
'colosseumGlory',
|
||||
'collectionsLogged',
|
||||
...BOSSES
|
||||
];
|
||||
|
||||
@@ -155,6 +170,8 @@ export type FormattedBossNames = {
|
||||
export const FORMATTED_BOSS_NAMES: FormattedBossNames = {
|
||||
abyssalSire: 'Abyssal Sire',
|
||||
alchemicalHydra: 'Alchemical Hydra',
|
||||
amoxliatl: 'Amoxliatl',
|
||||
araxxor: 'Araxxor',
|
||||
artio: 'Artio',
|
||||
barrows: 'Barrows Chests',
|
||||
bryophyta: 'Bryophyta',
|
||||
@@ -172,6 +189,7 @@ export const FORMATTED_BOSS_NAMES: FormattedBossNames = {
|
||||
dagannothRex: 'Dagannoth Rex',
|
||||
dagannothSupreme: 'Dagannoth Supreme',
|
||||
derangedArchaeologist: 'Deranged Archaeologist',
|
||||
dukeSucellus: 'Duke Sucellus',
|
||||
generalGraardor: 'General Graardor',
|
||||
giantMole: 'Giant Mole',
|
||||
grotesqueGuardians: 'Grotesque Guardians',
|
||||
@@ -181,19 +199,26 @@ export const FORMATTED_BOSS_NAMES: FormattedBossNames = {
|
||||
kraken: 'Kraken',
|
||||
kreeArra: "Kree'Arra",
|
||||
krilTsutsaroth: "K'ril Tsutsaroth",
|
||||
lunarChests: 'Lunar Chests',
|
||||
mimic: 'Mimic',
|
||||
nex: 'Nex',
|
||||
nightmare: 'The Nightmare of Ashihama',
|
||||
nightmare: 'Nightmare',
|
||||
phosanisNightmare: "Phosani's Nightmare",
|
||||
obor: 'Obor',
|
||||
phantomMuspah: 'Phantom Muspah',
|
||||
sarachnis: 'Sarachnis',
|
||||
scorpia: 'Scorpia',
|
||||
scurrius: 'Scurrius',
|
||||
skotizo: 'Skotizo',
|
||||
solHeredit: 'Sol Heredit',
|
||||
spindel: 'Spindel',
|
||||
tempoross: 'Tempoross',
|
||||
gauntlet: 'The Gauntlet',
|
||||
corruptedGauntlet: 'The Corrupted Gauntlet',
|
||||
hueycoatl: 'The Hueycoatl',
|
||||
leviathan: 'The Leviathan',
|
||||
royalTitans: 'The Royal Titans',
|
||||
whisperer: 'The Whisperer',
|
||||
theatreOfBlood: 'Theatre of Blood',
|
||||
theatreOfBloodHardMode: 'Theatre of Blood: Hard Mode',
|
||||
thermonuclearSmokeDevil: 'Thermonuclear Smoke Devil',
|
||||
@@ -201,6 +226,7 @@ export const FORMATTED_BOSS_NAMES: FormattedBossNames = {
|
||||
tombsOfAmascutExpertMode: 'Tombs of Amascut: Expert Mode',
|
||||
tzKalZuk: 'TzKal-Zuk',
|
||||
tzTokJad: 'TzTok-Jad',
|
||||
vardorvis: 'Vardorvis',
|
||||
venenatis: 'Venenatis',
|
||||
vetion: "Vet'ion",
|
||||
vorkath: 'Vorkath',
|
||||
@@ -265,10 +291,51 @@ export const FORMATTED_BH_NAMES: FormattedBHNames = {
|
||||
hunterV2: 'Bounty Hunter - Hunter'
|
||||
};
|
||||
|
||||
export const FORMATTED_LMS = 'Last Man Standing';
|
||||
export const FORMATTED_PVP_ARENA = 'PvP Arena';
|
||||
export const FORMATTED_LMS = 'LMS - Rank';
|
||||
export const FORMATTED_PVP_ARENA = 'PvP Arena - Rank';
|
||||
export const FORMATTED_SOUL_WARS = 'Soul Wars Zeal';
|
||||
export const FORMATTED_LEAGUE_POINTS = 'League Points';
|
||||
export const FORMATTED_RIFTS_CLOSED = 'Rifts Closed';
|
||||
export const FORMATTED_DEADMAN_POINTS = 'Deadman Points';
|
||||
export const FORMATTED_RIFTS_CLOSED = 'Rifts closed';
|
||||
export const FORMATTED_COLOSSEUM_GLORY = 'Colosseum Glory';
|
||||
export const FORMATTED_COLLECTIONS_LOGGED = 'Collections Logged';
|
||||
|
||||
export const INVALID_FORMAT_ERROR = 'Invalid hiscores format';
|
||||
export const PLAYER_NOT_FOUND_ERROR = 'Player not found';
|
||||
export const HISCORES_ERROR = 'HiScores not responding';
|
||||
|
||||
export class InvalidFormatError extends Error {
|
||||
__proto__ = Error;
|
||||
|
||||
constructor() {
|
||||
super(INVALID_FORMAT_ERROR);
|
||||
Object.setPrototypeOf(this, InvalidFormatError.prototype);
|
||||
}
|
||||
}
|
||||
|
||||
export class InvalidRSNError extends Error {
|
||||
__proto__ = Error;
|
||||
|
||||
constructor(message: string) {
|
||||
super(message);
|
||||
Object.setPrototypeOf(this, InvalidRSNError.prototype);
|
||||
}
|
||||
}
|
||||
|
||||
export class PlayerNotFoundError extends Error {
|
||||
__proto__ = Error;
|
||||
|
||||
constructor() {
|
||||
super(PLAYER_NOT_FOUND_ERROR);
|
||||
Object.setPrototypeOf(this, PlayerNotFoundError.prototype);
|
||||
}
|
||||
}
|
||||
|
||||
export class HiScoresError extends Error {
|
||||
__proto__ = Error;
|
||||
|
||||
constructor() {
|
||||
super(HISCORES_ERROR);
|
||||
Object.setPrototypeOf(this, HiScoresError.prototype);
|
||||
}
|
||||
}
|
||||
|
@@ -6,7 +6,9 @@ import {
|
||||
STATS_URL,
|
||||
SCORES_URL,
|
||||
SKILLS,
|
||||
ACTIVITIES
|
||||
ACTIVITIES,
|
||||
JSON_STATS_URL,
|
||||
InvalidRSNError
|
||||
} from './constants';
|
||||
|
||||
/**
|
||||
@@ -14,10 +16,13 @@ import {
|
||||
*
|
||||
* @param gamemode Gamemode to fetch ranks for.
|
||||
* @param rsn Username of the player.
|
||||
* @param json If the JSON endpoint is desired instead of CSV.
|
||||
* @returns Encoded stats URL.
|
||||
*/
|
||||
export const getStatsURL = (gamemode: Gamemode, rsn: string) =>
|
||||
`${GAMEMODE_URL[gamemode]}${STATS_URL}${encodeURIComponent(rsn)}`;
|
||||
export const getStatsURL = (gamemode: Gamemode, rsn: string, json = false) =>
|
||||
`${GAMEMODE_URL[gamemode]}${
|
||||
json ? JSON_STATS_URL : STATS_URL
|
||||
}${encodeURIComponent(rsn)}`;
|
||||
|
||||
/**
|
||||
* Will generate a player table URL for the official OSRS hiscores website.
|
||||
@@ -115,10 +120,10 @@ export const httpGet = <Response>(
|
||||
*/
|
||||
export const validateRSN = (rsn: string) => {
|
||||
if (typeof rsn !== 'string') {
|
||||
throw Error('RSN must be a string');
|
||||
throw new InvalidRSNError('RSN must be a string');
|
||||
} else if (!/^[a-zA-Z0-9 _-]+$/.test(rsn)) {
|
||||
throw Error('RSN contains invalid character');
|
||||
throw new InvalidRSNError('RSN contains invalid character');
|
||||
} else if (rsn.length > 12 || rsn.length < 1) {
|
||||
throw Error('RSN must be between 1 and 12 characters');
|
||||
throw new InvalidRSNError('RSN must be between 1 and 12 characters');
|
||||
}
|
||||
};
|
||||
|
@@ -6,10 +6,7 @@
|
||||
"outDir": "./lib",
|
||||
"strict": true,
|
||||
"lib": ["ES2015", "DOM", "DOM.Iterable"],
|
||||
"typeRoots": [
|
||||
"./node_modules/@types",
|
||||
"./src/@types"
|
||||
]
|
||||
"typeRoots": ["./node_modules/@types", "./src/@types"]
|
||||
},
|
||||
"include": ["src"],
|
||||
"exclude": ["node_modules", "**/__tests__/*"]
|
||||
|
Reference in New Issue
Block a user