From 20c5c2f730b2f170357aad40783ef85c75492b6a Mon Sep 17 00:00:00 2001 From: NotJayden Date: Thu, 10 Jun 2021 00:15:11 +0800 Subject: [PATCH] delete seasonal changes --- __tests__/fysadStatsSeasonal.csv | 82 -------------------------------- __tests__/hiscores.test.ts | 20 +------- src/hiscores.ts | 14 ++---- 3 files changed, 5 insertions(+), 111 deletions(-) delete mode 100644 __tests__/fysadStatsSeasonal.csv diff --git a/__tests__/fysadStatsSeasonal.csv b/__tests__/fysadStatsSeasonal.csv deleted file mode 100644 index fb7dfd3..0000000 --- a/__tests__/fysadStatsSeasonal.csv +++ /dev/null @@ -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 \ No newline at end of file diff --git a/__tests__/hiscores.test.ts b/__tests__/hiscores.test.ts index df0fe44..336921a 100644 --- a/__tests__/hiscores.test.ts +++ b/__tests__/hiscores.test.ts @@ -11,8 +11,7 @@ import { getPlayerTableURL, getSkillPageURL, getStatsURL, - BOSSES, - Boss + BOSSES } from '../src/index'; 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_HYPHEN_NAME = 'lYnX-tiTaN'; const LYNX_TITAN_FORMATTED_NAME = 'Lynx Titan'; -const FYSAD_FORMATTED_NAME = 'Fysad'; const attackTopPage = readFileSync(`${__dirname}/attackTopPage.html`, 'utf8'); const b0atyNamePage = readFileSync(`${__dirname}/b0atyNamePage.html`, 'utf8'); @@ -30,7 +28,6 @@ const lynxTitanNamePage = readFileSync( `${__dirname}/lynxTitanNamePage.html`, 'utf8' ); -const fysadStatsSeasonal = readFileSync(`${__dirname}/fysadStatsSeasonal.csv`, 'utf8'); jest.spyOn(axios, 'get').mockImplementation((url) => { const lynxUrls = [ @@ -50,9 +47,6 @@ jest.spyOn(axios, 'get').mockImplementation((url) => { if (getStatsURL('main', LYNX_TITAN_FORMATTED_NAME) === url) { 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}`); }); @@ -482,15 +476,3 @@ test('Get stats by gamemode', async () => { 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('theatreOfBloodHardMode'); - - expect.assertions(2); -}); diff --git a/src/hiscores.ts b/src/hiscores.ts index f4ecd90..2b3ce0d 100644 --- a/src/hiscores.ts +++ b/src/hiscores.ts @@ -68,7 +68,7 @@ export async function getRSNFormat(rsn: string): Promise { * @param csv Raw CSV from the official OSRS API. * @returns Parsed stats object. */ -export function parseStats(csv: string, mode: Gamemode = 'main'): Stats { +export function parseStats(csv: string): Stats { const splitCSV = csv .split('\n') .filter((entry) => !!entry) @@ -97,17 +97,11 @@ export function parseStats(csv: string, mode: Gamemode = 'main'): Stats { 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 bhObjects = activityObjects.splice(0, BH_MODES.length); const clueObjects = activityObjects.splice(0, CLUES.length); 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((prev, curr, index) => { const newSkills = { ...prev }; @@ -129,7 +123,7 @@ export function parseStats(csv: string, mode: Gamemode = 'main'): Stats { const bosses: Bosses = bossObjects.reduce((prev, curr, index) => { const newBosses = { ...prev }; - newBosses[filteredBosses[index]] = curr; + newBosses[BOSSES[index]] = curr; return newBosses; }, {} as Bosses); @@ -256,7 +250,7 @@ export async function getStatsByGamemode( if (response.status !== 200) { throw Error('Player not found'); } - const stats = parseStats(response.data, mode); + const stats = parseStats(response.data); return stats; }