Skip to content

Commit

Permalink
yes
Browse files Browse the repository at this point in the history
  • Loading branch information
DuckySoLucky committed Nov 25, 2024
1 parent 2efab66 commit 57e3ab9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
19 changes: 10 additions & 9 deletions src/lib/stats/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,13 @@ function getRaces(userProfile: Member) {
const isReturn = id.endsWith("_with_return_best_time");
const dungeonRaceId = raceId.replace(isReturn ? "_with_return" : "_no_return", "");

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
output[shortId].races[isReturn ? "with_return" : "no_return"][dungeonRaceId] = {
name: constants.RACE_NAMES[dungeonRaceId] ?? dungeonRaceId.split("_").map(helper.titleCase).join(" "),
time: data
};
const raceType = isReturn ? "with_return" : "no_return";
if (output[shortId].races[raceType] !== null) {
(output[shortId].races[raceType] as Misc["races"]["string"]["races"])[dungeonRaceId] = {
name: constants.RACE_NAMES[dungeonRaceId] ?? dungeonRaceId.split("_").map(helper.titleCase).join(" "),
time: data
};
}

if (output[shortId].races.with_return && Object.keys(output[shortId].races.with_return).length === 0) {
output[shortId].races.with_return = null;
Expand All @@ -113,11 +114,11 @@ function getRaces(userProfile: Member) {
}

function getDragons(userProfile: Member) {
const dragonKills = Object.keys(userProfile.player_stats.kills)
const lastDragonHits = Object.keys(userProfile.player_stats.kills)
.filter((key) => key.endsWith("_dragon") && !key.startsWith("master_wither_king"))
.reduce((obj, key) => ({ ...obj, [key.replace("_dragon", "")]: userProfile.player_stats.kills[key] }), {}) as Record<string, number>;

Object.assign(dragonKills, { total: Object.values(dragonKills).reduce((a, b) => a + b, 0) });
Object.assign(lastDragonHits, { total: Object.values(lastDragonHits).reduce((a, b) => a + b, 0) });

const dragonDeaths = Object.keys(userProfile.player_stats.deaths)
.filter((key) => key.endsWith("_dragon") && !key.startsWith("master_wither_king"))
Expand All @@ -129,7 +130,7 @@ function getDragons(userProfile: Member) {
ender_crystals_destroyed: userProfile.player_stats.end_island.dragon_fight.ender_crystals_destroyed,
most_damage: userProfile.player_stats.end_island.dragon_fight.most_damage,
fastest_kill: userProfile.player_stats.end_island.dragon_fight.fastest_kill,
kills: dragonKills,
last_hits: lastDragonHits,
deaths: dragonDeaths
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/types/processed/profile/misc.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export type Misc = {
ender_crystals_destroyed: number;
most_damage: Record<string, number>;
fastest_kill: Record<string, number>;
kills: Record<string, number>;
last_hits: Record<string, number>;
deaths: Record<string, number>;
};
endstone_protector: {
Expand Down

0 comments on commit 57e3ab9

Please sign in to comment.