Skip to content

Commit

Permalink
Merge pull request #2188 from DuckySoLucky/fixRacesv69
Browse files Browse the repository at this point in the history
fix: races
  • Loading branch information
Shiiyu authored Feb 26, 2024
2 parents 22749ea + 49f04d9 commit 4eca3de
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 99 deletions.
56 changes: 1 addition & 55 deletions src/constants/misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@ export const SLAYER_COST = {
5: 100000,
};

export const MOB_MOUNTS = {
sea_emperor: ["guardian_emperor", "skeleton_emperor"],
monster_of_the_deep: ["zombie_deep", "chicken_deep"],
};

export const MOB_NAMES = {
pond_squid: "Squid",
unburried_zombie: "Crypt Ghoul",
Expand All @@ -100,54 +95,13 @@ export const MOB_NAMES = {
pig_rider: "Taurus",
};

export const RACE_OBJECTIVE_TO_STAT_NAME = {
complete_the_end_race: "end_race_best_time",
complete_the_woods_race: "foraging_race_best_time",
complete_the_chicken_race: "chicken_race_best_time_2",
complete_the_giant_mushroom_anything_with_return_race: "dungeon_hub_giant_mushroom_anything_with_return_best_time",
complete_the_giant_mushroom_no_pearls_with_return_race: "dungeon_hub_giant_mushroom_no_pearls_with_return_best_time",
complete_the_giant_mushroom_no_abilities_with_return_race:
"dungeon_hub_giant_mushroom_no_abilities_with_return_best_time",
complete_the_giant_mushroom_nothing_with_return_race: "dungeon_hub_giant_mushroom_nothing_with_return_best_time",
complete_the_precursor_ruins_anything_with_return_race: "dungeon_hub_precursor_ruins_anything_with_return_best_time",
complete_the_precursor_ruins_no_pearls_with_return_race:
"dungeon_hub_precursor_ruins_no_pearls_with_return_best_time",
complete_the_precursor_ruins_no_abilities_with_return_race:
"dungeon_hub_precursor_ruins_no_abilities_with_return_best_time",
complete_the_precursor_ruins_nothing_with_return_race: "dungeon_hub_precursor_ruins_nothing_with_return_best_time",
complete_the_crystal_core_anything_with_return_race: "dungeon_hub_crystal_core_anything_with_return_best_time",
complete_the_crystal_core_no_pearls_with_return_race: "dungeon_hub_crystal_core_no_pearls_with_return_best_time",
complete_the_crystal_core_no_abilities_with_return_race:
"dungeon_hub_crystal_core_no_abilities_with_return_best_time",
complete_the_crystal_core_nothing_with_return_race: "dungeon_hub_crystal_core_nothing_with_return_best_time",
complete_the_giant_mushroom_anything_no_return_race: "dungeon_hub_giant_mushroom_anything_no_return_best_time",
complete_the_giant_mushroom_no_pearls_no_return_race: "dungeon_hub_giant_mushroom_no_pearls_no_return_best_time",
complete_the_giant_mushroom_no_abilities_no_return_race:
"dungeon_hub_giant_mushroom_no_abilities_no_return_best_time",
complete_the_giant_mushroom_nothing_no_return_race: "dungeon_hub_giant_mushroom_nothing_no_return_best_time",
complete_the_precursor_ruins_anything_no_return_race: "dungeon_hub_precursor_ruins_anything_no_return_best_time",
complete_the_precursor_ruins_no_pearls_no_return_race: "dungeon_hub_precursor_ruins_no_pearls_no_return_best_time",
complete_the_precursor_ruins_no_abilities_no_return_race:
"dungeon_hub_precursor_ruins_no_abilities_no_return_best_time",
complete_the_precursor_ruins_nothing_no_return_race: "dungeon_hub_precursor_ruins_nothing_no_return_best_time",
complete_the_crystal_core_anything_no_return_race: "dungeon_hub_crystal_core_anything_no_return_best_time",
complete_the_crystal_core_no_pearls_no_return_race: "dungeon_hub_crystal_core_no_pearls_no_return_best_time",
complete_the_crystal_core_no_abilities_no_return_race: "dungeon_hub_crystal_core_no_abilities_no_return_best_time",
complete_the_crystal_core_nothing_no_return_race: "dungeon_hub_crystal_core_nothing_no_return_best_time",
};

export const CUSTOM_RACE_IDS = {
woods_race_best_time: "foraging_race_best_time",
chicken_race_best_time: "chicken_race_best_time_2",
};

export const RACE_NAMES = {
crystal_core: "Crystal Core",
giant_mushroom: "Giant Mushroom",
precursor_ruins: "Precursor Ruins",
foraging_race: "Foraging",
end_race: "End",
chicken_race: "Chicken",
chicken_race_2: "Chicken",
rift_race: "Rift",
};

Expand Down Expand Up @@ -348,14 +302,6 @@ export const EXPERIMENTS = {

export const MAX_FAVORITES = 10;

export const INCREASE_MOST_STATS_EXCLUDE = [
"mining_speed",
"mining_fortune",
"farming_fortune",
"foraging_fortune",
"pristine",
];

export const FAIRY_SOULS = {
max: {
normal: 242,
Expand Down
74 changes: 32 additions & 42 deletions src/stats/misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,58 +128,48 @@ export function getMisc(profile, userProfile, hypixelProfile) {
}

const misc = {};

if ("races" in userProfile.player_stats) {
misc.races = {};
const races = userProfile.player_stats.races;
for (const key in userProfile.objectives) {
if (key.startsWith("complete_the_") === false) {
continue;
}

const raceTimeID = `${key.replace("complete_the_", "").split("_").slice(0, -1).join("_")}_best_time`;
const customRaceID = constants.CUSTOM_RACE_IDS[raceTimeID];
const tier = parseInt(key.split("_").at(-1));

const raceTime = races[raceTimeID] ?? races[customRaceID];
let actualRaceId = (customRaceID ?? raceTimeID).split("_").slice(0, 2).join("_");
if (raceTime) {
misc.races.other ??= { name: "Other", races: {} };
misc.races.other.races[actualRaceId] = {
name: constants.RACE_NAMES[actualRaceId],
time: moment.duration(raceTime, "milliseconds").format("m:ss.SSS"),
tier: tier,
};
} else {
// Thank you Hypxiel
actualRaceId = actualRaceId.replace("_race", "");
const categoryRaceID = raceTimeID.replace(`${actualRaceId}_`, "").replace("_best_time", "");

misc.races[actualRaceId] ??= {
name: constants.RACE_NAMES[actualRaceId],
races: {
no_return: {},
with_return: {},
},
const formatTime = (data) => moment.duration(data, "milliseconds").format("m:ss.SSS");
const getRaceName = (id) => constants.RACE_NAMES[id] ?? helper.titleCase(id.replace("_", " "));

for (let [id, data] of Object.entries(races)) {
if (typeof data === "number") {
misc.races.other = misc.races.other || {
name: "Other",
races: {},
};

const raceId = raceTimeID.replace("_race", "");
if (categoryRaceID.endsWith("no_return_race")) {
const subcategoryRaceId = categoryRaceID.replace("_no_return_race", "");
const raceName = helper.titleCase(subcategoryRaceId.replace("_", " "));
const raceId = id.replace("_best_time", "");
const raceName = getRaceName(raceId);

misc.races[actualRaceId].races.with_return[subcategoryRaceId] = {
misc.races.other.races[raceId] = {
name: raceName,
time: formatTime(data),
};
} else {
for ([id, data] of Object.entries(data)) {
const shortId = id.split("_").slice(0, 2).join("_");
const raceId = id.replace(`${shortId}_`, "").replace("_best_time", "");
const raceName = getRaceName(shortId);

misc.races[shortId] = misc.races[shortId] || {
name: raceName,
time: moment.duration(races.dungeon_hub[raceId], "milliseconds").format("m:ss.SSS"),
tier: tier,
races: {
with_return: {},
no_return: {},
},
};
} else {
const subcategoryRaceId = categoryRaceID.replace("_with_return_race", "");
const raceName = helper.titleCase(subcategoryRaceId.replace("_", " "));

misc.races[actualRaceId].races.no_return[subcategoryRaceId] = {
name: raceName,
time: moment.duration(races.dungeon_hub[raceId], "milliseconds").format("m:ss.SSS"),
tier: tier,
const isReturn = id.endsWith("_with_return_best_time");
const dungeonRaceId = raceId.replace(isReturn ? "_with_return" : "_no_return", "");

misc.races[shortId].races[isReturn ? "with_return" : "no_return"][dungeonRaceId] = {
name: getRaceName(dungeonRaceId),
time: formatTime(data),
};
}
}
Expand Down
8 changes: 6 additions & 2 deletions views/sections/stats/misc/races.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,26 @@ const raceOrder = ["crystal_core", "giant_mushroom", "precursor_ruins", "other"]
<span class="stat-value"><%= race.time %></span>
</div>
<!--
<div>
<span class="stat-value"><%= helper.renderRaceTier(race.tier) %></span>
</div>
-->
</div>
<% } else { %>
<% } else if (Object.keys(race).length > 0) { %>
<div class="narrow-info-section-header"><%= helper.titleCase(subcategory.replace("_", " ")) %>:</div>
<% for (const subcategoryRace of Object.values(race)) { %>
<div class="narrow-info-flexsb">
<div>
<span class="stat-name"><%= subcategoryRace.name %>: </span>
<span class="stat-value"><%= subcategoryRace.time %></span>
</div>
<!--
<div>
<span class="stat-value"><%= helper.renderRaceTier(subcategoryRace.tier) %></span>
</div>
-->
</div>
<% } %>
<% } %>
Expand Down

0 comments on commit 4eca3de

Please sign in to comment.