Skip to content

Commit

Permalink
fix(hiscores): fix scurrius breaking hiscores
Browse files Browse the repository at this point in the history
  • Loading branch information
FreekMencke committed Jan 24, 2024
1 parent e0a2fdb commit 345df2c
Show file tree
Hide file tree
Showing 18 changed files with 295 additions and 15 deletions.
4 changes: 4 additions & 0 deletions @osrs-tracker/hiscores/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v0.1.3 - 2023/09/11

- Add scurrius to parser to fix parser.

## v0.1.2 - 2023/09/11

- Fix bad DT2 boss parsing order.
Expand Down
1 change: 1 addition & 0 deletions @osrs-tracker/hiscores/dist/models/hiscore.enum.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export declare enum BossEnum {
PhantomMuspah = "Phantom Muspah",
Sarachnis = "Sarachnis",
Scorpia = "Scorpia",
Scurrius = "Scurrius",
Skotizo = "Skotizo",
Spindel = "Spindel",
Tempoross = "Tempoross",
Expand Down
1 change: 1 addition & 0 deletions @osrs-tracker/hiscores/dist/models/hiscore.enum.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export var BossEnum;
BossEnum["PhantomMuspah"] = "Phantom Muspah";
BossEnum["Sarachnis"] = "Sarachnis";
BossEnum["Scorpia"] = "Scorpia";
BossEnum["Scurrius"] = "Scurrius";
BossEnum["Skotizo"] = "Skotizo";
BossEnum["Spindel"] = "Spindel";
BossEnum["Tempoross"] = "Tempoross";
Expand Down
6 changes: 4 additions & 2 deletions @osrs-tracker/hiscores/dist/parser/parse-order/parse-order.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { PO_2023_04_13 } from './po-2023-04-13';
import { PO_2023_05_25 } from './po-2023-05-24';
import { PO_2023_07_27 } from './po-2023-07-27';
import { PO_2023_08_24 } from './po-2023-08-24';
import { PO_2023_08_23 } from './po-2023-08-23';
import { PO_2024_01_24 } from './po-2024-01-24';
import { PO_DEFAULT } from './po-default';
export const ParseOrderMap = {
'2023-08-24': PO_2023_08_24,
'2024-01-24': PO_2024_01_24,
'2023-08-23': PO_2023_08_23,
'2023-07-27': PO_2023_07_27,
'2023-05-25': PO_2023_05_25,
'2023-04-13': PO_2023_04_13,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { ParseOrder } from './parse-order';
export declare const PO_2023_08_23: ParseOrder;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BossEnum, BountyHunterEnum, ClueScrollsEnum, CompetitiveEnum, MiniGameEnum, RaidEnum, SkillEnum, } from '../../models/hiscore.enum';
export const PO_2023_08_24 = [
export const PO_2023_08_23 = [
SkillEnum.Overall,
SkillEnum.Attack,
SkillEnum.Defence,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { ParseOrder } from './parse-order';
export declare const PO_2024_01_24: ParseOrder;
103 changes: 103 additions & 0 deletions @osrs-tracker/hiscores/dist/parser/parse-order/po-2024-01-24.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import { BossEnum, BountyHunterEnum, ClueScrollsEnum, CompetitiveEnum, MiniGameEnum, RaidEnum, SkillEnum, } from '../../models/hiscore.enum';
export const PO_2024_01_24 = [
SkillEnum.Overall,
SkillEnum.Attack,
SkillEnum.Defence,
SkillEnum.Strength,
SkillEnum.Hitpoints,
SkillEnum.Ranged,
SkillEnum.Prayer,
SkillEnum.Magic,
SkillEnum.Cooking,
SkillEnum.Woodcutting,
SkillEnum.Fletching,
SkillEnum.Fishing,
SkillEnum.Firemaking,
SkillEnum.Crafting,
SkillEnum.Smithing,
SkillEnum.Mining,
SkillEnum.Herblore,
SkillEnum.Agility,
SkillEnum.Thieving,
SkillEnum.Slayer,
SkillEnum.Farming,
SkillEnum.Runecraft,
SkillEnum.Hunter,
SkillEnum.Construction,
CompetitiveEnum.LeaguePoints,
CompetitiveEnum.Unknown,
BountyHunterEnum.BountyHunter,
BountyHunterEnum.BountyHunterRogues,
BountyHunterEnum.BountyHunterLegacy,
BountyHunterEnum.BountyHunterLegacyRogues,
ClueScrollsEnum.ClueScrollsAll,
ClueScrollsEnum.ClueScrollsBeginner,
ClueScrollsEnum.ClueScrollsEasy,
ClueScrollsEnum.ClueScrollsMedium,
ClueScrollsEnum.ClueScrollsHard,
ClueScrollsEnum.ClueScrollsElite,
ClueScrollsEnum.ClueScrollsMaster,
CompetitiveEnum.LastManStanding,
CompetitiveEnum.PvpArena,
MiniGameEnum.SoulWarsZeal,
MiniGameEnum.RiftsClosed,
BossEnum.AbyssalSire,
BossEnum.AlchemicalHydra,
BossEnum.Artio,
BossEnum.BarrowsChests,
BossEnum.Bryophyta,
BossEnum.Callisto,
BossEnum.Calvarion,
BossEnum.Cerberus,
RaidEnum.ChambersOfXeric,
RaidEnum.ChambersOfXericChallengeMode,
BossEnum.ChaosElemental,
BossEnum.ChaosFanatic,
BossEnum.CommanderZilyana,
BossEnum.CorporealBeast,
BossEnum.CrazyArchaeologist,
BossEnum.DagannothPrime,
BossEnum.DagannothRex,
BossEnum.DagannothSupreme,
BossEnum.DerangedArchaeologist,
BossEnum.DukeSucellus,
BossEnum.GeneralGraardor,
BossEnum.GiantMole,
BossEnum.GrotesqueGuardians,
BossEnum.Hespori,
BossEnum.KalphiteQueen,
BossEnum.KingBlackDragon,
BossEnum.Kraken,
BossEnum.KreeArra,
BossEnum.KrilTsutsaroth,
BossEnum.Mimic,
BossEnum.Nex,
BossEnum.Nightmare,
BossEnum.PhosanisNightmare,
BossEnum.Obor,
BossEnum.PhantomMuspah,
BossEnum.Sarachnis,
BossEnum.Scorpia,
BossEnum.Scurrius,
BossEnum.Skotizo,
BossEnum.Spindel,
BossEnum.Tempoross,
RaidEnum.TheGauntlet,
RaidEnum.TheCorruptedGauntlet,
BossEnum.TheLeviathan,
BossEnum.TheWhisperer,
RaidEnum.TheatreOfBlood,
RaidEnum.TheatreOfBloodHardMode,
BossEnum.ThermoNuclearSmokeDevil,
RaidEnum.TombsOfAmascut,
RaidEnum.TombsOfAmascutExpertMode,
BossEnum.TzKalZuk,
BossEnum.TzTokJad,
BossEnum.Vardorvis,
BossEnum.Venenatis,
BossEnum.Vetion,
BossEnum.Vorkath,
BossEnum.Wintertodt,
BossEnum.Zalcano,
BossEnum.Zulrah,
];
5 changes: 3 additions & 2 deletions @osrs-tracker/hiscores/dist/parser/parser.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isAfter, parseISO } from 'date-fns';
import { addHours, isAfter, parseISO } from 'date-fns';
import { BossEnum, BountyHunterEnum, ClueScrollsEnum, CompetitiveEnum, MiniGameEnum, RaidEnum, SkillEnum, } from '../models/hiscore.enum';
import { ParseOrderMap } from './parse-order/parse-order';
import { PO_DEFAULT } from './parse-order/po-default';
Expand Down Expand Up @@ -96,8 +96,9 @@ function getSkillFromSourceString(sourceString, skill, date) {
}
function getCurrentParser(dateToParse) {
for (const [parseDate, parser] of Object.entries(ParseOrderMap)) {
if (isAfter(dateToParse, parseISO(parseDate)))
if (isAfter(dateToParse, addHours(parseISO(parseDate), 11))) {
return parser;
}
}
return PO_DEFAULT;
}
Expand Down
2 changes: 1 addition & 1 deletion @osrs-tracker/hiscores/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@osrs-tracker/hiscores",
"version": "0.1.2",
"version": "0.1.3",
"description": "Logic for parsing OSRS hiscores",
"license": "MIT",
"author": "Freek Mencke",
Expand Down
1 change: 1 addition & 0 deletions @osrs-tracker/hiscores/src/models/hiscore.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export enum BossEnum {
PhantomMuspah = 'Phantom Muspah',
Sarachnis = 'Sarachnis',
Scorpia = 'Scorpia',
Scurrius = 'Scurrius', // New boss 24/01/2024
Skotizo = 'Skotizo',
Spindel = 'Spindel', // New boss 13/04/2023
Tempoross = 'Tempoross',
Expand Down
6 changes: 4 additions & 2 deletions @osrs-tracker/hiscores/src/parser/parse-order/parse-order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import { HiscoreLineType } from '../../models/hiscore.model';
import { PO_2023_04_13 } from './po-2023-04-13';
import { PO_2023_05_25 } from './po-2023-05-24';
import { PO_2023_07_27 } from './po-2023-07-27';
import { PO_2023_08_24 } from './po-2023-08-24';
import { PO_2023_08_23 } from './po-2023-08-23';
import { PO_2024_01_24 } from './po-2024-01-24';
import { PO_DEFAULT } from './po-default';

export type ParseOrder = HiscoreLineType[];

export const ParseOrderMap: { [date: string]: ParseOrder } = {
'2023-08-24': PO_2023_08_24,
'2024-01-24': PO_2024_01_24,
'2023-08-23': PO_2023_08_23,
'2023-07-27': PO_2023_07_27,
'2023-05-25': PO_2023_05_25,
'2023-04-13': PO_2023_04_13,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { describe, expect, it } from '@jest/globals';
import { BossEnum, CompetitiveEnum } from '../../models/hiscore.enum';
import { parseHiscoreString } from '../parser';

describe('Parser with 2023-08-24 parse order', () => {
describe('Parser with 2023-08-23 parse order', () => {
it('should parse new competitive', () => {
const hiscoreString =
'1,2277,4330000070\n32,99,200000000\n10,99,200000000\n479,99,200000000\n16,99,200000000\n6,99,200000000\n2,99,200000000\n7,99,200000000\n183,99,200000000\n32,99,200000000\n7,99,200000000\n82,99,200000000\n30,99,200000000\n4,99,200000000\n6,99,200000000\n16,99,200000000\n8,99,200000000\n65,99,36999992\n13,99,200000000\n2,99,200000000\n7,99,200000000\n2,99,93000078\n5,99,200000000\n2,99,200000000\n11610,27665\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n101703,2\n110796,1\n-1,-1\n-1,-1\n48926,1\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n14464,72\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n16137,226\n-1,-1\n-1,-1\n425,15\n-1,-1\n-1,-1\n34244,75\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n2110,25\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n22229,63';

const hiscore = parseHiscoreString(hiscoreString, new Date(2023, 7, 24, 1));
const hiscore = parseHiscoreString(hiscoreString, new Date(2023, 7, 23, 13));

expect(hiscore.competitive[CompetitiveEnum.LeaguePoints]).toEqual({
name: CompetitiveEnum.LeaguePoints,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import { ParseOrder } from './parse-order';

/** Deadman: Apocalypse */
export const PO_2023_08_24: ParseOrder = [
export const PO_2023_08_23: ParseOrder = [
SkillEnum.Overall,
SkillEnum.Attack,
SkillEnum.Defence,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { describe, expect, it } from '@jest/globals';
import { BossEnum, BountyHunterEnum } from '../../models/hiscore.enum';
import { parseHiscoreString } from '../parser';

describe('Parser with 2024-01-24 parse order', () => {
it('should parse new scurries', () => {
const hiscoreString =
'29662,2277,412893314\n60733,99,21973569\n37363,99,21038715\n51220,99,33114139\n57327,99,44221838\n70048,99,39958954\n34499,99,13373152\n78574,99,20610579\n78127,99,14436977\n59847,99,13788559\n86251,99,13184630\n51249,99,13650444\n65642,99,13933700\n37083,99,14410362\n85067,99,13038084\n77902,99,13095989\n25776,99,13460001\n17417,99,13911338\n58982,99,13750029\n77538,99,14736808\n140480,99,13686733\n44726,99,13087967\n64775,99,13080480\n14895,99,13350267\n-1,-1\n-1,-1\n-1,-1\n-1,-1\n159115,7\n-1,-1\n14635,1512\n890029,2\n12263,403\n31643,386\n13416,449\n5594,204\n29859,68\n-1,-1\n-1,-1\n-1,-1\n109537,188\n91086,249\n92002,592\n-1,-1\n64961,596\n3419,156\n207907,6\n-1,-1\n75687,762\n41830,455\n-1,-1\n130828,25\n164821,25\n100946,118\n6563,1000\n202760,28\n133125,179\n171104,217\n130469,184\n108439,25\n-1,-1\n88128,413\n68299,466\n177094,54\n50015,110\n103760,115\n126853,258\n165022,1428\n46729,270\n27133,342\n21062,8\n-1,-1\n-1,-1\n27037,20\n215320,6\n-1,-1\n154289,42\n104259,30\n-1,-1\n218294,22\n-1,-1\n197906,86\n-1,-1\n86572,177\n-1,-1\n-1,-1\n28689,179\n-1,-1\n223859,23\n34128,113\n23940,165\n61722,1\n62789,14\n10282,1051\n-1,-1\n142826,9\n248070,232\n27721,688\n10186,638\n67481,1459';

const hiscore = parseHiscoreString(hiscoreString, new Date(2024, 0, 24, 12));

expect(hiscore.bountyHunter[BountyHunterEnum.BountyHunterLegacy]).toEqual({
name: BountyHunterEnum.BountyHunterLegacy,
rank: 159115,
score: 7,
});
expect(hiscore.bosses[BossEnum.Scorpia]).toEqual({
name: BossEnum.Scorpia,
rank: 104259,
score: 30,
});
expect(hiscore.bosses[BossEnum.Scurrius]).toEqual({
name: BossEnum.Scurrius,
rank: -1,
score: -1,
});
expect(hiscore.bosses[BossEnum.Skotizo]).toEqual({
name: BossEnum.Skotizo,
rank: 218294,
score: 22,
});
});
});
128 changes: 128 additions & 0 deletions @osrs-tracker/hiscores/src/parser/parse-order/po-2024-01-24.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
import {
BossEnum,
BountyHunterEnum,
ClueScrollsEnum,
CompetitiveEnum,
MiniGameEnum,
RaidEnum,
SkillEnum,
} from '../../models/hiscore.enum';
import { ParseOrder } from './parse-order';

/** Deadman: Apocalypse */
export const PO_2024_01_24: ParseOrder = [
SkillEnum.Overall,
SkillEnum.Attack,
SkillEnum.Defence,
SkillEnum.Strength,
SkillEnum.Hitpoints,
SkillEnum.Ranged,
SkillEnum.Prayer,
SkillEnum.Magic,
SkillEnum.Cooking,
SkillEnum.Woodcutting,
SkillEnum.Fletching,
SkillEnum.Fishing,
SkillEnum.Firemaking,
SkillEnum.Crafting,
SkillEnum.Smithing,
SkillEnum.Mining,
SkillEnum.Herblore,
SkillEnum.Agility,
SkillEnum.Thieving,
SkillEnum.Slayer,
SkillEnum.Farming,
SkillEnum.Runecraft,
SkillEnum.Hunter,
SkillEnum.Construction,

CompetitiveEnum.LeaguePoints,
CompetitiveEnum.Unknown,

BountyHunterEnum.BountyHunter,
BountyHunterEnum.BountyHunterRogues,
BountyHunterEnum.BountyHunterLegacy,
BountyHunterEnum.BountyHunterLegacyRogues,

ClueScrollsEnum.ClueScrollsAll,
ClueScrollsEnum.ClueScrollsBeginner,
ClueScrollsEnum.ClueScrollsEasy,
ClueScrollsEnum.ClueScrollsMedium,
ClueScrollsEnum.ClueScrollsHard,
ClueScrollsEnum.ClueScrollsElite,
ClueScrollsEnum.ClueScrollsMaster,

CompetitiveEnum.LastManStanding,
CompetitiveEnum.PvpArena,

MiniGameEnum.SoulWarsZeal,
MiniGameEnum.RiftsClosed,

BossEnum.AbyssalSire,
BossEnum.AlchemicalHydra,
BossEnum.Artio,
BossEnum.BarrowsChests,
BossEnum.Bryophyta,
BossEnum.Callisto,
BossEnum.Calvarion,
BossEnum.Cerberus,

RaidEnum.ChambersOfXeric,
RaidEnum.ChambersOfXericChallengeMode,

BossEnum.ChaosElemental,
BossEnum.ChaosFanatic,
BossEnum.CommanderZilyana,
BossEnum.CorporealBeast,
BossEnum.CrazyArchaeologist,
BossEnum.DagannothPrime,
BossEnum.DagannothRex,
BossEnum.DagannothSupreme,
BossEnum.DerangedArchaeologist,
BossEnum.DukeSucellus,
BossEnum.GeneralGraardor,
BossEnum.GiantMole,
BossEnum.GrotesqueGuardians,
BossEnum.Hespori,
BossEnum.KalphiteQueen,
BossEnum.KingBlackDragon,
BossEnum.Kraken,
BossEnum.KreeArra,
BossEnum.KrilTsutsaroth,
BossEnum.Mimic,
BossEnum.Nex,
BossEnum.Nightmare,
BossEnum.PhosanisNightmare,
BossEnum.Obor,
BossEnum.PhantomMuspah,
BossEnum.Sarachnis,
BossEnum.Scorpia,
BossEnum.Scurrius,
BossEnum.Skotizo,
BossEnum.Spindel,
BossEnum.Tempoross,

RaidEnum.TheGauntlet,
RaidEnum.TheCorruptedGauntlet,

BossEnum.TheLeviathan,
BossEnum.TheWhisperer,

RaidEnum.TheatreOfBlood,
RaidEnum.TheatreOfBloodHardMode,

BossEnum.ThermoNuclearSmokeDevil,

RaidEnum.TombsOfAmascut,
RaidEnum.TombsOfAmascutExpertMode,

BossEnum.TzKalZuk,
BossEnum.TzTokJad,
BossEnum.Vardorvis,
BossEnum.Venenatis,
BossEnum.Vetion,
BossEnum.Vorkath,
BossEnum.Wintertodt,
BossEnum.Zalcano,
BossEnum.Zulrah,
];
Loading

0 comments on commit 345df2c

Please sign in to comment.