mirror of
https://github.com/maxswa/osrs-json-hiscores.git
synced 2025-10-15 10:19:04 +00:00
Update getActivityPage to accept bosses.
This commit is contained in:
@@ -78,7 +78,7 @@ const topPage = await getSkillPage('overall');
|
||||
| Tournament | `tournament` |
|
||||
| Leagues | `seasonal` |
|
||||
|
||||
`getSkillPage` and `getActivityPage` require a skill/activity and optionally a gamemode and page:
|
||||
`getSkillPage` and `getActivityPage` require a skill / activity and optionally a gamemode and page:
|
||||
|
||||
```javascript
|
||||
hiscores
|
||||
@@ -109,6 +109,12 @@ Activities consist of all levels of clue scrolls as well as minigames and bosses
|
||||
| Bounty Hunter (Hunter) | `hunterBH` |
|
||||
| Last Man Standing | `lastManStanding` |
|
||||
|
||||
### Leagues
|
||||
|
||||
| Activity | Param |
|
||||
| ------------- | :------------: |
|
||||
| League Points | `leaguePoints` |
|
||||
|
||||
### Bosses
|
||||
|
||||
| Boss Name | Param |
|
||||
|
@@ -151,14 +151,15 @@ export async function getSkillPage(
|
||||
const players: PlayerSkillRow[] = playersHTML.map(row => {
|
||||
const cells = row.children.filter(el => el.name === 'td');
|
||||
const [rankEl, nameCell, levelEl, xpEl] = cells;
|
||||
const [nameEl] = nameCell.children.filter(el => el.name === 'a');
|
||||
const nameEl = nameCell.children.find(el => el.name === 'a');
|
||||
const isDead = !!nameCell.children.find(el => el.name === 'img');
|
||||
|
||||
return {
|
||||
name: rsnFromElement(nameEl),
|
||||
rank: numberFromElement(rankEl),
|
||||
level: numberFromElement(levelEl),
|
||||
xp: numberFromElement(xpEl),
|
||||
dead: nameCell.children.length === 4,
|
||||
dead: isDead,
|
||||
};
|
||||
});
|
||||
|
||||
@@ -186,13 +187,14 @@ export async function getActivityPage(
|
||||
const players: PlayerActivityRow[] = playersHTML.map(row => {
|
||||
const cells = row.children.filter(el => el.name === 'td');
|
||||
const [rankEl, nameCell, scoreEl] = cells;
|
||||
const [nameEl] = nameCell.children.filter(el => el.name === 'a');
|
||||
const nameEl = nameCell.children.find(el => el.name === 'a');
|
||||
const isDead = !!nameCell.children.find(el => el.name === 'img');
|
||||
|
||||
return {
|
||||
name: rsnFromElement(nameEl),
|
||||
rank: numberFromElement(rankEl),
|
||||
score: numberFromElement(scoreEl),
|
||||
dead: nameCell.children.length === 4,
|
||||
dead: isDead,
|
||||
};
|
||||
});
|
||||
|
||||
|
@@ -109,6 +109,7 @@ export type Boss =
|
||||
export type Bosses = { [Type in Boss]: Activity };
|
||||
|
||||
export type ActivityName =
|
||||
| 'leaguePoints'
|
||||
| 'hunterBH'
|
||||
| 'rogueBH'
|
||||
| 'lastManStanding'
|
||||
|
@@ -60,18 +60,6 @@ export const CLUES: ClueType[] = [
|
||||
'master',
|
||||
];
|
||||
export const BH_MODES: BHType[] = ['rogue', 'hunter'];
|
||||
export const ACTIVITIES: ActivityName[] = [
|
||||
'hunterBH',
|
||||
'rogueBH',
|
||||
'lastManStanding',
|
||||
'allClues',
|
||||
'beginnerClues',
|
||||
'easyClues',
|
||||
'mediumClues',
|
||||
'hardClues',
|
||||
'eliteClues',
|
||||
'masterClues',
|
||||
];
|
||||
export const GAMEMODES: Gamemode[] = [
|
||||
'main',
|
||||
'ironman',
|
||||
@@ -126,6 +114,20 @@ export const BOSSES: Boss[] = [
|
||||
'zalcano',
|
||||
'zulrah',
|
||||
];
|
||||
export const ACTIVITIES: ActivityName[] = [
|
||||
'leaguePoints',
|
||||
'hunterBH',
|
||||
'rogueBH',
|
||||
'allClues',
|
||||
'beginnerClues',
|
||||
'easyClues',
|
||||
'mediumClues',
|
||||
'hardClues',
|
||||
'eliteClues',
|
||||
'masterClues',
|
||||
'lastManStanding',
|
||||
...BOSSES,
|
||||
];
|
||||
|
||||
export type FormattedBossNames = {
|
||||
[key in Boss]: string;
|
||||
|
@@ -41,7 +41,7 @@ export const numberFromElement = (el: CheerioElement) => {
|
||||
return parseInt(number, 10);
|
||||
};
|
||||
|
||||
export const rsnFromElement = (el: CheerioElement) => {
|
||||
const innerText = el.firstChild.data;
|
||||
export const rsnFromElement = (el: CheerioElement | undefined) => {
|
||||
const innerText = el?.firstChild.data;
|
||||
return innerText ? innerText.replace(/\uFFFD/g, ' ') : '';
|
||||
};
|
||||
|
Reference in New Issue
Block a user