Merge pull request #37 from Not-Jayden/revert-seasonal-changes

[Bug] Remove conditional `seasonal` gameMode logic for bosses
This commit is contained in:
Max Swartwout
2021-06-11 14:44:07 -04:00
committed by GitHub
3 changed files with 5 additions and 111 deletions

View File

@@ -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
1 1 2277 4600000000
2 15 99 200000000
3 28 99 200000000
4 18 99 200000000
5 7 99 200000000
6 8 99 200000000
7 11 99 200000000
8 32 99 200000000
9 159 99 200000000
10 15 99 200000000
11 12 99 200000000
12 9 99 200000000
13 48 99 200000000
14 4 99 200000000
15 3 99 200000000
16 25 99 200000000
17 5 99 200000000
18 23 99 200000000
19 12 99 200000000
20 2 99 200000000
21 19 99 200000000
22 7 99 200000000
23 4 99 200000000
24 4 99 200000000
25 -1 -1
26 -1 -1
27 -1 -1
28 -1 -1
29 -1 -1
30 -1 -1
31 -1 -1
32 347584 22
33 -1 -1
34 -1 -1
35 -1 -1
36 -1 -1
37 -1 -1
38 -1 -1
39 -1 -1
40 -1 -1
41 -1 -1
42 -1 -1
43 -1 -1
44 -1 -1
45 -1 -1
46 -1 -1
47 -1 -1
48 -1 -1
49 -1 -1
50 -1 -1
51 -1 -1
52 -1 -1
53 -1 -1
54 -1 -1
55 -1 -1
56 -1 -1
57 -1 -1
58 -1 -1
59 -1 -1
60 -1 -1
61 -1 -1
62 -1 -1
63 -1 -1
64 -1 -1
65 -1 -1
66 -1 -1
67 -1 -1
68 -1 -1
69 -1 -1
70 -1 -1
71 -1 -1
72 -1 -1
73 -1 -1
74 -1 -1
75 -1 -1
76 -1 -1
77 -1 -1
78 -1 -1
79 -1 -1
80 -1 -1
81 -1 -1
82 -1 -1

View File

@@ -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}`);
}); });
@@ -482,15 +476,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);
});

View File

@@ -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;
} }