mirror of
https://github.com/maxswa/osrs-json-hiscores.git
synced 2025-10-15 10:19:04 +00:00
Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e0d6c5b20f | ||
|
|
c8a4440ac3 | ||
|
|
f3781cf142 | ||
|
|
5fbc04217b | ||
|
|
eb5d0ba49f | ||
|
|
c68e3bebea | ||
|
|
aa6fd6f39a | ||
|
|
cc9aae8ced | ||
|
|
12882b4e34 | ||
|
|
b17a8b9299 | ||
|
|
50f2c19257 | ||
|
|
d892f8e67b | ||
|
|
af5664ae6e | ||
|
|
20c5c2f730 | ||
|
|
04e59cff04 | ||
|
|
ad2249ba76 |
@@ -149,6 +149,7 @@ Activities consist of all levels of clue scrolls as well as minigames and bosses
|
|||||||
| K'ril Tsutsaroth | `krilTsutsaroth` |
|
| K'ril Tsutsaroth | `krilTsutsaroth` |
|
||||||
| Mimic | `mimic` |
|
| Mimic | `mimic` |
|
||||||
| The Nightmare of Ashihama | `nightmare` |
|
| The Nightmare of Ashihama | `nightmare` |
|
||||||
|
| Phosani's Nightmare | `phosanisNightmare` |
|
||||||
| Obor | `obor` |
|
| Obor | `obor` |
|
||||||
| Sarachnis | `sarachnis` |
|
| Sarachnis | `sarachnis` |
|
||||||
| Scorpia | `scorpia` |
|
| Scorpia | `scorpia` |
|
||||||
|
|||||||
@@ -1,82 +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
|
|
||||||
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
|
|
||||||
|
Can't render this file because it has a wrong number of fields in line 25.
|
@@ -11,8 +11,7 @@ import {
|
|||||||
getPlayerTableURL,
|
getPlayerTableURL,
|
||||||
getSkillPageURL,
|
getSkillPageURL,
|
||||||
getStatsURL,
|
getStatsURL,
|
||||||
BOSSES,
|
BOSSES
|
||||||
Boss
|
|
||||||
} from '../src/index';
|
} from '../src/index';
|
||||||
|
|
||||||
const B0ATY_NAME = 'B0ATY';
|
const B0ATY_NAME = 'B0ATY';
|
||||||
@@ -21,7 +20,6 @@ const LYNX_TITAN_SPACE_NAME = 'lYnX tiTaN';
|
|||||||
const LYNX_TITAN_UNDERSCORE_NAME = 'lYnX_tiTaN';
|
const LYNX_TITAN_UNDERSCORE_NAME = 'lYnX_tiTaN';
|
||||||
const LYNX_TITAN_HYPHEN_NAME = 'lYnX-tiTaN';
|
const LYNX_TITAN_HYPHEN_NAME = 'lYnX-tiTaN';
|
||||||
const LYNX_TITAN_FORMATTED_NAME = 'Lynx Titan';
|
const LYNX_TITAN_FORMATTED_NAME = 'Lynx Titan';
|
||||||
const FYSAD_FORMATTED_NAME = 'Fysad';
|
|
||||||
|
|
||||||
const attackTopPage = readFileSync(`${__dirname}/attackTopPage.html`, 'utf8');
|
const attackTopPage = readFileSync(`${__dirname}/attackTopPage.html`, 'utf8');
|
||||||
const b0atyNamePage = readFileSync(`${__dirname}/b0atyNamePage.html`, 'utf8');
|
const b0atyNamePage = readFileSync(`${__dirname}/b0atyNamePage.html`, 'utf8');
|
||||||
@@ -30,7 +28,6 @@ const lynxTitanNamePage = readFileSync(
|
|||||||
`${__dirname}/lynxTitanNamePage.html`,
|
`${__dirname}/lynxTitanNamePage.html`,
|
||||||
'utf8'
|
'utf8'
|
||||||
);
|
);
|
||||||
const fysadStatsSeasonal = readFileSync(`${__dirname}/fysadStatsSeasonal.csv`, 'utf8');
|
|
||||||
|
|
||||||
jest.spyOn(axios, 'get').mockImplementation((url) => {
|
jest.spyOn(axios, 'get').mockImplementation((url) => {
|
||||||
const lynxUrls = [
|
const lynxUrls = [
|
||||||
@@ -50,9 +47,6 @@ jest.spyOn(axios, 'get').mockImplementation((url) => {
|
|||||||
if (getStatsURL('main', LYNX_TITAN_FORMATTED_NAME) === url) {
|
if (getStatsURL('main', LYNX_TITAN_FORMATTED_NAME) === url) {
|
||||||
return Promise.resolve({ status: 200, data: lynxTitanStats });
|
return Promise.resolve({ status: 200, data: lynxTitanStats });
|
||||||
}
|
}
|
||||||
if (getStatsURL('seasonal', FYSAD_FORMATTED_NAME) === url) {
|
|
||||||
return Promise.resolve({ status: 200, data: fysadStatsSeasonal });
|
|
||||||
}
|
|
||||||
throw new Error(`No mock response for URL: ${url}`);
|
throw new Error(`No mock response for URL: ${url}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -121,6 +115,7 @@ test('Parse CSV to json', () => {
|
|||||||
120,2981
|
120,2981
|
||||||
1,109
|
1,109
|
||||||
3,22666
|
3,22666
|
||||||
|
2,84
|
||||||
26,323
|
26,323
|
||||||
201,1101
|
201,1101
|
||||||
82,3404
|
82,3404
|
||||||
@@ -212,6 +207,7 @@ test('Parse CSV to json', () => {
|
|||||||
krilTsutsaroth: { rank: 120, score: 2981 },
|
krilTsutsaroth: { rank: 120, score: 2981 },
|
||||||
mimic: { rank: 1, score: 109 },
|
mimic: { rank: 1, score: 109 },
|
||||||
nightmare: { rank: 3, score: 22666 },
|
nightmare: { rank: 3, score: 22666 },
|
||||||
|
phosanisNightmare: { rank: 2, score: 84 },
|
||||||
obor: { rank: 26, score: 323 },
|
obor: { rank: 26, score: 323 },
|
||||||
sarachnis: { rank: 201, score: 1101 },
|
sarachnis: { rank: 201, score: 1101 },
|
||||||
scorpia: { rank: 82, score: 3404 },
|
scorpia: { rank: 82, score: 3404 },
|
||||||
@@ -482,15 +478,3 @@ test('Get stats by gamemode', async () => {
|
|||||||
|
|
||||||
expect.assertions(2);
|
expect.assertions(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Get stats by game mode seasonal (omit TOB: Hard Mode from bosses)', async () => {
|
|
||||||
const {bosses} = await getStatsByGamemode(FYSAD_FORMATTED_NAME, 'seasonal');
|
|
||||||
const bossKeys = Object.keys(bosses);
|
|
||||||
|
|
||||||
const filteredBosses = BOSSES.filter(boss => boss !== 'theatreOfBloodHardMode');
|
|
||||||
|
|
||||||
expect(bossKeys).toStrictEqual(filteredBosses);
|
|
||||||
expect(bossKeys).not.toContain<Boss>('theatreOfBloodHardMode');
|
|
||||||
|
|
||||||
expect.assertions(2);
|
|
||||||
});
|
|
||||||
|
|||||||
@@ -79,4 +79,5 @@
|
|||||||
-1,-1
|
-1,-1
|
||||||
-1,-1
|
-1,-1
|
||||||
-1,-1
|
-1,-1
|
||||||
|
-1,-1
|
||||||
-1,-1
|
-1,-1
|
||||||
|
Can't render this file because it has a wrong number of fields in line 25.
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "osrs-json-hiscores",
|
"name": "osrs-json-hiscores",
|
||||||
"version": "2.5.1",
|
"version": "2.6.0",
|
||||||
"description": "The Old School Runescape API wrapper that does more!",
|
"description": "The Old School Runescape API wrapper that does more!",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"types": "lib/index.d.ts",
|
"types": "lib/index.d.ts",
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ export async function getRSNFormat(rsn: string): Promise<string> {
|
|||||||
* @param csv Raw CSV from the official OSRS API.
|
* @param csv Raw CSV from the official OSRS API.
|
||||||
* @returns Parsed stats object.
|
* @returns Parsed stats object.
|
||||||
*/
|
*/
|
||||||
export function parseStats(csv: string, mode: Gamemode = 'main'): Stats {
|
export function parseStats(csv: string): Stats {
|
||||||
const splitCSV = csv
|
const splitCSV = csv
|
||||||
.split('\n')
|
.split('\n')
|
||||||
.filter((entry) => !!entry)
|
.filter((entry) => !!entry)
|
||||||
@@ -97,17 +97,11 @@ export function parseStats(csv: string, mode: Gamemode = 'main'): Stats {
|
|||||||
return activity;
|
return activity;
|
||||||
});
|
});
|
||||||
|
|
||||||
/** `seasonal` API results don't currently include TOB: Hard Mode, so it needs to be filtered out in that case. */
|
|
||||||
const filteredBosses =
|
|
||||||
mode === 'seasonal'
|
|
||||||
? BOSSES.filter((boss) => boss !== 'theatreOfBloodHardMode')
|
|
||||||
: BOSSES;
|
|
||||||
|
|
||||||
const [leaguePoints] = activityObjects.splice(0, 1);
|
const [leaguePoints] = activityObjects.splice(0, 1);
|
||||||
const bhObjects = activityObjects.splice(0, BH_MODES.length);
|
const bhObjects = activityObjects.splice(0, BH_MODES.length);
|
||||||
const clueObjects = activityObjects.splice(0, CLUES.length);
|
const clueObjects = activityObjects.splice(0, CLUES.length);
|
||||||
const [lastManStanding, soulWarsZeal] = activityObjects.splice(0, 2);
|
const [lastManStanding, soulWarsZeal] = activityObjects.splice(0, 2);
|
||||||
const bossObjects = activityObjects.splice(0, filteredBosses.length);
|
const bossObjects = activityObjects.splice(0, BOSSES.length);
|
||||||
|
|
||||||
const skills: Skills = skillObjects.reduce<Skills>((prev, curr, index) => {
|
const skills: Skills = skillObjects.reduce<Skills>((prev, curr, index) => {
|
||||||
const newSkills = { ...prev };
|
const newSkills = { ...prev };
|
||||||
@@ -129,7 +123,7 @@ export function parseStats(csv: string, mode: Gamemode = 'main'): Stats {
|
|||||||
|
|
||||||
const bosses: Bosses = bossObjects.reduce<Bosses>((prev, curr, index) => {
|
const bosses: Bosses = bossObjects.reduce<Bosses>((prev, curr, index) => {
|
||||||
const newBosses = { ...prev };
|
const newBosses = { ...prev };
|
||||||
newBosses[filteredBosses[index]] = curr;
|
newBosses[BOSSES[index]] = curr;
|
||||||
return newBosses;
|
return newBosses;
|
||||||
}, {} as Bosses);
|
}, {} as Bosses);
|
||||||
|
|
||||||
@@ -256,7 +250,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 = parseStats(response.data, mode);
|
const stats = parseStats(response.data);
|
||||||
|
|
||||||
return stats;
|
return stats;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ export type Boss =
|
|||||||
| 'krilTsutsaroth'
|
| 'krilTsutsaroth'
|
||||||
| 'mimic'
|
| 'mimic'
|
||||||
| 'nightmare'
|
| 'nightmare'
|
||||||
|
| 'phosanisNightmare'
|
||||||
| 'obor'
|
| 'obor'
|
||||||
| 'sarachnis'
|
| 'sarachnis'
|
||||||
| 'scorpia'
|
| 'scorpia'
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ export const BOSSES: Boss[] = [
|
|||||||
'krilTsutsaroth',
|
'krilTsutsaroth',
|
||||||
'mimic',
|
'mimic',
|
||||||
'nightmare',
|
'nightmare',
|
||||||
|
'phosanisNightmare',
|
||||||
'obor',
|
'obor',
|
||||||
'sarachnis',
|
'sarachnis',
|
||||||
'scorpia',
|
'scorpia',
|
||||||
@@ -166,6 +167,7 @@ export const FORMATTED_BOSS_NAMES: FormattedBossNames = {
|
|||||||
krilTsutsaroth: "K'ril Tsutsaroth",
|
krilTsutsaroth: "K'ril Tsutsaroth",
|
||||||
mimic: 'Mimic',
|
mimic: 'Mimic',
|
||||||
nightmare: 'The Nightmare of Ashihama',
|
nightmare: 'The Nightmare of Ashihama',
|
||||||
|
phosanisNightmare: "Phosani's Nightmare",
|
||||||
obor: 'Obor',
|
obor: 'Obor',
|
||||||
sarachnis: 'Sarachnis',
|
sarachnis: 'Sarachnis',
|
||||||
scorpia: 'Scorpia',
|
scorpia: 'Scorpia',
|
||||||
|
|||||||
18
yarn.lock
18
yarn.lock
@@ -2775,9 +2775,9 @@ has@^1.0.3:
|
|||||||
function-bind "^1.1.1"
|
function-bind "^1.1.1"
|
||||||
|
|
||||||
hosted-git-info@^2.1.4:
|
hosted-git-info@^2.1.4:
|
||||||
version "2.8.8"
|
version "2.8.9"
|
||||||
resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.8.tgz#7539bd4bc1e0e0a895815a2e0262420b12858488"
|
resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.9.tgz#dffc0bf9a21c02209090f2aa69429e1414daf3f9"
|
||||||
integrity sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==
|
integrity sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==
|
||||||
|
|
||||||
hosted-git-info@^3.0.0:
|
hosted-git-info@^3.0.0:
|
||||||
version "3.0.8"
|
version "3.0.8"
|
||||||
@@ -4411,9 +4411,9 @@ normalize-path@^3.0.0:
|
|||||||
integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==
|
integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==
|
||||||
|
|
||||||
normalize-url@^4.1.0:
|
normalize-url@^4.1.0:
|
||||||
version "4.5.0"
|
version "4.5.1"
|
||||||
resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-4.5.0.tgz#453354087e6ca96957bd8f5baf753f5982142129"
|
resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-4.5.1.tgz#0dd90cf1288ee1d1313b87081c9a5932ee48518a"
|
||||||
integrity sha512-2s47yzUxdexf1OhyRi4Em83iQk0aPvwTddtFz4hnSSw9dCEsLEGf6SwIO8ss/19S9iBb5sJaOuTvTGDeZI00BQ==
|
integrity sha512-9UZCFRHQdNrfTpGg8+1INIg93B6zE0aXMVFkw1WFwvO4SlZywU6aLg5Of0Ap/PgcbSw4LNxvMWXMeugwMCX0AA==
|
||||||
|
|
||||||
normalize-version@^1.0.5:
|
normalize-version@^1.0.5:
|
||||||
version "1.0.5"
|
version "1.0.5"
|
||||||
@@ -5968,9 +5968,9 @@ tr46@^2.0.2:
|
|||||||
punycode "^2.1.1"
|
punycode "^2.1.1"
|
||||||
|
|
||||||
trim-newlines@^3.0.0:
|
trim-newlines@^3.0.0:
|
||||||
version "3.0.0"
|
version "3.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-3.0.0.tgz#79726304a6a898aa8373427298d54c2ee8b1cb30"
|
resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-3.0.1.tgz#260a5d962d8b752425b32f3a7db0dcacd176c144"
|
||||||
integrity sha512-C4+gOpvmxaSMKuEf9Qc134F1ZuOHVXKRbtEflf4NTtuuJDEIJ9p5PXsalL8SkeRw+qit1Mo+yuvMPAKwWg/1hA==
|
integrity sha512-c1PTsA3tYrIsLGkJkzHF+w9F2EyxfXGo4UyJc4pFL++FMjnq0HJS69T3M7d//gKrFKwy429bouPescbjecU+Zw==
|
||||||
|
|
||||||
ts-jest@^26.5.4:
|
ts-jest@^26.5.4:
|
||||||
version "26.5.4"
|
version "26.5.4"
|
||||||
|
|||||||
Reference in New Issue
Block a user