Skip to content

Commit

Permalink
delete seasonal changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Not-Jayden committed Jun 9, 2021
1 parent 04e59cf commit 20c5c2f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 111 deletions.
82 changes: 0 additions & 82 deletions __tests__/fysadStatsSeasonal.csv

This file was deleted.

20 changes: 1 addition & 19 deletions __tests__/hiscores.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import {
getPlayerTableURL,
getSkillPageURL,
getStatsURL,
BOSSES,
Boss
BOSSES
} from '../src/index';

const B0ATY_NAME = 'B0ATY';
Expand All @@ -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');
Expand All @@ -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 = [
Expand All @@ -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}`);
});

Expand Down Expand Up @@ -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<Boss>('theatreOfBloodHardMode');

expect.assertions(2);
});
14 changes: 4 additions & 10 deletions src/hiscores.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export async function getRSNFormat(rsn: string): Promise<string> {
* @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)
Expand Down Expand Up @@ -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<Skills>((prev, curr, index) => {
const newSkills = { ...prev };
Expand All @@ -129,7 +123,7 @@ export function parseStats(csv: string, mode: Gamemode = 'main'): Stats {

const bosses: Bosses = bossObjects.reduce<Bosses>((prev, curr, index) => {
const newBosses = { ...prev };
newBosses[filteredBosses[index]] = curr;
newBosses[BOSSES[index]] = curr;
return newBosses;
}, {} as Bosses);

Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 20c5c2f

Please sign in to comment.